diff --git a/solidity/contracts/lib/verifier_anon.sol b/solidity/contracts/lib/verifier_anon.sol index 6ef9172..47dc246 100644 --- a/solidity/contracts/lib/verifier_anon.sol +++ b/solidity/contracts/lib/verifier_anon.sol @@ -68,7 +68,7 @@ contract Groth16Verifier_Anon { function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[4] calldata _pubSignals) public view returns (bool) { assembly { function checkField(v) { - if iszero(lt(v, q)) { + if iszero(lt(v, r)) { mstore(0, 0) return(0, 0x20) } diff --git a/solidity/contracts/lib/verifier_anon_enc.sol b/solidity/contracts/lib/verifier_anon_enc.sol index c402b26..8b01e78 100644 --- a/solidity/contracts/lib/verifier_anon_enc.sol +++ b/solidity/contracts/lib/verifier_anon_enc.sol @@ -77,7 +77,7 @@ contract Groth16Verifier_AnonEnc { function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[7] calldata _pubSignals) public view returns (bool) { assembly { function checkField(v) { - if iszero(lt(v, q)) { + if iszero(lt(v, r)) { mstore(0, 0) return(0, 0x20) } diff --git a/solidity/contracts/lib/verifier_anon_enc_nullifier.sol b/solidity/contracts/lib/verifier_anon_enc_nullifier.sol index 5c224b5..36bff3c 100644 --- a/solidity/contracts/lib/verifier_anon_enc_nullifier.sol +++ b/solidity/contracts/lib/verifier_anon_enc_nullifier.sol @@ -86,7 +86,7 @@ contract Groth16Verifier_AnonEncNullifier { function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[10] calldata _pubSignals) public view returns (bool) { assembly { function checkField(v) { - if iszero(lt(v, q)) { + if iszero(lt(v, r)) { mstore(0, 0) return(0, 0x20) } diff --git a/solidity/contracts/lib/verifier_anon_nullifier.sol b/solidity/contracts/lib/verifier_anon_nullifier.sol index d412c06..fedeebf 100644 --- a/solidity/contracts/lib/verifier_anon_nullifier.sol +++ b/solidity/contracts/lib/verifier_anon_nullifier.sol @@ -77,7 +77,7 @@ contract Groth16Verifier_AnonNullifier { function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[7] calldata _pubSignals) public view returns (bool) { assembly { function checkField(v) { - if iszero(lt(v, q)) { + if iszero(lt(v, r)) { mstore(0, 0) return(0, 0x20) } diff --git a/solidity/contracts/lib/verifier_check_hashes_value.sol b/solidity/contracts/lib/verifier_check_hashes_value.sol index aa895d2..825874c 100644 --- a/solidity/contracts/lib/verifier_check_hashes_value.sol +++ b/solidity/contracts/lib/verifier_check_hashes_value.sol @@ -20,7 +20,7 @@ pragma solidity >=0.7.0 <0.9.0; -contract Groth16Verifier_CheckValue { +contract Groth16Verifier_CheckHashesValue { // Scalar field size uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617; // Base field size @@ -62,7 +62,7 @@ contract Groth16Verifier_CheckValue { function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[2] calldata _pubSignals) public view returns (bool) { assembly { function checkField(v) { - if iszero(lt(v, q)) { + if iszero(lt(v, r)) { mstore(0, 0) return(0, 0x20) } diff --git a/solidity/contracts/lib/verifier_check_inputs_outputs_value.sol b/solidity/contracts/lib/verifier_check_inputs_outputs_value.sol index 1b9945d..9c0da51 100644 --- a/solidity/contracts/lib/verifier_check_inputs_outputs_value.sol +++ b/solidity/contracts/lib/verifier_check_inputs_outputs_value.sol @@ -68,7 +68,7 @@ contract Groth16Verifier_CheckInputsOutputsValue { function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[4] calldata _pubSignals) public view returns (bool) { assembly { function checkField(v) { - if iszero(lt(v, q)) { + if iszero(lt(v, r)) { mstore(0, 0) return(0, 0x20) } diff --git a/solidity/contracts/lib/verifier_check_nullifier_value.sol b/solidity/contracts/lib/verifier_check_nullifier_value.sol index d32a97f..5d882de 100644 --- a/solidity/contracts/lib/verifier_check_nullifier_value.sol +++ b/solidity/contracts/lib/verifier_check_nullifier_value.sol @@ -77,7 +77,7 @@ contract Groth16Verifier_CheckNullifierValue { function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[7] calldata _pubSignals) public view returns (bool) { assembly { function checkField(v) { - if iszero(lt(v, q)) { + if iszero(lt(v, r)) { mstore(0, 0) return(0, 0x20) } diff --git a/solidity/contracts/lib/verifier_nf_anon.sol b/solidity/contracts/lib/verifier_nf_anon.sol index d6ab4b7..5b562d0 100644 --- a/solidity/contracts/lib/verifier_nf_anon.sol +++ b/solidity/contracts/lib/verifier_nf_anon.sol @@ -20,7 +20,7 @@ pragma solidity >=0.7.0 <0.9.0; -contract Groth16Verifier_NFAnon { +contract Groth16Verifier_NfAnon { // Scalar field size uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617; // Base field size @@ -62,7 +62,7 @@ contract Groth16Verifier_NFAnon { function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[2] calldata _pubSignals) public view returns (bool) { assembly { function checkField(v) { - if iszero(lt(v, q)) { + if iszero(lt(v, r)) { mstore(0, 0) return(0, 0x20) } diff --git a/solidity/contracts/lib/verifier_nf_anon_nullifier.sol b/solidity/contracts/lib/verifier_nf_anon_nullifier.sol index 7ed58ca..ac10c49 100644 --- a/solidity/contracts/lib/verifier_nf_anon_nullifier.sol +++ b/solidity/contracts/lib/verifier_nf_anon_nullifier.sol @@ -20,7 +20,7 @@ pragma solidity >=0.7.0 <0.9.0; -contract Groth16Verifier_NFAnonNullifier { +contract Groth16Verifier_NfAnonNullifier { // Scalar field size uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617; // Base field size @@ -65,7 +65,7 @@ contract Groth16Verifier_NFAnonNullifier { function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[3] calldata _pubSignals) public view returns (bool) { assembly { function checkField(v) { - if iszero(lt(v, q)) { + if iszero(lt(v, r)) { mstore(0, 0) return(0, 0x20) } diff --git a/solidity/contracts/lib/zeto_common.sol b/solidity/contracts/lib/zeto_common.sol index 3d661ba..d6ec992 100644 --- a/solidity/contracts/lib/zeto_common.sol +++ b/solidity/contracts/lib/zeto_common.sol @@ -17,7 +17,6 @@ pragma solidity ^0.8.20; import {Commonlib} from "./common.sol"; import {Registry} from "./registry.sol"; -import {Groth16Verifier_CheckValue} from "./verifier_check_hashes_value.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; /// @title A sample base implementation of a Zeto based token contract diff --git a/solidity/contracts/lib/zeto_fungible.sol b/solidity/contracts/lib/zeto_fungible.sol index 65344f2..e91f9e3 100644 --- a/solidity/contracts/lib/zeto_fungible.sol +++ b/solidity/contracts/lib/zeto_fungible.sol @@ -15,7 +15,7 @@ // limitations under the License. pragma solidity ^0.8.20; -import {Groth16Verifier_CheckValue} from "./verifier_check_hashes_value.sol"; +import {Groth16Verifier_CheckHashesValue} from "./verifier_check_hashes_value.sol"; import {Groth16Verifier_CheckNullifierValue} from "./verifier_check_nullifier_value.sol"; import {Commonlib} from "./common.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; @@ -28,11 +28,11 @@ abstract contract ZetoFungible is Ownable { // depositVerifier library for checking UTXOs against a claimed value. // this can be used in the optional deposit calls to verify that // the UTXOs match the deposited value - Groth16Verifier_CheckValue internal depositVerifier; + Groth16Verifier_CheckHashesValue internal depositVerifier; IERC20 internal erc20; - constructor(Groth16Verifier_CheckValue _depositVerifier) { + constructor(Groth16Verifier_CheckHashesValue _depositVerifier) { depositVerifier = _depositVerifier; } diff --git a/solidity/contracts/lib/zeto_fungible_withdraw.sol b/solidity/contracts/lib/zeto_fungible_withdraw.sol index 76d7b14..bc352b4 100644 --- a/solidity/contracts/lib/zeto_fungible_withdraw.sol +++ b/solidity/contracts/lib/zeto_fungible_withdraw.sol @@ -15,7 +15,7 @@ // limitations under the License. pragma solidity ^0.8.20; -import {Groth16Verifier_CheckValue} from "./verifier_check_hashes_value.sol"; +import {Groth16Verifier_CheckHashesValue} from "./verifier_check_hashes_value.sol"; import {Groth16Verifier_CheckInputsOutputsValue} from "./verifier_check_inputs_outputs_value.sol"; import {ZetoFungible} from "./zeto_fungible.sol"; import {Commonlib} from "./common.sol"; @@ -32,7 +32,7 @@ abstract contract ZetoFungibleWithdraw is ZetoFungible { Groth16Verifier_CheckInputsOutputsValue internal withdrawVerifier; constructor( - Groth16Verifier_CheckValue _depositVerifier, + Groth16Verifier_CheckHashesValue _depositVerifier, Groth16Verifier_CheckInputsOutputsValue _withdrawVerifier ) ZetoFungible(_depositVerifier) { withdrawVerifier = _withdrawVerifier; diff --git a/solidity/contracts/lib/zeto_fungible_withdraw_nullifier.sol b/solidity/contracts/lib/zeto_fungible_withdraw_nullifier.sol index 98928eb..e66f077 100644 --- a/solidity/contracts/lib/zeto_fungible_withdraw_nullifier.sol +++ b/solidity/contracts/lib/zeto_fungible_withdraw_nullifier.sol @@ -15,7 +15,7 @@ // limitations under the License. pragma solidity ^0.8.20; -import {Groth16Verifier_CheckValue} from "./verifier_check_hashes_value.sol"; +import {Groth16Verifier_CheckHashesValue} from "./verifier_check_hashes_value.sol"; import {Groth16Verifier_CheckNullifierValue} from "./verifier_check_nullifier_value.sol"; import {ZetoFungible} from "./zeto_fungible.sol"; import {Commonlib} from "./common.sol"; @@ -32,7 +32,7 @@ abstract contract ZetoFungibleWithdrawWithNullifiers is ZetoFungible { Groth16Verifier_CheckNullifierValue internal withdrawVerifier; constructor( - Groth16Verifier_CheckValue _depositVerifier, + Groth16Verifier_CheckHashesValue _depositVerifier, Groth16Verifier_CheckNullifierValue _withdrawVerifier ) ZetoFungible(_depositVerifier) { withdrawVerifier = _withdrawVerifier; diff --git a/solidity/contracts/zeto_anon.sol b/solidity/contracts/zeto_anon.sol index 2b7e47a..7912048 100644 --- a/solidity/contracts/zeto_anon.sol +++ b/solidity/contracts/zeto_anon.sol @@ -15,7 +15,7 @@ // limitations under the License. pragma solidity ^0.8.20; -import {Groth16Verifier_CheckValue} from "./lib/verifier_check_hashes_value.sol"; +import {Groth16Verifier_CheckHashesValue} from "./lib/verifier_check_hashes_value.sol"; import {Groth16Verifier_CheckInputsOutputsValue} from "./lib/verifier_check_inputs_outputs_value.sol"; import {Groth16Verifier_Anon} from "./lib/verifier_anon.sol"; import {Registry} from "./lib/registry.sol"; @@ -37,7 +37,7 @@ contract Zeto_Anon is ZetoBase, ZetoFungibleWithdraw { Groth16Verifier_Anon internal verifier; constructor( - Groth16Verifier_CheckValue _depositVerifier, + Groth16Verifier_CheckHashesValue _depositVerifier, Groth16Verifier_CheckInputsOutputsValue _withdrawVerifier, Groth16Verifier_Anon _verifier, Registry _registry diff --git a/solidity/contracts/zeto_anon_enc.sol b/solidity/contracts/zeto_anon_enc.sol index 14dc411..6a538ca 100644 --- a/solidity/contracts/zeto_anon_enc.sol +++ b/solidity/contracts/zeto_anon_enc.sol @@ -15,7 +15,7 @@ // limitations under the License. pragma solidity ^0.8.20; -import {Groth16Verifier_CheckValue} from "./lib/verifier_check_hashes_value.sol"; +import {Groth16Verifier_CheckHashesValue} from "./lib/verifier_check_hashes_value.sol"; import {Groth16Verifier_CheckInputsOutputsValue} from "./lib/verifier_check_inputs_outputs_value.sol"; import {Groth16Verifier_AnonEnc} from "./lib/verifier_anon_enc.sol"; import {ZetoFungibleWithdraw} from "./lib/zeto_fungible_withdraw.sol"; @@ -39,7 +39,7 @@ contract Zeto_AnonEnc is ZetoBase, ZetoFungibleWithdraw { Groth16Verifier_AnonEnc internal verifier; constructor( - Groth16Verifier_CheckValue _depositVerifier, + Groth16Verifier_CheckHashesValue _depositVerifier, Groth16Verifier_CheckInputsOutputsValue _withdrawVerifier, Groth16Verifier_AnonEnc _verifier, Registry _registry diff --git a/solidity/contracts/zeto_anon_enc_nullifier.sol b/solidity/contracts/zeto_anon_enc_nullifier.sol index ec9161c..6272753 100644 --- a/solidity/contracts/zeto_anon_enc_nullifier.sol +++ b/solidity/contracts/zeto_anon_enc_nullifier.sol @@ -15,7 +15,7 @@ // limitations under the License. pragma solidity ^0.8.20; -import {Groth16Verifier_CheckValue} from "./lib/verifier_check_hashes_value.sol"; +import {Groth16Verifier_CheckHashesValue} from "./lib/verifier_check_hashes_value.sol"; import {Groth16Verifier_CheckNullifierValue} from "./lib/verifier_check_nullifier_value.sol"; import {Groth16Verifier_AnonEncNullifier} from "./lib/verifier_anon_enc_nullifier.sol"; import {ZetoNullifier} from "./lib/zeto_nullifier.sol"; @@ -40,7 +40,7 @@ contract Zeto_AnonEncNullifier is Groth16Verifier_AnonEncNullifier verifier; constructor( - Groth16Verifier_CheckValue _depositVerifier, + Groth16Verifier_CheckHashesValue _depositVerifier, Groth16Verifier_CheckNullifierValue _withdrawVerifier, Groth16Verifier_AnonEncNullifier _verifier, Registry _registry diff --git a/solidity/contracts/zeto_anon_nullifier.sol b/solidity/contracts/zeto_anon_nullifier.sol index 257cc03..cd68a55 100644 --- a/solidity/contracts/zeto_anon_nullifier.sol +++ b/solidity/contracts/zeto_anon_nullifier.sol @@ -15,7 +15,7 @@ // limitations under the License. pragma solidity ^0.8.20; -import {Groth16Verifier_CheckValue} from "./lib/verifier_check_hashes_value.sol"; +import {Groth16Verifier_CheckHashesValue} from "./lib/verifier_check_hashes_value.sol"; import {Groth16Verifier_CheckNullifierValue} from "./lib/verifier_check_nullifier_value.sol"; import {Groth16Verifier_AnonNullifier} from "./lib/verifier_anon_nullifier.sol"; import {ZetoNullifier} from "./lib/zeto_nullifier.sol"; @@ -44,7 +44,7 @@ contract Zeto_AnonNullifier is Groth16Verifier_AnonNullifier verifier; constructor( - Groth16Verifier_CheckValue _depositVerifier, + Groth16Verifier_CheckHashesValue _depositVerifier, Groth16Verifier_CheckNullifierValue _withdrawVerifier, Groth16Verifier_AnonNullifier _verifier, Registry _registry diff --git a/solidity/contracts/zeto_nf_anon.sol b/solidity/contracts/zeto_nf_anon.sol index 03aa1cc..a9fd559 100644 --- a/solidity/contracts/zeto_nf_anon.sol +++ b/solidity/contracts/zeto_nf_anon.sol @@ -15,7 +15,7 @@ // limitations under the License. pragma solidity ^0.8.20; -import {Groth16Verifier_NFAnon} from "./lib/verifier_nf_anon.sol"; +import {Groth16Verifier_NfAnon} from "./lib/verifier_nf_anon.sol"; import {ZetoBase} from "./lib/zeto_base.sol"; import {Registry} from "./lib/registry.sol"; import {Commonlib} from "./lib/common.sol"; @@ -28,11 +28,11 @@ import "hardhat/console.sol"; /// - The sender owns the private key whose public key is part of the pre-image of the input UTXOs commitments /// (aka the sender is authorized to spend the input UTXOs) /// - The input UTXOs and output UTXOs are valid in terms of obeying mass conservation rules -contract Zeto_NFAnon is ZetoBase { - Groth16Verifier_NFAnon internal verifier; +contract Zeto_NfAnon is ZetoBase { + Groth16Verifier_NfAnon internal verifier; constructor( - Groth16Verifier_NFAnon _verifier, + Groth16Verifier_NfAnon _verifier, Registry _registry ) ZetoBase(_registry) { verifier = _verifier; diff --git a/solidity/contracts/zeto_nf_anon_nullifier.sol b/solidity/contracts/zeto_nf_anon_nullifier.sol index bfb428a..51535b1 100644 --- a/solidity/contracts/zeto_nf_anon_nullifier.sol +++ b/solidity/contracts/zeto_nf_anon_nullifier.sol @@ -15,7 +15,7 @@ // limitations under the License. pragma solidity ^0.8.20; -import {Groth16Verifier_NFAnonNullifier} from "./lib/verifier_nf_anon_nullifier.sol"; +import {Groth16Verifier_NfAnonNullifier} from "./lib/verifier_nf_anon_nullifier.sol"; import {ZetoNullifier} from "./lib/zeto_nullifier.sol"; import {Registry} from "./lib/registry.sol"; import {Commonlib} from "./lib/common.sol"; @@ -34,11 +34,11 @@ uint256 constant MAX_SMT_DEPTH = 64; /// - the hashes in the input and output match the hash(value, salt, owner public key) formula /// - the sender possesses the private BabyJubjub key, whose public key is part of the pre-image of the input commitment hashes, which match the corresponding nullifiers /// - the nullifiers represent input commitments that are included in a Sparse Merkle Tree represented by the root hash -contract Zeto_NFAnonNullifier is ZetoNullifier { - Groth16Verifier_NFAnonNullifier verifier; +contract Zeto_NfAnonNullifier is ZetoNullifier { + Groth16Verifier_NfAnonNullifier verifier; constructor( - Groth16Verifier_NFAnonNullifier _verifier, + Groth16Verifier_NfAnonNullifier _verifier, Registry _registry ) ZetoNullifier(_registry) { verifier = _verifier; diff --git a/solidity/contracts/zkDvP.sol b/solidity/contracts/zkDvP.sol index a45fb30..438f5c3 100644 --- a/solidity/contracts/zkDvP.sol +++ b/solidity/contracts/zkDvP.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.20; import {Commonlib} from "./lib/common.sol"; import {Zeto_Anon} from "./zeto_anon.sol"; -import {Zeto_NFAnon} from "./zeto_nf_anon.sol"; +import {Zeto_NfAnon} from "./zeto_nf_anon.sol"; import "hardhat/console.sol"; /// @title A sample on-chain implementation of a DvP escrow contract using ZKP based C-UTXO tokens @@ -56,7 +56,7 @@ contract zkDvP { } Zeto_Anon paymentToken; - Zeto_NFAnon assetToken; + Zeto_NfAnon assetToken; mapping(uint256 => Trade) trades; uint256 tradeCount; @@ -67,7 +67,7 @@ contract zkDvP { constructor(address paymentTokenAddress, address assetTokenAddress) { tradeCount = 0; paymentToken = Zeto_Anon(paymentTokenAddress); - assetToken = Zeto_NFAnon(assetTokenAddress); + assetToken = Zeto_NfAnon(assetTokenAddress); } function initiateTrade( diff --git a/solidity/ignition/modules/zeto_anon.ts b/solidity/ignition/modules/zeto_anon.ts index 6337de7..450ff94 100644 --- a/solidity/ignition/modules/zeto_anon.ts +++ b/solidity/ignition/modules/zeto_anon.ts @@ -16,8 +16,8 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; -const DepositVerifierModule = buildModule("Groth16Verifier_CheckValue", (m) => { - const verifier = m.contract('Groth16Verifier_CheckValue', []); +const DepositVerifierModule = buildModule("Groth16Verifier_CheckHashesValue", (m) => { + const verifier = m.contract('Groth16Verifier_CheckHashesValue', []); return { verifier }; }); diff --git a/solidity/ignition/modules/zeto_anon_enc.ts b/solidity/ignition/modules/zeto_anon_enc.ts index 06fdd42..ee12f39 100644 --- a/solidity/ignition/modules/zeto_anon_enc.ts +++ b/solidity/ignition/modules/zeto_anon_enc.ts @@ -16,8 +16,8 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; -const DepositVerifierModule = buildModule("Groth16Verifier_CheckValue", (m) => { - const verifier = m.contract('Groth16Verifier_CheckValue', []); +const DepositVerifierModule = buildModule("Groth16Verifier_CheckHashesValue", (m) => { + const verifier = m.contract('Groth16Verifier_CheckHashesValue', []); return { verifier }; }); diff --git a/solidity/ignition/modules/zeto_anon_enc_nullifier.ts b/solidity/ignition/modules/zeto_anon_enc_nullifier.ts index 2b6bfab..37a83d6 100644 --- a/solidity/ignition/modules/zeto_anon_enc_nullifier.ts +++ b/solidity/ignition/modules/zeto_anon_enc_nullifier.ts @@ -30,8 +30,8 @@ const SmtLibModule = buildModule("SmtLib", (m) => { return { smtLib, poseidon3 }; }); -const DepositVerifierModule = buildModule("Groth16Verifier_CheckValue", (m) => { - const verifier = m.contract('Groth16Verifier_CheckValue', []); +const DepositVerifierModule = buildModule("Groth16Verifier_CheckHashesValue", (m) => { + const verifier = m.contract('Groth16Verifier_CheckHashesValue', []); return { verifier }; }); diff --git a/solidity/ignition/modules/zeto_anon_nullifier.ts b/solidity/ignition/modules/zeto_anon_nullifier.ts index d9484d3..eeda983 100644 --- a/solidity/ignition/modules/zeto_anon_nullifier.ts +++ b/solidity/ignition/modules/zeto_anon_nullifier.ts @@ -30,8 +30,8 @@ const SmtLibModule = buildModule("SmtLib", (m) => { return { smtLib, poseidon3 }; }); -const DepositVerifierModule = buildModule("Groth16Verifier_CheckValue", (m) => { - const verifier = m.contract('Groth16Verifier_CheckValue', []); +const DepositVerifierModule = buildModule("Groth16Verifier_CheckHashesValue", (m) => { + const verifier = m.contract('Groth16Verifier_CheckHashesValue', []); return { verifier }; }); diff --git a/solidity/ignition/modules/zeto_nf_anon.ts b/solidity/ignition/modules/zeto_nf_anon.ts index 1bd3f46..eac1513 100644 --- a/solidity/ignition/modules/zeto_nf_anon.ts +++ b/solidity/ignition/modules/zeto_nf_anon.ts @@ -16,19 +16,19 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; -const VerifierModule = buildModule("Groth16Verifier_NFAnon", (m) => { - const verifier = m.contract('Groth16Verifier_NFAnon', []); +const VerifierModule = buildModule("Groth16Verifier_NfAnon", (m) => { + const verifier = m.contract('Groth16Verifier_NfAnon', []); return { verifier }; }); -export default buildModule("Zeto_NFAnon", (m) => { +export default buildModule("Zeto_NfAnon", (m) => { const { verifier } = m.useModule(VerifierModule); const commonlib = m.library('Commonlib'); const registryAddress = m.getParameter("registry"); const registry = m.contractAt('Registry', registryAddress); - const zeto = m.contract('Zeto_NFAnon', [verifier, registry], { + const zeto = m.contract('Zeto_NfAnon', [verifier, registry], { libraries: { Commonlib: commonlib, }, diff --git a/solidity/ignition/modules/zeto_nf_anon_nullifier.ts b/solidity/ignition/modules/zeto_nf_anon_nullifier.ts index 6231e41..83e81c1 100644 --- a/solidity/ignition/modules/zeto_nf_anon_nullifier.ts +++ b/solidity/ignition/modules/zeto_nf_anon_nullifier.ts @@ -30,19 +30,19 @@ const SmtLibModule = buildModule("SmtLib", (m) => { return { smtLib, poseidon3 }; }); -const VerifierModule = buildModule("Groth16Verifier_NFAnonNullifier", (m) => { - const verifier = m.contract('Groth16Verifier_NFAnonNullifier', []); +const VerifierModule = buildModule("Groth16Verifier_NfAnonNullifier", (m) => { + const verifier = m.contract('Groth16Verifier_NfAnonNullifier', []); return { verifier }; }); -export default buildModule("Zeto_NFAnonNullifier", (m) => { +export default buildModule("Zeto_NfAnonNullifier", (m) => { const { smtLib, poseidon3 } = m.useModule(SmtLibModule); const { verifier } = m.useModule(VerifierModule); const commonlib = m.library('Commonlib'); const registryAddress = m.getParameter("registry"); const registry = m.contractAt('Registry', registryAddress); - const zeto = m.contract('Zeto_NFAnonNullifier', [verifier, registry], { + const zeto = m.contract('Zeto_NfAnonNullifier', [verifier, registry], { libraries: { SmtLib: smtLib, PoseidonUnit3L: poseidon3, diff --git a/solidity/ignition/modules/zkDvP.ts b/solidity/ignition/modules/zkDvP.ts index 8395958..0fea4a6 100644 --- a/solidity/ignition/modules/zkDvP.ts +++ b/solidity/ignition/modules/zkDvP.ts @@ -20,7 +20,7 @@ export default buildModule("zkDvP", (m) => { const paymentTokenAddress = m.getParameter("paymentToken"); const paymentToken = m.contractAt('Zeto_Anon', paymentTokenAddress); const assetTokenAddress = m.getParameter("assetToken"); - const assetToken = m.contractAt('Zeto_NFAnon', assetTokenAddress); + const assetToken = m.contractAt('Zeto_NfAnon', assetTokenAddress); const zkDvP = m.contract('zkDvP', [paymentToken, assetToken]); return { zkDvP }; diff --git a/solidity/test/zeto_nf_anon.ts b/solidity/test/zeto_nf_anon.ts index 30b54df..061fb96 100644 --- a/solidity/test/zeto_nf_anon.ts +++ b/solidity/test/zeto_nf_anon.ts @@ -43,7 +43,7 @@ describe("Zeto based non-fungible token with anonymity without encryption or nul Bob = await newUser(b); Charlie = await newUser(c); const { registry } = await ignition.deploy(RegistryModule); - ({ zeto } = await ignition.deploy(zetoModule, { parameters: { Zeto_NFAnon: { registry: registry.target } } })); + ({ zeto } = await ignition.deploy(zetoModule, { parameters: { Zeto_NfAnon: { registry: registry.target } } })); const tx1 = await registry.connect(deployer).register(Alice.ethAddress, Alice.babyJubPublicKey as [BigNumberish, BigNumberish]); await tx1.wait(); diff --git a/solidity/test/zeto_nf_anon_nullifier.ts b/solidity/test/zeto_nf_anon_nullifier.ts index 093090c..1e11d29 100644 --- a/solidity/test/zeto_nf_anon_nullifier.ts +++ b/solidity/test/zeto_nf_anon_nullifier.ts @@ -44,7 +44,7 @@ describe("Zeto based non-fungible token with anonymity using nullifiers without Bob = await newUser(b); Charlie = await newUser(c); const { registry } = await ignition.deploy(RegistryModule); - ({ zeto } = await ignition.deploy(zetoModule, { parameters: { Zeto_NFAnonNullifier: { registry: registry.target } } })); + ({ zeto } = await ignition.deploy(zetoModule, { parameters: { Zeto_NfAnonNullifier: { registry: registry.target } } })); const tx1 = await registry.connect(deployer).register(Alice.ethAddress, Alice.babyJubPublicKey as [BigNumberish, BigNumberish]); await tx1.wait(); diff --git a/solidity/test/zkDvP.ts b/solidity/test/zkDvP.ts index acd6f5e..c19a062 100644 --- a/solidity/test/zkDvP.ts +++ b/solidity/test/zkDvP.ts @@ -56,7 +56,7 @@ describe("DvP flows between fungible and non-fungible tokens based on Zeto with Charlie = await newUser(c); const { registry } = await ignition.deploy(RegistryModule); - ({ zeto: zkAsset } = await ignition.deploy(zetoNFAnonModule, { parameters: { Zeto_NFAnon: { registry: registry.target } } })); + ({ zeto: zkAsset } = await ignition.deploy(zetoNFAnonModule, { parameters: { Zeto_NfAnon: { registry: registry.target } } })); console.log(`ZK Asset contract deployed at ${zkAsset.target}`); ({ zeto: zkPayment } = await ignition.deploy(zetoAnonModule, { parameters: { Zeto_Anon: { registry: registry.target } } })); console.log(`ZK Payment contract deployed at ${zkPayment.target}`); diff --git a/zkp/circuits/gen-config.json b/zkp/circuits/gen-config.json new file mode 100644 index 0000000..a2d8312 --- /dev/null +++ b/zkp/circuits/gen-config.json @@ -0,0 +1,42 @@ +{ + "anon": { + "ptau": "powersOfTau28_hez_final_12", + "skipSolidityGenaration": false + }, + "anon_enc": { + "ptau": "powersOfTau28_hez_final_13", + "skipSolidityGenaration": false + }, + "anon_nullifier": { + "ptau": "powersOfTau28_hez_final_16", + "skipSolidityGenaration": false + }, + "anon_enc_nullifier": { + "ptau": "powersOfTau28_hez_final_16", + "skipSolidityGenaration": false + }, + "nf_anon": { + "ptau": "powersOfTau28_hez_final_11", + "skipSolidityGenaration": false + }, + "nf_anon_nullifier": { + "ptau": "powersOfTau28_hez_final_15", + "skipSolidityGenaration": false + }, + "check_hashes_value": { + "ptau": "powersOfTau28_hez_final_09", + "skipSolidityGenaration": false + }, + "check_inputs_outputs_value": { + "ptau": "powersOfTau28_hez_final_11", + "skipSolidityGenaration": false + }, + "check_nullifier_value": { + "ptau": "powersOfTau28_hez_final_16", + "skipSolidityGenaration": false + }, + "check_nullifiers": { + "ptau": "powersOfTau28_hez_final_11", + "skipSolidityGenaration": true + } +} diff --git a/zkp/circuits/gen.js b/zkp/circuits/gen.js new file mode 100644 index 0000000..9c7004d --- /dev/null +++ b/zkp/circuits/gen.js @@ -0,0 +1,161 @@ +const fs = require('fs'); +const path = require('path'); +const { exec } = require('child_process'); +const { promisify } = require('util'); +const axios = require('axios'); + +const provingKeysRoot = process.env.PROVING_KEYS_ROOT; +const ptauDownload = process.env.PTAU_DOWNLOAD_PATH; +const specificCircuit = process.argv[2]; +const parallelLimit = parseInt(process.env.GEN_CONCURRENCY, 10) || 10; // Default to compile 10 circuits in parallel + +// check env vars + +if (!provingKeysRoot) { + console.error('Error: PROVING_KEYS_ROOT is not set.'); + process.exit(1); +} + +if (!ptauDownload) { + console.error('Error: PTAU_DOWNLOAD_PATH is not set.'); + process.exit(1); +} + +// load circuits + +const circuits = require('./gen-config.json'); + +const toCamelCase = (str) => { + return str + .split('_') + .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) + .join(''); +}; + +// util functions + +const execAsync = promisify(exec); + +const timestamp = () => new Date().toISOString(); +const logPrefix = (circuit) => `[${timestamp()}] [${circuit}]`; + +const log = (circuit, message) => { + console.log(logPrefix(circuit) + ' ' + message); +}; + +// main circuit process logic +const processCircuit = async (circuit, ptau, skipSolidityGenaration) => { + const circomInput = path.join('./', `${circuit}.circom`); + const ptauFile = path.join(ptauDownload, `${ptau}.ptau`); + const zkeyOutput = path.join(provingKeysRoot, `${circuit}.zkey`); + + if (!fs.existsSync(circomInput)) { + log(circuit, `Error: Input file does not exist: ${circomInput}`); + return; + } + + if (!fs.existsSync(ptauFile)) { + log(circuit, `PTAU file does not exist, downloading: ${ptauFile}`); + try { + const response = await axios.get( + `https://storage.googleapis.com/zkevm/ptau/${ptau}.ptau`, + { + responseType: 'stream', + } + ); + response.data.pipe(fs.createWriteStream(ptauFile)); + await new Promise((resolve, reject) => { + response.data.on('end', resolve); + response.data.on('error', reject); + }); + } catch (error) { + log(circuit, `Failed to download PTAU file: ${error}`); + process.exit(1); + } + } + + log(circuit, `Compiling circuit`); + await execAsync(`circom ${circomInput} --output ../js/lib --sym --wasm`); + await execAsync(`circom ${circomInput} --output ${provingKeysRoot} --r1cs`); + + log(circuit, `Generating test proving key with ${ptau}`); + await execAsync( + `snarkjs groth16 setup ${path.join( + provingKeysRoot, + `${circuit}.r1cs` + )} ${ptauFile} ${zkeyOutput}` + ); + + log(circuit, `Generating verification key`); + await execAsync( + `snarkjs zkey export verificationkey ${zkeyOutput} ${path.join( + provingKeysRoot, + `${circuit}-vkey.json` + )}` + ); + + if (skipSolidityGenaration) { + log(circuit, `Skipping solidity verifier generation`); + return; + } + + log(circuit, `Generating solidity verifier`); + const solidityFile = path.join( + '..', + '..', + 'solidity', + 'contracts', + 'lib', + `verifier_${circuit}.sol` + ); + await execAsync( + `snarkjs zkey export solidityverifier ${zkeyOutput} ${solidityFile}` + ); + + log(circuit, `Modifying the contract name in the Solidity file`); + const camelCaseCircuitName = toCamelCase(circuit); + const solidityFileTmp = `${solidityFile}.tmp`; + + const fileContent = fs.readFileSync(solidityFile, 'utf8'); + const updatedContent = fileContent.replace( + ' Groth16Verifier ', + ` Groth16Verifier_${camelCaseCircuitName} ` + ); + fs.writeFileSync(solidityFileTmp, updatedContent); + fs.renameSync(solidityFileTmp, solidityFile); +}; + +const run = async () => { + if (specificCircuit) { + // if a specific circuit is provided, check it's in the map + if (!circuits[specificCircuit]) { + console.error(`Error: Unknown circuit: ${specificCircuit}`); + process.exit(1); + } + } + + const circuitsArray = Object.entries(circuits); + const activePromises = new Set(); + + for (const [circuit, { ptau, skipSolidityGenaration }] of circuitsArray) { + if (specificCircuit && circuit !== specificCircuit) { + continue; + } + + const pcPromise = processCircuit(circuit, ptau, skipSolidityGenaration); + activePromises.add(pcPromise); + + if (activePromises.size >= parallelLimit) { + await Promise.race(activePromises); + } + + pcPromise.finally(() => activePromises.delete(pcPromise)); + } + + await Promise.all(activePromises); +}; + +run().catch((err) => { + console.error(`An error occurred: ${err.message}`); + process.exit(1); +}); diff --git a/zkp/circuits/package.json b/zkp/circuits/package.json index 0ff0904..b818b77 100644 --- a/zkp/circuits/package.json +++ b/zkp/circuits/package.json @@ -5,5 +5,12 @@ "license": "Apache-2.0", "dependencies": { "circomlib": "^2.0.5" + }, + "scripts": { + "gen": "node gen.js" + }, + "devDependencies": { + "axios": "^1.7.3", + "p-limit": "^6.1.0" } } diff --git a/zkp/js/README.md b/zkp/js/README.md index bdc2e84..65bb6b6 100644 --- a/zkp/js/README.md +++ b/zkp/js/README.md @@ -16,97 +16,32 @@ Follow the instructions here to install `circom`, the circuit compiler, and `sna [https://docs.circom.io/getting-started/installation/](https://docs.circom.io/getting-started/installation/) -## Compile the circuit +## Compile the circuits and generate verification keys and solidity libraries -First you must install the dependencies of the circuits, by going to the `/zkp/circuits` folder: +1. Install the dependencies of the circuits, by going to the `/zkp/circuits` folder: ```console cd zkp/circuits npm i ``` -You can then compile the circuits: - -```console -circom circuits/X.circom --output ./js/lib --sym --wasm -``` - -This generates the binary representations of the circuit, as a `.wasm` file. Only the top-level circuit, in our case `X.circom` needs to be compiled. - -## Generate the proving key - -The proving key is used by the prover code to generate the SNARK proof. This is accomplished with `snarkjs`. It supports 3 proving systems: `groth16`, `plonk` and `fflonk`. We use `groth16` as the default for its faster proof generation time and its support by the binary proof generator [rapidsnark](https://github.com/iden3/rapidsnark). - -The result of a trusted setup from a well-coordinated ceremony can be used here. Download one of them from [https://github.com/iden3/snarkjs](https://github.com/iden3/snarkjs?tab=readme-ov-file#7-prepare-phase-2), such as `powersOfTau28_hez_final_15.ptau`. - -The different `ptau` files represent different levels of complexity with the circuits. In general, you want to use the smallest file that can accommodate the size of your circuit. - -The steps below use `X` for the name of the circuit, and `Y` for the sequence number of the ptau files: - -| X | Y | -| ---------------------------- | --------------------------------- | -| `anon.circom` | `powersOfTau28_hez_final_12.ptau` | -| `anon_enc.circom` | `powersOfTau28_hez_final_13.ptau` | -| `anon_nullifier.circom` | `powersOfTau28_hez_final_16.ptau` | -| `anon_enc_nullifier.circom` | `powersOfTau28_hez_final_16.ptau` | -| `nf_anon.circom` | `powersOfTau28_hez_final_11.ptau` | -| `nf_anon_nullifier.circom` | `powersOfTau28_hez_final_15.ptau` | -| `check_hashes_value.circom` | `powersOfTau28_hez_final_09.ptau` | -| `check_inputs_outputs_value` | `powersOfTau28_hez_final_11.ptau` | -| `check_nullifier_value` | `powersOfTau28_hez_final_16.ptau` | -| `check_nullifiers.circom` | `powersOfTau28_hez_final_11.ptau` | - -### Generating the R1CS circuit format - -The first step is compiling the `.circom` files into an R1CS format that will then be used as input to generating the proving keys. - -```console -circom circuits/X.circom --output ~/proving-keys --r1cs -``` - -### Generating the proving keys for testing purposes - -```console -snarkjs groth16 setup ~/proving-keys/X.r1cs ~/Downloads/powersOfTau28_hez_final_Y.ptau ~/proving-keys/X.zkey -``` - -Note that the above setup command generates **UNSAFE** proving keys that should NOT be used in production. Doing the above skips the phase 2 of a groth16 set up ceremony to contribute more randomness to the proving keys, which is a required step to make the proof generation safe. Doing this is useful for testing purposes only. It also allows us to check in the verification logic in the verifier solidity libraries, which is derived from the proving key generated this way without any randomness. - -### Generating the proving keys for production usage - -When using the groth16 proving system, per-circuit set up ceremony must be conducted to introduce the required randomness to make the proving keys secure. Follow the procedure described here https://github.com/iden3/snarkjs?tab=readme-ov-file#15-setup to conduct the ceremony. After obtaining the proving key, the verification key and the verifier Solidity libraries in the contracts folder must also be re-generated. +2. Compile the circuits and generate verification keys and solidity files. -## Export the verification key +- set where you want to store the generated verification keys and the downloaded PTAU files + ```console + export PROVING_KEYS_ROOT="$HOME/proving-keys" + export PTAU_DOWNLOAD_PATH="$HOME/Downloads" + mkdir -p $PROVING_KEYS_ROOT $PTAU_DOWNLOAD_PATH + ``` +- run the generation script for **ALL** circuits + ```console + npm run gen + ``` + **run `npm run gen $circuit` for developing a single circuit** + **use `GEN_CONCURRENCY` to control how many circuits to be processed in parallel, default to 10** -The verification key is used by verifier code (either offchain with a JS library or onchain with Solidity). This can be derived from the proving key above. - -```console -snarkjs zkey export verificationkey ~/proving-keys/X.zkey ~/proving-keys/X-vkey.json -``` - -## Export the Solidity verifier library - -You can skip this step for running tests. Solidity verifiers have already been generated from the UNSAFE test proving keys as described above. - -However, if you have performed the per-circuit set up ceremonies to generate the proving keys, for instance in a production deployment, then you must re-generated the solidity verifiers. - -The verifier library in Solidity are also derived from the proving key: - -```console -snarkjs zkey export solidityverifier ~/proving-keys/X.zkey ../solidity/contracts/lib/verifier_X.sol -``` +> Refer to [generation script explanation](#generation-script-explanation) for what the script does -After EACH verifier library is generated, you need to navigate to the solidity file for the verifier and modify the name of the contract, to match the naming convention used by the top-level token contract that references the verifier library. For instance, for the `anon_nullifier` circuit, you will have generated the following file: - -``` -/solidity/contracts/lib/verifier_anon_nullifier.sol -``` - -The file contains a contract called `Groth16Verifier`. That must be renamed to `Groth16Verifier_AnonEncNullifier` to match it's name used by the contract: - -``` -/solidity/contracts/zeto_anon_nullifier.sol -``` # Run @@ -205,3 +140,82 @@ Proving time: 1.08 s 49 passing (9s) ``` + + + +## generation script explanation + +The `CIRCUIT_FILE_NAME` and `PTAU_FILE_NAME` referenced below refer to the circuit name and their corresponding ptau in [../circuits/gen-config.json](../circuits/gen-config.json). + +### Compile the circuit + +You can then compile the circuits: + +```console +circom circuits/CIRCUIT_FILE_NAME.circom --output ./js/lib --sym --wasm +``` + +This generates the binary representations of the circuit, as a `.wasm` file. Only the top-level circuit, in our case `CIRCUIT_FILE_NAME.circom` needs to be compiled. + +### Generate the proving key + +The proving key is used by the prover code to generate the SNARK proof. This is accomplished with `snarkjs`. It supports 3 proving systems: `groth16`, `plonk` and `fflonk`. We use `groth16` as the default for its faster proof generation time and its support by the binary proof generator [rapidsnark](https://github.com/iden3/rapidsnark). + +The result of a trusted setup from a well-coordinated ceremony can be used here. Download one of them from [https://github.com/iden3/snarkjs](https://github.com/iden3/snarkjs?tab=readme-ov-file#7-prepare-phase-2), such as `powersOfTau28_hez_final_15.ptau`. + +The different `ptau` files represent different levels of complexity with the circuits. In general, you want to use the smallest file that can accommodate the size of your circuit. + +#### Generating the R1CS circuit format + +The first step is compiling the `.circom` files into an R1CS format that will then be used as input to generate the proving keys. + +```console +circom circuits/CIRCUIT_FILE_NAME.circom --output ~/proving-keys --r1cs +``` + +#### Generating the proving keys for testing purposes + +```console +snarkjs groth16 setup ~/proving-keys/CIRCUIT_FILE_NAME.r1cs ~/Downloads/PTAU_FILE_NAME.ptau ~/proving-keys/CIRCUIT_FILE_NAME.zkey +``` + +Note that the above setup command generates **UNSAFE** proving keys that should NOT be used in production. Doing the above skips the phase 2 of a groth16 set up ceremony to contribute more randomness to the proving keys, which is a required step to make the proof generation safe. Doing this is useful for testing purposes only. It also allows us to check in the verification logic in the verifier solidity libraries, which is derived from the proving key generated this way without any randomness. + +#### Generating the proving keys for production usage + +When using the groth16 proving system, per-circuit set up ceremony must be conducted to introduce the required randomness to make the proving keys secure. Follow the procedure described here https://github.com/iden3/snarkjs?tab=readme-ov-file#15-setup to conduct the ceremony. After obtaining the proving key, the verification key and the verifier Solidity libraries in the contracts folder must also be re-generated. + +### Export the verification key + +The verification key is used by verifier code (either offchain with a JS library or onchain with Solidity). This can be derived from the proving key above. + +```console +snarkjs zkey export verificationkey ~/proving-keys/CIRCUIT_FILE_NAME.zkey ~/proving-keys/CIRCUIT_FILE_NAME-vkey.json +``` + +### Export the Solidity verifier library + +You can skip this step for running tests. Solidity verifiers have already been generated from the UNSAFE test proving keys as described above. + +However, if you have performed the per-circuit set up ceremonies to generate the proving keys, for instance in a production deployment, then you must re-generated the solidity verifiers. + +The verifier library in Solidity are also derived from the proving key: + +```console +snarkjs zkey export solidityverifier ~/proving-keys/CIRCUIT_FILE_NAME.zkey ../solidity/contracts/lib/verifier_CIRCUIT_FILE_NAME.sol +``` + + +### Rename contracts in the verifier solidity libraries + +After EACH verifier library is generated, you need to navigate to the solidity file for the verifier and modify the name of the contract, to match the naming convention used by the top-level token contract that references the verifier library. For instance, for the `anon_nullifier` circuit, you will have generated the following file: + +``` +/solidity/contracts/lib/verifier_anon_nullifier.sol +``` + +The file contains a contract called `Groth16Verifier`. That must be renamed to `Groth16Verifier_AnonEncNullifier` to match its name used by the contract: + +``` +/solidity/contracts/zeto_anon_nullifier.sol +``` \ No newline at end of file diff --git a/zkp/js/lib/anon_enc_js/anon_enc.wasm b/zkp/js/lib/anon_enc_js/anon_enc.wasm index d351307..4885b1f 100644 Binary files a/zkp/js/lib/anon_enc_js/anon_enc.wasm and b/zkp/js/lib/anon_enc_js/anon_enc.wasm differ diff --git a/zkp/js/lib/anon_enc_nullifier_js/anon_enc_nullifier.wasm b/zkp/js/lib/anon_enc_nullifier_js/anon_enc_nullifier.wasm index cfa3051..fd43e13 100644 Binary files a/zkp/js/lib/anon_enc_nullifier_js/anon_enc_nullifier.wasm and b/zkp/js/lib/anon_enc_nullifier_js/anon_enc_nullifier.wasm differ diff --git a/zkp/js/lib/anon_js/anon.wasm b/zkp/js/lib/anon_js/anon.wasm index fe61980..9e0e61d 100644 Binary files a/zkp/js/lib/anon_js/anon.wasm and b/zkp/js/lib/anon_js/anon.wasm differ diff --git a/zkp/js/lib/anon_nullifier_js/anon_nullifier.wasm b/zkp/js/lib/anon_nullifier_js/anon_nullifier.wasm index ef56df3..acdd1f1 100644 Binary files a/zkp/js/lib/anon_nullifier_js/anon_nullifier.wasm and b/zkp/js/lib/anon_nullifier_js/anon_nullifier.wasm differ diff --git a/zkp/js/lib/check_hashes_value_js/check_hashes_value.wasm b/zkp/js/lib/check_hashes_value_js/check_hashes_value.wasm index 6f72755..61cd8d8 100644 Binary files a/zkp/js/lib/check_hashes_value_js/check_hashes_value.wasm and b/zkp/js/lib/check_hashes_value_js/check_hashes_value.wasm differ diff --git a/zkp/js/lib/check_inputs_outputs_value_js/check_inputs_outputs_value.wasm b/zkp/js/lib/check_inputs_outputs_value_js/check_inputs_outputs_value.wasm index c03c515..6b549a3 100644 Binary files a/zkp/js/lib/check_inputs_outputs_value_js/check_inputs_outputs_value.wasm and b/zkp/js/lib/check_inputs_outputs_value_js/check_inputs_outputs_value.wasm differ diff --git a/zkp/js/lib/check_nullifier_value_js/check_nullifier_value.wasm b/zkp/js/lib/check_nullifier_value_js/check_nullifier_value.wasm index b915a70..5e14e59 100644 Binary files a/zkp/js/lib/check_nullifier_value_js/check_nullifier_value.wasm and b/zkp/js/lib/check_nullifier_value_js/check_nullifier_value.wasm differ diff --git a/zkp/js/lib/check-nullifiers.sym b/zkp/js/lib/check_nullifiers.sym similarity index 100% rename from zkp/js/lib/check-nullifiers.sym rename to zkp/js/lib/check_nullifiers.sym diff --git a/zkp/js/lib/check_nullifiers_js/check_nullifiers.wasm b/zkp/js/lib/check_nullifiers_js/check_nullifiers.wasm index 7c40ade..9fa4ad5 100644 Binary files a/zkp/js/lib/check_nullifiers_js/check_nullifiers.wasm and b/zkp/js/lib/check_nullifiers_js/check_nullifiers.wasm differ diff --git a/zkp/js/lib/nf_anon_js/nf_anon.wasm b/zkp/js/lib/nf_anon_js/nf_anon.wasm index 20f8da4..33f2055 100644 Binary files a/zkp/js/lib/nf_anon_js/nf_anon.wasm and b/zkp/js/lib/nf_anon_js/nf_anon.wasm differ diff --git a/zkp/js/lib/nf_anon_nullifier_js/nf_anon_nullifier.wasm b/zkp/js/lib/nf_anon_nullifier_js/nf_anon_nullifier.wasm index d23b54d..26ad7bc 100644 Binary files a/zkp/js/lib/nf_anon_nullifier_js/nf_anon_nullifier.wasm and b/zkp/js/lib/nf_anon_nullifier_js/nf_anon_nullifier.wasm differ diff --git a/zkp/js/test/anon.js b/zkp/js/test/anon.js index aa9735d..b3d7505 100644 --- a/zkp/js/test/anon.js +++ b/zkp/js/test/anon.js @@ -129,7 +129,7 @@ describe('main circuit tests for Zeto fungible tokens with anonymity without enc err = e; } // console.log(err); - expect(err).to.match(/Error in template CheckHashesAndSum_89 line: 95/); + expect(err).to.match(/Error in template CheckHashesAndSum_89 line: 110/); }); it('should generate a valid proof that can be verified successfully', async () => { diff --git a/zkp/js/test/anon_enc.js b/zkp/js/test/anon_enc.js index 99b2236..335eaee 100644 --- a/zkp/js/test/anon_enc.js +++ b/zkp/js/test/anon_enc.js @@ -142,7 +142,7 @@ describe('main circuit tests for Zeto fungible tokens with anonymity with encryp err = e; } // console.log(err); - expect(err).to.match(/Error in template CheckHashesAndSum_89 line: 95/); + expect(err).to.match(/Error in template CheckHashesAndSum_89 line: 110/); }); it('should generate a valid proof that can be verified successfully', async () => { diff --git a/zkp/js/test/anon_enc_nullifier.js b/zkp/js/test/anon_enc_nullifier.js index a772065..b2aa837 100644 --- a/zkp/js/test/anon_enc_nullifier.js +++ b/zkp/js/test/anon_enc_nullifier.js @@ -268,8 +268,8 @@ describe('main circuit tests for Zeto fungible tokens with encryption and anonym err = e; } // console.log(err); - expect(err).to.match(/Error in template CheckNullifierHashesAndSum_246 line: 156/); - expect(err).to.match(/Error in template Zeto_254 line: 46/); + expect(err).to.match(/Error in template CheckNullifierHashesAndSum_246 line: 171/); + expect(err).to.match(/Error in template Zeto_254 line: 61/); }); it('should generate a valid proof that can be verified successfully', async () => { diff --git a/zkp/js/test/check_nullifiers.js b/zkp/js/test/check_nullifiers.js index 6c6cb63..4cae668 100644 --- a/zkp/js/test/check_nullifiers.js +++ b/zkp/js/test/check_nullifiers.js @@ -116,7 +116,7 @@ describe('check-nullifiers circuit tests', () => { err = e; } // console.log(err); - expect(err).to.match(/Error in template CheckNullifiers_155 line: 63/); + expect(err).to.match(/Error in template CheckNullifiers_155 line: 78/); }); it('should generate a valid proof using groth16 that can be verified successfully', async () => {