@lfdecentralizedtrust/zeto-contracts 0.2.2 → 0.5.1
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/README.md +76 -162
- package/config/eip170.ts +30 -0
- package/contracts/factory.sol +30 -34
- package/contracts/factory_upgradeable.sol +11 -7
- package/contracts/lib/common/util.sol +40 -0
- package/contracts/lib/interfaces/ILockableCapability.sol +318 -0
- package/contracts/lib/interfaces/{izeto.sol → IZeto.sol} +13 -1
- package/contracts/lib/interfaces/{izeto_initializable.sol → IZetoInitializable.sol} +14 -12
- package/contracts/lib/interfaces/{izeto_kyc.sol → IZetoKyc.sol} +3 -3
- package/contracts/lib/interfaces/IZetoLockHooks.sol +42 -0
- package/contracts/lib/interfaces/IZetoLockableCapability.sol +237 -0
- package/contracts/lib/interfaces/IZetoStorage.sol +106 -0
- package/contracts/lib/interfaces/{izeto_lockable.sol → IZetoVerifier.sol} +8 -21
- package/contracts/lib/registry.sol +74 -26
- package/contracts/lib/storage/base.sol +210 -0
- package/contracts/lib/storage/nullifier.sol +166 -0
- package/contracts/lib/zeto_common.sol +277 -28
- package/contracts/lib/zeto_fungible.sol +443 -33
- package/contracts/lib/zeto_fungible_base.sol +69 -0
- package/contracts/lib/zeto_fungible_burn.sol +83 -53
- package/contracts/lib/zeto_fungible_burn_nullifier.sol +115 -72
- package/contracts/lib/zeto_fungible_nullifier.sol +167 -0
- package/contracts/lib/zeto_lockable.sol +219 -0
- package/contracts/lib/zeto_lockable_lib.sol +460 -0
- package/contracts/lib/zeto_lockable_storage.sol +43 -0
- package/contracts/lib/zeto_non_fungible.sol +228 -0
- package/contracts/lib/zeto_non_fungible_base.sol +61 -0
- package/contracts/lib/zeto_non_fungible_nullifier.sol +61 -0
- package/contracts/test/escrow1.sol +90 -34
- package/contracts/test/escrow2.sol +64 -29
- package/contracts/test/qurrency.sol +10 -2
- package/contracts/test/smt.sol +6 -1
- package/contracts/test/tendecimals.sol +14 -12
- package/contracts/verifiers/impl/anon.sol +189 -0
- package/contracts/verifiers/impl/anon_batch.sol +301 -0
- package/contracts/verifiers/impl/anon_enc.sol +266 -0
- package/contracts/verifiers/impl/anon_enc_batch.sol +602 -0
- package/contracts/verifiers/impl/anon_enc_nullifier.sol +287 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_batch.sol +679 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_kyc.sol +294 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_kyc_batch.sol +686 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation.sol +413 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation_batch.sol +1141 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transfer.sol +217 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked.sol +196 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked_batch.sol +308 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transfer_batch.sol +385 -0
- package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer.sol +497 -0
- package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer_batch.sol +1001 -0
- package/contracts/verifiers/{verifier_anon_nullifier_transferLocked.sol → impl/anon_nullifier_transfer.sol} +12 -19
- package/contracts/verifiers/{verifier_anon_nullifier_transferLocked_batch.sol → impl/anon_nullifier_transfer_batch.sol} +44 -51
- package/contracts/verifiers/impl/burn.sol +182 -0
- package/contracts/verifiers/impl/burn_batch.sol +238 -0
- package/contracts/verifiers/impl/burn_nullifier.sol +203 -0
- package/contracts/verifiers/impl/burn_nullifier_batch.sol +315 -0
- package/contracts/verifiers/impl/deposit.sol +182 -0
- package/contracts/verifiers/impl/deposit_kyc.sol +189 -0
- package/contracts/verifiers/impl/nf_anon.sol +175 -0
- package/contracts/verifiers/{verifier_nf_anon_nullifier_transferLocked.sol → impl/nf_anon_nullifier_transfer.sol} +6 -13
- package/contracts/verifiers/impl/withdraw.sol +189 -0
- package/contracts/verifiers/impl/withdraw_batch.sol +245 -0
- package/contracts/verifiers/impl/withdraw_nullifier.sol +210 -0
- package/contracts/verifiers/impl/withdraw_nullifier_batch.sol +322 -0
- package/contracts/verifiers/verifier_anon.sol +31 -186
- package/contracts/verifiers/verifier_anon_batch.sol +31 -298
- package/contracts/verifiers/verifier_anon_enc.sol +31 -263
- package/contracts/verifiers/verifier_anon_enc_batch.sol +31 -599
- package/contracts/verifiers/verifier_anon_enc_nullifier.sol +31 -284
- package/contracts/verifiers/verifier_anon_enc_nullifier_batch.sol +33 -676
- package/contracts/verifiers/verifier_anon_enc_nullifier_kyc.sol +31 -291
- package/contracts/verifiers/verifier_anon_enc_nullifier_kyc_batch.sol +33 -683
- package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation.sol +33 -410
- package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation_batch.sol +33 -1138
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer.sol +33 -214
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked.sol +33 -221
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked_batch.sol +33 -389
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer_batch.sol +33 -382
- package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer.sol +33 -221
- package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer_batch.sol +33 -389
- package/contracts/verifiers/verifier_anon_nullifier_transfer.sol +33 -207
- package/contracts/verifiers/verifier_anon_nullifier_transfer_batch.sol +33 -375
- package/contracts/verifiers/verifier_burn.sol +31 -179
- package/contracts/verifiers/verifier_burn_batch.sol +31 -235
- package/contracts/verifiers/verifier_burn_nullifier.sol +31 -200
- package/contracts/verifiers/verifier_burn_nullifier_batch.sol +31 -312
- package/contracts/verifiers/verifier_deposit.sol +31 -179
- package/contracts/verifiers/verifier_deposit_kyc.sol +34 -0
- package/contracts/verifiers/verifier_nf_anon.sol +31 -172
- package/contracts/verifiers/verifier_nf_anon_nullifier_transfer.sol +33 -179
- package/contracts/verifiers/verifier_withdraw.sol +31 -186
- package/contracts/verifiers/verifier_withdraw_batch.sol +31 -242
- package/contracts/verifiers/verifier_withdraw_nullifier.sol +31 -207
- package/contracts/verifiers/verifier_withdraw_nullifier_batch.sol +33 -319
- package/contracts/zeto_anon.sol +77 -231
- package/contracts/zeto_anon_burnable.sol +56 -12
- package/contracts/zeto_anon_enc.sol +93 -190
- package/contracts/zeto_anon_enc_nullifier.sol +249 -195
- package/contracts/zeto_anon_enc_nullifier_kyc.sol +51 -232
- package/contracts/zeto_anon_enc_nullifier_non_repudiation.sol +231 -238
- package/contracts/zeto_anon_nullifier.sol +164 -298
- package/contracts/zeto_anon_nullifier_burnable.sol +68 -18
- package/contracts/zeto_anon_nullifier_kyc.sol +40 -345
- package/contracts/zeto_anon_nullifier_qurrency.sol +217 -361
- package/contracts/zeto_nf_anon.sol +55 -130
- package/contracts/zeto_nf_anon_nullifier.sol +90 -152
- package/hardhat.config.ts +18 -3
- package/ignition/modules/lib/deps.ts +13 -0
- package/ignition/modules/test/tendecimals.ts +7 -1
- package/ignition/modules/zeto_anon.ts +3 -0
- package/ignition/modules/zeto_anon_burnable.ts +11 -7
- package/ignition/modules/zeto_anon_enc.ts +3 -0
- package/ignition/modules/zeto_anon_enc_nullifier.ts +34 -0
- package/ignition/modules/zeto_anon_enc_nullifier_kyc.ts +5 -2
- package/ignition/modules/zeto_anon_enc_nullifier_non_repudiation.ts +3 -0
- package/ignition/modules/zeto_anon_nullifier.ts +31 -4
- package/ignition/modules/zeto_anon_nullifier_burnable.ts +53 -16
- package/ignition/modules/zeto_anon_nullifier_kyc.ts +30 -12
- package/ignition/modules/zeto_anon_nullifier_qurrency.ts +3 -0
- package/ignition/modules/zeto_nf_anon.ts +3 -1
- package/ignition/modules/zeto_nf_anon_nullifier.ts +17 -12
- package/package.json +7 -3
- package/scripts/deploy_cloneable.ts +19 -10
- package/scripts/deploy_upgradeable.ts +9 -5
- package/scripts/lib/zeto_libraries.ts +47 -0
- package/scripts/tokens/Zeto_Anon.ts +6 -3
- package/scripts/tokens/Zeto_AnonBurnable.ts +4 -1
- package/scripts/tokens/Zeto_AnonEnc.ts +15 -3
- package/scripts/tokens/Zeto_AnonEncNullifier.ts +11 -8
- package/scripts/tokens/Zeto_AnonEncNullifierKyc.ts +7 -6
- package/scripts/tokens/Zeto_AnonEncNullifierNonRepudiation.ts +7 -6
- package/scripts/tokens/Zeto_AnonNullifier.ts +7 -6
- package/scripts/tokens/Zeto_AnonNullifierBurnable.ts +7 -6
- package/scripts/tokens/Zeto_AnonNullifierKyc.ts +7 -6
- package/scripts/tokens/Zeto_AnonNullifierQurrency.ts +7 -8
- package/scripts/tokens/Zeto_NfAnon.ts +5 -3
- package/scripts/tokens/Zeto_NfAnonNullifier.ts +7 -7
- package/test/factory.ts +55 -73
- package/test/lib/anon_nullifier_helpers.ts +89 -0
- package/test/lib/anon_zeto_helpers.ts +76 -0
- package/test/lib/deploy.ts +5 -2
- package/test/lib/eip170.ts +23 -0
- package/test/lib/utils.ts +74 -35
- package/test/test/escrow1.ts +185 -58
- package/test/test/escrow2.ts +200 -107
- package/test/test/qurrency.ts +13 -33
- package/test/usdc-shielding.ts +39 -27
- package/test/utils.ts +144 -21
- package/test/zeto_anon.ts +956 -465
- package/test/zeto_anon_enc.ts +881 -143
- package/test/zeto_anon_enc_nullifier.ts +850 -39
- package/test/zeto_anon_enc_nullifier_kyc.ts +123 -182
- package/test/zeto_anon_enc_nullifier_non_repudiation.ts +80 -47
- package/test/zeto_anon_nullifier.ts +1212 -954
- package/test/zeto_anon_nullifier_kyc.ts +677 -656
- package/test/zeto_anon_nullifier_qurrency.ts +455 -307
- package/test/zeto_nf_anon.ts +737 -138
- package/test/zeto_nf_anon_nullifier.ts +876 -247
- package/contracts/lib/zeto_base.sol +0 -293
- package/contracts/lib/zeto_fungible_withdraw.sol +0 -132
- package/contracts/lib/zeto_fungible_withdraw_nullifier.sol +0 -144
- package/contracts/lib/zeto_nullifier.sol +0 -340
- package/contracts/zkDvP.sol_ +0 -273
- package/test/zkDvP.ts_ +0 -455
- /package/contracts/lib/{common.sol → common/common.sol} +0 -0
|
@@ -1,294 +1,34 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
You should have received a copy of the GNU General Public License
|
|
18
|
-
along with snarkJS. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
-
*/
|
|
1
|
+
// Copyright © 2025 Kaleido, Inc.
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
//
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
// you may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
20
16
|
|
|
21
17
|
pragma solidity >=0.7.0 <0.9.0;
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
|
|
40
|
-
uint256 constant deltax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
|
|
41
|
-
uint256 constant deltax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
|
|
42
|
-
uint256 constant deltay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
|
|
43
|
-
uint256 constant deltay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
uint256 constant IC0x = 9972957676423380056673784223256078932980841003678364793218447784424567242654;
|
|
47
|
-
uint256 constant IC0y = 4678594914637956127205417146610793590180597808858748260085558471067735646440;
|
|
48
|
-
|
|
49
|
-
uint256 constant IC1x = 20626348243601941732485254721744961433387243156497283029787770192314797748294;
|
|
50
|
-
uint256 constant IC1y = 12467906258210777053579897630753699237126979653530927573625852071469027788317;
|
|
51
|
-
|
|
52
|
-
uint256 constant IC2x = 6593823740104839997830232591067413137289698354187960793239587062975502704395;
|
|
53
|
-
uint256 constant IC2y = 1208964512353496192995349595321583872589282936867361621893775164770671936259;
|
|
54
|
-
|
|
55
|
-
uint256 constant IC3x = 15777109981814715804270761573599942252458355283802084418219940272432340923836;
|
|
56
|
-
uint256 constant IC3y = 15303957250808818342232527495327655106335914190288624283092271308700261721488;
|
|
57
|
-
|
|
58
|
-
uint256 constant IC4x = 3026602697455099612424621952379719198106647440196544027831566838045899563399;
|
|
59
|
-
uint256 constant IC4y = 9759217536572173594100597225590351951742718270154166694001415874638976117970;
|
|
60
|
-
|
|
61
|
-
uint256 constant IC5x = 10241011336627199796875439327756556496211917170696485291602880134364359305923;
|
|
62
|
-
uint256 constant IC5y = 13109059612730014598407600565060859267317881684646038364444413771986130545591;
|
|
63
|
-
|
|
64
|
-
uint256 constant IC6x = 16798870830146200418406230272237520347083963190528195098891843259562006616117;
|
|
65
|
-
uint256 constant IC6y = 11575800640686696555301103442467173601393427106507012900858263213283384921733;
|
|
66
|
-
|
|
67
|
-
uint256 constant IC7x = 16743881743218552087006823147998862001875759476570632481491110928194791922666;
|
|
68
|
-
uint256 constant IC7y = 5964475690538263321758939551410109992632115372091858703151526488469035822017;
|
|
69
|
-
|
|
70
|
-
uint256 constant IC8x = 17422127430054015825756478146072520533062834697833835710892851882864086025755;
|
|
71
|
-
uint256 constant IC8y = 16011744779054642721761158139928702915700909481965976282895571023521329641998;
|
|
72
|
-
|
|
73
|
-
uint256 constant IC9x = 406864598759850034903206266841809709299006974235717637686404542045071540659;
|
|
74
|
-
uint256 constant IC9y = 175889075752243827973632421319337638760422674430499137962029351038387216028;
|
|
75
|
-
|
|
76
|
-
uint256 constant IC10x = 1365433920116397731183184351648662675938607238756469647878201870721139598011;
|
|
77
|
-
uint256 constant IC10y = 17681403877442813881698000123300540832497204052529359816196266673940688927778;
|
|
78
|
-
|
|
79
|
-
uint256 constant IC11x = 16996233415488730232143411633900464133690687209078016207520170707861435974305;
|
|
80
|
-
uint256 constant IC11y = 1810103810166176179953424353651847612550843269870234153139687345130352909748;
|
|
81
|
-
|
|
82
|
-
uint256 constant IC12x = 19749292968816566792125730503507591342045058913418847191688480047091858623447;
|
|
83
|
-
uint256 constant IC12y = 18322988542933428239427152508468519455102875496187013930559502816652347798889;
|
|
84
|
-
|
|
85
|
-
uint256 constant IC13x = 2633645969966525306466945635445646802037300798338089709531896116721322442035;
|
|
86
|
-
uint256 constant IC13y = 13297930312473482727503760897528504713980143844780635881599035147004746321398;
|
|
87
|
-
|
|
88
|
-
uint256 constant IC14x = 20813595778911781101662098313613623482759996578847151590953394494989668527815;
|
|
89
|
-
uint256 constant IC14y = 11915983855118140691532256393297373202287518135992160722094473917193821575315;
|
|
90
|
-
|
|
91
|
-
uint256 constant IC15x = 21713035948071561257837774341646111760925570212598972828958666528307525686602;
|
|
92
|
-
uint256 constant IC15y = 12227083114887612400712338541238794888971057159616123234966122880562265012227;
|
|
93
|
-
|
|
94
|
-
uint256 constant IC16x = 9573373319024029141319499026233137431359769202179732218332885564184218846564;
|
|
95
|
-
uint256 constant IC16y = 17857422282967345308190634163052853109132639786585857896270067058279970179103;
|
|
96
|
-
|
|
97
|
-
uint256 constant IC17x = 13408224352143326532373083240936488833622137941685971720863838022558805764399;
|
|
98
|
-
uint256 constant IC17y = 15549298112540486092394505339675622172567052048241457640523705317527749933996;
|
|
99
|
-
|
|
100
|
-
uint256 constant IC18x = 8627562997870790319764169121326712451307094724598814115390396193516841271820;
|
|
101
|
-
uint256 constant IC18y = 2713482906830679157748431196328948664301153729842912709060044518445226872360;
|
|
102
|
-
|
|
103
|
-
uint256 constant IC19x = 21468908901729680885940714898176278471265775602254987051148491907781747085704;
|
|
104
|
-
uint256 constant IC19y = 13769396822747935338034315759810065655383326207655477638699721796395572432678;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// Memory data
|
|
108
|
-
uint16 constant pVk = 0;
|
|
109
|
-
uint16 constant pPairing = 128;
|
|
110
|
-
|
|
111
|
-
uint16 constant pLastMem = 896;
|
|
112
|
-
|
|
113
|
-
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[19] calldata _pubSignals) public view returns (bool) {
|
|
114
|
-
assembly {
|
|
115
|
-
function checkField(v) {
|
|
116
|
-
if iszero(lt(v, r)) {
|
|
117
|
-
mstore(0, 0)
|
|
118
|
-
return(0, 0x20)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// G1 function to multiply a G1 value(x,y) to value in an address
|
|
123
|
-
function g1_mulAccC(pR, x, y, s) {
|
|
124
|
-
let success
|
|
125
|
-
let mIn := mload(0x40)
|
|
126
|
-
mstore(mIn, x)
|
|
127
|
-
mstore(add(mIn, 32), y)
|
|
128
|
-
mstore(add(mIn, 64), s)
|
|
129
|
-
|
|
130
|
-
success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
|
|
131
|
-
|
|
132
|
-
if iszero(success) {
|
|
133
|
-
mstore(0, 0)
|
|
134
|
-
return(0, 0x20)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
mstore(add(mIn, 64), mload(pR))
|
|
138
|
-
mstore(add(mIn, 96), mload(add(pR, 32)))
|
|
139
|
-
|
|
140
|
-
success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
|
|
141
|
-
|
|
142
|
-
if iszero(success) {
|
|
143
|
-
mstore(0, 0)
|
|
144
|
-
return(0, 0x20)
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
|
|
149
|
-
let _pPairing := add(pMem, pPairing)
|
|
150
|
-
let _pVk := add(pMem, pVk)
|
|
151
|
-
|
|
152
|
-
mstore(_pVk, IC0x)
|
|
153
|
-
mstore(add(_pVk, 32), IC0y)
|
|
154
|
-
|
|
155
|
-
// Compute the linear combination vk_x
|
|
156
|
-
|
|
157
|
-
g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
|
|
158
|
-
|
|
159
|
-
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
|
|
160
|
-
|
|
161
|
-
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
|
|
162
|
-
|
|
163
|
-
g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
|
|
164
|
-
|
|
165
|
-
g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
|
|
166
|
-
|
|
167
|
-
g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
|
|
168
|
-
|
|
169
|
-
g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
|
|
170
|
-
|
|
171
|
-
g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
|
|
172
|
-
|
|
173
|
-
g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
|
|
174
|
-
|
|
175
|
-
g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
|
|
176
|
-
|
|
177
|
-
g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
|
|
178
|
-
|
|
179
|
-
g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
|
|
180
|
-
|
|
181
|
-
g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
|
|
182
|
-
|
|
183
|
-
g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
|
|
184
|
-
|
|
185
|
-
g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
|
|
186
|
-
|
|
187
|
-
g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
|
|
188
|
-
|
|
189
|
-
g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
|
|
190
|
-
|
|
191
|
-
g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
|
|
192
|
-
|
|
193
|
-
g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
// -A
|
|
197
|
-
mstore(_pPairing, calldataload(pA))
|
|
198
|
-
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
|
|
199
|
-
|
|
200
|
-
// B
|
|
201
|
-
mstore(add(_pPairing, 64), calldataload(pB))
|
|
202
|
-
mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
|
|
203
|
-
mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
|
|
204
|
-
mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
|
|
205
|
-
|
|
206
|
-
// alpha1
|
|
207
|
-
mstore(add(_pPairing, 192), alphax)
|
|
208
|
-
mstore(add(_pPairing, 224), alphay)
|
|
209
|
-
|
|
210
|
-
// beta2
|
|
211
|
-
mstore(add(_pPairing, 256), betax1)
|
|
212
|
-
mstore(add(_pPairing, 288), betax2)
|
|
213
|
-
mstore(add(_pPairing, 320), betay1)
|
|
214
|
-
mstore(add(_pPairing, 352), betay2)
|
|
215
|
-
|
|
216
|
-
// vk_x
|
|
217
|
-
mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
|
|
218
|
-
mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
// gamma2
|
|
222
|
-
mstore(add(_pPairing, 448), gammax1)
|
|
223
|
-
mstore(add(_pPairing, 480), gammax2)
|
|
224
|
-
mstore(add(_pPairing, 512), gammay1)
|
|
225
|
-
mstore(add(_pPairing, 544), gammay2)
|
|
226
|
-
|
|
227
|
-
// C
|
|
228
|
-
mstore(add(_pPairing, 576), calldataload(pC))
|
|
229
|
-
mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
|
|
230
|
-
|
|
231
|
-
// delta2
|
|
232
|
-
mstore(add(_pPairing, 640), deltax1)
|
|
233
|
-
mstore(add(_pPairing, 672), deltax2)
|
|
234
|
-
mstore(add(_pPairing, 704), deltay1)
|
|
235
|
-
mstore(add(_pPairing, 736), deltay2)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
|
|
239
|
-
|
|
240
|
-
isOk := and(success, mload(_pPairing))
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
let pMem := mload(0x40)
|
|
244
|
-
mstore(0x40, add(pMem, pLastMem))
|
|
245
|
-
|
|
246
|
-
// Validate that all evaluations ∈ F
|
|
247
|
-
|
|
248
|
-
checkField(calldataload(add(_pubSignals, 0)))
|
|
249
|
-
|
|
250
|
-
checkField(calldataload(add(_pubSignals, 32)))
|
|
251
|
-
|
|
252
|
-
checkField(calldataload(add(_pubSignals, 64)))
|
|
253
|
-
|
|
254
|
-
checkField(calldataload(add(_pubSignals, 96)))
|
|
255
|
-
|
|
256
|
-
checkField(calldataload(add(_pubSignals, 128)))
|
|
257
|
-
|
|
258
|
-
checkField(calldataload(add(_pubSignals, 160)))
|
|
259
|
-
|
|
260
|
-
checkField(calldataload(add(_pubSignals, 192)))
|
|
261
|
-
|
|
262
|
-
checkField(calldataload(add(_pubSignals, 224)))
|
|
263
|
-
|
|
264
|
-
checkField(calldataload(add(_pubSignals, 256)))
|
|
265
|
-
|
|
266
|
-
checkField(calldataload(add(_pubSignals, 288)))
|
|
267
|
-
|
|
268
|
-
checkField(calldataload(add(_pubSignals, 320)))
|
|
269
|
-
|
|
270
|
-
checkField(calldataload(add(_pubSignals, 352)))
|
|
271
|
-
|
|
272
|
-
checkField(calldataload(add(_pubSignals, 384)))
|
|
273
|
-
|
|
274
|
-
checkField(calldataload(add(_pubSignals, 416)))
|
|
275
|
-
|
|
276
|
-
checkField(calldataload(add(_pubSignals, 448)))
|
|
277
|
-
|
|
278
|
-
checkField(calldataload(add(_pubSignals, 480)))
|
|
279
|
-
|
|
280
|
-
checkField(calldataload(add(_pubSignals, 512)))
|
|
281
|
-
|
|
282
|
-
checkField(calldataload(add(_pubSignals, 544)))
|
|
283
|
-
|
|
284
|
-
checkField(calldataload(add(_pubSignals, 576)))
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
// Validate all evaluations
|
|
288
|
-
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
|
|
289
|
-
|
|
290
|
-
mstore(0, isValid)
|
|
291
|
-
return(0, 0x20)
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
19
|
+
import {Verifier_AnonEncNullifierKyc} from "./impl/anon_enc_nullifier_kyc.sol";
|
|
20
|
+
|
|
21
|
+
contract Groth16Verifier_AnonEncNullifierKyc is Verifier_AnonEncNullifierKyc {
|
|
22
|
+
function verify(
|
|
23
|
+
uint[2] calldata _pA,
|
|
24
|
+
uint[2][2] calldata _pB,
|
|
25
|
+
uint[2] calldata _pC,
|
|
26
|
+
uint[] calldata _pubSignals
|
|
27
|
+
) public view returns (bool) {
|
|
28
|
+
uint256[19] memory fixedSizeInputs;
|
|
29
|
+
for (uint256 i = 0; i < fixedSizeInputs.length; i++) {
|
|
30
|
+
fixedSizeInputs[i] = _pubSignals[i];
|
|
31
|
+
}
|
|
32
|
+
return this.verifyProof(_pA, _pB, _pC, fixedSizeInputs);
|
|
33
|
+
}
|
|
34
|
+
}
|