-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ibarrond
committed
May 29, 2023
1 parent
d57f65c
commit c860d2c
Showing
6 changed files
with
392 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
# funshade | ||
Functional Secret Sharing for Secure Thresholded Distance Metric Evaluation. The code accompanying the paper. | ||
# Funshade | ||
Functional Secret Sharing for Two-Party Secure Thresholded Distance Evaluation. | ||
|
||
- _Languages_: C (99+), Python (3.8+, for the wrapper) | ||
- _Platforms_: Linux, Windows, MacOS (any system with a C compiler) | ||
- _Dependencies_: `libsodium` (optional, for fast and secure random number generation) | ||
- _Code Author_: Alberto Ibarrondo | ||
- _License_: GNU GPLv3 (any code derived from this must be **open source**) | ||
- _Version_: 1.1.0 | ||
|
||
### Description | ||
Funshade is a library that implements a protocol to securely compute a distance metric between two vectors, followed by a secure comparison to a threshold. It is extremely lightweight, making use of cheap primitives such as AES and requiring a single intermediate round of communication and just two numbers sent per distance computation in the preprocessing model (besides input sharing and output reconstruction, common to all secret-sharing MPC schemes). | ||
|
||
Consider citing the paper if you use it in your research! | ||
|
||
|
||
### Installation | ||
The library is written in plain C to make it **portable**. | ||
It has been tested in Linux and Windows, but it should work in any system with a C compiler. | ||
To compile it, you can: | ||
- Use the provided CMakeLists.txt with `cmake`(`mkdir build && cd build && cmake .. & cmake --build .`) | ||
- Directly call your compiler with the `-msse -msse2 -maes` flags for faster hardware-based AES acceleration (and consider `-O3 -march=native` for further optimizations). | ||
|
||
For conveniency and for seamless integration with higher-level languages, we also provide a Python wrapper. | ||
Install it with: | ||
- `pip install .` | ||
|
||
As an optional dependency, it uses `libsodium` for fast and secure random number generation. | ||
|
||
### Usage | ||
The library is designed to be used as a black-box, with a simple API. | ||
|
||
Chech the bottom of `fss.h` for the available functions, `test_fss.c` for some uses in C, or `test_funshade.py` for a step-by-step Python example. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,229 @@ | ||
l,t_setup,t_share,t_eval_sp,t_eval_sign,n_bits,n_samples | ||
1,9134.6651,19.2485,20.5937,2351.1352,8,1 | ||
128,12295.2,29.55,184.7,2351.85,8,1 | ||
256,15635.7,28.45,349.55,2360.4,8,1 | ||
512,25729.7,36.05,641.9,2358.15,8,1 | ||
1024,47080.1,53.7,1268.3,2376.7,8,1 | ||
1,11533.4694,19.2603,20.45005,4612.06,16,1 | ||
128,18814.896,29.623,185.72,4734.2295,16,1 | ||
256,27964.7,32.7,393.25,4614.2,16,1 | ||
512,47839.7,42.45,761.4,4766.65,16,1 | ||
1024,87853.7,82.35,1486.95,4618.65,16,1 | ||
1,16573.8864,19.44015,21.0205,9393.1637,32,1 | ||
128,33631.3,38.468,190.607,9201.22,32,1 | ||
256,53997.833,53.678,470.7215,9238.38,32,1 | ||
512,94417.228,110.512,905.41,9242.6,32,1 | ||
1024,175136.414,176.432,1774.1155,9248.95,32,1 | ||
1,31582.3314,19.34365,24.33735,23814.23505,64,1 | ||
128,70101.37,46.838,216.2915,24734.6865,64,1 | ||
256,108849.8,97.8,214.95,25248.5,64,1 | ||
512,189245.2,171.45,548.85,23727.85,64,1 | ||
1024,351221.3,535.0,1057.45,23750.7,64,1 | ||
128,2690122.2,4425.65,23385.8,964220.5,32,100 | ||
256,4674317.9,12125.85,42821.1,932451.7,32,100 | ||
512,8770881.2,32083.95,80682.95,932587.45,32,100 | ||
1024,16975570.3,75132.2,162313.25,932941.55,32,100 | ||
128,5272928.0,12415.3,44372.1,1865085.4,32,200 | ||
256,9371399.7,31474.05,86251.4,1865141.9,32,200 | ||
512,17590453.5,75676.35,172206.7,1866267.7,32,200 | ||
1024,34037666.4,159737.3,336496.4,1869451.3,32,200 | ||
128,13254693.4,42792.6,108564.65,4662221.6,32,500 | ||
256,23516427.3,97113.85,225934.1,4664801.2,32,500 | ||
512,44105844.1,210435.1,463071.6,4670776.3,32,500 | ||
1024,85275342.5,436140.05,960691.6,4669678.0,32,500 | ||
128,26586987.3,100006.15,226473.45,9327612.45,32,1000 | ||
256,47197230.5,216173.65,461541.7,9337999.3,32,1000 | ||
512,88363199.0,440073.95,940592.65,9336576.35,32,1000 | ||
1024,170732593.1,885768.8,1955720.65,9333439.85,32,1000 | ||
128,53235991.9,213862.95,472882.45,18662751.9,32,2000 | ||
256,94413163.4,438220.05,942137.85,18663917.85,32,2000 | ||
512,176716249.8,889216.5,1916193.3,18660645.1,32,2000 | ||
1024,341399174.1,1777413.95,3930217.95,18662169.15,32,2000 | ||
128,133257319.1,549012.15,1226786.85,46648695.9,32,5000 | ||
256,236236216.6,1117400.05,2392537.8,46673571.75,32,5000 | ||
512,442394344.3,2231633.6,4995769.7,46706350.75,32,5000 | ||
1024,854306218.2,4477431.9,9972029.35,46712703.3,32,5000 | ||
128,266673568.2,1114240.1,2447239.65,93328880.8,32,10000 | ||
256,472358365.7,2232447.15,4831983.05,93266617.25,32,10000 | ||
512,884042418.0,4491837.7,9611594.3,93278175.4,32,10000 | ||
1024,1706316124.0,8946308.3,19749663.9,93270724.55,32,10000 | ||
128,532163466.9,2237265.05,4953777.1,186611339.6,32,20000 | ||
256,944616353.3,4495507.5,9746340.0,186744754.1,32,20000 | ||
512,1768266562.0,8948618.1,19782498.3,186592120.4,32,20000 | ||
1024,3536847842.0,17896622.92,39562608.02,186592120.4,32,20000 | ||
128,738180.9,756.0,17539.75,230483.3,8,100 | ||
256,1238276.4,1593.8,33366.3,230207.1,8,100 | ||
512,2234616.7,3336.15,65043.95,230739.15,8,100 | ||
1024,4240125.4,10400.7,129023.25,231118.05,8,100 | ||
128,1470457.2,840.65,34911.85,460751.2,8,200 | ||
256,2479342.1,3142.6,66655.6,460486.8,8,200 | ||
512,4483959.3,10824.1,130930.65,461099.6,8,200 | ||
1024,8503078.4,32768.35,258930.25,461532.4,8,200 | ||
128,3686668.2,4552.4,88324.0,1150744.2,8,500 | ||
256,6190628.9,17319.25,166477.1,1150933.0,8,500 | ||
512,11228485.1,44183.25,327817.8,1154144.2,8,500 | ||
1024,21338757.4,97843.2,650591.55,1155390.15,8,500 | ||
128,7368158.6,17723.25,176419.25,2300184.65,8,1000 | ||
256,12396714.8,43162.8,334975.85,2301568.65,8,1000 | ||
512,22535388.9,98053.05,657107.35,2304097.25,8,1000 | ||
1024,42750874.9,211085.75,1314478.1,2309287.15,8,1000 | ||
128,14751583.4,43441.1,352272.8,4602215.45,8,2000 | ||
256,24869784.0,98027.6,674444.5,4603884.75,8,2000 | ||
512,45205133.9,213151.0,1315042.9,4609366.65,8,2000 | ||
1024,85537130.4,428944.05,2660974.9,4609815.25,8,2000 | ||
128,36993822.4,126560.2,880294.9,11516041.3,8,5000 | ||
256,62519782.3,265057.2,1686123.65,11537587.25,8,5000 | ||
512,113283731.4,542315.0,3358914.65,11520569.9,8,5000 | ||
1024,214829420.2,1087751.15,6631941.7,11511444.0,8,5000 | ||
128,74258386.7,265087.7,1761781.0,23013423.4,8,10000 | ||
256,125115273.8,540901.05,3393602.55,23017654.9,8,10000 | ||
512,226752455.2,1092653.05,6597296.8,23039885.05,8,10000 | ||
1024,429799246.2,2182742.0,13379688.0,23019304.85,8,10000 | ||
128,148516773.4,530175.4,3523562.0,46026846.8,8,20000 | ||
256,250230547.6,1081802.1,6787205.1,46035309.8,8,20000 | ||
512,453504910.4,2185306.1,13194593.6,46079770.1,8,20000 | ||
1024,859598492.4,4365484.0,26759376.0,46038609.7,8,20000 | ||
128,1367093.2,2475.1,16232.6,462076.1,16,100 | ||
256,2367167.8,4933.0,32119.8,462974.9,16,100 | ||
512,4384557.4,13658.3,64289.9,462994.8,16,100 | ||
1024,8421895.4,38529.4,128232.1,462512.3,16,100 | ||
128,2722886.0,2609.7,32409.5,925313.5,16,200 | ||
256,4734379.2,13602.3,64673.3,924041.6,16,200 | ||
512,8783922.4,38436.0,128909.8,926703.1,16,200 | ||
1024,16885336.4,85866.1,258559.4,927176.8,16,200 | ||
128,6828039.2,20721.9,80865.0,2311578.4,16,500 | ||
256,11893528.4,50011.5,161517.6,2313178.2,16,500 | ||
512,22009951.8,107938.3,324211.5,2314735.4,16,500 | ||
1024,42355541.0,234018.2,663078.3,2318114.9,16,500 | ||
128,13697122.6,50190.0,161826.9,4623211.4,16,1000 | ||
256,23858745.8,110056.4,327761.4,4626879.7,16,1000 | ||
512,44134872.6,232577.9,653870.1,4630417.8,16,1000 | ||
1024,84777364.0,477038.0,1361706.8,4632185.6,16,1000 | ||
128,27457598.8,110692.2,326562.5,9249989.2,16,2000 | ||
256,47768364.2,235994.1,654543.2,9253712.9,16,2000 | ||
512,88484387.2,483641.7,1313237.4,9258386.4,16,2000 | ||
1024,169675927.8,969858.8,2709641.7,9258224.6,16,2000 | ||
128,68777726.4,294293.8,819512.0,23134819.8,16,5000 | ||
256,119557290.8,596519.7,1655752.2,23132823.4,16,5000 | ||
512,221163879.0,1204461.7,3419464.0,23131101.8,16,5000 | ||
1024,423841892.6,2430862.5,6927181.6,23151421.4,16,5000 | ||
128,137576586.4,603042.3,1657770.4,46298768.0,16,10000 | ||
256,239266402.0,1217211.3,3282157.7,46324974.4,16,10000 | ||
512,442559113.0,2446404.8,6574284.2,46353852.3,16,10000 | ||
1024,848201081.4,4882081.8,13753104.8,46320122.0,16,10000 | ||
128,275153172.8,1206084.6,3315540.8,92597536.0,16,20000 | ||
256,478532804.0,2434422.6,6564315.4,92649948.8,16,20000 | ||
512,885118226.0,4892809.6,13148568.4,92707704.6,16,20000 | ||
1024,1696402162.8,9764163.6,27506209.6,92640244.0,16,20000 | ||
128,5489734.4,15414.7,17512.0,2380260.5,64,100 | ||
256,9885270.4,41381.1,48085.9,2383118.5,64,100 | ||
512,17761713.2,83914.2,108122.3,2379900.3,64,100 | ||
1024,34203883.0,183551.6,232517.2,2389231.0,64,100 | ||
128,10910064.8,37362.1,44562.9,4761871.5,64,200 | ||
256,19139900.8,81637.6,104984.3,4757392.3,64,200 | ||
512,35563623.4,180983.7,229674.9,4766906.3,64,200 | ||
1024,68512116.8,384491.4,536839.9,4772320.0,64,200 | ||
128,27437482.2,110904.5,136237.5,11899045.9,64,500 | ||
256,47992320.0,232580.9,291423.4,11910119.0,64,500 | ||
512,89149262.8,482263.6,673255.8,11920708.5,64,500 | ||
1024,171442841.6,975669.8,1448646.4,11918739.6,64,500 | ||
128,55008906.0,237602.3,294753.9,23803682.9,64,1000 | ||
256,96085446.4,483701.4,659836.6,23809489.5,64,1000 | ||
512,178447886.0,983597.2,1428506.5,23808285.5,64,1000 | ||
1024,343331626.6,1961924.1,3013797.6,23809311.8,64,1000 | ||
128,110182998.6,485423.9,660485.0,47604816.8,64,2000 | ||
256,192557191.0,982417.4,1442813.3,47587270.9,64,2000 | ||
512,357693983.0,1985906.8,3011931.5,47607660.4,64,2000 | ||
1024,686391096.0,3933846.8,6099478.9,47602675.8,64,2000 | ||
128,470221039.8,1222856.3,1893663.2,119240727.8,64,5000 | ||
256,926051701.6,2427819.7,3751094.9,119152337.8,64,5000 | ||
512,1775865225.0,4852690.0,7558547.9,119129264.1,64,5000 | ||
1024,1692491705.0,9704184.3,15193277.8,119149274.3,64,5000 | ||
128,547053036.0,2448057.6,3714396.4,238280271.0,64,10000 | ||
256,954514488.2,4908475.5,7470089.5,238265615.0,64,10000 | ||
512,1770753960.0,9741903.9,15223064.8,238447838.6,64,10000 | ||
1024,3392680955.0,19480098.2,30937188.2,238312382.2,64,10000 | ||
128,1094106072.0,4896115.2,7428792.8,476560542.0,64,20000 | ||
256,1909028976.4,9816951.0,14940179.0,476531230.0,64,20000 | ||
512,3541507920.0,19483807.8,30446129.6,476895677.2,64,20000 | ||
1024,6785361910.0,38960196.4,61874376.4,476624764.4,64,20000 | ||
128,1332573191.0,5490121.5,12267868.5,466486959.0,32,50000 | ||
256,2362362166.0,11174000.5,23925378.0,466735717.5,32,50000 | ||
512,4423943443.0,22316336.0,49957697.0,467063507.5,32,50000 | ||
1024,8543062182.0,44774319.0,99720293.5,467127033.0,32,50000 | ||
128,2666735682.0,11142401.0,24472396.5,933288808.0,32,100000 | ||
256,4723583657.0,22324471.5,48319830.5,932666172.5,32,100000 | ||
512,8840424180.0,44918377.0,96115943.0,932781754.0,32,100000 | ||
1024,17063161240.0,89463083.0,197496639.0,932707245.5,32,100000 | ||
128,5321634669.0,22372650.5,49537771.0,1866113396.0,32,200000 | ||
256,9446163533.0,44955075.0,97463400.0,1867447541.0,32,200000 | ||
512,17682665620.0,89486181.0,197824983.0,1865921204.0,32,200000 | ||
1024,35368478420.0,178966229.2,395626080.2,1865921204.0,32,200000 | ||
128,369938224.0,1265602.0,8802949.0,115160413.0,8,50000 | ||
256,625197823.0,2650572.0,16861236.5,115375872.5,8,50000 | ||
512,1132837314.0,5423150.0,33589146.5,115205699.0,8,50000 | ||
1024,2148294202.0,10877511.5,66319417.0,115114440.0,8,50000 | ||
128,742583867.0,2650877.0,17617810.0,230134234.0,8,100000 | ||
256,1251152738.0,5409010.5,33936025.5,230176549.0,8,100000 | ||
512,2267524552.0,10926530.5,65972968.0,230398850.5,8,100000 | ||
1024,4297992462.0,21827420.0,133796880.0,230193048.5,8,100000 | ||
128,1485167734.0,5301754.0,35235620.0,460268468.0,8,200000 | ||
256,2502305476.0,10818021.0,67872051.0,460353098.0,8,200000 | ||
512,4535049104.0,21853061.0,131945936.0,460797701.0,8,200000 | ||
1024,8595984924.0,43654840.0,267593760.0,460386097.0,8,200000 | ||
128,687777264.0,2942938.0,8195120.0,231348198.0,16,50000 | ||
256,1195572908.0,5965197.0,16557522.0,231328234.0,16,50000 | ||
512,2211638790.0,12044617.0,34194640.0,231311018.0,16,50000 | ||
1024,4238418926.0,24308625.0,69271816.0,231514214.0,16,50000 | ||
128,1375765864.0,6030423.0,16577704.0,462987680.0,16,100000 | ||
256,2392664020.0,12172113.0,32821577.0,463249744.0,16,100000 | ||
512,4425591130.0,24464048.0,65742842.0,463538523.0,16,100000 | ||
1024,8482010814.0,48820818.0,137531048.0,463201220.0,16,100000 | ||
128,2751531728.0,12060846.0,33155408.0,925975360.0,16,200000 | ||
256,4785328040.0,24344226.0,65643154.0,926499488.0,16,200000 | ||
512,8851182260.0,48928096.0,131485684.0,927077046.0,16,200000 | ||
1024,16964021628.0,97641636.0,275062096.0,926402440.0,16,200000 | ||
128,4702210398.0,12228563.0,18936632.0,1192407278.0,64,50000 | ||
256,9260517016.0,24278197.0,37510949.0,1191523378.0,64,50000 | ||
512,17758652250.0,48526900.0,75585479.0,1191292641.0,64,50000 | ||
1024,16924917050.0,97041843.0,151932778.0,1191492743.0,64,50000 | ||
128,5470530360.0,24480576.0,37143964.0,2382802710.0,64,100000 | ||
256,9545144882.0,49084755.0,74700895.0,2382656150.0,64,100000 | ||
512,17707539600.0,97419039.0,152230648.0,2384478386.0,64,100000 | ||
1024,33926809550.0,194800982.0,309371882.0,2383123822.0,64,100000 | ||
128,10941060720.0,48961152.0,74287928.0,4765605420.0,64,200000 | ||
256,19090289764.0,98169510.0,149401790.0,4765312300.0,64,200000 | ||
512,35415079200.0,194838078.0,304461296.0,4768956772.0,64,200000 | ||
1024,67853619100.0,389601964.0,618743764.0,4766247644.0,64,200000 | ||
128,13325731910.0,54901215.0,122678685.0,4664869590.0,32,500000 | ||
256,23623621660.0,111740005.0,239253780.0,4667357175.0,32,500000 | ||
512,44239434430.0,223163360.0,499576970.0,4670635075.0,32,500000 | ||
1024,85430621820.0,447743190.0,997202935.0,4671270330.0,32,500000 | ||
128,26667356820.0,111424010.0,244723965.0,9332888080.0,32,1000000 | ||
256,47235836570.0,223244715.0,483198305.0,9326661725.0,32,1000000 | ||
512,88404241800.0,449183770.0,961159430.0,9327817540.0,32,1000000 | ||
1024,170631612400.0,894630830.0,1974966390.0,9327072455.0,32,1000000 | ||
128,3699382240.0,12656020.0,88029490.0,1151604130.0,8,500000 | ||
256,6251978230.0,26505720.0,168612365.0,1153758725.0,8,500000 | ||
512,11328373140.0,54231500.0,335891465.0,1152056990.0,8,500000 | ||
1024,21482942020.0,108775115.0,663194170.0,1151144400.0,8,500000 | ||
128,7425838670.0,26508770.0,176178100.0,2301342340.0,8,1000000 | ||
256,12511527380.0,54090105.0,339360255.0,2301765490.0,8,1000000 | ||
512,22675245520.0,109265305.0,659729680.0,2303988505.0,8,1000000 | ||
1024,42979924620.0,218274200.0,1337968800.0,2301930485.0,8,1000000 | ||
128,6877772640.000001,29429380.0,81951200.0,2313481980.0,16,500000 | ||
256,11955729080.0,59651970.0,165575220.0,2313282340.0,16,500000 | ||
512,22116387900.0,120446170.0,341946400.0,2313110180.0,16,500000 | ||
1024,42384189260.0,243086250.0,692718160.0,2315142140.0,16,500000 | ||
128,13757658640.0,60304230.,165777040.0,4629876800.0,16,1000000 | ||
256,23926640200.0,121721130.0,328215770.0,4632497440.0,16,1000000 | ||
512,44255911300.0,244640480.0,657428420.0,4635385230.0,16,1000000 | ||
1024,84820108140.0,488208180.0,1375310480.0,4632012200.0,16,1000000 | ||
128,47022103980.0,122285630.0,189366320.0,11924072780.0,64,500000 | ||
256,92605170160.0,242781970.0,375109490.0,11915233780.0,64,500000 | ||
512,177586522500.0,485269000.0,755854790.0,11912926410.0,64,500000 | ||
1024,169249170500.0,970418430.0,1519327780.0,11914927430.0,64,500000 | ||
128,54705303600.0,244805760.0,371439640.0,23828027100.0,64,1000000 | ||
256,95451448820.0,490847550.0,747008950.0,23826561500.0,64,1000000 | ||
512,177075396000.0,974190390.0,1522306480.0,23844783860.0,64,1000000 | ||
1024,339268095500.0,1948009820.0,3093718820.0,23831238220.0,64,1000000 |
Oops, something went wrong.