Comments (10)
One way that you can know the id of each wire is to cast the block into an array of uint64_t. the higher int is the id.
See e.g.: https://github.com/emp-toolkit/emp-tool/blob/master/emp-tool/execution/plain_circ.h#L65
from emp-tool.
On a second examination, I think the wires should all be ordered as one would expect rather than the order you mentioned above. Can you double-check? :)
from emp-tool.
Hi. Thank you very much for your reply!
I retried to generate the circuit but it still not works as my expectation. Specifically, the program I executed is as follow:
#include <emp-tool/execution/plain_prot.h>
#include <emp-sh2pc/emp-sh2pc.h>
#include <emp-tool/circuits/bit.h>
#include <emp-tool/circuits/circuit_file.h>
#include <iostream>
static const char* FILENAME = "test.txt";
int main() {
using Circuit = emp::BristolFormat;
{
emp::setup_plain_prot(true, FILENAME);
emp::Integer a {2, 0, emp::ALICE};
emp::Integer b {2, 0, emp::ALICE};
emp::Bit cond1 = (b > a);
cond1.reveal<bool>();
emp::finalize_plain_prot();
}
}
The test.txt will be:
13 17
4 0 1
2 1 0 2 4 XOR
2 1 4 2 5 AND
2 1 1 3 6 XOR
2 1 5 3 7 XOR
2 1 6 5 8 XOR
2 1 6 7 9 AND
2 1 5 9 10 XOR
2 1 1 3 11 XOR
2 1 11 10 12 XOR
1 1 12 13 INV
1 1 13 14 INV
2 1 0 0 15 XOR
2 1 15 14 16 XOR
I tried to set in[0..3] and see out[16], for example:
in[0..3] := 1000 ---> out[16] = 0
in[0..3] := 0100 ---> out[16] = 1
in[0..3] := 0010 ---> out[16] = 1
in[0..3] := 0001 ---> out[16] = 0
which means in[0] and in[3] belong to emp::Integer a && in[1] and in[2] belong to emp::Integer b.
from emp-tool.
little-endian or big-endian in your representation? Try 0011 :)
from emp-tool.
Hi!
in[0..3] := 1000 <——> in[0] := 1, in[1] := 0, in[2] := 0, in[3] := 0
Therefore, 0011 will result in 0.
from emp-tool.
Please try this example
setup_plain_prot(true, "sort.txt");
Integer a(2,0,ALICE);
Integer b(2,0,ALICE);
(a[0] & b[0]).reveal();
You will see that the output circuit is
3 7
4 0 1
2 1 0 2 4 AND
2 1 0 0 5 XOR
2 1 5 4 6 XOR
Here only wire 0 and 2 are used. This is because 0 is for a[0] and 2 is for b[0].
from emp-tool.
Thank you very much! I tried your example (with a[0]&a[1], a[0]&b[1] ...). It indeed works.
The experiment shows that a[0] := in[0], a[1] := in[1], b[0] := in[2] and b[1] := in[3].
Then, there must be some problem in (b > a) circuit generating procedure. Let's set
a[0] = in[0] := 0
a[1] = in[1] := 1
b[0] = in[2] := 0
b[1] = in[3] := 0
(b > a) should be 0, obviously.
However, based on the BF circuit in my previous reply, which is:
13 17
4 0 1
2 1 0 2 4 XOR
2 1 4 2 5 AND
2 1 1 3 6 XOR
2 1 5 3 7 XOR
2 1 6 5 8 XOR
2 1 6 7 9 AND
2 1 5 9 10 XOR
2 1 1 3 11 XOR
2 1 11 10 12 XOR
1 1 12 13 INV
1 1 13 14 INV
2 1 0 0 15 XOR
2 1 15 14 16 XOR
The entire calculation process will be:
wire[0] = 0
wire[1] = 1
wire[2] = 0
wire[3] = 0
wire[4] = wire[0] XOR wire[2] = 0
wire[5] = wire[4] AND wire[2] = 0
wire[6] = wire[1] XOR wire[3] = 1
wire[7] = wire[5] XOR wire[3] = 0
wire[8] = wire[6] XOR wire[5] = 1
wire[9] = wire[6] AND wire[7] = 0
wire[10] = wire[5] XOR wire[9] = 0
wire[11] = wire[1] XOR wire[3] = 1
wire[12] = wire[10] XOR wire[11] = 1
wire[13] = INV wire[12] = 0
wire[14] = INV wire[13] = 1
wire[15] = wire[0] XOR wire[0] = 0
wire[16] = wire[14] XOR wire[15] = 1, which is wrong.
from emp-tool.
actually, the comparison assumes signed input. so if the highest bit is 1. it is a negative number.
from emp-tool.
Oops, I also realized this problem after going into integer.hpp source code just now. Thank you very much for your kindly help! Sorry for causing troubles.
from emp-tool.
np. closing the issue.
from emp-tool.
Related Issues (20)
- trouble understanding NetIO code HOT 2
- Problem with PRG HOT 1
- Add an option to enable the optimization to reduce circuit size
- Ability to marshall session state to disk. HOT 1
- how to run netio test? HOT 2
- Unused `con` in `AES_opt_key_schedule` HOT 2
- Using Salsa20 instead of AES for random permutation. HOT 5
- Code assumption failed to pass static analyzer HOT 1
- Commitment functionality missing HOT 2
- Overflow in Interger::modExp implementation HOT 2
- How to generate a circuit containing out-of-circuit or fixed information? HOT 3
- unused value sent over the wire HOT 4
- Overflow in NetIO HOT 2
- Is it a bug in Hash class? HOT 2
- The output of AES_ecb_decrypt_blks is not correct on ARM HOT 2
- Is miTCCR still needed in light of GKWY19 findings? HOT 3
- SHA3_256 and AES_128 tests do not work properly HOT 8
- ```f2k``` multiplication seems to mismatch operations HOT 9
- sha3_256 can not be compiled
- gcc13 compiled failed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emp-tool.