zkjson 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,10 +37,10 @@ contract Groth16VerifierJSON {
37
37
  uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
38
38
  uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
39
39
  uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
40
- uint256 constant deltax1 = 16323886806377948767625289345386923912488425685292264502851407533751890364893;
41
- uint256 constant deltax2 = 15728036135898260810892479278030679906213338463446298332250898095140196532350;
42
- uint256 constant deltay1 = 7311361608150524708643711937539709432213365833416427921151717898214981893794;
43
- uint256 constant deltay2 = 5360237348765695204487062346058482342794521371770543578645384390456849442785;
40
+ uint256 constant deltax1 = 10548989649020101460514539324030972308502034681633392883991961616863130637984;
41
+ uint256 constant deltax2 = 1049946570122174039975801346728261460931086847141295177952236227197145479746;
42
+ uint256 constant deltay1 = 10558381744179704646192748283236903784158982943346653783344902335722321321384;
43
+ uint256 constant deltay2 = 16748276816739890599042583608461502899144793788720809401511640542800930620065;
44
44
 
45
45
 
46
46
  uint256 constant IC0x = 11086791052709537593958527982551466373543557342479473456486918346706557110272;
@@ -82,6 +82,12 @@ contract Groth16VerifierJSON {
82
82
  uint256 constant IC12x = 3003572233500184455318954446784006239696026573012811847295348627074111281539;
83
83
  uint256 constant IC12y = 6485361686957307324235352983357156310358934769793375149333110905137006337248;
84
84
 
85
+ uint256 constant IC13x = 2025484288051762304170760878169695013364214111997466862551524207031601382631;
86
+ uint256 constant IC13y = 7038960739366138059493181524660940249493960394838603142532679804397882049709;
87
+
88
+ uint256 constant IC14x = 11387856957329089595489992260814785056704488293876837097183204151395206987719;
89
+ uint256 constant IC14y = 17844362785282169318131685916181008035618810588862118232161118858351706006467;
90
+
85
91
 
86
92
  // Memory data
87
93
  uint16 constant pVk = 0;
@@ -89,7 +95,7 @@ contract Groth16VerifierJSON {
89
95
 
90
96
  uint16 constant pLastMem = 896;
91
97
 
92
- function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[12] calldata _pubSignals) public view returns (bool) {
98
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[14] calldata _pubSignals) public view returns (bool) {
93
99
  assembly {
94
100
  function checkField(v) {
95
101
  if iszero(lt(v, q)) {
@@ -157,6 +163,10 @@ contract Groth16VerifierJSON {
157
163
 
158
164
  g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
159
165
 
166
+ g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
167
+
168
+ g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
169
+
160
170
 
161
171
  // -A
162
172
  mstore(_pPairing, calldataload(pA))
@@ -236,6 +246,10 @@ contract Groth16VerifierJSON {
236
246
 
237
247
  checkField(calldataload(add(_pubSignals, 384)))
238
248
 
249
+ checkField(calldataload(add(_pubSignals, 416)))
250
+
251
+ checkField(calldataload(add(_pubSignals, 448)))
252
+
239
253
 
240
254
  // Validate all evaluations
241
255
  let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
@@ -37,47 +37,47 @@ contract Groth16VerifierRU {
37
37
  uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
38
38
  uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
39
39
  uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
40
- uint256 constant deltax1 = 20503591479484091524389745903571071797103515451455738548515763475839920684921;
41
- uint256 constant deltax2 = 5617943403828393228867947181181000280381763965560908736009901041763172427158;
42
- uint256 constant deltay1 = 19083313989582849416852727426203922087129577621288485271208858162180563989517;
43
- uint256 constant deltay2 = 6862756714407978275897080062526754044127957156216819881004695153747745594448;
40
+ uint256 constant deltax1 = 12826039923985305509172445548825630308307897385636638314103089050117034765807;
41
+ uint256 constant deltax2 = 5777316040111550683119122338100696671533578054713112313962719197468777904391;
42
+ uint256 constant deltay1 = 13100118653411399080908320939554734522926116642572965561618759712020115377487;
43
+ uint256 constant deltay2 = 4863992084126820334137644474127866316351574790993028000936897867731380377202;
44
44
 
45
45
 
46
- uint256 constant IC0x = 8117166905692109919104291343856029475477412767491303376211389191152967038468;
47
- uint256 constant IC0y = 9786515749803639719852807382408592347129424775311166090035686108630492765324;
46
+ uint256 constant IC0x = 6270950016247133466336754274326443126017687703801742756948638236534086892047;
47
+ uint256 constant IC0y = 20310453393525738917452540227487036745129047678621136376195858836563533911527;
48
48
 
49
- uint256 constant IC1x = 8372619712685736857836778212277410061184000966061820660353663736436010324900;
50
- uint256 constant IC1y = 7067497483771029122224543049910217766313555809959258482125432607420578209549;
49
+ uint256 constant IC1x = 1141343197515056438569346347535803858564689453833647046018791462772549149227;
50
+ uint256 constant IC1y = 16491780663163267442130703331018113562992698794258578658230547724337214632511;
51
51
 
52
- uint256 constant IC2x = 8664544978528071254218294973797032588678014503773496766308416357733046318778;
53
- uint256 constant IC2y = 1718370739886043626655047048989167081845643514431816517183086335106787323814;
52
+ uint256 constant IC2x = 5569694830107596991306292701850289725347601942273592203980263593485643232633;
53
+ uint256 constant IC2y = 5496875873369182800954050214612959091907601104963709673444966250025502326758;
54
54
 
55
- uint256 constant IC3x = 17751478333748864683647456466294726036073972233143791990284780060329145813120;
56
- uint256 constant IC3y = 5332438974111244723611637766367681701415489964863909660487320379077476391752;
55
+ uint256 constant IC3x = 856226396972901355666350894014284120170327945287396680478814592107007149805;
56
+ uint256 constant IC3y = 4080222902213037494283476857599202091267684100021446005131603140238216815391;
57
57
 
58
- uint256 constant IC4x = 20742828080385750796683930560189396553036781354782278562302384256732853843949;
59
- uint256 constant IC4y = 1351673933396889997409523595926983213620423546050525776383348532660582633773;
58
+ uint256 constant IC4x = 10764306455319897189590233363611208010675243280639689255137625645138943859385;
59
+ uint256 constant IC4y = 19346540917500920047750697423047140511552971607568238316315807020898102730868;
60
60
 
61
- uint256 constant IC5x = 20503268205499473416904271262498573431374552398139117269682363052068963140978;
62
- uint256 constant IC5y = 3732804412299701993142127591762498360367649767364421523113109866299226710165;
61
+ uint256 constant IC5x = 16857068565745876906748660361991141069946983257614833579471638734061485457112;
62
+ uint256 constant IC5y = 14632180805427053926564788976583761986580123762441719835724709161702471836981;
63
63
 
64
- uint256 constant IC6x = 14257995503266038917376264725392135727319727614567664291464265707947560137941;
65
- uint256 constant IC6y = 341674734661014039525000101720981104421961371042562178520683297866596707154;
64
+ uint256 constant IC6x = 12315747360356477219902572740218642460149278211574165192334271766621665438376;
65
+ uint256 constant IC6y = 1313234108449442273460693358644853644145068014633280121061495643296281134420;
66
66
 
67
- uint256 constant IC7x = 8193832556543527639708689676411352413933876589415237015016698770441031255042;
68
- uint256 constant IC7y = 6594427869611603078697503063082014095062802376771554910392397589449346189644;
67
+ uint256 constant IC7x = 15252212582859770288887248094717972825568314500168925087757606041256952964029;
68
+ uint256 constant IC7y = 19751607759272618647644406330677066920139018206963959740625861713276025168423;
69
69
 
70
- uint256 constant IC8x = 13583345943944676979948187443700187050998549308300528606491967244177176520006;
71
- uint256 constant IC8y = 4938411793249197289917720689106756285526796809363092891408044710943884674802;
70
+ uint256 constant IC8x = 8432690145128824085267914412714661508760195558814883868966832777728733350601;
71
+ uint256 constant IC8y = 20683188851611894785172396447809130386092126094512442322570355864144302756164;
72
72
 
73
- uint256 constant IC9x = 11332284497411134754454830299053795514601435700763578724160974435166700044531;
74
- uint256 constant IC9y = 13019000604073974366403109311897527900603263821666939992822627393063021671404;
73
+ uint256 constant IC9x = 19369987132771616043793275659835942692385855791064890369063891639761686156657;
74
+ uint256 constant IC9y = 8426683055759400985089789088504223062497842350159798813155638560974712761643;
75
75
 
76
- uint256 constant IC10x = 14399226292391120536283418546213611923264868223599916657548457588778188745914;
77
- uint256 constant IC10y = 15721807309515116598525148493431362514780681023570830598111469229105621080436;
76
+ uint256 constant IC10x = 20860096825664394339889589645802586392309097833727587594050802394079690409091;
77
+ uint256 constant IC10y = 17908147166318266417496260692526339764629505794576827802816790292654348457101;
78
78
 
79
- uint256 constant IC11x = 9762413796519510440691741324561546062505760014187240868624893625208356342750;
80
- uint256 constant IC11y = 16246137136591544636923946475468706707718504791810616178029498386514365251482;
79
+ uint256 constant IC11x = 7111525545052173450141644018481693095722931164254044734852844952175519360375;
80
+ uint256 constant IC11y = 14968059451881120855243147686628983750275388350316603656458857787322628363714;
81
81
 
82
82
 
83
83
  // Memory data
package/encoder.js CHANGED
@@ -394,24 +394,19 @@ function decode(arr) {
394
394
  return json
395
395
  }
396
396
 
397
- const toIndex = str => {
398
- return (
399
- "1" +
400
- str
401
- .split("")
402
- .map(s => base64Map[s])
403
- .join("")
404
- )
397
+ function toIndex(rawStr) {
398
+ const b64url = Buffer.from(rawStr, "utf8").toString("base64url")
399
+ const bi = BigInt("0x" + Buffer.from(b64url, "base64url").toString("hex"))
400
+ return bi.toString(10)
405
401
  }
406
402
 
407
- const fromIndex = id => {
408
- let _id = id.toString().split("")
409
- _id.shift()
410
- return splitEvery(2, _id)
411
- .map(s => {
412
- return strMap[s.join("")]
413
- })
414
- .join("")
403
+ function fromIndex(idxStr) {
404
+ const bi = BigInt(idxStr)
405
+ let hex = bi.toString(16)
406
+ if (hex.length % 2) hex = "0" + hex
407
+ const buf = Buffer.from(hex, "hex")
408
+ const b64url = buf.toString("base64url")
409
+ return Buffer.from(b64url, "base64url").toString("utf8")
415
410
  }
416
411
 
417
412
  function toSignal(arr) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zkjson",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "Zero Knowledge Provable JSON",
5
5
  "main": "index.js",
6
6
  "license": "MIT",