Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more examles? #16

Open
cyberhorse208 opened this issue Jan 29, 2019 · 2 comments
Open

more examles? #16

cyberhorse208 opened this issue Jan 29, 2019 · 2 comments

Comments

@cyberhorse208
Copy link

can u give more examples about how to use all the functions of tinygarble, like compare, sum, aes, etc

i run the hamming example, and get the right result. but when i run compare, bob always get 01:

[ TinyGarble-master]# bin/garbled_circuit/TinyGarble --bob -p 1234 --log2std --scd_file bin/scd/netlists/compare_nbit_ncc.scd --input 0000
garbled_circuit_main.cpp:304 INFO: Connect Bob's client to Alice's server on 127.0.0.1:1234
garbled_circuit_high_mem.cpp:118 INFO: Bob transfer labels time (cc) = 52467460 (cc/bit) = 5.24675e+07
garbled_circuit_high_mem.cpp:705 INFO: Bob communication time (cc) = 8348
garbled_circuit_high_mem.cpp:706 INFO: Bob evaluation time (cc) = 11216
garbled_circuit_main.cpp:319 INFO: Bob's output = 01
garbled_circuit_main.cpp:320 INFO: Total Bob time (cc) = 52879668
01
[ TinyGarble-master]# bin/garbled_circuit/TinyGarble --alice -p 1234 --log2std --scd_file bin/scd/netlists/compare_nbit_ncc.scd --input 0001
garbled_circuit_main.cpp:268 INFO: Open Alice's server on port: 1234
garbled_circuit_high_mem.cpp:75 INFO: Alice transfer labels time (cc) = 53173668 (cc/bit) = 5.31737e+07
garbled_circuit_high_mem.cpp:421 INFO: Non-secret skipped non-XOR gates = 0 out of 1 (0%)
garbled_circuit_high_mem.cpp:427 INFO: Total garbled non-XOR gates = 1
garbled_circuit_high_mem.cpp:430 INFO: Alice communication time (cc) = 29092
garbled_circuit_high_mem.cpp:431 INFO: Alice garbling time (cc) = 17328
garbled_circuit_main.cpp:282 INFO: Alice's output = 0
garbled_circuit_main.cpp:283 INFO: Total Alice time (cc) = 53772364
0


[ TinyGarble-master]# bin/garbled_circuit/TinyGarble --bob -p 1234 --log2std --scd_file bin/scd/netlists/compare_nbit_ncc.scd --input 0002
garbled_circuit_main.cpp:304 INFO: Connect Bob's client to Alice's server on 127.0.0.1:1234
garbled_circuit_high_mem.cpp:118 INFO: Bob transfer labels time (cc) = 100081704 (cc/bit) = 1.00082e+08
garbled_circuit_high_mem.cpp:705 INFO: Bob communication time (cc) = 8056
garbled_circuit_high_mem.cpp:706 INFO: Bob evaluation time (cc) = 9036
garbled_circuit_main.cpp:319 INFO: Bob's output = 01
garbled_circuit_main.cpp:320 INFO: Total Bob time (cc) = 100558580
01
[ TinyGarble-master]# bin/garbled_circuit/TinyGarble --alice -p 1234 --log2std --scd_file bin/scd/netlists/compare_nbit_ncc.scd --input 0001
garbled_circuit_main.cpp:268 INFO: Open Alice's server on port: 1234
garbled_circuit_high_mem.cpp:75 INFO: Alice transfer labels time (cc) = 100223568 (cc/bit) = 1.00224e+08
garbled_circuit_high_mem.cpp:421 INFO: Non-secret skipped non-XOR gates = 0 out of 1 (0%)
garbled_circuit_high_mem.cpp:427 INFO: Total garbled non-XOR gates = 1
garbled_circuit_high_mem.cpp:430 INFO: Alice communication time (cc) = 23780
garbled_circuit_high_mem.cpp:431 INFO: Alice garbling time (cc) = 15428
garbled_circuit_main.cpp:282 INFO: Alice's output = 0
garbled_circuit_main.cpp:283 INFO: Total Alice time (cc) = 100782820
0

@siaaron045
Copy link

Due to some force majeure factors,I cannot download the source code of Tinygarble .
Could you send the source code to me?
Thanks a million.
email: [email protected]

@siamumar
Copy link
Collaborator

siamumar commented May 8, 2019

To compare two n-bit numbers we need to execute GC for n cycles. Here, your inputs are 16 bits (inputs are in HEX format). So we need to execute GC for 16 cycles by adding the argument -c 16. Moreover, for this function, we are only interested in the output of the last cycle, after all the bits are compared. So we should add the argument --output_mode 2. Please run TinyGarble -h to see all the options.

Following are the correct commands:
For the first example:

bin/garbled_circuit/TinyGarble --alice -p 1234 --log2std --scd_file bin/scd/netlists/compare_nbit_ncc.scd --input 0001 -c 16
garbled_circuit_main.cpp:271 INFO: Open Alice's server on port: 1234
garbled_circuit_high_mem.cpp:75 INFO: Alice transfer labels time (cc) = 153303966       (cc/bit) = 9.5815e+06
garbled_circuit_high_mem.cpp:421 INFO: Non-secret skipped non-XOR gates = 0 out of 16    (0%)
garbled_circuit_high_mem.cpp:427 INFO: Total garbled non-XOR gates = 16
garbled_circuit_high_mem.cpp:430 INFO: Alice communication time (cc) = 358476
garbled_circuit_high_mem.cpp:431 INFO: Alice garbling time (cc) = 28448
garbled_circuit_main.cpp:290 INFO: Alice's output = 0
garbled_circuit_main.cpp:291 INFO: Total Alice time (cc) = 154492420
0
bin/garbled_circuit/TinyGarble --bob -p 1234 --log2std --scd_file bin/scd/netlists/compare_nbit_ncc.scd --input 0000 -c 16 --output_mode 2
garbled_circuit_main.cpp:312 INFO: Connect Bob's client to Alice's server on 127.0.0.1:1234
garbled_circuit_high_mem.cpp:118 INFO: Bob transfer labels time (cc) = 153488500        (cc/bit) = 9.59303e+06
garbled_circuit_high_mem.cpp:705 INFO: Bob communication time (cc) = 261380
garbled_circuit_high_mem.cpp:706 INFO: Bob evaluation time (cc) = 22204
garbled_circuit_main.cpp:331 INFO: Bob's output = 01
garbled_circuit_main.cpp:332 INFO: Total Bob time (cc) = 154686319
01

For the second example:

bin/garbled_circuit/TinyGarble --alice -p 1234 --log2std --scd_file bin/scd/netlists/compare_nbit_ncc.scd --input 0001 -c 16
garbled_circuit_main.cpp:271 INFO: Open Alice's server on port: 1234
garbled_circuit_high_mem.cpp:75 INFO: Alice transfer labels time (cc) = 147205000       (cc/bit) = 9.20031e+06
garbled_circuit_high_mem.cpp:421 INFO: Non-secret skipped non-XOR gates = 0 out of 16    (0%)
garbled_circuit_high_mem.cpp:427 INFO: Total garbled non-XOR gates = 16
garbled_circuit_high_mem.cpp:430 INFO: Alice communication time (cc) = 222840
garbled_circuit_high_mem.cpp:431 INFO: Alice garbling time (cc) = 42516
garbled_circuit_main.cpp:290 INFO: Alice's output = 0
garbled_circuit_main.cpp:291 INFO: Total Alice time (cc) = 148049529
0
bin/garbled_circuit/TinyGarble --bob -p 1234 --log2std --scd_file bin/scd/netlists/compare_nbit_ncc.scd --input 0002 -c 16 --output_mode 2
garbled_circuit_main.cpp:312 INFO: Connect Bob's client to Alice's server on 127.0.0.1:1234
garbled_circuit_high_mem.cpp:118 INFO: Bob transfer labels time (cc) = 147383361        (cc/bit) = 9.21146e+06
garbled_circuit_high_mem.cpp:705 INFO: Bob communication time (cc) = 227626
garbled_circuit_high_mem.cpp:706 INFO: Bob evaluation time (cc) = 38367
garbled_circuit_main.cpp:331 INFO: Bob's output = 0
garbled_circuit_main.cpp:332 INFO: Total Bob time (cc) = 148425567
0

Note that by default, Bob always receives the output. If you want Alice to receive the outputs, you should configure the output_mask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants