Add nullifier=H(key, secret)

This commit is contained in:
arnaucube
2020-05-24 00:32:53 +02:00
parent 9776f46e4b
commit a756810fc9
11 changed files with 103 additions and 77 deletions

View File

@@ -2,22 +2,29 @@
# deposit.circom
+----------+ +----------+
PUB_nullifier+------>+ | | |
| | | SMT |
PUB_coinCode+------->+ | | Poseidon +<------+PUB_rootOld
| Poseidon +-+----------->+ Verifier |
PUB_amount+--------->+ | | | Non |
| | | | Existance+<------+PRI_siblings
PRI_secret+--------->+ | | | | +
+----------+ | +----------+ |
| |
| |
| +----------+ |
| | | |
| | | |
+----+ | | SMT +<---------+
PUB_commitment+----> == +<--------+----------->+ Poseidon |
+----------+
| |
PRI_secret+--------->+ Poseidon +<----+PUB_key
| | | +
| +----------+ |
| nullifier |
| + |
| | | +----------+
| v | | |
| +----+-----+ +---->+ SMT |
+--------->+ | | Poseidon +<------+PUB_rootOld
| +-----+------->+ Verifier |
PUB_coinCode+------->+ Poseidon | | | Non |
| | | | Existance+<------+PRI_siblings
PUB_amount+--------->+ | | | | +
+----------+ | +----------+ |
| |
| |
| +----------+ |
| | | |
| | | |
+----+ | | SMT +<---------+
PUB_commitment+----> == +<------------+------->+ Poseidon |
+----+ | Verifier |
| +<------+PUB_rootNew
| |
@@ -34,7 +41,6 @@ template Deposit(nLevels) {
signal input coinCode;
signal input amount;
signal private input secret;
signal private input nullifier;
signal private input oldKey;
signal private input oldValue;
signal private input siblingsOld[nLevels];
@@ -44,11 +50,15 @@ template Deposit(nLevels) {
signal input commitment;
signal input key;
component nullifierCmp = Poseidon(2, 6, 8, 57);
nullifierCmp.inputs[0] <== key;
nullifierCmp.inputs[1] <== secret;
component hash = Poseidon(4, 6, 8, 57);
hash.inputs[0] <== coinCode;
hash.inputs[1] <== amount;
hash.inputs[2] <== secret;
hash.inputs[3] <== nullifier; // nullifier
hash.inputs[3] <== nullifierCmp.out; // nullifier
component comCheck = IsEqual();
comCheck.in[0] <== hash.out;
@@ -106,5 +116,3 @@ template Deposit(nLevels) {
smtNew.key <== key;
smtNew.value <== hash.out;
}
/* component main = Deposit(17); // 16 real levels (due circom leaf protection) */

View File

@@ -4,21 +4,27 @@
WARNING: WIP, very initial version of the miksi circuit
-----------+ +----------+
PUB_nullifier+------>+ | | |
| | | |
PUB_coinCode+------->+ | | SMT +<------+PRI_siblings
| Poseidon +------------->+ Poseidon |
PUB_amount+--------->+ | | Verifier |
| | | +<------+PUB_root
PRI_secret+--------->+ | | | +
+----------+ +----------+ |
|
|
+----+ +----+ |
PUB_address+--->+ != +<-------+0+------>+ != +<-------+
+----+ +----+
+----------+
| |
PRI_secret+--------->+ Poseidon +<------+PRI_key+---------+
| | | |
| +----------+ +----+ |
| nullifier+----->+ != +<-----+0 |
| + +----+ v
| | +--+-------+
| v | |
| +-----+----+ | |
+--------->+ | | SMT +<------+PRI_siblings
| +--------------------->+ Poseidon |
PUB_coinCode+------->+ Poseidon | | Verifier |
| | | +<------+PUB_root
PUB_amount+--------->+ | | | +
+----------+ +----------+ |
|
|
+----+ +----+ |
PUB_address+--->+ != +<-------+0+-------------->+ != +<-------+
+----+ +----+
@@ -38,11 +44,20 @@ template Withdraw(nLevels) {
signal input address;
signal private input key;
component nullifierCmp = Poseidon(2, 6, 8, 57);
nullifierCmp.inputs[0] <== key;
nullifierCmp.inputs[1] <== secret;
component nullifierCheck = IsEqual();
nullifierCheck.in[0] <== nullifierCmp.out;
nullifierCheck.in[1] <== nullifier;
nullifierCheck.out === 1;
component hash = Poseidon(4, 6, 8, 57);
hash.inputs[0] <== coinCode;
hash.inputs[1] <== amount;
hash.inputs[2] <== secret;
hash.inputs[3] <== nullifier;
hash.inputs[3] <== nullifierCmp.out;
component z = IsZero();
z.in <== address;
@@ -61,5 +76,3 @@ template Withdraw(nLevels) {
smtV.key <== key;
smtV.value <== hash.out;
}
/* component main = Withdraw(17); // 16 real levels (due circom leaf protection) */