zkjson 0.5.3 → 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.
@@ -1,31 +1,12 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
 
3
3
  pragma solidity >=0.7.0 <0.9.0;
4
- import "./ZKQuery.sol";
4
+ import "./ZKRollup.sol";
5
5
 
6
- interface VerifierRU {
7
- function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[11] calldata _pubSignals) view external returns (bool);
8
6
 
9
- }
10
-
11
- contract OPRollup is ZKQuery {
12
- address public verifierRU;
13
- address public committer;
14
- uint public root;
7
+ contract OPRollup is ZKRollup {
15
8
 
16
- function _validateQueryRU(uint[] memory path, uint[] memory zkp, uint size_path, uint size_val) internal view returns(uint[] memory){
17
- require(zkp[19] == root, "root mismatch");
18
- require(zkp[size_path + size_val + 10] == path[0], "wrong collection");
19
- require(zkp[size_path + size_val + 11] == path[1], "wrong doc");
20
- require(zkp[8] == 1, "value doesn't exist");
21
- require(path.length <= size_path + size_val, "path too long");
22
- for(uint i = 9; i < 9 + path.length - 2; i++) require(path[i - 7] == zkp[i], "wrong path");
23
- uint[] memory value = new uint[](size_val);
24
- for(uint i = 9 + size_path; i < 9 + size_path + size_val; i++) value[i - (9 + size_path)] = zkp[i];
25
- return toArr(value);
26
- }
27
-
28
- function commit (uint _root) public returns (uint) {
9
+ function commitRoot (uint _root) public returns (uint) {
29
10
  require(msg.sender == committer, "sender is not committer");
30
11
  root = _root;
31
12
  return root;
@@ -2,7 +2,6 @@
2
2
 
3
3
  pragma solidity >=0.7.0 <0.9.0;
4
4
  import "./ZKQuery.sol";
5
- import "hardhat/console.sol";
6
5
 
7
6
  interface VerifierIPFS {
8
7
  function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[43] calldata _pubSignals) external view returns (bool);
@@ -13,7 +13,7 @@ contract ZKJson is ZKQuery{
13
13
  }
14
14
  uint[] memory value = new uint[](size_val);
15
15
  for(uint i = 10 + size_path; i < 10 + size_path + size_val; i++){
16
- value[i - (10 + size_val)] = zkp[i];
16
+ value[i - (10 + size_path)] = zkp[i];
17
17
  }
18
18
  return toArr(value);
19
19
  }
@@ -14,7 +14,7 @@ contract ZKRollup is ZKQuery {
14
14
  uint public root;
15
15
 
16
16
  function _validateQueryRU(uint[] memory path, uint[] memory zkp, uint size_path, uint size_val) internal view returns(uint[] memory){
17
- require(zkp[19] == root, "root mismatch");
17
+ require(zkp[size_path + size_val + 9] == root, "root mismatch");
18
18
  require(zkp[size_path + size_val + 10] == path[0], "wrong collection");
19
19
  require(zkp[size_path + size_val + 11] == path[1], "wrong doc");
20
20
  require(zkp[8] == 1, "value doesn't exist");
@@ -0,0 +1,64 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.7.0 <0.9.0;
4
+
5
+ import "../ZKJson.sol";
6
+
7
+ interface VerifierJSON {
8
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[14] calldata _pubSignals) view external returns (bool);
9
+ }
10
+
11
+ contract SimpleJSON is ZKJson {
12
+ uint constant SIZE_PATH = 4;
13
+ uint constant SIZE_VAL = 8;
14
+
15
+ constructor (address _verifierJSON){
16
+ verifierJSON = _verifierJSON;
17
+ }
18
+
19
+ function validateQuery(uint[] memory path, uint[] memory zkp) private view returns(uint[] memory){
20
+ verify(zkp, VerifierJSON.verifyProof.selector, verifierJSON);
21
+ return _validateQueryJSON(path, zkp, SIZE_PATH, SIZE_VAL);
22
+ }
23
+
24
+ function qInt (uint[] memory path, uint[] memory zkp) public view returns (int) {
25
+ uint[] memory value = validateQuery(path, zkp);
26
+ return _qInt(value);
27
+ }
28
+
29
+ function qFloat (uint[] memory path, uint[] memory zkp) public view returns (uint[3] memory) {
30
+ uint[] memory value = validateQuery(path, zkp);
31
+ return _qFloat(value);
32
+ }
33
+
34
+ function qRaw (uint[] memory path, uint[] memory zkp) public view returns (uint[] memory) {
35
+ uint[] memory value = validateQuery(path, zkp);
36
+ return _qRaw(value);
37
+ }
38
+
39
+ function qString (uint[] memory path, uint[] memory zkp) public view returns (string memory) {
40
+ uint[] memory value = validateQuery(path, zkp);
41
+ return _qString(value);
42
+ }
43
+
44
+ function qBool (uint[] memory path, uint[] memory zkp) public view returns (bool) {
45
+ uint[] memory value = validateQuery(path, zkp);
46
+ return _qBool(value);
47
+ }
48
+
49
+ function qNull (uint[] memory path, uint[] memory zkp) public view returns (bool) {
50
+ uint[] memory value = validateQuery(path, zkp);
51
+ return _qNull(value);
52
+ }
53
+
54
+ function qCond (uint[] memory path, uint[] memory cond, uint[] memory zkp) public view returns (bool) {
55
+ uint[] memory value = validateQuery(path, zkp);
56
+ return _qCond(value, cond);
57
+ }
58
+
59
+ function qCustom (uint[] memory path, uint[] memory path2, uint[] memory zkp) public view returns (int) {
60
+ uint[] memory value = validateQuery(path, zkp);
61
+ return getInt(path2, value);
62
+ }
63
+
64
+ }
@@ -0,0 +1,67 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.7.0 <0.9.0;
4
+
5
+ import "../OPRollup.sol";
6
+
7
+ interface VerifierDB {
8
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[16] calldata _pubSignals) view external returns (bool);
9
+ }
10
+
11
+ contract SimpleOPRU is OPRollup {
12
+ uint constant SIZE_PATH = 4;
13
+ uint constant SIZE_VAL = 8;
14
+ address public verifierDB;
15
+
16
+ constructor (address _verifierRU, address _verifierDB, address _committer){
17
+ verifierRU = _verifierRU;
18
+ verifierDB = _verifierDB;
19
+ committer = _committer;
20
+ }
21
+
22
+ function validateQuery(uint[] memory path, uint[] memory zkp) private view returns(uint[] memory){
23
+ verify(zkp, VerifierDB.verifyProof.selector, verifierDB);
24
+ return _validateQueryRU(path, zkp, SIZE_PATH, SIZE_VAL);
25
+ }
26
+
27
+ function qInt (uint[] memory path, uint[] memory zkp) public view returns (int) {
28
+ uint[] memory value = validateQuery(path, zkp);
29
+ return _qInt(value);
30
+ }
31
+
32
+ function qFloat (uint[] memory path, uint[] memory zkp) public view returns (uint[3] memory) {
33
+ uint[] memory value = validateQuery(path, zkp);
34
+ return _qFloat(value);
35
+ }
36
+
37
+ function qRaw (uint[] memory path, uint[] memory zkp) public view returns (uint[] memory) {
38
+ uint[] memory value = validateQuery(path, zkp);
39
+ return _qRaw(value);
40
+ }
41
+
42
+ function qString (uint[] memory path, uint[] memory zkp) public view returns (string memory) {
43
+ uint[] memory value = validateQuery(path, zkp);
44
+ return _qString(value);
45
+ }
46
+
47
+ function qBool (uint[] memory path, uint[] memory zkp) public view returns (bool) {
48
+ uint[] memory value = validateQuery(path, zkp);
49
+ return _qBool(value);
50
+ }
51
+
52
+ function qNull (uint[] memory path, uint[] memory zkp) public view returns (bool) {
53
+ uint[] memory value = validateQuery(path, zkp);
54
+ return _qNull(value);
55
+ }
56
+
57
+ function qCond (uint[] memory path, uint[] memory cond, uint[] memory zkp) public view returns (bool) {
58
+ uint[] memory value = validateQuery(path, zkp);
59
+ return _qCond(value, cond);
60
+ }
61
+
62
+ function qCustom (uint[] memory path, uint[] memory path2, uint[] memory zkp) public view returns (int) {
63
+ uint[] memory value = validateQuery(path, zkp);
64
+ return getInt(path2, value);
65
+ }
66
+
67
+ }
@@ -0,0 +1,67 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.7.0 <0.9.0;
4
+
5
+ import "../ZKRollup.sol";
6
+
7
+ interface VerifierDB {
8
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[16] calldata _pubSignals) view external returns (bool);
9
+ }
10
+
11
+ contract SimpleRU is ZKRollup {
12
+ uint constant SIZE_PATH = 4;
13
+ uint constant SIZE_VAL = 8;
14
+ address public verifierDB;
15
+
16
+ constructor (address _verifierRU, address _verifierDB, address _committer){
17
+ verifierRU = _verifierRU;
18
+ verifierDB = _verifierDB;
19
+ committer = _committer;
20
+ }
21
+
22
+ function validateQuery(uint[] memory path, uint[] memory zkp) private view returns(uint[] memory){
23
+ verify(zkp, VerifierDB.verifyProof.selector, verifierDB);
24
+ return _validateQueryRU(path, zkp, SIZE_PATH, SIZE_VAL);
25
+ }
26
+
27
+ function qInt (uint[] memory path, uint[] memory zkp) public view returns (int) {
28
+ uint[] memory value = validateQuery(path, zkp);
29
+ return _qInt(value);
30
+ }
31
+
32
+ function qFloat (uint[] memory path, uint[] memory zkp) public view returns (uint[3] memory) {
33
+ uint[] memory value = validateQuery(path, zkp);
34
+ return _qFloat(value);
35
+ }
36
+
37
+ function qRaw (uint[] memory path, uint[] memory zkp) public view returns (uint[] memory) {
38
+ uint[] memory value = validateQuery(path, zkp);
39
+ return _qRaw(value);
40
+ }
41
+
42
+ function qString (uint[] memory path, uint[] memory zkp) public view returns (string memory) {
43
+ uint[] memory value = validateQuery(path, zkp);
44
+ return _qString(value);
45
+ }
46
+
47
+ function qBool (uint[] memory path, uint[] memory zkp) public view returns (bool) {
48
+ uint[] memory value = validateQuery(path, zkp);
49
+ return _qBool(value);
50
+ }
51
+
52
+ function qNull (uint[] memory path, uint[] memory zkp) public view returns (bool) {
53
+ uint[] memory value = validateQuery(path, zkp);
54
+ return _qNull(value);
55
+ }
56
+
57
+ function qCond (uint[] memory path, uint[] memory cond, uint[] memory zkp) public view returns (bool) {
58
+ uint[] memory value = validateQuery(path, zkp);
59
+ return _qCond(value, cond);
60
+ }
61
+
62
+ function qCustom (uint[] memory path, uint[] memory path2, uint[] memory zkp) public view returns (int) {
63
+ uint[] memory value = validateQuery(path, zkp);
64
+ return getInt(path2, value);
65
+ }
66
+
67
+ }
@@ -0,0 +1,12 @@
1
+ // contracts/GLDToken.sol
2
+ // SPDX-License-Identifier: MIT
3
+ pragma solidity ^0.8.0;
4
+
5
+ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
6
+
7
+ contract Token is ERC20 {
8
+ constructor() ERC20("Token", "TOKEN") {}
9
+ function mint(address to, uint amount) public {
10
+ _mint(to, amount);
11
+ }
12
+ }
@@ -0,0 +1,89 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.7.0 <0.9.0;
4
+
5
+ import "../ZKJson.sol";
6
+
7
+ interface VerifierJSON {
8
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[14] calldata _pubSignals) view external returns (bool);
9
+
10
+ }
11
+
12
+ contract ZKArweave is ZKJson {
13
+ address public verifier;
14
+ address public validator;
15
+ uint constant SIZE_PATH = 4;
16
+ uint constant SIZE_VAL = 8;
17
+
18
+ constructor (address _verifier, address _validator){
19
+ verifier = _verifier;
20
+ validator = _validator;
21
+ }
22
+
23
+ function validateQuery(string memory txid, uint[] memory path, uint[] memory zkp, bytes memory sig) public view returns(uint[] memory){
24
+ verify(zkp, VerifierJSON.verifyProof.selector, verifier);
25
+ verifyMessage(txid, zkp[9], sig);
26
+ return _validateQueryJSON(path, zkp, SIZE_PATH, SIZE_VAL);
27
+ }
28
+
29
+ function qInt (string memory txid, uint[] memory path, uint[] memory zkp, bytes memory sig) public view returns (int) {
30
+ uint[] memory value = validateQuery(txid, path, zkp, sig);
31
+ return _qInt(value);
32
+ }
33
+
34
+ function qFloat (string memory txid, uint[] memory path, uint[] memory zkp, bytes memory sig) public view returns (uint[3] memory) {
35
+ uint[] memory value = validateQuery(txid, path, zkp, sig);
36
+ return _qFloat(value);
37
+ }
38
+
39
+ function qRaw (string memory txid, uint[] memory path, uint[] memory zkp, bytes memory sig) public view returns (uint[] memory) {
40
+ uint[] memory value = validateQuery(txid, path, zkp, sig);
41
+ return _qRaw(value);
42
+ }
43
+
44
+ function qString (string memory txid, uint[] memory path, uint[] memory zkp, bytes memory sig) public view returns (string memory) {
45
+ uint[] memory value = validateQuery(txid, path, zkp, sig);
46
+ return _qString(value);
47
+ }
48
+
49
+ function qBool (string memory txid, uint[] memory path, uint[] memory zkp, bytes memory sig) public view returns (bool) {
50
+ uint[] memory value = validateQuery(txid, path, zkp, sig);
51
+ return _qBool(value);
52
+ }
53
+
54
+ function qNull (string memory txid, uint[] memory path, uint[] memory zkp, bytes memory sig) public view returns (bool) {
55
+ uint[] memory value = validateQuery(txid, path, zkp, sig);
56
+ return _qNull(value);
57
+ }
58
+
59
+ function getMessageHash(string memory txid, uint hash) public pure returns (bytes32) {
60
+ return keccak256(abi.encodePacked(txid, hash));
61
+ }
62
+
63
+ function getEthSignedMessageHash( bytes32 _messageHash ) private pure returns (bytes32) {
64
+ return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _messageHash));
65
+ }
66
+
67
+ function verifyMessage(string memory txid, uint _message, bytes memory signature) public view returns (bool) {
68
+ bytes32 messageHash = getMessageHash(txid, _message);
69
+ bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash);
70
+ return recoverSigner(ethSignedMessageHash, signature) == validator;
71
+ }
72
+
73
+ function recoverSigner(
74
+ bytes32 _ethSignedMessageHash,
75
+ bytes memory _signature
76
+ ) private pure returns (address) {
77
+ (bytes32 r, bytes32 s, uint8 v) = splitSignature(_signature);
78
+ return ecrecover(_ethSignedMessageHash, v, r, s);
79
+ }
80
+
81
+ function splitSignature(bytes memory sig) private pure returns (bytes32 r, bytes32 s, uint8 v) {
82
+ require(sig.length == 65, "invalid signature length");
83
+ assembly {
84
+ r := mload(add(sig, 32))
85
+ s := mload(add(sig, 64))
86
+ v := byte(0, mload(add(sig, 96)))
87
+ }
88
+ }
89
+ }
@@ -0,0 +1,74 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.7.0 <0.9.0;
4
+
5
+ interface IZKDB {
6
+
7
+ function qInt (uint[] memory path, uint[] memory zkp) external view returns (int);
8
+
9
+ function qString ( uint[] memory path, uint[] memory zkp) external view returns (string memory);
10
+
11
+ }
12
+
13
+ interface IERC20 {
14
+ function mint (address, uint) external;
15
+ }
16
+
17
+ contract ZKBridge {
18
+ address public zkdb;
19
+ address public token;
20
+ mapping(uint => bool) public done;
21
+ constructor (address _zkdb, address _token){
22
+ zkdb = _zkdb;
23
+ token = _token;
24
+ }
25
+
26
+ function hexCharToByte(uint8 c) public pure returns (uint8) {
27
+ if (bytes1(c) >= bytes1('0') && bytes1(c) <= bytes1('9')) {
28
+ return c - uint8(bytes1('0'));
29
+ }
30
+ if (bytes1(c) >= bytes1('a') && bytes1(c) <= bytes1('f')) {
31
+ return 10 + c - uint8(bytes1('a'));
32
+ }
33
+ if (bytes1(c) >= bytes1('A') && bytes1(c) <= bytes1('F')) {
34
+ return 10 + c - uint8(bytes1('A'));
35
+ }
36
+ revert("Invalid hex character");
37
+ }
38
+
39
+ function toAddr(string memory s) public pure returns (address) {
40
+ bytes memory ss = bytes(s);
41
+ require(ss.length == 42, "Invalid length");
42
+
43
+ uint256 r = 0;
44
+ for (uint256 i = 2; i < 42; i++) {
45
+ r = r * 16 + hexCharToByte(uint8(ss[i]));
46
+ }
47
+
48
+ return address(uint160(r));
49
+ }
50
+
51
+ function char(bytes1 b) internal pure returns (bytes1 c) {
52
+ if (uint8(b) < 10) return bytes1(uint8(b) + 0x30);
53
+ else return bytes1(uint8(b) + 0x57);
54
+ }
55
+
56
+ function bridge(uint col, uint doc, uint[] memory zkp, uint[] memory zkp2) public returns (address){
57
+ require(done[doc] == false, "already minted");
58
+ done[doc] = true;
59
+ uint[] memory path = new uint[](3);
60
+ path[0] = col;
61
+ path[1] = doc;
62
+ path[2] = 1111231163111;
63
+ uint[] memory path2 = new uint[](3);
64
+ path2[0] = col;
65
+ path2[1] = doc;
66
+ path2[2] = 1111629731093111311731103116;
67
+ string memory str = IZKDB(zkdb).qString(path, zkp);
68
+ address addr = toAddr(str);
69
+ int balance = IZKDB(zkdb).qInt(path2, zkp2);
70
+ IERC20(token).mint(addr, uint(balance));
71
+ return addr;
72
+ }
73
+
74
+ }
@@ -0,0 +1,63 @@
1
+ /// SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.20;
3
+
4
+ import "../ZKIPFS.sol";
5
+
6
+ import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
7
+
8
+ import {ERC721URIStorage} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
9
+
10
+ contract ZKNFT is ERC721URIStorage, ZKIPFS {
11
+ uint256 private _nextTokenId;
12
+ constructor(address _verifierIPFS) ERC721("ZKNFT", "ZKNFT") {
13
+ verifierIPFS = _verifierIPFS;
14
+ }
15
+
16
+ function mint(address to, string memory tokenURI)
17
+ public
18
+ returns (uint256)
19
+ {
20
+ uint256 tokenId = _nextTokenId++;
21
+ _mint(to, tokenId);
22
+ _setTokenURI(tokenId, tokenURI);
23
+
24
+ return tokenId;
25
+ }
26
+
27
+ function _verify (uint tokenId, uint[] memory path, uint[] memory zkp) private view returns (uint[] memory) {
28
+ return validateQuery(tokenURI(tokenId), path, zkp);
29
+ }
30
+
31
+ function qString (uint tokenId, uint[] memory path, uint[] memory zkp) public view returns (string memory) {
32
+ return _qString(_verify(tokenId, path, zkp));
33
+ }
34
+
35
+ function qInt (uint tokenId, uint[] memory path, uint[] memory zkp) public view returns (int) {
36
+ return _qInt(_verify(tokenId, path, zkp));
37
+ }
38
+
39
+ function qFloat (uint tokenId, uint[] memory path, uint[] memory zkp) public view returns (uint[3] memory) {
40
+ return _qFloat(_verify(tokenId, path, zkp));
41
+ }
42
+
43
+ function qBool (uint tokenId, uint[] memory path, uint[] memory zkp) public view returns (bool) {
44
+ return _qBool(_verify(tokenId, path, zkp));
45
+ }
46
+
47
+ function qNull (uint tokenId, uint[] memory path, uint[] memory zkp) public view returns (bool) {
48
+ return _qNull(_verify(tokenId, path, zkp));
49
+ }
50
+
51
+ function qRaw (uint tokenId, uint[] memory path, uint[] memory zkp) internal view returns (uint[] memory) {
52
+ return _qRaw(_verify(tokenId, path, zkp));
53
+ }
54
+
55
+ function qCustom (uint tokenId, uint[] memory path, uint[] memory path2, uint[] memory zkp) public view returns (int) {
56
+ return getInt(path2, qRaw(tokenId, path, zkp));
57
+ }
58
+
59
+ function qCond (uint tokenId, uint[] memory path, uint[] memory cond, uint[] memory zkp) public view returns (bool) {
60
+ return _qCond(_verify(tokenId, path, zkp), cond);
61
+ }
62
+
63
+ }
@@ -37,56 +37,62 @@ contract Groth16VerifierDB {
37
37
  uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
38
38
  uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
39
39
  uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
40
- uint256 constant deltax1 = 4503582552430561212779022449004306860952515258252510730703342683904433748529;
41
- uint256 constant deltax2 = 18425111920911215222332253146797783332823283746160018203034073853247125442993;
42
- uint256 constant deltay1 = 4453946082216241594348271243333609134155973515870520791839116124952157106489;
43
- uint256 constant deltay2 = 6299943403529237547647875143706632408243402531062446767696226637461756039372;
40
+ uint256 constant deltax1 = 566319682436850529692773273170461279524268577891150635825387390239831567882;
41
+ uint256 constant deltax2 = 18860268461005016027048821926573675096822806032916343944940397566918262972873;
42
+ uint256 constant deltay1 = 18469561290186198192930600182225641948070680663786775400869545881576215584097;
43
+ uint256 constant deltay2 = 16843711002267486950099400107694084564320643561117060725912074365097520873528;
44
44
 
45
45
 
46
- uint256 constant IC0x = 21321207194104473227475304543920529140777253812445062785414102137810628823351;
47
- uint256 constant IC0y = 17435301628228161373103753422842813332325503638744597201144754851019312998703;
46
+ uint256 constant IC0x = 15211415922364842912753184178425045511192002084183450091972766587897729031131;
47
+ uint256 constant IC0y = 15971336196196622349517605395705397293225200783943199092270415284510546939053;
48
48
 
49
- uint256 constant IC1x = 12820400866256307684567623036475747952236795131426943895421353782394091927742;
50
- uint256 constant IC1y = 60275713036652700837316478219950928712704126788272985582350169411243461644;
49
+ uint256 constant IC1x = 3464979308878298246776645144833226341117035087307090727251356729925690049544;
50
+ uint256 constant IC1y = 2701132742000937878189241109199334668029723964378951774716229117963684334785;
51
51
 
52
- uint256 constant IC2x = 857253043166092910744552687303159485904872523742588131455423770248915368285;
53
- uint256 constant IC2y = 14195849356583660474308242114329315396764028733952643683061195745221866004517;
52
+ uint256 constant IC2x = 17746992021893097019070205838284045039565036550366113750079443947456708932914;
53
+ uint256 constant IC2y = 20205302109688801012538493936661638426411524231619729625407218303411393971055;
54
54
 
55
- uint256 constant IC3x = 21758746957477097206930100418195981232696693412252142756415630022251620498988;
56
- uint256 constant IC3y = 13410227681809155220050013564476536866963972600821261716783794631827707904349;
55
+ uint256 constant IC3x = 12245350253809957962446325719420284548409481797652910572382809447209300296011;
56
+ uint256 constant IC3y = 2181944750218360909814361656088418665618898112511704294612292313825818583174;
57
57
 
58
- uint256 constant IC4x = 863580107893288900828264046203999618333374859561603309534755206187548007845;
59
- uint256 constant IC4y = 17276530052140799694039014154041098203841609580394223470304419489978941020095;
58
+ uint256 constant IC4x = 14272371780610106622173486440520433262823996106221430333841111091741849894946;
59
+ uint256 constant IC4y = 2651668025058914772481681251893270544825897012494799335931264036971472027402;
60
60
 
61
- uint256 constant IC5x = 20860866781226655978193967912232894914994034954825205708931667985751271655154;
62
- uint256 constant IC5y = 12177441101666309938978105246002445372089044967481369877555009124474329640505;
61
+ uint256 constant IC5x = 15368773499402856795009961960791288514014805980406357981082924459251021982345;
62
+ uint256 constant IC5y = 19702123112400711796073644885827586177870326559870904640843668152019488063904;
63
63
 
64
- uint256 constant IC6x = 10253410591025171769139608115823458515554722863591962190480237037964222989835;
65
- uint256 constant IC6y = 2300854166049230775727949815888955384104705675980904483480782073188875432218;
64
+ uint256 constant IC6x = 10677187776951951873630238944736414260225581042281553648384370976204183115940;
65
+ uint256 constant IC6y = 1992236736977150082653976323411946326010253872212815347510072691523085595255;
66
66
 
67
- uint256 constant IC7x = 9245031860281158825371686872766118053567656180865626846873554393892189651843;
68
- uint256 constant IC7y = 18513814971835729370836379685375481264692236826421466003977840558207277913353;
67
+ uint256 constant IC7x = 21415137280411204335091094503224446366978234376524115265045654108152006539895;
68
+ uint256 constant IC7y = 18542175761555436023959545358821820821282980394602494205800055757297012906764;
69
69
 
70
- uint256 constant IC8x = 2754620511499804101010165108130638609126165250442796483020701485428889593474;
71
- uint256 constant IC8y = 21543955085620310283456271839558892054215536683326587016759091514123004776495;
70
+ uint256 constant IC8x = 6283856560272202991953013809355758204828896535304136319974685636684888856128;
71
+ uint256 constant IC8y = 14499901693513608835779722317486164346309825524575154749627267356894076467615;
72
72
 
73
- uint256 constant IC9x = 7226523333475405455471783299389388256960485582655675212929034730327278898093;
74
- uint256 constant IC9y = 5056090250187692130221637329845012688890940869984044755973476873548610820578;
73
+ uint256 constant IC9x = 19685518566119573827093988474850506880006629001058664371716514877455244663914;
74
+ uint256 constant IC9y = 8481292601887397637049972433197231800580995340144247273832382075808559008848;
75
75
 
76
- uint256 constant IC10x = 10107033883545633867195921318423461010318227740867478163570877213298959179572;
77
- uint256 constant IC10y = 503817861296261242201817887974509587032687921855950877235697350857170430743;
76
+ uint256 constant IC10x = 223137936376193785345096638287096394886709464533117482694619505935732331537;
77
+ uint256 constant IC10y = 4193175916548019617597370686901033731734454606724750484807673453694700951952;
78
78
 
79
- uint256 constant IC11x = 21035943047303381225570192698677598249462130417684515089990469613546011008550;
80
- uint256 constant IC11y = 7261441348374767801093007257999121003733259642366629311136938544979253433119;
79
+ uint256 constant IC11x = 16453801468826605202509345195157388810770747557053039494013978418267763931861;
80
+ uint256 constant IC11y = 9875951739441984097810674555101191788888352673039488118805457327521421929503;
81
81
 
82
- uint256 constant IC12x = 20453521999827294992536897361543222148394244433474196230498330885560620003829;
83
- uint256 constant IC12y = 18476327162478621518583504728598744035870583497372084378654039079117097682;
82
+ uint256 constant IC12x = 21492667345885781313718619285662713900245557314551393448696666210356792295028;
83
+ uint256 constant IC12y = 13513771098803659055046650647390462300798249154666189755091027612809331818956;
84
84
 
85
- uint256 constant IC13x = 15724968258919878061585416513119667249637764275276227548708222282031970422796;
86
- uint256 constant IC13y = 15146709066947881278827713419811426264008528066434458265193671798769307857310;
85
+ uint256 constant IC13x = 4220313889112567763732397801925007682896952364521933389131895252279385675080;
86
+ uint256 constant IC13y = 4489372840961844505718038698916106673528658906928588565989450268053621743612;
87
87
 
88
- uint256 constant IC14x = 9097393479338656770619464061691689490135837081335461486896937720741934261539;
89
- uint256 constant IC14y = 3771549967344233937612853274190217413635208199629257189936808052809357297423;
88
+ uint256 constant IC14x = 14271407211698650570939162738932653937074499981772815895780302661786173648938;
89
+ uint256 constant IC14y = 19455923871335066470920134858740491433267919882177953263240475980057134848859;
90
+
91
+ uint256 constant IC15x = 16133332441580541207424712869162600438872610254859964823012819022285880626496;
92
+ uint256 constant IC15y = 205394163904875832569231417271795177705566674339331369995643748855708511527;
93
+
94
+ uint256 constant IC16x = 20041249883696113203488105074051660077326597780992987346896682994784878002567;
95
+ uint256 constant IC16y = 17581544103776691653953052153212138864315675260675640899993173889329216891748;
90
96
 
91
97
 
92
98
  // Memory data
@@ -95,7 +101,7 @@ contract Groth16VerifierDB {
95
101
 
96
102
  uint16 constant pLastMem = 896;
97
103
 
98
- function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[14] calldata _pubSignals) public view returns (bool) {
104
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[16] calldata _pubSignals) public view returns (bool) {
99
105
  assembly {
100
106
  function checkField(v) {
101
107
  if iszero(lt(v, q)) {
@@ -167,6 +173,10 @@ contract Groth16VerifierDB {
167
173
 
168
174
  g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
169
175
 
176
+ g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
177
+
178
+ g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
179
+
170
180
 
171
181
  // -A
172
182
  mstore(_pPairing, calldataload(pA))
@@ -250,6 +260,10 @@ contract Groth16VerifierDB {
250
260
 
251
261
  checkField(calldataload(add(_pubSignals, 448)))
252
262
 
263
+ checkField(calldataload(add(_pubSignals, 480)))
264
+
265
+ checkField(calldataload(add(_pubSignals, 512)))
266
+
253
267
 
254
268
  // Validate all evaluations
255
269
  let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
@@ -37,10 +37,10 @@ contract Groth16VerifierIPFS {
37
37
  uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
38
38
  uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
39
39
  uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
40
- uint256 constant deltax1 = 146777209207054605867012766179094502537968350551215607925008955076263549067;
41
- uint256 constant deltax2 = 2633871596100807401284925083226459189796882085586154321492118367916651237117;
42
- uint256 constant deltay1 = 21012385740760062171685374025920180961146768579042536716146176459660919755825;
43
- uint256 constant deltay2 = 609193939489547291159258179603724194177454651776958423928855714448170018063;
40
+ uint256 constant deltax1 = 16750032045563760710929521100859621241226846513668026156029771684316880404599;
41
+ uint256 constant deltax2 = 16898207697433710914864976772340912260166064601616416232383205018567189411131;
42
+ uint256 constant deltay1 = 3515011879290403013877934743012053356401335889951849763330532564325612883650;
43
+ uint256 constant deltay2 = 8625609472899458752119724414156732692585644842390067317870160518196882424997;
44
44
 
45
45
 
46
46
  uint256 constant IC0x = 14336108542425917447460243179215548887531443288921789758034763267112594821597;
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zkjson",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
4
4
  "description": "Zero Knowledge Provable JSON",
5
5
  "main": "index.js",
6
6
  "license": "MIT",