Browse Source

Extend eq and neq in bigint

master
Jordi Baylina 5 years ago
parent
commit
3343981187
No known key found for this signature in database GPG Key ID: 7480C80C1BE43112
8 changed files with 37 additions and 30 deletions
  1. +3
    -3
      README.md
  2. +1
    -1
      package-lock.json
  3. +1
    -1
      package.json
  4. +11
    -7
      src/bigint.js
  5. +11
    -8
      src/calculateWitness.js
  6. +8
    -8
      src/circuit.js
  7. +1
    -1
      vk_proof.json
  8. +1
    -1
      vk_verifier.json

+ 3
- 3
README.md

@ -64,10 +64,10 @@ const circuit = new zkSnark.Circuit(circuitDef);
// returns signal Idx given a signalId
// if the idx >= n , it is a constant
// if the idx == -1, the signal does not exist
circuit.signalId2idx(signalId);
circuit.getSignalIdx(name);
// returns an array aliases names for a given signalId
circuit.signalNames(signalId)
// returns an array aliases names of the i'th signal
circuit.signalNames(i)
// input is a key value object where keys are the signal names
// of all the inputs (public and private)

+ 1
- 1
package-lock.json

@ -1,6 +1,6 @@
{
"name": "zksnark",
"version": "0.0.2",
"version": "0.0.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

+ 1
- 1
package.json

@ -1,6 +1,6 @@
{
"name": "zksnark",
"version": "0.0.5",
"version": "0.0.10",
"description": "zkSNARKs implementation in JavaScript",
"main": "index.js",
"scripts": {

+ 11
- 7
src/bigint.js

@ -3,17 +3,17 @@
This file is part of zksnark JavaScript library.
zksnark JavaScript library is a free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your option)
zksnark JavaScript library is a free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your option)
any later version.
zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
You should have received a copy of the GNU General Public License along with
zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/
@ -196,10 +196,14 @@ if (typeof(BigInt) != "undefined") {
wBigInt.prototype.lt = wBigInt.prototype.lesser;
wBigInt.prototype.equals = function(b) {
return this.valueOf == b.valueOf;
return this == b;
};
wBigInt.prototype.eq = wBigInt.prototype.equals;
wBigInt.prototype.neq = function(b) {
return this != b;
};
} else {
wBigInt = bigInt;

+ 11
- 8
src/calculateWitness.js

@ -3,17 +3,17 @@
This file is part of zksnark JavaScript library.
zksnark JavaScript library is a free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your option)
zksnark JavaScript library is a free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your option)
any later version.
zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
You should have received a copy of the GNU General Public License along with
zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/
@ -63,7 +63,8 @@ function calculateWitness(circuit, inputSignals, log) {
}
log(circuit.signalNames(i) + " --> " + ctx.witness[i].toString());
}
return ctx.witness.slice(0, circuit.nVars);
// return ctx.witness.slice(0, circuit.nVars);
return ctx.witness;
}
class RTCtx {
@ -102,7 +103,8 @@ class RTCtx {
}
triggerComponent(c) {
this.log("Component Treiggered: " + c);
this.log("Component Treiggered: " + this.circuit.components[c].name);
// console.log("Start Component Treiggered: " + this.circuit.components[c].name);
// Set notInitSignals to -1 to not initialize again
this.notInitSignals[c] --;
@ -123,6 +125,7 @@ class RTCtx {
this.circuit.templates[template](this);
this.scopes = oldScope;
this.currentComponent = oldComponent;
// console.log("End Component Treiggered: " + this.circuit.components[c].name);
}
callFunction(functionName, params) {

+ 8
- 8
src/circuit.js

@ -3,17 +3,17 @@
This file is part of zksnark JavaScript library.
zksnark JavaScript library is a free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your option)
zksnark JavaScript library is a free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your option)
any later version.
zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
You should have received a copy of the GNU General Public License along with
zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/
@ -55,8 +55,8 @@ module.exports = class Circuit {
}
}
calculateWitness(input) {
return calculateWitness(this, input);
calculateWitness(input, log) {
return calculateWitness(this, input, log);
}
getSignalIdx(name) {

+ 1
- 1
vk_proof.json
File diff suppressed because it is too large
View File


+ 1
- 1
vk_verifier.json

@ -1 +1 @@
{"nPublic":2,"A":[["8869480890407400540469055963359590507987597393199097673027091987650264364061","5571907540423363476841022818006679599665853137083440200184777102165277098817","1"],["6633468076564780863514337919192698659670454271838273855072390679308886530310","429493619176981385766703804751832373350001551268095165774411888948969491950","1"],["19426274234765689814302294909820181848270118587988082067156950064905560926931","1695477578673085121076028646361009269587800426136069029657833948839317064337","1"]],"vk_a":[["9558065993096722619194348013003368448455409149209998185448725231242350559037","13239868567274065766518626919165092515693823482301378347535196751087568534444"],["15755283830213584683068171246338843258532229236358958552014038612487929896062","3153284277012109552592951624813624632174752658107256746771368513013038228043"],["1","0"]],"vk_b":["17354262195547823174876699589198990688681878796536601531562937007514516671853","7162052175129872674271805560925971314168271233337491952757123238320537067879","1"],"vk_c":[["7693684659995323340441116715427481225095994411375752825539273279038259454951","10648716232561230073794574427969376323946394300393013505624550867362612174214"],["11734707860058618049534410500192734768105180910065417858398014404265709352271","21506229572548609231162936645658298292512149586246110033845868713358599629278"],["1","0"]],"vk_gb_1":["15199098438219395704649974705700501004072202950326097683120792370668183201506","13299363141613092755383156216642793279087604636332222643379319320134567293629","1"],"vk_gb_2":[["2495211911722558402361816493871854939721351321264743350228722750619762019851","11072264826888167640230080860242406855142747886036602311071889683947024413374"],["1870380426396851921468082138410047376113205220686247333524259418069006545584","5795709345107136167474523802037689880174609756763741663153027030192574284600"],["1","0"]],"vk_g":[["16502879486405452648347881982387306429485452949136993847302940683378115949680","21851496291674945989844013109262365122606457776299303431809616926117687307476"],["19775694068609122229399084459362866576707393855951866590081960512562438426082","4788247667758387200027229334961625040838388285858126172643675111850793702743"],["1","0"]],"vk_z":[["13149164608723998054087483988287670870065310147853196434398655904923682722297","13041349085808911888919639829378875740211950179957717170427958580861863453491"],["11051209221709485835318728113780202233394218312574766047108621841112894950486","6100918243225388259690002723108589237985714117354432529032595467352126024985"],["1","0"]]}
{"nPublic":2,"A":[["3740027577784637667755831236754838923221273668253985582842553244858885771258","9592571309994574425960298767340264425416752429626387947544366380226364324587","1"],["7929428367483823414431305147874609197054687547694158223231137663454402521312","2248440986587677607597843554632141824705855338145348882671586523260115087530","1"],["291424160018420396441612890158894565798364527836500117169829214206636680634","2314365418414074678808872877824077678398444055163717596481315211292403211703","1"]],"vk_a":[["8881275104457031447224967306498092521752075875252825035920773112144641846533","19044074891661339453363799668292250441393928778638562506942549325553739387200"],["2086829591441965942047600720384071748562203149116242805347620094720458818364","2233583170742205993218399461931028314009815505476085282430862361579971126486"],["1","0"]],"vk_b":["3022074772410355237457935361303925729387055474049271722726603725848677792168","10407266220832660740657444756182368494915109838913375295052340072271331429457","1"],"vk_c":[["179895878146808655821211465612339406859227017334850619007680172849425985840","19050526750289359018815298131792858960664573755498997445844774200494542565852"],["6780511559103126099154098009101613765969188400533666882008477357437695027605","16734561688793545456153820167934358059807932504441565983543811976626584958040"],["1","0"]],"vk_gb_1":["2628943267973028565949758192881870666879529352541557255149917575832069266308","16026829005628508560177742705526021974620368929136073489318031095119292261740","1"],"vk_gb_2":[["5570325277489877498516577287656641342175870705261614631660098797940839673076","1977921746034887717493736339358725390141607976633718410996211921553386196740"],["2596920045027594355475206701355478387324145804118005571275494683015430229044","16178114461713920926474969726772649463565503086252628855547215011041035520835"],["1","0"]],"vk_g":[["1491749999826863613247241097181525246952705133989986458927479762724777044307","2838724581887439647088873221702826176337930907599262862813348358553102558538"],["12794274084162456889944076250233128882085602227657801416955137977141721925351","18155062735416014101866922652316001738005875441736254102396009150688894845731"],["1","0"]],"vk_z":[["476212861342478727995500214196208542694089397343431743542571278870137702749","4054571642880358884345967989330262058477084212626257242856205493563060216986"],["20733042221264242116649916650027549760962977734178936800414268544559411559893","9707580111670134911851558964954952311243783582602693500120451921213502951369"],["1","0"]]}

Loading…
Cancel
Save