From 9c67e475881738294d7ebe8abb28cabca5ab218f Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Sun, 9 Sep 2018 14:08:15 +0200 Subject: [PATCH] Spelling fixes --- README.md | 24 +++++++++--------- circuits/multiplexer.circom | 10 ++++---- circuits/sha256/binsum.circom | 2 +- circuits/sha256/sha256compression.circom | 2 +- package.json | 4 +-- src/compiler.js | 32 ++++++++++++------------ src/exec.js | 2 +- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index d838a7b..c1a1702 100644 --- a/README.md +++ b/README.md @@ -25,17 +25,17 @@ template NAND() { component main = NAND(); ``` -The language is mainly a javascript/c syntax but with extra 5 operators in order to define the constrains: +The language is mainly a javascript/c syntax but with extra 5 operators in order to define the constraints: -`<==` , `==>` This operator is used to connect signals. This operator also implies a constrain. +`<==` , `==>` This operator is used to connect signals. This operator also implies a constraint. -As you can see in the example above, `out` is assigned a value and a constrain is also generated. The assigned value must be of the form a*b+c where a,b and c are linear convinations of the signals. +As you can see in the example above, `out` is assigned a value and a constraint is also generated. The assigned value must be of the form a*b+c where a,b and c are linear convinations of the signals. -`<--` , `-->` This operators assign values to a signals but does not generate any constrain. This allow to assign any value to a signal including extrange operations like shifhts, modules, divisiones, etc. Generally this operator goes together wit a `===` operator in order to force the constrain. +`<--` , `-->` This operators assign values to a signals but does not generate any constraint. This allow to assign any value to a signal including extrange operations like shifhts, modules, divisiones, etc. Generally this operator goes together wit a `===` operator in order to force the constraint. -`===` This operator defines a constrain. The constrain must be simplificable to the form a*b+c=0 where a,b and c are linear convinations. +`===` This operator defines a constraint. The constraint must be simplificable to the form a*b+c=0 where a,b and c are linear convinations. -In the example above, we force the two inputs to be binary by adding the constrain `a*(a-1)===0` and `b*(b-1) === 0` +In the example above, we force the two inputs to be binary by adding the constraint `a*(a-1)===0` and `b*(b-1) === 0` ### Compile the circui @@ -81,10 +81,10 @@ The first thing we observe in this example is that templates can have parameters Then we define the inputs and the outputs. We see that we can work with arrays. The program allows multidimension arrays for signals and variables. -Then we need to assign the values to the different signals. In this case, we assign the value without the constrain by using the shift and & operators: +Then we need to assign the values to the different signals. In this case, we assign the value without the constraint by using the shift and & operators: `out[i] <-- (in >> i) & 1;` -But we need to define also the constrains. In this case there is a big constrain of the form: +But we need to define also the constraints. In this case there is a big constraint of the form: ``` in === out[0]*2**0 + out[1]*2**1 + out[2]*2**2 .... @@ -92,7 +92,7 @@ in === out[0]*2**0 + out[1]*2**1 + out[2]*2**2 .... We do this by using a variable `lc1` and adding each signal multiplied by his coefficient. -This variable does not hold a value in compilation time, but it holds a linear combination. and it is used in the last constrain: +This variable does not hold a value in compilation time, but it holds a linear combination. and it is used in the last constraint: ``` lc1 === in; @@ -100,7 +100,7 @@ lc1 === in; Finally we also have to force each output to be binary. -We do this by adding this constrain for each output: +We do this by adding this constraint for each output: ``` out[i] * (out[i] -1 ) === 0; @@ -111,7 +111,7 @@ Lets now create a 32bits adder. The strategy will be to first convert the number to binary, do the addition in the binary space and then finally convert it back to a number. -We could do it directly by adding a simple constrain where out === in1 + in2, but if we do this the operation will not be module 2**32 but `r` where r is the range of the elliptic curve. In the case of regular zkSnarks typically is some prime number close to 2**253 +We could do it directly by adding a simple constraint where out === in1 + in2, but if we do this the operation will not be module 2**32 but `r` where r is the range of the elliptic curve. In the case of regular zkSnarks typically is some prime number close to 2**253 With this example we also demostrate the normal patter of binarize a number, work in binary (reguular electronic circuit), and then convert the result back to a number. @@ -159,7 +159,7 @@ This component creates a binary sum componet of ops operands and n bits each ope e is Number of carries: Depends on the number of operands in the input. -Main Constrain: +Main Constraint: in[0][0] * 2^0 + in[0][1] * 2^1 + ..... + in[0][n-1] * 2^(n-1) + + in[1][0] * 2^0 + in[1][1] * 2^1 + ..... + in[1][n-1] * 2^(n-1) + + .. diff --git a/circuits/multiplexer.circom b/circuits/multiplexer.circom index 3145e1b..8925709 100644 --- a/circuits/multiplexer.circom +++ b/circuits/multiplexer.circom @@ -1,8 +1,8 @@ -// --> Assignation without constrain -// <-- Assignation without constrain -// === Constrain -// <== Assignation with constrain -// ==> Assignation with constrain +// --> Assignation without constraint +// <-- Assignation without constraint +// === Constraint +// <== Assignation with constraint +// ==> Assignation with constraint // All variables are members of the field F[p] // https://github.com/zcash-hackworks/sapling-crypto // https://github.com/ebfull/bellman diff --git a/circuits/sha256/binsum.circom b/circuits/sha256/binsum.circom index 6c4cd11..b72fea7 100644 --- a/circuits/sha256/binsum.circom +++ b/circuits/sha256/binsum.circom @@ -7,7 +7,7 @@ This component creates a binary sum componet of ops operands and n bits each ope e is Number of carries: Depends on the number of operands in the input. -Main Constrain: +Main Constraint: in[0][0] * 2^0 + in[0][1] * 2^1 + ..... + in[0][n-1] * 2^(n-1) + + in[1][0] * 2^0 + in[1][1] * 2^1 + ..... + in[1][n-1] * 2^(n-1) + + .. diff --git a/circuits/sha256/sha256compression.circom b/circuits/sha256/sha256compression.circom index a310ca9..1158964 100644 --- a/circuits/sha256/sha256compression.circom +++ b/circuits/sha256/sha256compression.circom @@ -2,7 +2,7 @@ include "constants.jaz"; include "t1.jaz"; include "t2.jaz"; -include "sum.jaz"; +include "binsum.jaz"; include "sigmaplus.jaz"; template sha256compression() { diff --git a/package.json b/package.json index c1e38ce..f034d64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "circom", - "version": "0.0.3", + "version": "0.0.4", "description": "Language to generate logica circuits", "main": "index.js", "directories": { @@ -37,6 +37,6 @@ "eslint": "^5.0.1", "eslint-plugin-mocha": "^5.0.0", "jison": "^0.4.18", - "zksnark": "0.0.3" + "zksnark": "0.0.4" } } diff --git a/src/compiler.js b/src/compiler.js index 9c3bd26..2e6df79 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -53,7 +53,7 @@ function compile(srcFile) { } }, currentComponent: "", - constrains: [], + constraints: [], components: {}, templates: {}, functions: {}, @@ -64,7 +64,7 @@ function compile(srcFile) { exec(ctx, ast); - reduceConstrains(ctx); + reduceConstraints(ctx); generateWitnessNames(ctx); if (ctx.error) { @@ -176,15 +176,15 @@ function generateWitnessNames(ctx) { ctx.totals = totals; } -function reduceConstrains(ctx) { - const newConstrains = []; - for (let i=0; i