diff --git a/README.md b/README.md index 2cc879cc..79cb24e8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ ## Organisation -This respository contains 3 folders: +This repository contains 3 folders: + - `circuits`: it contains the implementation of different cryptographic primitives in circom language. - `doc`: it contains some circuit schemes in ASCII (must be opened with Monodraw, an ASCII art editor for Mac). - `test`: tests. diff --git a/circuits/README.md b/circuits/README.md index 40a833e7..a24fd71a 100644 --- a/circuits/README.md +++ b/circuits/README.md @@ -3,7 +3,7 @@ ## Description - This folder contains circuit templates for standard operations and many cryptographic primitives. -- Below you can find specifications of each function. In the representation of elements, there are three tyes: +- Below you can find specifications of each function. In the representation of elements, there are three types: - Binary - String - Field element (the field is specified in each case. We consider 2 possible fields: Fp and Fr, where p... and r... .) @@ -15,7 +15,7 @@ ## Jordi * compconstant - Returns 1 if `in` (expanded to binary array) > `ct` -* aliascheck - check if `in` (expanded to binary array) oveflowed its 254 bits (<= -1) +* aliascheck - check if `in` (expanded to binary array) overflowed its 254 bits (<= -1) * babyjub - twisted Edwards curve 168700.x^2 + y^2 = 1 + 168696.x^2.y^2 * BabyAdd - (`xout`,`yout`) = (`x1`,`y1`) + (`x2`,`y2`) * BabyDbl - (`xout`,`yout`) = 2*(`x`,`y`) @@ -129,7 +129,7 @@ Arithmetic on [Baby Jubjub elliptic curve](https://github.com/barryWhiteHat/baby - `BinSub(n)` - - DESCRIPTION: binary substraction. + - DESCRIPTION: binary subtraction. - SCHEMA - INPUT - OUTPUT @@ -688,8 +688,7 @@ Implementation of MiMC-7 hash in Fp being... (link to description of the hash) ### pedersen_old -Old version of the Pedersen hash (do not use any -more?). +Old version of the Pedersen hash (do not use anymore?). ### pedersen diff --git a/circuits/binsub.circom b/circuits/binsub.circom index a20fbf81..5277565b 100644 --- a/circuits/binsub.circom +++ b/circuits/binsub.circom @@ -18,7 +18,7 @@ */ /* -This component creates a binary substraction. +This component creates a binary subtraction. Main Constraint: diff --git a/circuits/binsum.circom b/circuits/binsum.circom index 28c7fcce..57187834 100644 --- a/circuits/binsum.circom +++ b/circuits/binsum.circom @@ -22,7 +22,7 @@ Binary Sum ========== -This component creates a binary sum componet of ops operands and n bits each operand. +This component creates a binary sum component of ops operands and n bits each operand. e is Number of carries: Depends on the number of operands in the input. @@ -34,7 +34,7 @@ Main Constraint: === out[0] * 2^0 + out[1] * 2^1 + + out[n+e-1] *2(n+e-1) -To waranty binary outputs: +To warranty binary outputs: out[0] * (out[0] - 1) === 0 out[1] * (out[0] - 1) === 0 diff --git a/circuits/eddsa.circom b/circuits/eddsa.circom index 04b5f87c..5a459a3e 100644 --- a/circuits/eddsa.circom +++ b/circuits/eddsa.circom @@ -132,7 +132,7 @@ template EdDSAVerifier(n) { mulFix.e[i] <== S[i]; } -// Do the comparation left == right +// Do the comparison left == right mulFix.out[0] === addRight.xout; mulFix.out[1] === addRight.yout; diff --git a/circuits/eddsamimc.circom b/circuits/eddsamimc.circom index b0b9f636..9edfc093 100644 --- a/circuits/eddsamimc.circom +++ b/circuits/eddsamimc.circom @@ -110,7 +110,7 @@ template EdDSAMiMCVerifier() { mulFix.e[i] <== snum2bits.out[i]; } -// Do the comparation left == right if enabled; +// Do the comparison left == right if enabled; component eqCheckX = ForceEqualIfEnabled(); eqCheckX.enabled <== enabled; diff --git a/circuits/eddsamimcsponge.circom b/circuits/eddsamimcsponge.circom index 3267c455..38089b6e 100644 --- a/circuits/eddsamimcsponge.circom +++ b/circuits/eddsamimcsponge.circom @@ -110,7 +110,7 @@ template EdDSAMiMCSpongeVerifier() { mulFix.e[i] <== snum2bits.out[i]; } -// Do the comparation left == right if enabled; +// Do the comparison left == right if enabled; component eqCheckX = ForceEqualIfEnabled(); eqCheckX.enabled <== enabled; diff --git a/circuits/eddsaposeidon.circom b/circuits/eddsaposeidon.circom index 1fce1f32..f7c546e8 100644 --- a/circuits/eddsaposeidon.circom +++ b/circuits/eddsaposeidon.circom @@ -109,7 +109,7 @@ template EdDSAPoseidonVerifier() { mulFix.e[i] <== snum2bits.out[i]; } -// Do the comparation left == right if enabled; +// Do the comparison left == right if enabled; component eqCheckX = ForceEqualIfEnabled(); eqCheckX.enabled <== enabled; diff --git a/circuits/escalarmulfix.circom b/circuits/escalarmulfix.circom index 4669d36f..82931d6c 100644 --- a/circuits/escalarmulfix.circom +++ b/circuits/escalarmulfix.circom @@ -37,10 +37,10 @@ include "babyjub.circom"; Then we calculate S1 = 2*2^246*B + (1 + a0)*B + (2^3 + a1)*B + .....+ (2^243 + a81)*B - And Finaly we compute the result: RES = SQ - Q + And finally we compute the result: RES = SQ - Q As you can see the input of the adders cannot be equal nor zero, except for the last - substraction that it's done in montgomery. + subtraction that it's done in montgomery. A good way to see it is that the accumulator input of the adder >= 2^247*B and the other input is the output of the windows that it's going to be <= 2^246*B diff --git a/circuits/pedersen.circom b/circuits/pedersen.circom index a29f4863..cd18a958 100644 --- a/circuits/pedersen.circom +++ b/circuits/pedersen.circom @@ -232,7 +232,7 @@ template Pedersen(n) { } /* - coponent packPoint = PackPoint(); + component packPoint = PackPoint(); if (nSegments>1) { packPoint.in[0] <== adders[nSegments-2].xout; diff --git a/circuits/smt/smtlevins.circom b/circuits/smt/smtlevins.circom index a03ae50a..54fb1fa5 100644 --- a/circuits/smt/smtlevins.circom +++ b/circuits/smt/smtlevins.circom @@ -23,7 +23,7 @@ This component finds the level where the oldInsert is done. The rules are: levIns[i] == 1 if its level and all the child levels have a sibling of 0 and -the parent level has a sibling != 0. Considere that the root level always has +the parent level has a sibling != 0. Consider that the root level always has a parent with a sibling != 0. @@ -78,7 +78,7 @@ template SMTLevIns(nLevels) { signal input enabled; signal input siblings[nLevels]; signal output levIns[nLevels]; - signal done[nLevels-1]; // Indicates if the insLevel has aready been detected. + signal done[nLevels-1]; // Indicates if the insLevel has already been detected. var i; diff --git a/circuits/smt/smtprocessor.circom b/circuits/smt/smtprocessor.circom index b75f17c7..9b63d09d 100644 --- a/circuits/smt/smtprocessor.circom +++ b/circuits/smt/smtprocessor.circom @@ -118,7 +118,7 @@ Insert to a used leaf. ┗━━━━━━━┛ ┗━━━━━━━┛ -Fnction +Function fnc[0] fnc[1] 0 0 NOP 0 1 UPDATE @@ -247,7 +247,7 @@ template SMTProcessor(nLevels) { // topSwitcher.outL === oldRoot*enabled; // topSwitcher.outR === newRoot*enabled; - // Ckeck keys are equal if updating + // Check keys are equal if updating component areKeyEquals = IsEqual(); areKeyEquals.in[0] <== oldKey; areKeyEquals.in[1] <== newKey; diff --git a/circuits/smt/smtprocessorlevel.circom b/circuits/smt/smtprocessorlevel.circom index 4312c971..384b0728 100644 --- a/circuits/smt/smtprocessorlevel.circom +++ b/circuits/smt/smtprocessorlevel.circom @@ -35,7 +35,7 @@ na 0 0 upd old1leaf new1leaf -H' is the Hash function with the inputs shifted acordingly. +H' is the Hash function with the inputs shifted accordingly. *****/ pragma circom 2.0.0; diff --git a/circuits/smt/smtprocessorsm.circom b/circuits/smt/smtprocessorsm.circom index e40356f9..2de13ac1 100644 --- a/circuits/smt/smtprocessorsm.circom +++ b/circuits/smt/smtprocessorsm.circom @@ -20,7 +20,7 @@ /*************************************************************************************************** Each level on a SMTProcessor has a state. -The state of the level depends on the state of te botom level and on `xor` and +The state of the level depends on the state of te bottom level and on `xor` and `is0` signals. `isOldLev` 1 when is the level where oldLeaf is. @@ -33,16 +33,16 @@ are inserting/deleting in a leaf that contains an element. The states are: -top: While the index bits of the old and new insex in the top level is the same, whe are in the top state. +top: While the index bits of the old and new index in the top level is the same, we are in the top state. old0: When the we reach insert level, we go to old0 state if `is0`=1. btn: Once in insert level and `is0` =0 we go to btn or new1 level if xor=1 new1: This level is reached when xor=1. Here is where we insert/delete the hash of the old and the new trees with just one element. -na: Not appliable. After processing it, we go to the na level. +na: Not applicable. After processing it, we go to the na level. -Fnction +Function fnc[0] fnc[1] 0 0 NOP 0 1 UPDATE diff --git a/circuits/smt/smtverifierlevel.circom b/circuits/smt/smtverifierlevel.circom index defeee33..fac64a93 100644 --- a/circuits/smt/smtverifierlevel.circom +++ b/circuits/smt/smtverifierlevel.circom @@ -33,7 +33,7 @@ iold old1leaf inew new1leaf na 0 -H' is the Hash function with the inputs shifted acordingly. +H' is the Hash function with the inputs shifted accordingly. *****/ pragma circom 2.0.0; diff --git a/test/binsub.js b/test/binsub.js index 12809c92..6b932e9d 100644 --- a/test/binsub.js +++ b/test/binsub.js @@ -29,7 +29,7 @@ describe("BinSub test", function () { circuit = await wasm_tester(path.join(__dirname, "circuits", "binsub_test.circom")); }); - it("Should check variuos ege cases", async () => { + it("Should check various edge cases", async () => { await checkSub(0,0, circuit); await checkSub(1,0, circuit); await checkSub(-1,0, circuit); diff --git a/test/eddsamimc.js b/test/eddsamimc.js index 0cf51211..5f6e7c4a 100644 --- a/test/eddsamimc.js +++ b/test/eddsamimc.js @@ -75,7 +75,7 @@ describe("EdDSA MiMC test", function () { }); - it("Test a dissabled circuit with a bad signature", async () => { + it("Test a disabled circuit with a bad signature", async () => { const msg = F.e(1234); const prvKey = Buffer.from("0001020304050607080900010203040506070809000102030405060708090001", "hex"); diff --git a/test/eddsaposeidon.js b/test/eddsaposeidon.js index 3dec2cd6..e0d51f66 100644 --- a/test/eddsaposeidon.js +++ b/test/eddsaposeidon.js @@ -77,7 +77,7 @@ describe("EdDSA Poseidon test", function () { }); - it("Test a dissabled circuit with a bad signature", async () => { + it("Test a disabled circuit with a bad signature", async () => { const msg = F.e(1234); const prvKey = Buffer.from("0001020304050607080900010203040506070809000102030405060708090001", "hex"); diff --git a/test/point2bits.js b/test/point2bits.js index 98af5166..e118217f 100644 --- a/test/point2bits.js +++ b/test/point2bits.js @@ -17,12 +17,12 @@ describe("Point 2 bits test", function() { circuit = await wasm_tester(path.join(__dirname, "circuits", "pointbits_loopback.circom")); }); - it("Should do the both convertions for 8Base", async () => { + it("Should do both conversions for 8Base", async () => { const w = await circuit.calculateWitness({ in: [F.toObject(babyJub.Base8[0]), F.toObject(babyJub.Base8[1])]}, true); await circuit.checkConstraints(w); }); - it("Should do the both convertions for Zero point", async () => { + it("Should do both conversions for Zero point", async () => { const w = await circuit.calculateWitness({ in: [0, 1]}, true); await circuit.checkConstraints(w); diff --git a/test/smtprocessor.js b/test/smtprocessor.js index 1935b9e8..7d7e2b43 100644 --- a/test/smtprocessor.js +++ b/test/smtprocessor.js @@ -120,7 +120,7 @@ describe("SMT Processor test", function () { await testDelete(tree, 333, circuit); }); - it("Should test convination of adding and removing 3 elements", async () => { + it("Should test combination of adding and removing 3 elements", async () => { const keys = [Fr.e(8), Fr.e(9), Fr.e(32)]; const values = [Fr.e(88), Fr.e(99), Fr.e(3232)]; const tree1 = await newMemEmptyTrie();