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.
- package/contracts/OPRollup.sol +3 -22
- package/contracts/ZKIPFS.sol +0 -1
- package/contracts/ZKJson.sol +1 -1
- package/contracts/ZKRollup.sol +1 -1
- package/contracts/apps/SimpleJSON.sol +64 -0
- package/contracts/apps/SimpleOPRU.sol +67 -0
- package/contracts/apps/SimpleRU.sol +67 -0
- package/contracts/apps/Token.sol +12 -0
- package/contracts/apps/ZKArweave.sol +89 -0
- package/contracts/apps/ZKBridge.sol +74 -0
- package/contracts/apps/ZKNFT.sol +63 -0
- package/contracts/verifiers/verifier_db.sol +49 -35
- package/contracts/verifiers/verifier_ipfs.sol +4 -4
- package/contracts/verifiers/verifier_json.sol +19 -5
- package/contracts/verifiers/verifier_rollup.sol +28 -28
- package/encoder.js +11 -16
- package/package.json +1 -1
- package/decoder-v2.js +0 -604
- package/encoder-v2.1.js +0 -425
- package/encoder-v2.js +0 -886
- package/utils.js +0 -54
@@ -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 =
|
41
|
-
uint256 constant deltax2 =
|
42
|
-
uint256 constant deltay1 =
|
43
|
-
uint256 constant deltay2 =
|
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[
|
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 =
|
41
|
-
uint256 constant deltax2 =
|
42
|
-
uint256 constant deltay1 =
|
43
|
-
uint256 constant deltay2 =
|
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 =
|
47
|
-
uint256 constant IC0y =
|
46
|
+
uint256 constant IC0x = 6270950016247133466336754274326443126017687703801742756948638236534086892047;
|
47
|
+
uint256 constant IC0y = 20310453393525738917452540227487036745129047678621136376195858836563533911527;
|
48
48
|
|
49
|
-
uint256 constant IC1x =
|
50
|
-
uint256 constant IC1y =
|
49
|
+
uint256 constant IC1x = 1141343197515056438569346347535803858564689453833647046018791462772549149227;
|
50
|
+
uint256 constant IC1y = 16491780663163267442130703331018113562992698794258578658230547724337214632511;
|
51
51
|
|
52
|
-
uint256 constant IC2x =
|
53
|
-
uint256 constant IC2y =
|
52
|
+
uint256 constant IC2x = 5569694830107596991306292701850289725347601942273592203980263593485643232633;
|
53
|
+
uint256 constant IC2y = 5496875873369182800954050214612959091907601104963709673444966250025502326758;
|
54
54
|
|
55
|
-
uint256 constant IC3x =
|
56
|
-
uint256 constant IC3y =
|
55
|
+
uint256 constant IC3x = 856226396972901355666350894014284120170327945287396680478814592107007149805;
|
56
|
+
uint256 constant IC3y = 4080222902213037494283476857599202091267684100021446005131603140238216815391;
|
57
57
|
|
58
|
-
uint256 constant IC4x =
|
59
|
-
uint256 constant IC4y =
|
58
|
+
uint256 constant IC4x = 10764306455319897189590233363611208010675243280639689255137625645138943859385;
|
59
|
+
uint256 constant IC4y = 19346540917500920047750697423047140511552971607568238316315807020898102730868;
|
60
60
|
|
61
|
-
uint256 constant IC5x =
|
62
|
-
uint256 constant IC5y =
|
61
|
+
uint256 constant IC5x = 16857068565745876906748660361991141069946983257614833579471638734061485457112;
|
62
|
+
uint256 constant IC5y = 14632180805427053926564788976583761986580123762441719835724709161702471836981;
|
63
63
|
|
64
|
-
uint256 constant IC6x =
|
65
|
-
uint256 constant IC6y =
|
64
|
+
uint256 constant IC6x = 12315747360356477219902572740218642460149278211574165192334271766621665438376;
|
65
|
+
uint256 constant IC6y = 1313234108449442273460693358644853644145068014633280121061495643296281134420;
|
66
66
|
|
67
|
-
uint256 constant IC7x =
|
68
|
-
uint256 constant IC7y =
|
67
|
+
uint256 constant IC7x = 15252212582859770288887248094717972825568314500168925087757606041256952964029;
|
68
|
+
uint256 constant IC7y = 19751607759272618647644406330677066920139018206963959740625861713276025168423;
|
69
69
|
|
70
|
-
uint256 constant IC8x =
|
71
|
-
uint256 constant IC8y =
|
70
|
+
uint256 constant IC8x = 8432690145128824085267914412714661508760195558814883868966832777728733350601;
|
71
|
+
uint256 constant IC8y = 20683188851611894785172396447809130386092126094512442322570355864144302756164;
|
72
72
|
|
73
|
-
uint256 constant IC9x =
|
74
|
-
uint256 constant IC9y =
|
73
|
+
uint256 constant IC9x = 19369987132771616043793275659835942692385855791064890369063891639761686156657;
|
74
|
+
uint256 constant IC9y = 8426683055759400985089789088504223062497842350159798813155638560974712761643;
|
75
75
|
|
76
|
-
uint256 constant IC10x =
|
77
|
-
uint256 constant IC10y =
|
76
|
+
uint256 constant IC10x = 20860096825664394339889589645802586392309097833727587594050802394079690409091;
|
77
|
+
uint256 constant IC10y = 17908147166318266417496260692526339764629505794576827802816790292654348457101;
|
78
78
|
|
79
|
-
uint256 constant IC11x =
|
80
|
-
uint256 constant IC11y =
|
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
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
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
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
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) {
|