From 4dcb60eaca5eccaf601640e8b3e38819c4d83eca Mon Sep 17 00:00:00 2001 From: ryardley Date: Mon, 10 Nov 2025 20:57:29 -0300 Subject: [PATCH 01/22] add new params --- crates/bfv-helpers/src/lib.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/bfv-helpers/src/lib.rs b/crates/bfv-helpers/src/lib.rs index 2727135442..c074052da4 100644 --- a/crates/bfv-helpers/src/lib.rs +++ b/crates/bfv-helpers/src/lib.rs @@ -33,7 +33,7 @@ pub mod params { /// Note that 10 is the default value for both error1 and error2 variance /// for both BFV and TRBFV (if not explicitly set). - /// Standard development parameters set (DO NOT USE IN PRODUCTION). + /// Standard BFV development parameters set (DO NOT USE IN PRODUCTION). /// - Degree: 2048 (polynomial ring size) /// - Plaintext modulus: 1032193 /// - Moduli: [0x3FFFFFFF000001] (provides good security level) @@ -44,6 +44,30 @@ pub mod params { error2_variance: None, }; + /// Testing TrBFV development parameters set (DO NOT USE IN PRODUCTION). + /// - Degree: 512 + /// - Moduli: [0xffffee001, 0xffffc4001] + /// - Plaintext modulus: 10 + /// - Error2 Variance: 3 + pub const SET_512_10_1: BfvParamSet = BfvParamSet { + degree: 512, + moduli: &[0xffffee001, 0xffffc4001], + plaintext_modulus: 10, + error2_variance: Some("3"), + }; + + /// Testing BFV development parameters for share encryption (DO NOT USE IN PRODUCTION). + /// - Degree: 512 + /// - Moduli: [0x7fffffffe0001] + /// - Plaintext modulus: 0xffffee001 + /// - Error2 Variance: 3 + pub const SET_512_0XFFFFEE001_1: BfvParamSet = BfvParamSet { + degree: 512, + moduli: &[0x7fffffffe0001], + plaintext_modulus: 0xffffee001, + error2_variance: None, + }; + /// 128bits security TRBFV parameters set (PRODUCTION READY). /// - Degree: 8192 /// - Plaintext modulus: 1000 From 1ab2a0e9891d20f967f88672d0ba520184139072 Mon Sep 17 00:00:00 2001 From: Cedoor Date: Tue, 11 Nov 2025 11:00:17 +0100 Subject: [PATCH 02/22] test: add test for on-chain zk verification (#984) --- examples/CRISP/circuits/.gitignore | 3 +- examples/CRISP/circuits/src/main.nr | 24 +-- .../client/libs/wasm/pkg/crisp_worker.js | 63 ++++-- examples/CRISP/client/package.json | 9 +- .../voteManagement/VoteManagement.types.ts | 8 +- .../client/src/hooks/voting/useVoteCasting.ts | 200 ++++++++--------- .../client/src/hooks/wasm/useWebAssembly.tsx | 14 +- examples/CRISP/client/src/model/vote.model.ts | 18 +- examples/CRISP/client/vite.config.ts | 11 +- examples/CRISP/package.json | 6 +- .../contracts/CRISPVerifier.sol | 183 +++++++++------- .../packages/crisp-contracts/package.json | 2 +- .../tests/crisp.contracts.test.ts | 193 ++++++++++++----- .../CRISP/packages/crisp-sdk/package.json | 15 +- .../CRISP/packages/crisp-sdk/src/constants.ts | 2 + .../CRISP/packages/crisp-sdk/src/utils.ts | 14 +- examples/CRISP/packages/crisp-sdk/src/vote.ts | 30 ++- .../packages/crisp-sdk/tests/constants.ts | 2 +- .../packages/crisp-sdk/tests/utils.test.ts | 9 +- .../packages/crisp-sdk/tests/vote.test.ts | 25 +-- .../packages/crisp-zk-inputs/package.json | 2 +- examples/CRISP/scripts/setup.sh | 2 + examples/CRISP/test/crisp.spec.ts | 14 +- pnpm-lock.yaml | 204 +++++++++++------- 24 files changed, 633 insertions(+), 420 deletions(-) diff --git a/examples/CRISP/circuits/.gitignore b/examples/CRISP/circuits/.gitignore index 767eaf4c68..5ea1c2abe2 100644 --- a/examples/CRISP/circuits/.gitignore +++ b/examples/CRISP/circuits/.gitignore @@ -1,2 +1,3 @@ target/ -Prover.toml \ No newline at end of file +Prover.toml +crs \ No newline at end of file diff --git a/examples/CRISP/circuits/src/main.nr b/examples/CRISP/circuits/src/main.nr index afb60af7a3..0d1e02a8f3 100644 --- a/examples/CRISP/circuits/src/main.nr +++ b/examples/CRISP/circuits/src/main.nr @@ -18,16 +18,16 @@ use utils::{check_coefficient_values_with_balance, check_coefficient_zero}; fn main( // Ciphertext Addition Section. - prev_ct0is: pub [Polynomial<2048>; 1], - prev_ct1is: pub [Polynomial<2048>; 1], + prev_ct0is: [Polynomial<2048>; 1], + prev_ct1is: [Polynomial<2048>; 1], sum_ct0is: [Polynomial<2048>; 1], sum_ct1is: [Polynomial<2048>; 1], sum_r0is: [Polynomial<2048>; 1], sum_r1is: [Polynomial<2048>; 1], // Greco Section. - params: pub Params<2048, 1>, - pk0is: pub [Polynomial<2048>; 1], - pk1is: pub [Polynomial<2048>; 1], + params: Params<2048, 1>, + pk0is: [Polynomial<2048>; 1], + pk1is: [Polynomial<2048>; 1], ct0is: [Polynomial<2048>; 1], ct1is: [Polynomial<2048>; 1], u: Polynomial<2048>, @@ -45,17 +45,17 @@ fn main( signature: [u8; 64], hashed_message: [u8; 32], // Merkle Tree Section. - merkle_root: pub Field, + merkle_root: Field, merkle_proof_length: u32, merkle_proof_indices: [u1; 20], merkle_proof_siblings: [Field; 20], // Slot Address Section. - slot_address: pub Field, + slot_address: Field, // Balance Section. balance: Field, // Whether this is the first vote for this slot. - is_first_vote: pub bool, -) -> pub ([Polynomial<2048>; 1], [Polynomial<2048>; 1]) { + is_first_vote: bool, +) { // Verify the ECDSA signature. let is_signature_valid = verify_signature(hashed_message, public_key_x, public_key_y, signature); @@ -118,7 +118,7 @@ fn main( // Verify the correct coefficient values and that the vote is <= balance check_coefficient_values_with_balance(k1, params.crypto_params().q_mod_t, balance); - (ct0is, ct1is) + // (ct0is, ct1is) } else { // check if vote == 0. let is_vote_zero = check_coefficient_zero(k1); @@ -128,11 +128,11 @@ fn main( // If so, (ct0is, ct1is) should be returned. if is_first_vote { - (ct0is, ct1is) + // (ct0is, ct1is) } else { // check if the sum is valid assert(is_ct_add_valid); - (sum_ct0is, sum_ct1is) + // (sum_ct0is, sum_ct1is) } } } diff --git a/examples/CRISP/client/libs/wasm/pkg/crisp_worker.js b/examples/CRISP/client/libs/wasm/pkg/crisp_worker.js index 35a7aa5656..2928eba2a2 100755 --- a/examples/CRISP/client/libs/wasm/pkg/crisp_worker.js +++ b/examples/CRISP/client/libs/wasm/pkg/crisp_worker.js @@ -4,38 +4,63 @@ // without even the implied warranty of MERCHANTABILITY // or FITNESS FOR A PARTICULAR PURPOSE. -import { EnclaveSDK, FheProtocol } from '@enclave-e3/sdk' -import circuit from '../../noir/crisp_circuit.json' +import { + encryptVoteAndGenerateCRISPInputs, + generateProofWithReturnValue, + VotingMode, + encodeVote, + encryptVote, + generateMerkleProof, + verifyProof, + hashLeaf, +} from '@crisp-e3/sdk' self.onmessage = async function (event) { const { type, data } = event.data switch (type) { case 'encrypt_vote': try { - const { voteId, publicKey } = data - // use default params for now as they do not matter for what we are doing here, - // which is just encrypting the vote and generating a proof - const sdk = EnclaveSDK.create({ - chainId: 31337, - contracts: { - enclave: '0xc6e7DF5E7b4f2A278906862b61205850344D4e7d', - ciphernodeRegistry: '0xc6e7DF5E7b4f2A278906862b61205850344D4e7d', - }, - // local node - rpcUrl: 'http://localhost:8545', - // default Anvil private key - privateKey: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', - protocol: FheProtocol.BFV, + const { voteId, publicKey, address, signature, message } = data + + // voteId is either 0 or 1, so we need to encode the vote accordingly. + // We are adapting to the current CRISP application. + const vote = voteId === 0 ? { yes: 0n, no: 1n } : { yes: 1n, no: 0n } + const balance = 1n + + const leaf = hashLeaf(address.toLowerCase(), balance.toString()) + // TODO: get the leaves from the server (pass them from the client). + const merkleProof = generateMerkleProof(0n, balance, address.toLowerCase(), [ + leaf, + 4720511075913887710172192848636076523165432993226978491435561065722130431597n, + 14131255645332550266535358189863475289290770471998199141522479556687499890181n, + ]) + + const encodedVote = encodeVote(vote, VotingMode.GOVERNANCE, balance) + const encryptedVote = await encryptVote(encodedVote, publicKey) + + const inputs = await encryptVoteAndGenerateCRISPInputs({ + encodedVote, + publicKey, + previousCiphertext: encryptedVote, + signature, + message, + merkleData: merkleProof, + balance, + slotAddress: address.toLowerCase(), + isFirstVote: true, }) - const result = await sdk.encryptNumberAndGenProof(voteId, publicKey, circuit) + const { proof, returnValue } = await generateProofWithReturnValue(inputs) + + // TODO: returnValue is the encrypted vote. We need to convert it from Noir format to BFV format + // instead of using the encryptVote function (which should be removed from the SDK). self.postMessage({ type: 'encrypt_vote', success: true, encryptedVote: { - vote: result.encryptedVote, - proofData: result.proof, + vote: encryptedVote, + proofData: proof, }, }) } catch (error) { diff --git a/examples/CRISP/client/package.json b/examples/CRISP/client/package.json index ee0b5c94dc..4e624c5673 100644 --- a/examples/CRISP/client/package.json +++ b/examples/CRISP/client/package.json @@ -12,20 +12,17 @@ "cli": "pnpm sh ./scripts/cli.sh", "dev": "vite --no-open --host", "dev-static": "NO_HOT=1 vite --no-open --host", - "build": "tsc && vite build", + "build:sdk": "pnpm -C ../packages/crisp-sdk build", + "build": "pnpm build:sdk && tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview", "predeploy": "pnpm run build", "deploy": "gh-pages -d dist" }, "dependencies": { - "@aztec/bb.js": "^0.82.2", + "@crisp-e3/sdk": "workspace:*", "@emotion/babel-plugin": "^11.11.0", "@emotion/react": "^11.11.4", - "@enclave-e3/sdk": "^0.1.5", - "@noir-lang/acvm_js": "1.0.0-beta.3", - "@noir-lang/noir_js": "1.0.0-beta.3", - "@noir-lang/noirc_abi": "1.0.0-beta.3", "@phosphor-icons/react": "^2.1.4", "@svgr/rollup": "^8.1.0", "@tanstack/react-query": "^5.74.3", diff --git a/examples/CRISP/client/src/context/voteManagement/VoteManagement.types.ts b/examples/CRISP/client/src/context/voteManagement/VoteManagement.types.ts index 042a367242..fe8acff6f5 100644 --- a/examples/CRISP/client/src/context/voteManagement/VoteManagement.types.ts +++ b/examples/CRISP/client/src/context/voteManagement/VoteManagement.types.ts @@ -27,7 +27,13 @@ export type VoteManagementContextType = { getPastPolls: () => Promise setVotingRound: React.Dispatch> setUser: React.Dispatch> - encryptVote: (voteId: bigint, publicKey: Uint8Array) => Promise + encryptVote: ( + voteId: bigint, + publicKey: Uint8Array, + address: string, + signature: string, + message: string, + ) => Promise broadcastVote: (vote: BroadcastVoteRequest) => Promise getRoundStateLite: (roundCount: number) => Promise setPastPolls: React.Dispatch> diff --git a/examples/CRISP/client/src/hooks/voting/useVoteCasting.ts b/examples/CRISP/client/src/hooks/voting/useVoteCasting.ts index c9e0a31b76..2141e38483 100644 --- a/examples/CRISP/client/src/hooks/voting/useVoteCasting.ts +++ b/examples/CRISP/client/src/hooks/voting/useVoteCasting.ts @@ -4,125 +4,111 @@ // without even the implied warranty of MERCHANTABILITY // or FITNESS FOR A PARTICULAR PURPOSE. -import { useState, useCallback } from 'react'; -import { useNavigate } from 'react-router-dom'; -import { useSignMessage } from 'wagmi'; +import { useState, useCallback } from 'react' +import { useNavigate } from 'react-router-dom' +import { useSignMessage } from 'wagmi' -import { useVoteManagementContext } from '@/context/voteManagement'; -import { useNotificationAlertContext } from '@/context/NotificationAlert/NotificationAlert.context.tsx'; -import { Poll } from '@/model/poll.model'; -import { BroadcastVoteRequest } from '@/model/vote.model'; +import { useVoteManagementContext } from '@/context/voteManagement' +import { useNotificationAlertContext } from '@/context/NotificationAlert/NotificationAlert.context.tsx' +import { Poll } from '@/model/poll.model' +import { BroadcastVoteRequest } from '@/model/vote.model' export const useVoteCasting = () => { - const { - user, - roundState, - votingRound, - encryptVote, - broadcastVote, - setTxUrl, - } = useVoteManagementContext(); + const { user, roundState, votingRound, encryptVote, broadcastVote, setTxUrl } = useVoteManagementContext() - const { signMessageAsync } = useSignMessage(); - const { showToast } = useNotificationAlertContext(); - const navigate = useNavigate(); - const [isLoading, setIsLoading] = useState(false); + const { signMessageAsync } = useSignMessage() + const { showToast } = useNotificationAlertContext() + const navigate = useNavigate() + const [isLoading, setIsLoading] = useState(false) - const handleVoteEncryption = useCallback( - async (vote: Poll) => { - if (!votingRound) throw new Error('No voting round available for encryption'); - return encryptVote(BigInt(vote.value), new Uint8Array(votingRound.pk_bytes)); - }, - [encryptVote, votingRound], - ); + const handleVoteEncryption = useCallback( + async (vote: Poll, address: string, signature: string, message: string) => { + if (!votingRound) throw new Error('No voting round available for encryption') + return encryptVote(BigInt(vote.value), new Uint8Array(votingRound.pk_bytes), address, signature, message) + }, + [encryptVote, votingRound], + ) - const castVoteWithProof = useCallback(async (pollSelected: Poll | null) => { - if (!pollSelected) { - console.log("Cannot cast vote: Poll option not selected."); - showToast({ type: 'danger', message: 'Please select a poll option first.' }); - return; - } - if (!user || !roundState) { - console.error("Cannot cast vote: Missing user or round state."); - showToast({ type: 'danger', message: 'Cannot cast vote. Ensure you are connected, and the round is active.' }); - return; - } + const castVoteWithProof = useCallback( + async (pollSelected: Poll | null) => { + if (!pollSelected) { + console.log('Cannot cast vote: Poll option not selected.') + showToast({ type: 'danger', message: 'Please select a poll option first.' }) + return + } + if (!user || !roundState) { + console.error('Cannot cast vote: Missing user or round state.') + showToast({ type: 'danger', message: 'Cannot cast vote. Ensure you are connected, and the round is active.' }) + return + } - setIsLoading(true); - console.log("Processing vote..."); + setIsLoading(true) + console.log('Processing vote...') - // For now just sign and do not do nothing with the signature - // await signMessageAsync({ message: `Vote for round ${roundState.id}` }); + // For now just sign and do not do nothing with the signature + const message = `Vote for round ${roundState.id}` + const signature = await signMessageAsync({ message }) - try { - const voteEncrypted = await handleVoteEncryption(pollSelected); - if (!voteEncrypted) { - throw new Error("Failed to encrypt vote."); - } + try { + const voteEncrypted = await handleVoteEncryption(pollSelected, user.address, signature, message) + if (!voteEncrypted) { + throw new Error('Failed to encrypt vote.') + } - const voteRequest: BroadcastVoteRequest = { - round_id: roundState.id, - enc_vote_bytes: Array.from(voteEncrypted.vote), - proof: Array.from(voteEncrypted.proof), - public_inputs: voteEncrypted.public_inputs, - address: user.address, - }; + const voteRequest: BroadcastVoteRequest = { + round_id: roundState.id, + enc_vote_bytes: Array.from(voteEncrypted.vote), + proof: Array.from(voteEncrypted.proof), + public_inputs: voteEncrypted.public_inputs, + address: user.address, + } - const broadcastVoteResponse = await broadcastVote(voteRequest); + const broadcastVoteResponse = await broadcastVote(voteRequest) - if (broadcastVoteResponse) { - switch (broadcastVoteResponse.status) { - case 'success': { - const url = `https://sepolia.etherscan.io/tx/${broadcastVoteResponse.tx_hash}`; - setTxUrl(url); - showToast({ - type: 'success', - message: broadcastVoteResponse.message || 'Successfully voted', - linkUrl: url, - }); - navigate(`/result/${roundState.id}/confirmation`); - break; - } - case 'user_already_voted': - showToast({ - type: 'danger', - message: broadcastVoteResponse.message || 'User has already voted', - }); - break; - case 'failed_broadcast': - showToast({ - type: 'danger', - message: 'Failed to broadcast the vote' - }) - break; - default: - showToast({ - type: 'danger', - message: broadcastVoteResponse.message || 'Error broadcasting the vote', - }); - break; - } - } else { - throw new Error('Received no response after broadcasting vote.'); + if (broadcastVoteResponse) { + switch (broadcastVoteResponse.status) { + case 'success': { + const url = `https://sepolia.etherscan.io/tx/${broadcastVoteResponse.tx_hash}` + setTxUrl(url) + showToast({ + type: 'success', + message: broadcastVoteResponse.message || 'Successfully voted', + linkUrl: url, + }) + navigate(`/result/${roundState.id}/confirmation`) + break } - } catch (error) { - console.error("Vote processing failed:", error); - showToast({ type: 'danger', message: `Vote failed: ${error instanceof Error ? error.message : String(error)}` }); - } finally { - setIsLoading(false); + case 'user_already_voted': + showToast({ + type: 'danger', + message: broadcastVoteResponse.message || 'User has already voted', + }) + break + case 'failed_broadcast': + showToast({ + type: 'danger', + message: 'Failed to broadcast the vote', + }) + break + default: + showToast({ + type: 'danger', + message: broadcastVoteResponse.message || 'Error broadcasting the vote', + }) + break + } + } else { + throw new Error('Received no response after broadcasting vote.') } - }, [ - user, - roundState, - votingRound, - encryptVote, - broadcastVote, - setTxUrl, - showToast, - navigate, - handleVoteEncryption, - signMessageAsync, - ]); + } catch (error) { + console.error('Vote processing failed:', error) + showToast({ type: 'danger', message: `Vote failed: ${error instanceof Error ? error.message : String(error)}` }) + } finally { + setIsLoading(false) + } + }, + [user, roundState, votingRound, encryptVote, broadcastVote, setTxUrl, showToast, navigate, handleVoteEncryption, signMessageAsync], + ) - return { castVoteWithProof, isLoading }; -}; \ No newline at end of file + return { castVoteWithProof, isLoading } +} diff --git a/examples/CRISP/client/src/hooks/wasm/useWebAssembly.tsx b/examples/CRISP/client/src/hooks/wasm/useWebAssembly.tsx index 784c1274d9..007ad07a0c 100644 --- a/examples/CRISP/client/src/hooks/wasm/useWebAssembly.tsx +++ b/examples/CRISP/client/src/hooks/wasm/useWebAssembly.tsx @@ -24,7 +24,13 @@ export const useWebAssemblyHook = () => { } }, []) - const encryptVote = async (voteId: bigint, publicKey: Uint8Array): Promise => { + const encryptVote = async ( + voteId: bigint, + publicKey: Uint8Array, + address: string, + signature: string, + message: string, + ): Promise => { if (!worker) { console.error('WebAssembly worker not initialized') return @@ -32,14 +38,14 @@ export const useWebAssemblyHook = () => { return new Promise((resolve, reject) => { setIsLoading(true) - worker.postMessage({ type: 'encrypt_vote', data: { voteId, publicKey } }) + worker.postMessage({ type: 'encrypt_vote', data: { voteId, publicKey, address, signature, message } }) worker.onmessage = async (event) => { const { type, success, encryptedVote, error } = event.data if (type === 'encrypt_vote') { if (success) { - const { vote, proofData } = encryptedVote; + const { vote, proofData } = encryptedVote const { proof, publicInputs } = proofData - + resolve({ vote: vote, proof: proof, diff --git a/examples/CRISP/client/src/model/vote.model.ts b/examples/CRISP/client/src/model/vote.model.ts index 9c017a61e3..d922cf7a78 100644 --- a/examples/CRISP/client/src/model/vote.model.ts +++ b/examples/CRISP/client/src/model/vote.model.ts @@ -22,18 +22,18 @@ export interface CurrentRound { } export interface BroadcastVoteRequest { - round_id: number; - enc_vote_bytes: number[]; - proof: number[]; - public_inputs: string[]; - address: string; + round_id: number + enc_vote_bytes: number[] + proof: number[] + public_inputs: string[] + address: string } -export type VoteResponseStatus = 'success' | 'user_already_voted' | 'failed_broadcast'; +export type VoteResponseStatus = 'success' | 'user_already_voted' | 'failed_broadcast' export interface BroadcastVoteResponse { - status: VoteResponseStatus; - tx_hash?: string; - message?: string; + status: VoteResponseStatus + tx_hash?: string + message?: string } export interface VoteStateLite { diff --git a/examples/CRISP/client/vite.config.ts b/examples/CRISP/client/vite.config.ts index b50269281c..9d1f5d68fe 100644 --- a/examples/CRISP/client/vite.config.ts +++ b/examples/CRISP/client/vite.config.ts @@ -23,7 +23,15 @@ export default defineConfig({ }, optimizeDeps: { esbuildOptions: { target: 'esnext' }, - exclude: ['@rollup/browser', '@noir-lang/noirc_abi', '@noir-lang/acvm_js', '@enclave-e3/wasm', '@enclave-e3/wasm/init'], + exclude: [ + '@rollup/browser', + '@crisp-e3/zk-inputs', + '@crisp-e3/sdk', + '@noir-lang/noirc_abi', + '@noir-lang/acvm_js', + '@noir-lang/noir_js', + '@aztec/bb.js', + ], }, resolve: { alias: { @@ -33,6 +41,7 @@ export default defineConfig({ }, worker: { format: 'es', + plugins: () => [wasm(), topLevelAwait()], }, plugins: [ // here is the main update diff --git a/examples/CRISP/package.json b/examples/CRISP/package.json index c289a49acf..2e33479df0 100644 --- a/examples/CRISP/package.json +++ b/examples/CRISP/package.json @@ -31,12 +31,12 @@ "@synthetixio/synpress": "^4.1.0", "@synthetixio/synpress-cache": "^0.0.12", "@types/node": "^22.18.0", - "dotenv": "^16.4.5", "concurrently": "^9.1.2", + "dotenv": "^16.4.5", + "ethers": "^6.15.0", "playwright": "1.52.0", "typescript": "5.8.3", - "wait-on": "^8.0.3", - "ethers": "^6.15.0" + "wait-on": "^8.0.3" }, "packageManager": "pnpm@10.7.1+sha512.2d92c86b7928dc8284f53494fb4201f983da65f0fb4f0d40baafa5cf628fa31dae3e5968f12466f17df7e97310e30f343a648baea1b9b350685dafafffdf5808" } diff --git a/examples/CRISP/packages/crisp-contracts/contracts/CRISPVerifier.sol b/examples/CRISP/packages/crisp-contracts/contracts/CRISPVerifier.sol index 93216d4fd5..520b7ebe06 100644 --- a/examples/CRISP/packages/crisp-contracts/contracts/CRISPVerifier.sol +++ b/examples/CRISP/packages/crisp-contracts/contracts/CRISPVerifier.sol @@ -5,122 +5,122 @@ // or FITNESS FOR A PARTICULAR PURPOSE. pragma solidity >=0.8.21; -uint256 constant N = 1048576; -uint256 constant LOG_N = 20; -uint256 constant NUMBER_OF_PUBLIC_INPUTS = 0; +uint256 constant N = 524288; +uint256 constant LOG_N = 19; +uint256 constant NUMBER_OF_PUBLIC_INPUTS = 16; library HonkVerificationKey { function loadVerificationKey() internal pure returns (Honk.VerificationKey memory) { Honk.VerificationKey memory vk = Honk.VerificationKey({ - circuitSize: uint256(1048576), - logCircuitSize: uint256(20), - publicInputsSize: uint256(0), + circuitSize: uint256(524288), + logCircuitSize: uint256(19), + publicInputsSize: uint256(16), ql: Honk.G1Point({ - x: uint256(0x10d36906c36e560297d7bc49c7661fbf50a476bea06e780c40d53a45c459599e), - y: uint256(0x1ed002ce45e75474d75d25ef1764280c6f1974b704ae77315baf31726978c175) + x: uint256(0x13ab223ff59cd43e0728277b3e37bce97e3d2faac23f2b3311d8a30a44e25963), + y: uint256(0x16f019597ce96b3e75f6ba1c88a2ca4d229090e158eb668690748f9dbe53d557) }), qr: Honk.G1Point({ - x: uint256(0x248d6c5782f08a14f794dae5832e8d4a5b42afebf0b248532d725e5d633e7215), - y: uint256(0x266b795b6cf4aa5fff2eb8c3e5a9b9780d6fd5d7170fc2b87f0e6aec8eaa9551) + x: uint256(0x0efc1c7316fb670707e58edc7b3b27311d1885a1c991a07b33867c684a9a863c), + y: uint256(0x174f93332ed828e0bef2437d6db802d5126ebab2c3702e8974c6a4ae0646c0c2) }), qo: Honk.G1Point({ - x: uint256(0x2137d78eee77dfd53fc4bf2adeacef7b15a94cc050a06fb8f52e5a28e938a78e), - y: uint256(0x1b0888693ee93d8804044d8d5e8d950ed53fbb451da45863f6f768145c7d24b1) + x: uint256(0x208152ab37453ed055b7108a1424e41ac9e878722aa8ef880c6c012d21eef3d5), + y: uint256(0x1f7dcf9351580536e0fff33cb7b13fb3b0609f0f38c309935a6324959ef64338) }), q4: Honk.G1Point({ - x: uint256(0x00dceb0527695295e8bc90df562acf14d9bdb55e6250ca81034c7f56b9345985), - y: uint256(0x07963d90a20b5fbd22fcb35424b408b2ed41ab59fb2014027d9ec235a5f5905f) + x: uint256(0x0963ddfd632aedb1ebae9f7f3ae7ef217ff9bdf5d5dee30d1f0425d7e5d598b1), + y: uint256(0x220a29354f7f15a3a56faea2719c51fd96b0bc9bb5be5278cc18e4a70b73daec) }), qm: Honk.G1Point({ - x: uint256(0x11a037d3a9259c512f1039f1049fc7541cbbf315ddb90fe2869e6281c12023ef), - y: uint256(0x2d9966faba8461ee70d9db68e1d817fb21b15fb1e09e7476839dc6d07135cc23) + x: uint256(0x13c6f463efbfdbb1f61e4d88750781b6739363c7892f9833226d65c0ccd9033e), + y: uint256(0x1a46391907c3fb9562fa563bab195d093cc843ede63f936b25344901919d90db) }), qc: Honk.G1Point({ - x: uint256(0x1219c094d86699487f09191b809a6be165c9b4808bbcadef831592295a1d7da6), - y: uint256(0x20b99b2dcadc856a88cc731f349aa47893a0569c4e747b4af0d7aae0dc9bdcda) + x: uint256(0x1bb538b0a6019118e246dce49852f4bdbcd60fb4150833dafc064b1a8a73e8e5), + y: uint256(0x2969a444b671dd94a764dbd631698886cc3b2e64750c2c4143c6736fa7c56845) }), qArith: Honk.G1Point({ - x: uint256(0x147b6a393db982d0f0c7764012b6835c95bc0fa7926fda3f8bf684105282d388), - y: uint256(0x25b693e3f55d510c41dde8bd6b0d61b5c39db3888b55aeada5d7622f34254edf) + x: uint256(0x1928e8e9fee021507d02bcd30412ce506a543e67a85bee951d8af25432cf1e2d), + y: uint256(0x258bf8ef04faf434cc77fe4edaffcc94e6013df01f85ca64260d5d7099280381) }), qDeltaRange: Honk.G1Point({ - x: uint256(0x2c9e01c750140eb161d24b9ee0fc8984acb60bf4e395b8e6ebbaa91c1be174e9), - y: uint256(0x1bc18c861d47b1f9a988e2e3d3d7a0a6252dc986d614fcca0e4f8ac7457c0892) + x: uint256(0x01dbbbd0cd1b7aa0b578c58d34b271245b64061ef676ef15e092b3089a54cb24), + y: uint256(0x1f1bfae9f9c59de7326795e9f089c7bbbdb1925f439b29206c58b90f624ff057) }), qElliptic: Honk.G1Point({ - x: uint256(0x088a610ed8e4090aefcac9ab7277b21fdfb04ce437eb458bdb3696bff53c1cd0), - y: uint256(0x2c5353cedecc1e5f4d84b3ae7f3711e36deebc3071201975bf0fecc655545f5e) + x: uint256(0x0daade853bee6788e93755b59e0da87732527349b02c44a04c71c0facc512df0), + y: uint256(0x08d2431b4246dde4c512fef36fd2057f756fa86df9437b82499788521accab1e) }), qAux: Honk.G1Point({ - x: uint256(0x1baad7c6c4a0f76d721636e31a5b5c28c1062d21f2148339266343c8c1d38996), - y: uint256(0x1eb16da6aed4aa1a55302d002d233fd4dbb885c96431a494683dc97a9275f43b) + x: uint256(0x091d75c333a546baa162025fc5413bd6a15b73b744bff710a75299a9b1cbb11e), + y: uint256(0x160cd0464b1e360218bb120bf522b2f4c51564750d5acce626d87dadd594ca5e) }), qLookup: Honk.G1Point({ - x: uint256(0x1d64341216e323f076ac53aa06192392677f44b67b6947dd6a0a1490fb32a083), - y: uint256(0x28d02cea9cc379ace2ae8779011e247ddc4213ef69895a8e634f425844107141) + x: uint256(0x0d8127977a1a35c9a0d79cb984e7c146cf55d0dcfffed4fe47ba792d80630a57), + y: uint256(0x29a459a12da1ff349a61bc22f74ccf21003c6023d6c2eacfff820f034ca4c4d0) }), qPoseidon2External: Honk.G1Point({ - x: uint256(0x1e0266510d883b6379b58686bd63642eae499ea68a706cc9e70c14c9c0e8536a), - y: uint256(0x11491f77ce7999d3618f0bac66ef7c4f1ed122f862d1c1465e71ce1262c4d7bd) + x: uint256(0x2e7849b38119f1afb8aefdac89a181e566c5be05150575534bb783802819ae88), + y: uint256(0x039cda5b4478a254bcd6b192d1c67b3ac2143bac86b241b08dc50e0a8d23ceca) }), qPoseidon2Internal: Honk.G1Point({ - x: uint256(0x22b036a9ca9be4e71743a125c08648843a55f2cf070dafbbda117ca79e071ad5), - y: uint256(0x12fd44e4853d17621023115fbb658d1150aa85fae5a020f07eddd2215812b2f8) + x: uint256(0x11bca67681de3ea476550a63f2b35b177d7c0fc83eeaf5534832e05e67d1477f), + y: uint256(0x258998c74d0c585178ed727548943a4497be15d53bb82603a365a8fa859cbb2c) }), s1: Honk.G1Point({ - x: uint256(0x1a18a989b31c09eea3da5ae3faa7680ef410474de274210f9c39ebfe6a798c7d), - y: uint256(0x2108883b1e5364123ffd7c32161f9228987ee6aa31ba3c579765f6096579b8e0) + x: uint256(0x183047a917ca53516ae710d178cdb35c17b58d4cf6bebe73ab84edc260969dac), + y: uint256(0x16fa136788614a8d2a8bbb8a40742a2ec88200a7557899dc22eebb9917f39e79) }), s2: Honk.G1Point({ - x: uint256(0x26ddc6264203943a7c31aed2afb7d53fe32a7a38249897fc2a8771c65c414096), - y: uint256(0x0249864a3e742b55386cf6ab4051915fa677a11885e4b0eb04d20d38e9632afe) + x: uint256(0x2337ae7661f0d0a9cc43523f73e3ccca7f2e98e6de8eff0caef5a2e38bac8050), + y: uint256(0x2dbdd39e65dccf475c00f58e0eb06a9be49797a86404bc850eb56fc27a4ca8eb) }), s3: Honk.G1Point({ - x: uint256(0x250a1f5dd0a1e0ec7ab855db5863a25a567877ef1bd1c19e5bc1ccdb733b2956), - y: uint256(0x2cc285a8d6a6e91d142e2a941e23c0a7aee361316975b582e0370e46c4939d9f) + x: uint256(0x15569d9f85dc5d0f5d1e8f18ae7eea3b909c7e68626c609b33e7959bb9918648), + y: uint256(0x2d6729e1c9a15ba58ba3cbe46e8c97880014e3f126b17a1b300715cd449be8b1) }), s4: Honk.G1Point({ - x: uint256(0x0fc8be2a322d1c45d22b210211992629be0450555321e4a55c2cf2d8f5498c6c), - y: uint256(0x1091f3056debdf6a98ab5e4c6df48dc4fded590c78788baf2b394ff6005df6f6) + x: uint256(0x062d199e2a3abdc6bd9c51c9e304859f1c52c29a07449cb515a36ad7ec377240), + y: uint256(0x28000e3b5fe7da7621520bab4c69e5141c6d6d4dc542a8333748d76a07df71b2) }), t1: Honk.G1Point({ - x: uint256(0x1bf7da4add7c858eb94b75f2e78fbd89c84f5fa43824a0d5534173872ee099c2), - y: uint256(0x1b35fa2a35673699ee1cb260d9e6c4be79b26d488c26dc2531194e43c8f747ea) + x: uint256(0x0d64abbea744f03212f1bf39e9d9c693424fa71ab2235b3f501ac3bc615e8577), + y: uint256(0x03abf1a9c83fe43033856e016b6940b2cde1a7438d4150d5f6343e54e692544d) }), t2: Honk.G1Point({ - x: uint256(0x16bf79791869cec464180d5322eeaaef18fed6dc10c3e64e314c04d85c3faece), - y: uint256(0x2e2ec6341669b5b975e25e465af5d9e40533d5ac173554df19daed27f66c36ff) + x: uint256(0x112dfebe6cfb2e00aeee241e82c6091f7706a596da1ed976801260f85fced62b), + y: uint256(0x0cf123627a5260072ece8c03020a378094ef14d4ecd6fa7787cb92b0ff41e16f) }), t3: Honk.G1Point({ - x: uint256(0x150253026f1b985165783c2f4ee1df612c826dda543d06d34711b965730ab69e), - y: uint256(0x0c4062ebcca21d81273b9c58d64447e4ee4d55effa8cbc8fdbd6a76bc3092264) + x: uint256(0x0a7a39e50057960052581f511cb596259f1e1588666bc96a9795c0194676c2a3), + y: uint256(0x18d60133c86a16d9192eaffc8a6ac18ccaf3a7ef9f7a2c2a8c0e04df810193a2) }), t4: Honk.G1Point({ - x: uint256(0x159f2541ce446c6d59ea3f06be91ec9f47c9c82f3e4fd10696511efaff4121fa), - y: uint256(0x15f873b33ec9467e1f0c4fb3a0b59a6fcd6f3480515f1ff5506c48f0c521f00f) + x: uint256(0x2ced4be26f6936520870ea5f91a46f746098f71fbd39136e72e816fd1ccf3fcb), + y: uint256(0x05e4f50caa7b245e81355a0f8966474c9669792cf09f6b4d807a6604ef93cfba) }), id1: Honk.G1Point({ - x: uint256(0x0c02225e1d329e09a738ff6a3d1f2eefee2d9c2446f748430a4c9e3db3af493e), - y: uint256(0x22970a47d992efe75e1a9ae8c48617327596f0b9d1536898b516e9dc0d92e351) + x: uint256(0x1b4b9477e130161cd3a4dab7b5a107cf6eff7794a4dadef3bc0cdf65ec6aa7e5), + y: uint256(0x1abd71747ef723da70730a348cc041dc13da45be7318091d98b6b9d74c79f399) }), id2: Honk.G1Point({ - x: uint256(0x025b15baf18a3565112553243b581ab7c1ef2bb7b6cecb6fd3dbcb494f131c1b), - y: uint256(0x0784d79e6aa29c9c710670f3e62df4c3bf99a73a85bb255a009d5566da762426) + x: uint256(0x12fab07a701a5614890650c7bb37dade42de520bc6933812670c802fcd5c1a69), + y: uint256(0x29a07f1b4b391180ec8bf71f361f2b1ce53959dbbfdada7bd2578ed270e20b82) }), id3: Honk.G1Point({ - x: uint256(0x2f0d8870dfa4fe4f0bcf1e8a8b69f750b15e8315a76dea5965fe82d369e00ffd), - y: uint256(0x0b8a634aa17cb7e29434a052392f7c40e013e37f2dfdcce584ecaa23a3508c89) + x: uint256(0x125c6b504f1acc65b0fb6e30eced8baff778514e407bf588dd108153fbeda5af), + y: uint256(0x15f46d027b762ec2aa4a7d59511d5e17e1e13d4df10eb2a5e9748599045d131b) }), id4: Honk.G1Point({ - x: uint256(0x126143c034d5218ac854d254492806967ae0d23ec5684d341d730cd4dda79f08), - y: uint256(0x1c00c21435080bb1e5b99a42eba611eda1328b0e38e92fcd955d81e96b9b2917) + x: uint256(0x0bbc2d69742f95edbeffe3f80527c6e11e9644918540121093c5244ac6d67737), + y: uint256(0x05780b6e9938c0ff75721918d5a4039840c7b9e2827a02e74845a0b51049794f) }), lagrangeFirst: Honk.G1Point({ x: uint256(0x0000000000000000000000000000000000000000000000000000000000000001), y: uint256(0x0000000000000000000000000000000000000000000000000000000000000002) }), lagrangeLast: Honk.G1Point({ - x: uint256(0x1120d97a81a9c90c251f46b1ec3998bc67e7978323aebf46551a536bf4d0f167), - y: uint256(0x26d1e132ba53edea7d5e8aa5b21067176a3cf0ba74257f595e17bf0db56a98de) + x: uint256(0x2616fcd041a9cf147f53b259e2110fc80de4cf4382c39a7f6b75109300489dbd), + y: uint256(0x1329a5245299bcd004a3ba9f7b72bcd050d16cbb6c437cb690343e131697fed8) }) }); return vk; @@ -272,6 +272,7 @@ uint256 constant BATCHED_RELATION_PARTIAL_LENGTH = 8; uint256 constant NUMBER_OF_ENTITIES = 40; uint256 constant NUMBER_UNSHIFTED = 35; uint256 constant NUMBER_TO_BE_SHIFTED = 5; +uint256 constant PAIRING_POINTS_SIZE = 16; // Alphas are used as relation separators so there should be NUMBER_OF_SUBRELATIONS - 1 uint256 constant NUMBER_OF_ALPHAS = 25; @@ -389,6 +390,8 @@ library Honk { struct Proof { + // Pairing point object + Fr[PAIRING_POINTS_SIZE] pairingPointObject; // Free wires Honk.G1ProofPoint w1; Honk.G1ProofPoint w2; @@ -486,9 +489,13 @@ library TranscriptLib { round0[0] = bytes32(circuitSize); round0[1] = bytes32(publicInputsSize); round0[2] = bytes32(pubInputsOffset); - for (uint256 i = 0; i < publicInputsSize; i++) { + // TODO(https://github.com/AztecProtocol/barretenberg/issues/1331): Consider making publicInputsSize not include pairing point object. + for (uint256 i = 0; i < publicInputsSize - PAIRING_POINTS_SIZE; i++) { round0[3 + i] = bytes32(publicInputs[i]); } + for (uint256 i = 0; i < PAIRING_POINTS_SIZE; i++) { + round0[3 + publicInputsSize - PAIRING_POINTS_SIZE + i] = FrLib.toBytes32(proof.pairingPointObject[i]); + } // Create the first challenge // Note: w4 is added to the challenge later on @@ -673,19 +680,33 @@ library TranscriptLib { } function loadProof(bytes calldata proof) internal pure returns (Honk.Proof memory p) { - // Commitments - p.w1 = bytesToG1ProofPoint(proof[0x0:0x80]); + // TODO(https://github.com/AztecProtocol/barretenberg/issues/1332): Optimize this away when we finalize. + uint256 boundary = 0x0; - p.w2 = bytesToG1ProofPoint(proof[0x80:0x100]); - p.w3 = bytesToG1ProofPoint(proof[0x100:0x180]); + // Pairing point object + for (uint256 i = 0; i < PAIRING_POINTS_SIZE; i++) { + p.pairingPointObject[i] = bytesToFr(proof[boundary:boundary + 0x20]); + boundary += 0x20; + } + // Commitments + p.w1 = bytesToG1ProofPoint(proof[boundary:boundary + 0x80]); + boundary += 0x80; + p.w2 = bytesToG1ProofPoint(proof[boundary:boundary + 0x80]); + boundary += 0x80; + p.w3 = bytesToG1ProofPoint(proof[boundary:boundary + 0x80]); + boundary += 0x80; // Lookup / Permutation Helper Commitments - p.lookupReadCounts = bytesToG1ProofPoint(proof[0x180:0x200]); - p.lookupReadTags = bytesToG1ProofPoint(proof[0x200:0x280]); - p.w4 = bytesToG1ProofPoint(proof[0x280:0x300]); - p.lookupInverses = bytesToG1ProofPoint(proof[0x300:0x380]); - p.zPerm = bytesToG1ProofPoint(proof[0x380:0x400]); - uint256 boundary = 0x400; + p.lookupReadCounts = bytesToG1ProofPoint(proof[boundary:boundary + 0x80]); + boundary += 0x80; + p.lookupReadTags = bytesToG1ProofPoint(proof[boundary:boundary + 0x80]); + boundary += 0x80; + p.w4 = bytesToG1ProofPoint(proof[boundary:boundary + 0x80]); + boundary += 0x80; + p.lookupInverses = bytesToG1ProofPoint(proof[boundary:boundary + 0x80]); + boundary += 0x80; + p.zPerm = bytesToG1ProofPoint(proof[boundary:boundary + 0x80]); + boundary += 0x80; // Sumcheck univariates for (uint256 i = 0; i < CONST_PROOF_SIZE_LOG_N; i++) { @@ -715,7 +736,7 @@ library TranscriptLib { // Shplonk p.shplonkQ = bytesToG1ProofPoint(proof[boundary:boundary + 0x80]); - boundary = boundary + 0x80; + boundary += 0x80; // KZG p.kzgQuotient = bytesToG1ProofPoint(proof[boundary:boundary + 0x80]); } @@ -1542,7 +1563,7 @@ abstract contract BaseHonkVerifier is IVerifier { error ShpleminiFailed(); // Number of field elements in a ultra honk zero knowledge proof - uint256 constant PROOF_SIZE = 440; + uint256 constant PROOF_SIZE = 456; function loadVerificationKey() internal pure virtual returns (Honk.VerificationKey memory); @@ -1555,7 +1576,7 @@ abstract contract BaseHonkVerifier is IVerifier { Honk.VerificationKey memory vk = loadVerificationKey(); Honk.Proof memory p = TranscriptLib.loadProof(proof); - if (publicInputs.length != vk.publicInputsSize) { + if (publicInputs.length != vk.publicInputsSize - PAIRING_POINTS_SIZE) { revert PublicInputsLengthWrong(); } @@ -1566,7 +1587,7 @@ abstract contract BaseHonkVerifier is IVerifier { // Derive public input delta // TODO(https://github.com/AztecProtocol/barretenberg/issues/1281): Add pubInputsOffset to VK or remove entirely. t.relationParameters.publicInputsDelta = computePublicInputDelta( - publicInputs, t.relationParameters.beta, t.relationParameters.gamma, /*pubInputsOffset=*/1 + publicInputs, p.pairingPointObject, t.relationParameters.beta, t.relationParameters.gamma, /*pubInputsOffset=*/1 ); // Sumcheck @@ -1579,7 +1600,7 @@ abstract contract BaseHonkVerifier is IVerifier { return sumcheckVerified && shpleminiVerified; // Boolean condition not required - nice for vanity :) } - function computePublicInputDelta(bytes32[] memory publicInputs, Fr beta, Fr gamma, uint256 offset) + function computePublicInputDelta(bytes32[] memory publicInputs, Fr[PAIRING_POINTS_SIZE] memory pairingPointObject, Fr beta, Fr gamma, uint256 offset) internal view returns (Fr publicInputDelta) @@ -1591,7 +1612,7 @@ abstract contract BaseHonkVerifier is IVerifier { Fr denominatorAcc = gamma - (beta * FrLib.from(offset + 1)); { - for (uint256 i = 0; i < numPublicInputs; i++) { + for (uint256 i = 0; i < numPublicInputs - PAIRING_POINTS_SIZE; i++) { Fr pubInput = FrLib.fromBytes32(publicInputs[i]); numerator = numerator * (numeratorAcc + pubInput); @@ -1600,6 +1621,16 @@ abstract contract BaseHonkVerifier is IVerifier { numeratorAcc = numeratorAcc + beta; denominatorAcc = denominatorAcc - beta; } + + for (uint256 i = 0; i < PAIRING_POINTS_SIZE; i++) { + Fr pubInput = pairingPointObject[i]; + + numerator = numerator * (numeratorAcc + pubInput); + denominator = denominator * (denominatorAcc + pubInput); + + numeratorAcc = numeratorAcc + beta; + denominatorAcc = denominatorAcc - beta; + } } // Fr delta = numerator / denominator; // TOOO: batch invert later? @@ -1883,4 +1914,4 @@ contract HonkVerifier is BaseHonkVerifier(N, LOG_N, NUMBER_OF_PUBLIC_INPUTS) { function loadVerificationKey() internal pure override returns (Honk.VerificationKey memory) { return HonkVerificationKey.loadVerificationKey(); } -} \ No newline at end of file +} diff --git a/examples/CRISP/packages/crisp-contracts/package.json b/examples/CRISP/packages/crisp-contracts/package.json index ded5daca9d..93d4c0b3b7 100644 --- a/examples/CRISP/packages/crisp-contracts/package.json +++ b/examples/CRISP/packages/crisp-contracts/package.json @@ -1,6 +1,6 @@ { "name": "@crisp-e3/contracts", - "version": "0.0.2-test", + "version": "0.2.0-test", "type": "module", "files": [ "contracts", diff --git a/examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts b/examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts index 2f318ebf51..e3e5e75b1d 100644 --- a/examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts +++ b/examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts @@ -6,69 +6,152 @@ import { network } from "hardhat"; import { zeroAddress, zeroHash } from "viem"; +import { ZKInputsGenerator } from "@crisp-e3/zk-inputs"; +import { + encryptVoteAndGenerateCRISPInputs, + generateProof, + VotingMode, + encodeVote, + MESSAGE, + generateMerkleProof, + hashLeaf, +} from "@crisp-e3/sdk"; import { expect } from "chai"; -import { MockEnclave } from "../types"; +import type { HonkVerifier, MockEnclave } from "../types"; + +let zkInputsGenerator = ZKInputsGenerator.withDefaults(); +let publicKey = zkInputsGenerator.generatePublicKey(); +const previousCiphertext = zkInputsGenerator.encryptVote( + publicKey, + new BigInt64Array([0n]) +); describe("CRISP Contracts", function () { - const nonZeroAddress = "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d"; + const nonZeroAddress = "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d"; - describe("deployment", () => { - it("should deploy the contracts", async () => { - const { ethers } = await network.connect(); - /* + describe("deployment", () => { + it("should deploy the contracts", async () => { + const { ethers } = await network.connect(); + /* IEnclave _enclave, IRiscZeroVerifier _verifier, CRISPInputValidatorFactory _inputValidatorFactory, HonkVerifier _honkVerifier, bytes32 _imageId */ - const program = await ethers.deployContract("CRISPProgram", [ - nonZeroAddress, - nonZeroAddress, - nonZeroAddress, - nonZeroAddress, - zeroHash - ]) - - expect(await program.getAddress()).to.not.equal(zeroAddress) - }) - }) - - describe("decode tally", () => { - it("should decode different tallies correctly", async () => { - const { ethers } = await network.connect(); - const mockEnclave = await ethers.deployContract("MockEnclave") as MockEnclave; - - const program = await ethers.deployContract("CRISPProgram", [ - await mockEnclave.getAddress(), - nonZeroAddress, - nonZeroAddress, - nonZeroAddress, - zeroHash - ]) - - // 2 * 2 + 1 * 1 = 5 Y - // 2 * 1 + 0 * 1 = 2 N - const tally1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 1, 0]; - - await mockEnclave.setPlaintextOutput(tally1); - - const decodedTally1 = await program.decodeTally(0); - - expect(decodedTally1[0]).to.equal(5n) - expect(decodedTally1[1]).to.equal(2n) - - // 1 * 1 + 2 * 2 + 5 * 16 + 8 * 1024 = 8277 - // 2 * 1 + 3 * 64 + 1024 = - const tally2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0 , 0, 0, 0, 5, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 , 0, 3, 0, 0, 0, 0, 1, 0]; - await mockEnclave.setPlaintextOutput(tally2); - - const decodedTally2 = await program.decodeTally(0); - - expect(decodedTally2[0]).to.equal(8277n) - expect(decodedTally2[1]).to.equal(1218n) - - }) - }) -}) + const program = await ethers.deployContract("CRISPProgram", [ + nonZeroAddress, + nonZeroAddress, + nonZeroAddress, + nonZeroAddress, + zeroHash, + ]); + + expect(await program.getAddress()).to.not.equal(zeroAddress); + }); + }); + + describe("decode tally", () => { + it("should decode different tallies correctly", async () => { + const { ethers } = await network.connect(); + const mockEnclave = (await ethers.deployContract( + "MockEnclave" + )) as MockEnclave; + + const program = await ethers.deployContract("CRISPProgram", [ + await mockEnclave.getAddress(), + nonZeroAddress, + nonZeroAddress, + nonZeroAddress, + zeroHash, + ]); + + // 2 * 2 + 1 * 1 = 5 Y + // 2 * 1 + 0 * 1 = 2 N + const tally1 = [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, + ]; + + await mockEnclave.setPlaintextOutput(tally1); + + const decodedTally1 = await program.decodeTally(0); + + expect(decodedTally1[0]).to.equal(5n); + expect(decodedTally1[1]).to.equal(2n); + + // 1 * 1 + 2 * 2 + 5 * 16 + 8 * 1024 = 8277 + // 2 * 1 + 3 * 64 + 1024 = + const tally2 = [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 5, + 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 3, 0, 0, 0, 0, 1, 0, + ]; + await mockEnclave.setPlaintextOutput(tally2); + + const decodedTally2 = await program.decodeTally(0); + + expect(decodedTally2[0]).to.equal(8277n); + expect(decodedTally2[1]).to.equal(1218n); + }); + }); + + describe("validate input", () => { + it("should verify the proof correctly with the crisp verifier", async function () { + // It needs some time to generate the proof. + this.timeout(60000); + + const { ethers } = await network.connect(); + + const signers = await ethers.getSigners(); + const signer = signers[0]; + const address = ( + await signer.getAddress() + ).toLowerCase() as `0x${string}`; + + const honkVerifier = (await ethers.deployContract( + "HonkVerifier" + )) as HonkVerifier; + + const vote = { yes: 10n, no: 0n }; + const votingPower = vote.yes; + + const encodedVote = encodeVote(vote, VotingMode.GOVERNANCE, votingPower); + + const signature = (await signer.signMessage(MESSAGE)) as `0x${string}`; + const leaf = hashLeaf(address, vote.yes.toString()); + const leaves = [...[10n, 20n], leaf]; + + const threshold = 0n; + const merkleProof = generateMerkleProof( + threshold, + vote.yes, + address, + leaves + ); + + const inputs = await encryptVoteAndGenerateCRISPInputs({ + encodedVote, + publicKey, + previousCiphertext, + signature, + message: MESSAGE, + merkleData: merkleProof, + balance: vote.yes, + slotAddress: address, + isFirstVote: true, + }); + + const proof = await generateProof(inputs); + + const isValid = await honkVerifier.verify( + proof.proof, + proof.publicInputs + ); + + expect(isValid).to.be.true; + }); + }); +}); diff --git a/examples/CRISP/packages/crisp-sdk/package.json b/examples/CRISP/packages/crisp-sdk/package.json index 48f2c2e5c5..8cc9bbeab6 100644 --- a/examples/CRISP/packages/crisp-sdk/package.json +++ b/examples/CRISP/packages/crisp-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@crisp-e3/sdk", - "version": "0.0.2-test", + "version": "0.2.0-test", "type": "module", "author": { "name": "gnosisguild", @@ -14,7 +14,8 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js" + "import": "./dist/index.js", + "default": "./dist/index.js" } }, "homepage": "https://github.com/gnosisguild/enclave", @@ -33,21 +34,21 @@ "devDependencies": { "@types/chai": "^5.2.2", "@types/node": "22.7.5", - "tsup": "^8.5.0", - "typescript": "5.8.3", "chai": "^6.2.0", "prettier": "^3.2.5", + "tsup": "^8.5.0", + "typescript": "5.8.3", "vite": "^5.4.19", "vite-plugin-wasm": "^3.2.2", "vitest": "^1.6.1" }, "dependencies": { + "@aztec/bb.js": "0.87.0", "@crisp-e3/zk-inputs": "workspace:*", + "@noir-lang/noir_js": "1.0.0-beta.9", "@zk-kit/lean-imt": "^2.2.4", "poseidon-lite": "^0.3.0", - "viem": "2.30.6", - "@aztec/bb.js": "^0.82.2", - "@noir-lang/noir_js": "1.0.0-beta.3" + "viem": "2.30.6" }, "packageManager": "pnpm@10.7.1+sha512.2d92c86b7928dc8284f53494fb4201f983da65f0fb4f0d40baafa5cf628fa31dae3e5968f12466f17df7e97310e30f343a648baea1b9b350685dafafffdf5808" } diff --git a/examples/CRISP/packages/crisp-sdk/src/constants.ts b/examples/CRISP/packages/crisp-sdk/src/constants.ts index 3cf49dfb41..96af5126ec 100644 --- a/examples/CRISP/packages/crisp-sdk/src/constants.ts +++ b/examples/CRISP/packages/crisp-sdk/src/constants.ts @@ -10,6 +10,8 @@ import { BFVParams } from './types' export const CRISP_SERVER_TOKEN_TREE_ENDPOINT = 'state/token-holders' export const CRISP_SERVER_STATE_LITE_ENDPOINT = 'state/lite' +export const MERKLE_TREE_MAX_DEPTH = 20 // static, hardcoded in the circuit. + /** * Half the minimum degree needed to support the maxium vote value * If you change MAXIMUM_VOTE_VALUE, make sure to update this value too. diff --git a/examples/CRISP/packages/crisp-sdk/src/utils.ts b/examples/CRISP/packages/crisp-sdk/src/utils.ts index 804013b60f..db6a388b6f 100644 --- a/examples/CRISP/packages/crisp-sdk/src/utils.ts +++ b/examples/CRISP/packages/crisp-sdk/src/utils.ts @@ -8,6 +8,7 @@ import { poseidon2 } from 'poseidon-lite' import { LeanIMT } from '@zk-kit/lean-imt' import type { IMerkleProof } from './types' +import { MERKLE_TREE_MAX_DEPTH } from './constants' /** * Hash a leaf node for the Merkle tree @@ -34,15 +35,8 @@ export const generateMerkleTree = (leaves: bigint[]): LeanIMT => { * @param balance The voter's balance * @param address The voter's address * @param leaves The leaves of the Merkle tree - * @param maxDepth The maximum depth of the Merkle tree */ -export const generateMerkleProof = ( - threshold: bigint, - balance: bigint, - address: string, - leaves: bigint[], - maxDepth: number, -): IMerkleProof => { +export const generateMerkleProof = (threshold: bigint, balance: bigint, address: string, leaves: bigint[]): IMerkleProof => { if (balance < threshold) { throw new Error('Balance is below the threshold') } @@ -60,10 +54,10 @@ export const generateMerkleProof = ( const proof = tree.generateProof(index) // Pad siblings with zeros - const paddedSiblings = [...proof.siblings, ...Array(maxDepth - proof.siblings.length).fill(0n)] + const paddedSiblings = [...proof.siblings, ...Array(MERKLE_TREE_MAX_DEPTH - proof.siblings.length).fill(0n)] // Pad indices with zeros const indices = proof.siblings.map((_, i) => Number((BigInt(proof.index) >> BigInt(i)) & 1n)) - const paddedIndices = [...indices, ...Array(maxDepth - indices.length).fill(0)] + const paddedIndices = [...indices, ...Array(MERKLE_TREE_MAX_DEPTH - indices.length).fill(0)] return { leaf, diff --git a/examples/CRISP/packages/crisp-sdk/src/vote.ts b/examples/CRISP/packages/crisp-sdk/src/vote.ts index 86bc8ce47b..6c2e2895c8 100644 --- a/examples/CRISP/packages/crisp-sdk/src/vote.ts +++ b/examples/CRISP/packages/crisp-sdk/src/vote.ts @@ -152,6 +152,18 @@ export const validateVote = (votingMode: VotingMode, vote: IVote, votingPower: b } } +export const encryptVote = async (encodedVote: string[], publicKey: Uint8Array): Promise => { + const zkInputsGenerator: ZKInputsGenerator = new ZKInputsGenerator( + DEFAULT_BFV_PARAMS.degree, + DEFAULT_BFV_PARAMS.plaintextModulus, + DEFAULT_BFV_PARAMS.moduli, + ) + + const vote = BigInt64Array.from(encodedVote.map(BigInt)) + + return zkInputsGenerator.encryptVote(publicKey, vote) +} + /** * This is a wrapper around enclave-e3/sdk encryption functions as CRISP circuit will require some more * input values which generic Greco do not need. @@ -263,10 +275,12 @@ export const generateMaskVote = async ( export const generateProof = async (crispInputs: CRISPCircuitInputs): Promise => { const noir = new Noir(circuit as CompiledCircuit) - const backend = new UltraHonkBackend((circuit as CompiledCircuit).bytecode) + const backend = new UltraHonkBackend((circuit as CompiledCircuit).bytecode, { threads: 4 }) const { witness } = await noir.execute(crispInputs as any) - const proof = await backend.generateProof(witness) + const proof = await backend.generateProof(witness, { keccak: true }) + + await backend.destroy() return proof } @@ -275,10 +289,12 @@ export const generateProofWithReturnValue = async ( crispInputs: CRISPCircuitInputs, ): Promise<{ returnValue: unknown; proof: ProofData }> => { const noir = new Noir(circuit as CompiledCircuit) - const backend = new UltraHonkBackend((circuit as CompiledCircuit).bytecode) + const backend = new UltraHonkBackend((circuit as CompiledCircuit).bytecode, { threads: 4 }) const { witness, returnValue } = await noir.execute(crispInputs as any) - const proof = await backend.generateProof(witness) + const proof = await backend.generateProof(witness, { keccak: true }) + + await backend.destroy() return { returnValue, proof } } @@ -294,5 +310,9 @@ export const getCircuitOutputValue = async (crispInputs: CRISPCircuitInputs): Pr export const verifyProof = async (proof: ProofData): Promise => { const backend = new UltraHonkBackend((circuit as CompiledCircuit).bytecode) - return await backend.verifyProof(proof) + const isValid = await backend.verifyProof(proof, { keccak: true }) + + await backend.destroy() + + return isValid } diff --git a/examples/CRISP/packages/crisp-sdk/tests/constants.ts b/examples/CRISP/packages/crisp-sdk/tests/constants.ts index 26d797d734..c1328cba4e 100644 --- a/examples/CRISP/packages/crisp-sdk/tests/constants.ts +++ b/examples/CRISP/packages/crisp-sdk/tests/constants.ts @@ -30,4 +30,4 @@ export const MAX_DEPTH = 20 export const votingPowerLeaf = 1000n export const testAddress = '0x1234567890123456789012345678901234567890' -export const merkleProof = generateMerkleProof(0n, votingPowerLeaf, testAddress, LEAVES, MAX_DEPTH) +export const merkleProof = generateMerkleProof(0n, votingPowerLeaf, testAddress, LEAVES) diff --git a/examples/CRISP/packages/crisp-sdk/tests/utils.test.ts b/examples/CRISP/packages/crisp-sdk/tests/utils.test.ts index 7e76573ca5..20890c53f2 100644 --- a/examples/CRISP/packages/crisp-sdk/tests/utils.test.ts +++ b/examples/CRISP/packages/crisp-sdk/tests/utils.test.ts @@ -6,7 +6,7 @@ import { expect, describe, it } from 'vitest' import { generateMerkleProof, generateMerkleTree, hashLeaf } from '../src/utils' -import { LEAVES, MAX_DEPTH } from './constants' +import { LEAVES } from './constants' describe('Utils', () => { describe('hashLeaf', () => { @@ -29,11 +29,10 @@ describe('Utils', () => { it('should generate a valid merkle proof for a leaf', () => { const tree = generateMerkleTree(LEAVES) - const proof = generateMerkleProof(0n, balance, address, LEAVES, MAX_DEPTH) + const proof = generateMerkleProof(0n, balance, address, LEAVES) expect(proof.leaf).toBe(hashLeaf(address, balance.toString())) expect(proof.length).toBe(4) - expect(proof.indices.length).toBe(MAX_DEPTH) // Unpad the proof for verification const unpaddedProof = { ...proof.proof, @@ -43,8 +42,8 @@ describe('Utils', () => { expect(tree.verifyProof(unpaddedProof)).toBe(true) }) it('should throw if the leaf does not exist in the tree', () => { - expect(() => generateMerkleProof(0n, balance, address, [], MAX_DEPTH)).toThrow('Leaf not found in the tree') - expect(() => generateMerkleProof(0n, 999n, address, LEAVES, MAX_DEPTH)).toThrow('Leaf not found in the tree') + expect(() => generateMerkleProof(0n, balance, address, [])).toThrow('Leaf not found in the tree') + expect(() => generateMerkleProof(0n, 999n, address, LEAVES)).toThrow('Leaf not found in the tree') }) }) }) diff --git a/examples/CRISP/packages/crisp-sdk/tests/vote.test.ts b/examples/CRISP/packages/crisp-sdk/tests/vote.test.ts index de399e0c0a..33ef26d9dc 100644 --- a/examples/CRISP/packages/crisp-sdk/tests/vote.test.ts +++ b/examples/CRISP/packages/crisp-sdk/tests/vote.test.ts @@ -124,8 +124,6 @@ describe('Vote', () => { const validVote = { yes: 10n, no: 0n } const invalidVote = { yes: 5n, no: 5n } - const votingPower = 10n - it('should throw an error for invalid GOVERNANCE votes', () => { expect(() => { validateVote(VotingMode.GOVERNANCE, invalidVote, votingPower) @@ -136,11 +134,6 @@ describe('Vote', () => { validateVote(VotingMode.GOVERNANCE, validVote, votingPower) }).not.toThrow() }) - it('should throw when vote are greater than the voting power available', () => { - expect(() => { - validateVote(VotingMode.GOVERNANCE, { yes: 11n, no: 0n }, votingPower) - }).toThrow('Invalid vote for GOVERNANCE mode: vote exceeds voting power') - }) it('should not throw when vote does not exceed the maximum value supported', () => { expect(() => { validateVote(VotingMode.GOVERNANCE, { yes: 10n, no: 0n }, votingPower) @@ -275,7 +268,7 @@ describe('Vote', () => { const signature = await account.signMessage({ message: MESSAGE }) const leaf = hashLeaf(account.address.toLowerCase(), votingPowerLeaf.toString()) const leaves = [...LEAVES, leaf] - const merkleProof = generateMerkleProof(0n, votingPowerLeaf, account.address.toLowerCase(), leaves, 20) + const merkleProof = generateMerkleProof(0n, votingPowerLeaf, account.address.toLowerCase(), leaves) const inputs = await encryptVoteAndGenerateCRISPInputs({ encodedVote, @@ -350,7 +343,7 @@ describe('Vote', () => { }) it('should throw when the signature is invalid and it is a vote (no masking)', { timeout: 100000 }, async () => { - const encodedVote = encodeVote(VOTE, VotingMode.GOVERNANCE, votingPowerLeaf) + const encodedVote = encodeVote(VOTE, VotingMode.GOVERNANCE, votingPower) // hardhat default private key const privateKey = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' @@ -358,7 +351,7 @@ describe('Vote', () => { const signature = await account.signMessage({ message: MESSAGE }) const leaf = hashLeaf(account.address.toLowerCase(), votingPowerLeaf.toString()) const leaves = [...LEAVES, leaf] - const merkleProof = generateMerkleProof(0n, votingPowerLeaf, account.address.toLowerCase(), leaves, 20) + const merkleProof = generateMerkleProof(0n, votingPowerLeaf, account.address.toLowerCase(), leaves) const inputs = await encryptVoteAndGenerateCRISPInputs({ encodedVote, @@ -379,7 +372,7 @@ describe('Vote', () => { }) it('should throw when the merkle tree inclusion proof is invalid and it is a vote (no masking)', { timeout: 100000 }, async () => { - const encodedVote = encodeVote(VOTE, VotingMode.GOVERNANCE, votingPowerLeaf) + const encodedVote = encodeVote(VOTE, VotingMode.GOVERNANCE, votingPower) // hardhat default private key const privateKey = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' @@ -387,7 +380,7 @@ describe('Vote', () => { const signature = await account.signMessage({ message: MESSAGE }) const leaf = hashLeaf(account.address.toLowerCase(), votingPowerLeaf.toString()) const leaves = [...LEAVES, leaf] - const merkleProof = generateMerkleProof(0n, votingPowerLeaf, account.address.toLowerCase(), leaves, 20) + const merkleProof = generateMerkleProof(0n, votingPowerLeaf, account.address.toLowerCase(), leaves) const inputs = await encryptVoteAndGenerateCRISPInputs({ encodedVote, @@ -417,7 +410,7 @@ describe('Vote', () => { no: 0n, } - const encodedVote = encodeVote(VOTE, VotingMode.GOVERNANCE, votingPowerLeaf) + const encodedVote = encodeVote(VOTE, VotingMode.GOVERNANCE, votingPower) // hardhat default private key const privateKey = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' @@ -425,7 +418,7 @@ describe('Vote', () => { const signature = await account.signMessage({ message: MESSAGE }) const leaf = hashLeaf(account.address.toLowerCase(), votingPowerLeaf.toString()) const leaves = [...LEAVES, leaf] - const merkleProof = generateMerkleProof(0n, votingPowerLeaf, account.address.toLowerCase(), leaves, 20) + const merkleProof = generateMerkleProof(0n, votingPowerLeaf, account.address.toLowerCase(), leaves) const inputs = await encryptVoteAndGenerateCRISPInputs({ encodedVote, @@ -446,7 +439,7 @@ describe('Vote', () => { }) it('should throw when the vote is > balance', { timeout: 100000 }, async () => { - const encodedVote = encodeVote(VOTE, VotingMode.GOVERNANCE, votingPowerLeaf) + const encodedVote = encodeVote(VOTE, VotingMode.GOVERNANCE, votingPower) // hardhat default private key const privateKey = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' @@ -454,7 +447,7 @@ describe('Vote', () => { const signature = await account.signMessage({ message: MESSAGE }) const leaf = hashLeaf(account.address.toLowerCase(), votingPowerLeaf.toString()) const leaves = [...LEAVES, leaf] - const merkleProof = generateMerkleProof(0n, votingPowerLeaf, account.address.toLowerCase(), leaves, 20) + const merkleProof = generateMerkleProof(0n, votingPowerLeaf, account.address.toLowerCase(), leaves) const inputs = await encryptVoteAndGenerateCRISPInputs({ encodedVote, diff --git a/examples/CRISP/packages/crisp-zk-inputs/package.json b/examples/CRISP/packages/crisp-zk-inputs/package.json index 485e40629d..93d82ccc4c 100644 --- a/examples/CRISP/packages/crisp-zk-inputs/package.json +++ b/examples/CRISP/packages/crisp-zk-inputs/package.json @@ -2,7 +2,7 @@ "name": "@crisp-e3/zk-inputs", "type": "module", "description": "Core logic to pre-compute CRISP ZK inputs (WASM/JavaScript bindings).", - "version": "0.0.2-test", + "version": "0.2.0-test", "license": "LGPL-3.0-only", "repository": { "type": "git", diff --git a/examples/CRISP/scripts/setup.sh b/examples/CRISP/scripts/setup.sh index 2428dd002f..c9c1aef1bd 100755 --- a/examples/CRISP/scripts/setup.sh +++ b/examples/CRISP/scripts/setup.sh @@ -7,6 +7,8 @@ export CARGO_INCREMENTAL=1 echo "SETUP..." echo "pnpm install" (cd ../../ && pnpm install --frozen-lockfile) +echo "sdk" +(cd packages/crisp-sdk && pnpm install && pnpm build) echo "evm" (cd ../../packages/enclave-contracts && pnpm compile) echo "server" diff --git a/examples/CRISP/test/crisp.spec.ts b/examples/CRISP/test/crisp.spec.ts index 7848adb66a..70f3eb3bdd 100644 --- a/examples/CRISP/test/crisp.spec.ts +++ b/examples/CRISP/test/crisp.spec.ts @@ -15,7 +15,7 @@ async function runCliInit(): Promise { // Execute the command and wait for it to complete const output = execSync( "pnpm cli init --token-address 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 --balance-threshold 1000", - { encoding: "utf-8" }, + { encoding: "utf-8" } ); console.log("Command output:", output); const lines = output.trim().split("\n"); @@ -47,7 +47,7 @@ async function checkE3Activated(e3id: number): Promise { async function waitForE3Activation( e3id: number, - maxWaitMs: number = 300000, + maxWaitMs: number = 300000 ): Promise { const startTime = Date.now(); while (Date.now() - startTime < maxWaitMs) { @@ -66,7 +66,7 @@ const { expect } = test; async function ensureHomePageLoaded(page: Page) { return await expect(page.locator("h4")).toHaveText( - "Coercion-Resistant Impartial Selection Protocol", + "Coercion-Resistant Impartial Selection Protocol" ); } @@ -93,7 +93,7 @@ test("CRISP smoke test", async ({ context, metamaskPage, basicSetup.walletPassword, - extensionId, + extensionId ); log("runCliInit()..."); @@ -125,6 +125,8 @@ test("CRISP smoke test", async ({ .click(); log(`clicking Cast Vote...`); await page.locator('button:has-text("Cast Vote")').click(); + log(`confirming MetaMask signature request...`); + await metamask.confirmSignature(); const WAIT = 300_000; log(`waiting for ${WAIT}ms...`); await page.waitForTimeout(WAIT); @@ -134,11 +136,11 @@ test("CRISP smoke test", async ({ await expect(page.locator("h1")).toHaveText("Historic polls"); log(`asserting that result has 100% on the vote we clicked on...`); await expect( - page.locator("[data-test-id='poll-0-0'] [data-test-id='poll-result-0'] h3"), + page.locator("[data-test-id='poll-0-0'] [data-test-id='poll-result-0'] h3") ).toHaveText("100%"); log(`asserting that result has 0% on the vote we did not click on...`); await expect( - page.locator("[data-test-id='poll-0-0'] [data-test-id='poll-result-1'] h3"), + page.locator("[data-test-id='poll-0-0'] [data-test-id='poll-result-1'] h3") ).toHaveText("0%"); log("============================================"); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0bd915214b..c30a3dce9f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -118,27 +118,15 @@ importers: examples/CRISP/client: dependencies: - '@aztec/bb.js': - specifier: ^0.82.2 - version: 0.82.3 + '@crisp-e3/sdk': + specifier: workspace:* + version: link:../packages/crisp-sdk '@emotion/babel-plugin': specifier: ^11.11.0 version: 11.13.5 '@emotion/react': specifier: ^11.11.4 version: 11.14.0(@types/react@18.3.26)(react@18.3.1) - '@enclave-e3/sdk': - specifier: ^0.1.5 - version: 0.1.5(@openzeppelin/contracts@5.3.0)(@swc/helpers@0.5.17)(@types/node@22.7.5)(bufferutil@4.0.9)(rollup@4.52.5)(typescript@5.8.3)(utf-8-validate@5.0.10)(vite@5.4.21(@types/node@22.7.5))(zod@4.1.12) - '@noir-lang/acvm_js': - specifier: 1.0.0-beta.3 - version: 1.0.0-beta.3 - '@noir-lang/noir_js': - specifier: 1.0.0-beta.3 - version: 1.0.0-beta.3 - '@noir-lang/noirc_abi': - specifier: 1.0.0-beta.3 - version: 1.0.0-beta.3 '@phosphor-icons/react': specifier: ^2.1.4 version: 2.1.10(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -349,14 +337,14 @@ importers: examples/CRISP/packages/crisp-sdk: dependencies: '@aztec/bb.js': - specifier: ^0.82.2 - version: 0.82.3 + specifier: 0.87.0 + version: 0.87.0 '@crisp-e3/zk-inputs': specifier: workspace:* version: link:../crisp-zk-inputs '@noir-lang/noir_js': - specifier: 1.0.0-beta.3 - version: 1.0.0-beta.3 + specifier: 1.0.0-beta.9 + version: 1.0.0-beta.9 '@zk-kit/lean-imt': specifier: ^2.2.4 version: 2.2.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) @@ -844,6 +832,10 @@ packages: resolution: {integrity: sha512-jtnCqf+/QLw5yJGOmy818RMQqzHzHqcROtTdQZJybSxp0z3h76xpLSwoDQUBmZZVbP9e46FJjOLqB6gM9gY5cw==} hasBin: true + '@aztec/bb.js@0.87.0': + resolution: {integrity: sha512-1tGxrJc/or9p4zwP7yvSLHU0z0N/DQGLfIeTYRdlQQPBMcnKX51rMI0PJ07/zZj0XxwHVFlqtV+PqvFBszIPwA==} + hasBin: true + '@babel/code-frame@7.27.1': resolution: {integrity: sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==} engines: {node: '>=6.9.0'} @@ -1562,15 +1554,6 @@ packages: '@emotion/weak-memoize@0.4.0': resolution: {integrity: sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==} - '@enclave-e3/contracts@0.1.5': - resolution: {integrity: sha512-C1Mo9z2JG6netDhpOsk0kZV8DBjVd4ftE5oqhpXDDbK+HHD4XHozjKMqmlUYTooSzzT3INGYNS/IEDUHxYOqTA==} - - '@enclave-e3/sdk@0.1.5': - resolution: {integrity: sha512-AZGIYrlJZ6FeK6DIQWqNKZDwvDpw+l1zCd7hc97giFX2LrNbSAzf/UJmNewAXFfaGtlnOePSVsuixk/ZQd1TVw==} - - '@enclave-e3/wasm@0.1.5': - resolution: {integrity: sha512-PZ/TpABK/PAAzO0d2+q17i3plzCs/E3chihc4yOi9DqCxdGFhm76hTueY/lDXusDnM+LUrEuaD11YR/2kBRvTg==} - '@esbuild/aix-ppc64@0.20.0': resolution: {integrity: sha512-fGFDEctNh0CcSwsiRPxiaqX0P5rq+AqE0SRhYGZ4PX46Lg1FNR6oCxJghf8YgY0WQEgQuh3lErUFE4KxLeRmmw==} engines: {node: '>=12'} @@ -2472,6 +2455,36 @@ packages: '@motionone/utils@10.18.0': resolution: {integrity: sha512-3XVF7sgyTSI2KWvTf6uLlBJ5iAgRgmvp3bpuOiQJvInd4nZ19ET8lX5unn30SlmRH7hXbBbH+Gxd0m0klJ3Xtw==} + '@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3': + resolution: {integrity: sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw==} + cpu: [arm64] + os: [darwin] + + '@msgpackr-extract/msgpackr-extract-darwin-x64@3.0.3': + resolution: {integrity: sha512-mdzd3AVzYKuUmiWOQ8GNhl64/IoFGol569zNRdkLReh6LRLHOXxU4U8eq0JwaD8iFHdVGqSy4IjFL4reoWCDFw==} + cpu: [x64] + os: [darwin] + + '@msgpackr-extract/msgpackr-extract-linux-arm64@3.0.3': + resolution: {integrity: sha512-YxQL+ax0XqBJDZiKimS2XQaf+2wDGVa1enVRGzEvLLVFeqa5kx2bWbtcSXgsxjQB7nRqqIGFIcLteF/sHeVtQg==} + cpu: [arm64] + os: [linux] + + '@msgpackr-extract/msgpackr-extract-linux-arm@3.0.3': + resolution: {integrity: sha512-fg0uy/dG/nZEXfYilKoRe7yALaNmHoYeIoJuJ7KJ+YyU2bvY8vPv27f7UKhGRpY6euFYqEVhxCFZgAUNQBM3nw==} + cpu: [arm] + os: [linux] + + '@msgpackr-extract/msgpackr-extract-linux-x64@3.0.3': + resolution: {integrity: sha512-cvwNfbP07pKUfq1uH+S6KJ7dT9K8WOE4ZiAcsrSes+UY55E/0jLYc+vq+DO7jlmqRb5zAggExKm0H7O/CBaesg==} + cpu: [x64] + os: [linux] + + '@msgpackr-extract/msgpackr-extract-win32-x64@3.0.3': + resolution: {integrity: sha512-x0fWaQtYp4E6sktbsdAqnehxDgEc/VwM7uLsRCYWaiGu0ykYdZPiS8zCWdnjHwyiumousxfBm4SO31eXqwEZhQ==} + cpu: [x64] + os: [win32] + '@napi-rs/simple-git-android-arm-eabi@0.1.22': resolution: {integrity: sha512-JQZdnDNm8o43A5GOzwN/0Tz3CDBQtBUNqzVwEopm32uayjdjxev1Csp1JeaqF3v9djLDIvsSE39ecsN2LhCKKQ==} engines: {node: '>= 10'} @@ -2702,15 +2715,27 @@ packages: '@noir-lang/acvm_js@1.0.0-beta.3': resolution: {integrity: sha512-Dc6g5rJr/x7tKsWvnTbZvjwqI1uiAtvq+NAz5tcLRzUHJw6NAvDXEH5h117h+BfIAhhsHXuPTkDfDB1Gnqp/Bg==} + '@noir-lang/acvm_js@1.0.0-beta.9': + resolution: {integrity: sha512-cWDKgOkDCj6USfSITB0IM/o3ThndLOsrH6pDptaB6D6wHpSxTOpl/pKP8m1KHXGLVsU0BjIImZ2RrWB4F3a2Pw==} + '@noir-lang/noir_js@1.0.0-beta.3': resolution: {integrity: sha512-Nt/rP7zRMOfNq9urD8+GtRpYqEc0K10FoKXs/v+ZTbGaP6Jkm7+F+UPj2bkWy66k1HNzsN6ortli7c7mnLDHwA==} + '@noir-lang/noir_js@1.0.0-beta.9': + resolution: {integrity: sha512-UDHvQBvWiAbo70+taFQyUgBysVxgxuMkEXxtQUPD8v9sbHp4J5ecGRrtp/1eq15D0zpVc34Vfo8zy2CWndfbaA==} + '@noir-lang/noirc_abi@1.0.0-beta.3': resolution: {integrity: sha512-L6BI64ennatwTUciHqQ14ahUFsgzL41tzghqUELzO7XojasStcWDaSMjlTxca/2pvpWtEJHDtseKe1VZWIIVXQ==} + '@noir-lang/noirc_abi@1.0.0-beta.9': + resolution: {integrity: sha512-JOBLJBZqE6skGztI5xy4GW5WB40YGADt0mU/vf1QAuVY9yArRU3oAJIjuXi4Mo1fvE1TSx/4XPZr7Rocl6Effg==} + '@noir-lang/types@1.0.0-beta.3': resolution: {integrity: sha512-BPOmf0qDiTn4wH1Lo7mHa67GTQFueIVaDUcUb+N9+ALiXC5nVU8HrzWmx1yvZB64ZiCEy7yPdNEaNrszSrE2fg==} + '@noir-lang/types@1.0.0-beta.9': + resolution: {integrity: sha512-2KB4uSUUHjDZzrUY8CIRyaIS4Q9d0s1T9bwabw1rysSBICDkgKOdVKkG0szaCFbmeDNQ3kqanPjqBj7IEEHD7A==} + '@nomicfoundation/edr-darwin-arm64@0.12.0-next.10': resolution: {integrity: sha512-LYXaU0Pk7zA4iAHMdvZ9Gs5QaScs9n5IpclWBNVevSHnL1/uJiFLDF4FYE/NonvaCST6Rd0E4MS3pJltsrBQmA==} engines: {node: '>= 20'} @@ -7441,6 +7466,13 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + msgpackr-extract@3.0.3: + resolution: {integrity: sha512-P0efT1C9jIdVRefqjzOQ9Xml57zpOXnIuS+csaB4MdZbTdmGDLo8XhzBG1N7aO11gKDDkJvBLULeFTo46wwreA==} + hasBin: true + + msgpackr@1.11.5: + resolution: {integrity: sha512-UjkUHN0yqp9RWKy0Lplhh+wlpdt9oQBYgULZOiFhV3VclSF1JnSQWZ5r9gORQlNYaUKQoR8itv7g7z1xDDuACA==} + muggle-string@0.4.1: resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==} @@ -7549,6 +7581,10 @@ packages: encoding: optional: true + node-gyp-build-optional-packages@5.2.2: + resolution: {integrity: sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==} + hasBin: true + node-gyp-build@4.8.4: resolution: {integrity: sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==} hasBin: true @@ -9997,6 +10033,18 @@ snapshots: transitivePeerDependencies: - supports-color + '@aztec/bb.js@0.87.0': + dependencies: + comlink: 4.4.2 + commander: 12.1.0 + debug: 4.4.3(supports-color@8.1.1) + fflate: 0.8.2 + msgpackr: 1.11.5 + pako: 2.1.0 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + '@babel/code-frame@7.27.1': dependencies: '@babel/helper-validator-identifier': 7.28.5 @@ -11066,52 +11114,6 @@ snapshots: '@emotion/weak-memoize@0.4.0': {} - '@enclave-e3/contracts@0.1.5(@openzeppelin/contracts@5.3.0)': - dependencies: - '@openzeppelin/contracts-upgradeable': 5.4.0(@openzeppelin/contracts@5.3.0) - '@zk-kit/lean-imt.sol': 2.0.1 - poseidon-solidity: 0.0.5 - transitivePeerDependencies: - - '@openzeppelin/contracts' - - '@enclave-e3/sdk@0.1.5(@openzeppelin/contracts@5.3.0)(@swc/helpers@0.5.17)(@types/node@22.7.5)(bufferutil@4.0.9)(rollup@4.52.5)(typescript@5.8.3)(utf-8-validate@5.0.10)(vite@5.4.21(@types/node@22.7.5))(zod@4.1.12)': - dependencies: - '@aztec/bb.js': 0.82.3 - '@enclave-e3/contracts': 0.1.5(@openzeppelin/contracts@5.3.0) - '@enclave-e3/wasm': 0.1.5 - '@noir-lang/noir_js': 1.0.0-beta.3 - comlink: 4.4.2 - viem: 2.38.6(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10)(zod@4.1.12) - vite-plugin-top-level-await: 1.6.0(@swc/helpers@0.5.17)(rollup@4.52.5)(vite@5.4.21(@types/node@22.7.5)) - vite-plugin-wasm: 3.5.0(vite@5.4.21(@types/node@22.7.5)) - vitest: 1.6.1(@types/node@22.7.5) - web-worker: 1.5.0 - transitivePeerDependencies: - - '@edge-runtime/vm' - - '@openzeppelin/contracts' - - '@swc/helpers' - - '@types/node' - - '@vitest/browser' - - '@vitest/ui' - - bufferutil - - happy-dom - - jsdom - - less - - lightningcss - - rollup - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - - typescript - - utf-8-validate - - vite - - zod - - '@enclave-e3/wasm@0.1.5': {} - '@esbuild/aix-ppc64@0.20.0': optional: true @@ -12108,6 +12110,24 @@ snapshots: hey-listen: 1.0.8 tslib: 2.8.1 + '@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3': + optional: true + + '@msgpackr-extract/msgpackr-extract-darwin-x64@3.0.3': + optional: true + + '@msgpackr-extract/msgpackr-extract-linux-arm64@3.0.3': + optional: true + + '@msgpackr-extract/msgpackr-extract-linux-arm@3.0.3': + optional: true + + '@msgpackr-extract/msgpackr-extract-linux-x64@3.0.3': + optional: true + + '@msgpackr-extract/msgpackr-extract-win32-x64@3.0.3': + optional: true + '@napi-rs/simple-git-android-arm-eabi@0.1.22': optional: true @@ -12262,18 +12282,33 @@ snapshots: '@noir-lang/acvm_js@1.0.0-beta.3': {} + '@noir-lang/acvm_js@1.0.0-beta.9': {} + '@noir-lang/noir_js@1.0.0-beta.3': dependencies: '@noir-lang/acvm_js': 1.0.0-beta.3 '@noir-lang/noirc_abi': 1.0.0-beta.3 '@noir-lang/types': 1.0.0-beta.3 + '@noir-lang/noir_js@1.0.0-beta.9': + dependencies: + '@noir-lang/acvm_js': 1.0.0-beta.9 + '@noir-lang/noirc_abi': 1.0.0-beta.9 + '@noir-lang/types': 1.0.0-beta.9 + pako: 2.1.0 + '@noir-lang/noirc_abi@1.0.0-beta.3': dependencies: '@noir-lang/types': 1.0.0-beta.3 + '@noir-lang/noirc_abi@1.0.0-beta.9': + dependencies: + '@noir-lang/types': 1.0.0-beta.9 + '@noir-lang/types@1.0.0-beta.3': {} + '@noir-lang/types@1.0.0-beta.9': {} + '@nomicfoundation/edr-darwin-arm64@0.12.0-next.10': {} '@nomicfoundation/edr-darwin-x64@0.12.0-next.10': {} @@ -19255,6 +19290,22 @@ snapshots: ms@2.1.3: {} + msgpackr-extract@3.0.3: + dependencies: + node-gyp-build-optional-packages: 5.2.2 + optionalDependencies: + '@msgpackr-extract/msgpackr-extract-darwin-arm64': 3.0.3 + '@msgpackr-extract/msgpackr-extract-darwin-x64': 3.0.3 + '@msgpackr-extract/msgpackr-extract-linux-arm': 3.0.3 + '@msgpackr-extract/msgpackr-extract-linux-arm64': 3.0.3 + '@msgpackr-extract/msgpackr-extract-linux-x64': 3.0.3 + '@msgpackr-extract/msgpackr-extract-win32-x64': 3.0.3 + optional: true + + msgpackr@1.11.5: + optionalDependencies: + msgpackr-extract: 3.0.3 + muggle-string@0.4.1: {} multiformats@9.9.0: {} @@ -19407,6 +19458,11 @@ snapshots: dependencies: whatwg-url: 5.0.0 + node-gyp-build-optional-packages@5.2.2: + dependencies: + detect-libc: 2.1.2 + optional: true + node-gyp-build@4.8.4: {} node-mock-http@1.0.3: {} From e68eedb7cf573d7d0596912c2e86f2a288890782 Mon Sep 17 00:00:00 2001 From: ryardley Date: Tue, 11 Nov 2025 13:15:32 -0300 Subject: [PATCH 03/22] expose wasm functions to get parameters --- Cargo.lock | 14 +++++ Cargo.toml | 1 + crates/bfv-helpers/Cargo.toml | 9 +-- crates/bfv-helpers/src/client.rs | 10 +-- crates/bfv-helpers/src/lib.rs | 43 ++++++++++--- crates/test-helpers/src/bin/fake_encrypt.rs | 4 +- crates/test-helpers/src/lib.rs | 4 +- crates/wasm/Cargo.toml | 2 + crates/wasm/src/lib.rs | 62 ++++++++++++++++++- examples/CRISP/Cargo.lock | 49 +++++++++++++++ examples/CRISP/server/src/cli/commands.rs | 4 +- .../CRISP/server/src/server/routes/rounds.rs | 4 +- packages/enclave-sdk/src/utils.ts | 6 +- templates/default/program/src/lib.rs | 6 +- 14 files changed, 187 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5b507e713..c6145c961d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2675,6 +2675,7 @@ dependencies = [ "fhe-util", "hex", "num-bigint", + "phf", "rand 0.8.5", "thiserror 1.0.69", "zkfhe-greco", @@ -3249,6 +3250,8 @@ version = "0.1.5" dependencies = [ "e3-bfv-helpers", "getrandom 0.2.16", + "serde", + "serde-wasm-bindgen", "wasm-bindgen", ] @@ -7203,6 +7206,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_core" version = "1.0.228" diff --git a/Cargo.toml b/Cargo.toml index fea1f73cc6..809cf33eac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -150,6 +150,7 @@ rayon = "=1.10.0" regex = "=1.11.1" reqwest = { version = "=0.12.22", features = ["json"] } serde = { version = "=1.0.228", features = ["derive"] } +serde-wasm-bindgen = "=0.6.5" serde_json = "=1.0.141" serial_test = "=3.2.0" sled = "=0.34.7" diff --git a/crates/bfv-helpers/Cargo.toml b/crates/bfv-helpers/Cargo.toml index ca0e40a0df..9406ccc22b 100644 --- a/crates/bfv-helpers/Cargo.toml +++ b/crates/bfv-helpers/Cargo.toml @@ -9,14 +9,15 @@ repository = "https://github.com/gnosisguild/enclave/crates/bfv-helpers" [dependencies] alloy-dyn-abi = { workspace = true } alloy-primitives = { workspace = true } -fhe-traits.workspace = true -fhe.workspace = true -rand.workspace = true anyhow.workspace = true -fhe-util = { git = "https://github.com/gnosisguild/fhe.rs" } fhe-math = { git = "https://github.com/gnosisguild/fhe.rs" } +fhe-traits.workspace = true +fhe-util = { git = "https://github.com/gnosisguild/fhe.rs" } +fhe.workspace = true greco = { package = "zkfhe-greco", git = "https://github.com/gnosisguild/zkfhe-generator" } num-bigint = { workspace = true } +phf.workspace = true +rand.workspace = true thiserror = { workspace = true } [dev-dependencies] diff --git a/crates/bfv-helpers/src/client.rs b/crates/bfv-helpers/src/client.rs index 1aede0675b..31b817c467 100644 --- a/crates/bfv-helpers/src/client.rs +++ b/crates/bfv-helpers/src/client.rs @@ -125,7 +125,7 @@ where #[cfg(test)] mod tests { - use crate::params::SET_2048_1032193_1; + use crate::params::INSECURE_SET_2048_1032193_1; use super::*; @@ -135,7 +135,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = SET_2048_1032193_1; + let param_set = INSECURE_SET_2048_1032193_1; let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; @@ -160,7 +160,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = SET_2048_1032193_1; + let param_set = INSECURE_SET_2048_1032193_1; let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; @@ -192,7 +192,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = SET_2048_1032193_1; + let param_set = INSECURE_SET_2048_1032193_1; let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; @@ -223,7 +223,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = SET_2048_1032193_1; + let param_set = INSECURE_SET_2048_1032193_1; let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; diff --git a/crates/bfv-helpers/src/lib.rs b/crates/bfv-helpers/src/lib.rs index c074052da4..d3d713a6ca 100644 --- a/crates/bfv-helpers/src/lib.rs +++ b/crates/bfv-helpers/src/lib.rs @@ -11,6 +11,7 @@ use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::U256; use fhe::bfv::{BfvParameters, BfvParametersBuilder, Encoding, Plaintext}; use fhe_traits::FheDecoder; +use phf::phf_map; use std::sync::Arc; use thiserror::Error as ThisError; @@ -21,6 +22,8 @@ pub enum Error { // TODO: add errors from client.rs #[error("Input was not encoded correctly")] BadEncoding, + #[error("Unknown parameter set: {0}")] + UnknownParamSet(String), } /// Result that returns a type T or a BfvHelpersError @@ -37,7 +40,7 @@ pub mod params { /// - Degree: 2048 (polynomial ring size) /// - Plaintext modulus: 1032193 /// - Moduli: [0x3FFFFFFF000001] (provides good security level) - pub const SET_2048_1032193_1: BfvParamSet = BfvParamSet { + pub const INSECURE_SET_2048_1032193_1: BfvParamSet = BfvParamSet { degree: 2048, plaintext_modulus: 1032193, moduli: &[0x3FFFFFFF000001], @@ -49,7 +52,7 @@ pub mod params { /// - Moduli: [0xffffee001, 0xffffc4001] /// - Plaintext modulus: 10 /// - Error2 Variance: 3 - pub const SET_512_10_1: BfvParamSet = BfvParamSet { + pub const INSECURE_SET_512_10_1: BfvParamSet = BfvParamSet { degree: 512, moduli: &[0xffffee001, 0xffffc4001], plaintext_modulus: 10, @@ -61,7 +64,7 @@ pub mod params { /// - Moduli: [0x7fffffffe0001] /// - Plaintext modulus: 0xffffee001 /// - Error2 Variance: 3 - pub const SET_512_0XFFFFEE001_1: BfvParamSet = BfvParamSet { + pub const INSECURE_SET_512_0XFFFFEE001_1: BfvParamSet = BfvParamSet { degree: 512, moduli: &[0x7fffffffe0001], plaintext_modulus: 0xffffee001, @@ -97,6 +100,15 @@ pub mod params { }; } +// Map for getters +static PARAMS_MAP: phf::Map<&'static str, BfvParamSet> = phf_map! { + "INSECURE_SET_2048_1032193_1" => params::INSECURE_SET_2048_1032193_1, + "INSECURE_SET_512_10_1" => params::INSECURE_SET_512_10_1, + "INSECURE_SET_512_0XFFFFEE001_1" => params::INSECURE_SET_512_0XFFFFEE001_1, + "SET_8192_1000_4" => params::SET_8192_1000_4, + "SET_8192_144115188075855872_2" => params::SET_8192_144115188075855872_2, +}; + /// A consistent type representing a BFV parameter set. /// /// This struct provides a uniform way to represent BFV parameter sets, @@ -113,6 +125,21 @@ pub struct BfvParamSet { pub error2_variance: Option<&'static str>, } +impl BfvParamSet { + /// Return the given param set based on the input key + pub fn get_params(key: &str) -> Result { + PARAMS_MAP + .get(key) + .copied() + .ok_or_else(|| Error::UnknownParamSet(key.to_string())) + } + + /// List all the available parameter keys + pub fn get_params_list() -> Vec { + PARAMS_MAP.keys().map(|n| n.to_string()).collect() + } +} + /// Builds BFV parameters from a `BfvParamSet`. /// /// This is a convenience function that consumes a `BfvParamSet` struct @@ -573,7 +600,7 @@ mod tests { #[test] fn test_params_constant() { - let param_set = params::SET_2048_1032193_1; + let param_set = params::INSECURE_SET_2048_1032193_1; assert_eq!(param_set.degree, 2048); assert_eq!(param_set.plaintext_modulus, 1032193); assert_eq!(param_set.moduli, &[0x3FFFFFFF000001]); @@ -581,7 +608,7 @@ mod tests { #[test] fn test_params_function() { - let param_set = params::SET_2048_1032193_1; + let param_set = params::INSECURE_SET_2048_1032193_1; let params = build_bfv_params_from_set(param_set); assert_eq!(params.degree(), param_set.degree); @@ -591,7 +618,7 @@ mod tests { #[test] fn test_params_arc_function() { - let param_set = params::SET_2048_1032193_1; + let param_set = params::INSECURE_SET_2048_1032193_1; let params = build_bfv_params_from_set_arc(param_set); assert_eq!(params.degree(), param_set.degree); @@ -601,7 +628,7 @@ mod tests { #[test] fn test_params_encoding_roundtrip() { - let param_set = params::SET_2048_1032193_1; + let param_set = params::INSECURE_SET_2048_1032193_1; let params = build_bfv_params_from_set(param_set); let encoded = encode_bfv_params(¶ms); let decoded = decode_bfv_params(&encoded); @@ -615,7 +642,7 @@ mod tests { #[test] fn test_params_arc_encoding_roundtrip() { - let param_set = params::SET_2048_1032193_1; + let param_set = params::INSECURE_SET_2048_1032193_1; let params = build_bfv_params_from_set_arc(param_set); let encoded = encode_bfv_params(¶ms); let decoded = decode_bfv_params_arc(&encoded); diff --git a/crates/test-helpers/src/bin/fake_encrypt.rs b/crates/test-helpers/src/bin/fake_encrypt.rs index 8f59f72c5d..87c6459eea 100644 --- a/crates/test-helpers/src/bin/fake_encrypt.rs +++ b/crates/test-helpers/src/bin/fake_encrypt.rs @@ -7,7 +7,7 @@ // This is a test script designed to encrypt some fixed data to a fhe public key use clap::Parser; use e3_sdk::bfv_helpers::decode_bfv_params; -use e3_sdk::bfv_helpers::{build_bfv_params_from_set_arc, params::SET_2048_1032193_1}; +use e3_sdk::bfv_helpers::{build_bfv_params_from_set_arc, params::INSECURE_SET_2048_1032193_1}; use fhe::bfv::{Encoding, Plaintext, PublicKey}; use fhe_traits::{DeserializeParametrized, FheEncoder, FheEncrypter, Serialize}; use rand::SeedableRng; @@ -54,7 +54,7 @@ fn main() -> Result<(), Box> { let params = if let Some(params_bytes) = args.params { Arc::new(decode_bfv_params(¶ms_bytes.0)) } else { - build_bfv_params_from_set_arc(SET_2048_1032193_1) + build_bfv_params_from_set_arc(INSECURE_SET_2048_1032193_1) }; let pubkey = PublicKey::from_bytes(&bytes, ¶ms)?; let raw_plaintext = args.plaintext; diff --git a/crates/test-helpers/src/lib.rs b/crates/test-helpers/src/lib.rs index c539e825d5..96aeecc79e 100644 --- a/crates/test-helpers/src/lib.rs +++ b/crates/test-helpers/src/lib.rs @@ -19,7 +19,7 @@ use e3_events::{ }; use e3_fhe::{create_crp, setup_crp_params, ParamsWithCrp}; use e3_net::{DocumentPublisher, NetEventTranslator}; -use e3_sdk::bfv_helpers::{params::SET_2048_1032193_1, BfvParamSet}; +use e3_sdk::bfv_helpers::{params::INSECURE_SET_2048_1032193_1, BfvParamSet}; use e3_utils::SharedRng; use fhe::bfv::{BfvParameters, Ciphertext, Encoding, Plaintext, PublicKey}; use fhe::mbfv::CommonRandomPoly; @@ -87,7 +87,7 @@ pub fn get_common_setup( let rng = create_shared_rng_from_u64(42); let seed = create_seed_from_u64(123); - let param_set = param_set.unwrap_or(SET_2048_1032193_1); + let param_set = param_set.unwrap_or(INSECURE_SET_2048_1032193_1); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; let moduli = param_set.moduli; diff --git a/crates/wasm/Cargo.toml b/crates/wasm/Cargo.toml index 46480c4613..f7f00696dd 100644 --- a/crates/wasm/Cargo.toml +++ b/crates/wasm/Cargo.toml @@ -11,5 +11,7 @@ crate-type = ["cdylib"] [dependencies] e3-bfv-helpers.workspace = true +serde.workspace = true +serde-wasm-bindgen.workspace = true getrandom = { version = "0.2", features = ["js"] } wasm-bindgen = "0.2.99" diff --git a/crates/wasm/src/lib.rs b/crates/wasm/src/lib.rs index 9111aca25a..1ec714adcf 100644 --- a/crates/wasm/src/lib.rs +++ b/crates/wasm/src/lib.rs @@ -4,7 +4,11 @@ // without even the implied warranty of MERCHANTABILITY // or FITNESS FOR A PARTICULAR PURPOSE. -use e3_bfv_helpers::client::{bfv_encrypt, bfv_verifiable_encrypt}; +use e3_bfv_helpers::{ + client::{bfv_encrypt, bfv_verifiable_encrypt}, + BfvParamSet, +}; +use serde::{Deserialize, Serialize}; use wasm_bindgen::prelude::*; #[wasm_bindgen] @@ -138,3 +142,59 @@ pub fn bfv_verifiable_encrypt_vector( JsValue::from(result.circuit_inputs), ]) } + +#[wasm_bindgen] +/// Retrieves a BFV parameter set by name. +/// +/// # Parameters +/// * `name` - Parameter set identifier (e.g., "SET_8192_1000_4") +/// +/// # Returns +/// A JavaScript object with the following structure: +/// ```typescript +/// { +/// degree: number; // Polynomial degree (e.g., 8192) +/// plaintext_modulus: number; // Plaintext modulus value (e.g., 1000) +/// moduli: number[]; // Array of moduli +/// error2_variance: string | null; // Error variance as string or null +/// } +/// ``` +/// +/// # Errors +/// Returns error if the parameter set name is invalid or serialization fails. +pub fn get_bfv_params(name: &str) -> Result { + let params = BfvParamSet::get_params(name).map_err(|e| JsValue::from_str(&e.to_string()))?; + let js_params = BfvParamSetJs::from(¶ms); + serde_wasm_bindgen::to_value(&js_params) + .map_err(|e| JsValue::from_str(&format!("Serialization error: {}", e))) +} + +#[wasm_bindgen] +/// Returns all available BFV parameter set identifiers. +/// +/// # Returns +/// Array of parameter set names that can be passed to `get_bfv_params()`. +/// Includes both production-ready sets (e.g., "SET_8192_1000_4") and +/// insecure sets for testing (prefixed with "INSECURE_"). +pub fn get_bfv_params_list() -> Vec { + BfvParamSet::get_params_list() +} + +#[derive(Serialize, Deserialize)] +pub struct BfvParamSetJs { + pub degree: usize, + pub plaintext_modulus: u64, + pub moduli: Vec, + pub error2_variance: Option, +} + +impl From<&BfvParamSet> for BfvParamSetJs { + fn from(params: &BfvParamSet) -> Self { + BfvParamSetJs { + degree: params.degree, + plaintext_modulus: params.plaintext_modulus, + moduli: params.moduli.to_vec(), + error2_variance: params.error2_variance.map(|s| s.to_string()), + } + } +} diff --git a/examples/CRISP/Cargo.lock b/examples/CRISP/Cargo.lock index 63b33914ad..6f5539c401 100644 --- a/examples/CRISP/Cargo.lock +++ b/examples/CRISP/Cargo.lock @@ -2256,6 +2256,7 @@ dependencies = [ "fhe-traits", "fhe-util", "num-bigint", + "phf", "rand 0.8.5", "thiserror 1.0.69", "zkfhe-greco", @@ -4116,6 +4117,48 @@ dependencies = [ "rustc_version 0.4.1", ] +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_macros", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +dependencies = [ + "phf_shared", + "rand 0.8.5", +] + +[[package]] +name = "phf_macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2 1.0.103", + "quote 1.0.42", + "syn 2.0.109", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.1.10" @@ -5193,6 +5236,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "slab" version = "0.4.11" diff --git a/examples/CRISP/server/src/cli/commands.rs b/examples/CRISP/server/src/cli/commands.rs index a1767899f6..e79c6245ad 100644 --- a/examples/CRISP/server/src/cli/commands.rs +++ b/examples/CRISP/server/src/cli/commands.rs @@ -16,7 +16,7 @@ use alloy::primitives::{Address, Bytes, U256}; use alloy::providers::{Provider, ProviderBuilder}; use crisp::config::CONFIG; use e3_sdk::bfv_helpers::{ - build_bfv_params_from_set_arc, encode_bfv_params, params::SET_2048_1032193_1, + build_bfv_params_from_set_arc, encode_bfv_params, params::INSECURE_SET_2048_1032193_1, }; use e3_sdk::evm_helpers::contracts::{EnclaveContract, EnclaveRead, EnclaveWrite, E3}; use fhe::bfv::{BfvParameters, Ciphertext, Encoding, Plaintext, PublicKey, SecretKey}; @@ -329,7 +329,7 @@ pub async fn decrypt_and_publish_result( } fn generate_bfv_parameters() -> Arc { - build_bfv_params_from_set_arc(SET_2048_1032193_1) + build_bfv_params_from_set_arc(INSECURE_SET_2048_1032193_1) } fn generate_keys(params: &Arc) -> (SecretKey, PublicKey) { diff --git a/examples/CRISP/server/src/server/routes/rounds.rs b/examples/CRISP/server/src/server/routes/rounds.rs index 83a7746940..db51867719 100644 --- a/examples/CRISP/server/src/server/routes/rounds.rs +++ b/examples/CRISP/server/src/server/routes/rounds.rs @@ -14,7 +14,7 @@ use actix_web::{web, HttpResponse, Responder}; use alloy::primitives::{Address, Bytes, U256}; use chrono::Utc; use e3_sdk::bfv_helpers::{ - build_bfv_params_from_set_arc, encode_bfv_params, params::SET_2048_1032193_1, + build_bfv_params_from_set_arc, encode_bfv_params, params::INSECURE_SET_2048_1032193_1, }; use e3_sdk::evm_helpers::contracts::{EnclaveContract, EnclaveRead, EnclaveWrite}; use log::{error, info}; @@ -181,7 +181,7 @@ pub async fn initialize_crisp_round( } info!("Generating parameters..."); - let params = encode_bfv_params(&build_bfv_params_from_set_arc(SET_2048_1032193_1)); + let params = encode_bfv_params(&build_bfv_params_from_set_arc(INSECURE_SET_2048_1032193_1)); let token_address: Address = token_address.parse()?; let balance_threshold = BigUint::parse_bytes(balance_threshold.as_bytes(), 10) diff --git a/packages/enclave-sdk/src/utils.ts b/packages/enclave-sdk/src/utils.ts index ead9dce144..f0007e8f47 100644 --- a/packages/enclave-sdk/src/utils.ts +++ b/packages/enclave-sdk/src/utils.ts @@ -61,8 +61,8 @@ export function getCurrentTimestamp(): number { return Math.floor(Date.now() / 1000); } -// BFV parameter set matching the Rust SET_2048_1032193_1 configuration -export const SET_2048_1032193_1 = { +// BFV parameter set matching the Rust INSECURE_SET_2048_1032193_1 configuration +export const INSECURE_SET_2048_1032193_1 = { degree: 2048, plaintext_modulus: 1032193, moduli: [0x3fffffff000001n], // BigInt for the modulus @@ -84,7 +84,7 @@ export const SET_8192_1000_4 = { }; // Set default parameter set -export const BFV_PARAMS_SET = SET_2048_1032193_1; +export const BFV_PARAMS_SET = INSECURE_SET_2048_1032193_1; // Compute provider parameters structure export interface ComputeProviderParams { diff --git a/templates/default/program/src/lib.rs b/templates/default/program/src/lib.rs index 58a2cdbd1c..ddc2f3b842 100644 --- a/templates/default/program/src/lib.rs +++ b/templates/default/program/src/lib.rs @@ -26,7 +26,9 @@ pub fn fhe_processor(fhe_inputs: &FHEInputs) -> Vec { mod tests { use super::*; use anyhow::Result; - use e3_bfv_helpers::{build_bfv_params_arc, encode_bfv_params, params::SET_2048_1032193_1}; + use e3_bfv_helpers::{ + build_bfv_params_arc, encode_bfv_params, params::INSECURE_SET_2048_1032193_1, + }; use fhe::bfv::{Encoding, Plaintext, PublicKey, SecretKey}; use fhe_traits::FheEncoder; use fhe_traits::FheEncrypter; @@ -37,7 +39,7 @@ mod tests { fn test() -> Result<()> { let mut rng = thread_rng(); - let (degree, plaintext, moduli) = SET_2048_1032193_1; + let (degree, plaintext, moduli) = INSECURE_SET_2048_1032193_1; let params = build_bfv_params_arc(degree, plaintext, &moduli); let secret_key = SecretKey::random(¶ms, &mut OsRng); From 624ba8e6dfb17f4e093d4425b85315c484e9a8c3 Mon Sep 17 00:00:00 2001 From: ryardley Date: Tue, 11 Nov 2025 16:10:49 -0300 Subject: [PATCH 04/22] refactor to an enum --- Cargo.lock | 2 +- Cargo.toml | 3 +- crates/bfv-helpers/Cargo.toml | 2 +- crates/bfv-helpers/src/client.rs | 10 +- crates/bfv-helpers/src/lib.rs | 155 +++++++++++--------- crates/test-helpers/src/bin/fake_encrypt.rs | 5 +- crates/test-helpers/src/lib.rs | 4 +- crates/wasm/src/lib.rs | 7 +- 8 files changed, 102 insertions(+), 86 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c6145c961d..77c34b5209 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2675,8 +2675,8 @@ dependencies = [ "fhe-util", "hex", "num-bigint", - "phf", "rand 0.8.5", + "strum", "thiserror 1.0.69", "zkfhe-greco", ] diff --git a/Cargo.toml b/Cargo.toml index 809cf33eac..dab0929cba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -153,10 +153,11 @@ serde = { version = "=1.0.228", features = ["derive"] } serde-wasm-bindgen = "=0.6.5" serde_json = "=1.0.141" serial_test = "=3.2.0" -sled = "=0.34.7" serde_yaml = "=0.9.34" sha2 = "=0.10.9" shellexpand = "=3.1.1" +sled = "=0.34.7" +strum = "=0.27.2" tempfile = "=3.20.0" thiserror = { version = "=1.0.69" } tokio = { version = "=1.46.1", features = ["full"] } diff --git a/crates/bfv-helpers/Cargo.toml b/crates/bfv-helpers/Cargo.toml index 9406ccc22b..ff4608be0f 100644 --- a/crates/bfv-helpers/Cargo.toml +++ b/crates/bfv-helpers/Cargo.toml @@ -16,7 +16,7 @@ fhe-util = { git = "https://github.com/gnosisguild/fhe.rs" } fhe.workspace = true greco = { package = "zkfhe-greco", git = "https://github.com/gnosisguild/zkfhe-generator" } num-bigint = { workspace = true } -phf.workspace = true +strum.workspace = true rand.workspace = true thiserror = { workspace = true } diff --git a/crates/bfv-helpers/src/client.rs b/crates/bfv-helpers/src/client.rs index 31b817c467..2f7f740572 100644 --- a/crates/bfv-helpers/src/client.rs +++ b/crates/bfv-helpers/src/client.rs @@ -125,7 +125,7 @@ where #[cfg(test)] mod tests { - use crate::params::INSECURE_SET_2048_1032193_1; + use crate::BfvParams; use super::*; @@ -135,7 +135,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = INSECURE_SET_2048_1032193_1; + let param_set = BfvParams::InsecureSet2048_1032193_1.params(); let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; @@ -160,7 +160,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = INSECURE_SET_2048_1032193_1; + let param_set = BfvParams::InsecureSet2048_1032193_1.params(); let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; @@ -192,7 +192,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = INSECURE_SET_2048_1032193_1; + let param_set = BfvParams::InsecureSet2048_1032193_1.params(); let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; @@ -223,7 +223,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = INSECURE_SET_2048_1032193_1; + let param_set = BfvParams::InsecureSet2048_1032193_1.params(); let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; diff --git a/crates/bfv-helpers/src/lib.rs b/crates/bfv-helpers/src/lib.rs index d3d713a6ca..868d7294e3 100644 --- a/crates/bfv-helpers/src/lib.rs +++ b/crates/bfv-helpers/src/lib.rs @@ -11,8 +11,8 @@ use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::U256; use fhe::bfv::{BfvParameters, BfvParametersBuilder, Encoding, Plaintext}; use fhe_traits::FheDecoder; -use phf::phf_map; -use std::sync::Arc; +use std::{ops::Deref, sync::Arc}; +use strum::{EnumIter, EnumString, IntoEnumIterator, IntoStaticStr}; use thiserror::Error as ThisError; #[derive(ThisError, Debug)] @@ -29,85 +29,113 @@ pub enum Error { /// Result that returns a type T or a BfvHelpersError type Result = std::result::Result; +#[derive(Debug, Clone, Copy, EnumString, IntoStaticStr, EnumIter)] +#[strum(serialize_all = "SCREAMING_SNAKE_CASE")] /// Predefined BFV parameters for common use cases -pub mod params { - use super::BfvParamSet; - - /// Note that 10 is the default value for both error1 and error2 variance - /// for both BFV and TRBFV (if not explicitly set). - +/// Note that 10 is the default value for both error1 and error2 variance +/// for both BFV and TRBFV (if not explicitly set). +pub enum BfvParams { /// Standard BFV development parameters set (DO NOT USE IN PRODUCTION). /// - Degree: 2048 (polynomial ring size) /// - Plaintext modulus: 1032193 /// - Moduli: [0x3FFFFFFF000001] (provides good security level) - pub const INSECURE_SET_2048_1032193_1: BfvParamSet = BfvParamSet { - degree: 2048, - plaintext_modulus: 1032193, - moduli: &[0x3FFFFFFF000001], - error2_variance: None, - }; + #[strum(serialize = "INSECURE_SET_2048_1032193_1")] + InsecureSet2048_1032193_1, /// Testing TrBFV development parameters set (DO NOT USE IN PRODUCTION). /// - Degree: 512 /// - Moduli: [0xffffee001, 0xffffc4001] /// - Plaintext modulus: 10 /// - Error2 Variance: 3 - pub const INSECURE_SET_512_10_1: BfvParamSet = BfvParamSet { - degree: 512, - moduli: &[0xffffee001, 0xffffc4001], - plaintext_modulus: 10, - error2_variance: Some("3"), - }; + #[strum(serialize = "INSECURE_SET_512_10_1")] + InsecureSet512_10_1, /// Testing BFV development parameters for share encryption (DO NOT USE IN PRODUCTION). /// - Degree: 512 /// - Moduli: [0x7fffffffe0001] /// - Plaintext modulus: 0xffffee001 /// - Error2 Variance: 3 - pub const INSECURE_SET_512_0XFFFFEE001_1: BfvParamSet = BfvParamSet { - degree: 512, - moduli: &[0x7fffffffe0001], - plaintext_modulus: 0xffffee001, - error2_variance: None, - }; + #[strum(serialize = "INSECURE_SET_512_0XFFFFEE001_1")] + InsecureSet512_0xffffee001_1, /// 128bits security TRBFV parameters set (PRODUCTION READY). /// - Degree: 8192 /// - Plaintext modulus: 1000 /// - Moduli: [0x00800000022a0001, 0x00800000021a0001, 0x0080000002120001, 0x0080000001f60001] /// - Error2 Variance: 52309181128222339698631578526730685514457152477762943514050560000 - pub const SET_8192_1000_4: BfvParamSet = BfvParamSet { - degree: 8192, - plaintext_modulus: 1000, - moduli: &[ - 0x00800000022a0001, - 0x00800000021a0001, - 0x0080000002120001, - 0x0080000001f60001, - ], - error2_variance: Some("52309181128222339698631578526730685514457152477762943514050560000"), - }; + #[strum(serialize = "SET_8192_1000_4")] + Set8192_1000_4, /// 128bits security BFV parameters set (PRODUCTION READY). /// - Degree: 8192 /// - Plaintext modulus: 144115188075855872 /// - Moduli: [288230376173076481, 288230376167047169] - pub const SET_8192_144115188075855872_2: BfvParamSet = BfvParamSet { - degree: 8192, - plaintext_modulus: 144115188075855872, - moduli: &[288230376173076481, 288230376167047169], - error2_variance: None, - }; + #[strum(serialize = "SET_8192_144115188075855872_2")] + Set8192_144115188075855872_2, } // Map for getters -static PARAMS_MAP: phf::Map<&'static str, BfvParamSet> = phf_map! { - "INSECURE_SET_2048_1032193_1" => params::INSECURE_SET_2048_1032193_1, - "INSECURE_SET_512_10_1" => params::INSECURE_SET_512_10_1, - "INSECURE_SET_512_0XFFFFEE001_1" => params::INSECURE_SET_512_0XFFFFEE001_1, - "SET_8192_1000_4" => params::SET_8192_1000_4, - "SET_8192_144115188075855872_2" => params::SET_8192_144115188075855872_2, -}; +impl BfvParams { + /// Get the params for the current variant + pub fn params(self) -> BfvParamSet { + match self { + Self::InsecureSet2048_1032193_1 => BfvParamSet { + degree: 2048, + plaintext_modulus: 1032193, + moduli: &[0x3FFFFFFF000001], + error2_variance: None, + }, + Self::InsecureSet512_10_1 => BfvParamSet { + degree: 512, + moduli: &[0xffffee001, 0xffffc4001], + plaintext_modulus: 10, + error2_variance: Some("3"), + }, + Self::InsecureSet512_0xffffee001_1 => BfvParamSet { + degree: 512, + moduli: &[0x7fffffffe0001], + plaintext_modulus: 0xffffee001, + error2_variance: None, + }, + Self::Set8192_1000_4 => BfvParamSet { + degree: 8192, + plaintext_modulus: 1000, + moduli: &[ + 0x00800000022a0001, + 0x00800000021a0001, + 0x0080000002120001, + 0x0080000001f60001, + ], + error2_variance: Some( + "52309181128222339698631578526730685514457152477762943514050560000", + ), + }, + Self::Set8192_144115188075855872_2 => BfvParamSet { + degree: 8192, + plaintext_modulus: 144115188075855872, + moduli: &[288230376173076481, 288230376167047169], + error2_variance: None, + }, + } + } + + /// Return the given param set based on the input key &str. + pub fn get_params_by_str(key: &str) -> Result { + key.parse::() + .map(|k| k.params()) + .map_err(|_| Error::UnknownParamSet(key.to_string())) + } + + /// List all the available parameter keys + pub fn get_params_list() -> Vec { + BfvParams::iter() + .map(|key| { + let s: &'static str = key.into(); + s.to_string() + }) + .collect() + } +} /// A consistent type representing a BFV parameter set. /// @@ -125,21 +153,6 @@ pub struct BfvParamSet { pub error2_variance: Option<&'static str>, } -impl BfvParamSet { - /// Return the given param set based on the input key - pub fn get_params(key: &str) -> Result { - PARAMS_MAP - .get(key) - .copied() - .ok_or_else(|| Error::UnknownParamSet(key.to_string())) - } - - /// List all the available parameter keys - pub fn get_params_list() -> Vec { - PARAMS_MAP.keys().map(|n| n.to_string()).collect() - } -} - /// Builds BFV parameters from a `BfvParamSet`. /// /// This is a convenience function that consumes a `BfvParamSet` struct @@ -600,7 +613,7 @@ mod tests { #[test] fn test_params_constant() { - let param_set = params::INSECURE_SET_2048_1032193_1; + let param_set = BfvParams::InsecureSet2048_1032193_1.params(); assert_eq!(param_set.degree, 2048); assert_eq!(param_set.plaintext_modulus, 1032193); assert_eq!(param_set.moduli, &[0x3FFFFFFF000001]); @@ -608,7 +621,7 @@ mod tests { #[test] fn test_params_function() { - let param_set = params::INSECURE_SET_2048_1032193_1; + let param_set = BfvParams::InsecureSet2048_1032193_1.params(); let params = build_bfv_params_from_set(param_set); assert_eq!(params.degree(), param_set.degree); @@ -618,7 +631,7 @@ mod tests { #[test] fn test_params_arc_function() { - let param_set = params::INSECURE_SET_2048_1032193_1; + let param_set = BfvParams::InsecureSet2048_1032193_1.params(); let params = build_bfv_params_from_set_arc(param_set); assert_eq!(params.degree(), param_set.degree); @@ -628,7 +641,7 @@ mod tests { #[test] fn test_params_encoding_roundtrip() { - let param_set = params::INSECURE_SET_2048_1032193_1; + let param_set = BfvParams::InsecureSet2048_1032193_1.params(); let params = build_bfv_params_from_set(param_set); let encoded = encode_bfv_params(¶ms); let decoded = decode_bfv_params(&encoded); @@ -642,7 +655,7 @@ mod tests { #[test] fn test_params_arc_encoding_roundtrip() { - let param_set = params::INSECURE_SET_2048_1032193_1; + let param_set = BfvParams::InsecureSet2048_1032193_1.params(); let params = build_bfv_params_from_set_arc(param_set); let encoded = encode_bfv_params(¶ms); let decoded = decode_bfv_params_arc(&encoded); @@ -656,7 +669,7 @@ mod tests { #[test] fn test_params_trbfv_encoding_roundtrip() { - let param_set = params::SET_8192_1000_4; + let param_set = BfvParams::Set8192_1000_4.params(); let params = build_bfv_params_from_set(param_set); let encoded = encode_bfv_params(¶ms); let decoded = decode_bfv_params(&encoded); diff --git a/crates/test-helpers/src/bin/fake_encrypt.rs b/crates/test-helpers/src/bin/fake_encrypt.rs index 87c6459eea..12be4448c3 100644 --- a/crates/test-helpers/src/bin/fake_encrypt.rs +++ b/crates/test-helpers/src/bin/fake_encrypt.rs @@ -6,8 +6,9 @@ // This is a test script designed to encrypt some fixed data to a fhe public key use clap::Parser; +use e3_sdk::bfv_helpers::build_bfv_params_from_set_arc; use e3_sdk::bfv_helpers::decode_bfv_params; -use e3_sdk::bfv_helpers::{build_bfv_params_from_set_arc, params::INSECURE_SET_2048_1032193_1}; +use e3_sdk::bfv_helpers::BfvParams; use fhe::bfv::{Encoding, Plaintext, PublicKey}; use fhe_traits::{DeserializeParametrized, FheEncoder, FheEncrypter, Serialize}; use rand::SeedableRng; @@ -54,7 +55,7 @@ fn main() -> Result<(), Box> { let params = if let Some(params_bytes) = args.params { Arc::new(decode_bfv_params(¶ms_bytes.0)) } else { - build_bfv_params_from_set_arc(INSECURE_SET_2048_1032193_1) + build_bfv_params_from_set_arc(BfvParams::InsecureSet2048_1032193_1.params()) }; let pubkey = PublicKey::from_bytes(&bytes, ¶ms)?; let raw_plaintext = args.plaintext; diff --git a/crates/test-helpers/src/lib.rs b/crates/test-helpers/src/lib.rs index 96aeecc79e..a9e17d2c12 100644 --- a/crates/test-helpers/src/lib.rs +++ b/crates/test-helpers/src/lib.rs @@ -19,7 +19,7 @@ use e3_events::{ }; use e3_fhe::{create_crp, setup_crp_params, ParamsWithCrp}; use e3_net::{DocumentPublisher, NetEventTranslator}; -use e3_sdk::bfv_helpers::{params::INSECURE_SET_2048_1032193_1, BfvParamSet}; +use e3_sdk::bfv_helpers::{BfvParamSet, BfvParams}; use e3_utils::SharedRng; use fhe::bfv::{BfvParameters, Ciphertext, Encoding, Plaintext, PublicKey}; use fhe::mbfv::CommonRandomPoly; @@ -87,7 +87,7 @@ pub fn get_common_setup( let rng = create_shared_rng_from_u64(42); let seed = create_seed_from_u64(123); - let param_set = param_set.unwrap_or(INSECURE_SET_2048_1032193_1); + let param_set = param_set.unwrap_or(BfvParams::InsecureSet2048_1032193_1.params()); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; let moduli = param_set.moduli; diff --git a/crates/wasm/src/lib.rs b/crates/wasm/src/lib.rs index 1ec714adcf..488a50b76c 100644 --- a/crates/wasm/src/lib.rs +++ b/crates/wasm/src/lib.rs @@ -6,7 +6,7 @@ use e3_bfv_helpers::{ client::{bfv_encrypt, bfv_verifiable_encrypt}, - BfvParamSet, + BfvParamSet, BfvParams, }; use serde::{Deserialize, Serialize}; use wasm_bindgen::prelude::*; @@ -163,7 +163,8 @@ pub fn bfv_verifiable_encrypt_vector( /// # Errors /// Returns error if the parameter set name is invalid or serialization fails. pub fn get_bfv_params(name: &str) -> Result { - let params = BfvParamSet::get_params(name).map_err(|e| JsValue::from_str(&e.to_string()))?; + let params = + BfvParams::get_params_by_str(name).map_err(|e| JsValue::from_str(&e.to_string()))?; let js_params = BfvParamSetJs::from(¶ms); serde_wasm_bindgen::to_value(&js_params) .map_err(|e| JsValue::from_str(&format!("Serialization error: {}", e))) @@ -177,7 +178,7 @@ pub fn get_bfv_params(name: &str) -> Result { /// Includes both production-ready sets (e.g., "SET_8192_1000_4") and /// insecure sets for testing (prefixed with "INSECURE_"). pub fn get_bfv_params_list() -> Vec { - BfvParamSet::get_params_list() + BfvParams::get_params_list() } #[derive(Serialize, Deserialize)] From 743eecea2385fbcbf1ab4bf9390c8c9e444204af Mon Sep 17 00:00:00 2001 From: ryardley Date: Tue, 11 Nov 2025 16:19:32 -0300 Subject: [PATCH 05/22] tidy up traits --- crates/bfv-helpers/src/client.rs | 8 +-- crates/bfv-helpers/src/lib.rs | 69 +++++++++++---------- crates/test-helpers/src/bin/fake_encrypt.rs | 2 +- crates/test-helpers/src/lib.rs | 2 +- 4 files changed, 43 insertions(+), 38 deletions(-) diff --git a/crates/bfv-helpers/src/client.rs b/crates/bfv-helpers/src/client.rs index 2f7f740572..fbda448154 100644 --- a/crates/bfv-helpers/src/client.rs +++ b/crates/bfv-helpers/src/client.rs @@ -135,7 +135,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = BfvParams::InsecureSet2048_1032193_1.params(); + let param_set = BfvParams::InsecureSet2048_1032193_1.into(); let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; @@ -160,7 +160,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = BfvParams::InsecureSet2048_1032193_1.params(); + let param_set = BfvParams::InsecureSet2048_1032193_1.into(); let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; @@ -192,7 +192,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = BfvParams::InsecureSet2048_1032193_1.params(); + let param_set = BfvParams::InsecureSet2048_1032193_1.into(); let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; @@ -223,7 +223,7 @@ mod tests { use fhe::bfv::{Ciphertext, PublicKey, SecretKey}; use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize}; - let param_set = BfvParams::InsecureSet2048_1032193_1.params(); + let param_set = BfvParams::InsecureSet2048_1032193_1.into(); let params = build_bfv_params_from_set_arc(param_set); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; diff --git a/crates/bfv-helpers/src/lib.rs b/crates/bfv-helpers/src/lib.rs index 868d7294e3..900e7fec5d 100644 --- a/crates/bfv-helpers/src/lib.rs +++ b/crates/bfv-helpers/src/lib.rs @@ -11,7 +11,7 @@ use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_primitives::U256; use fhe::bfv::{BfvParameters, BfvParametersBuilder, Encoding, Plaintext}; use fhe_traits::FheDecoder; -use std::{ops::Deref, sync::Arc}; +use std::sync::Arc; use strum::{EnumIter, EnumString, IntoEnumIterator, IntoStaticStr}; use thiserror::Error as ThisError; @@ -35,6 +35,8 @@ type Result = std::result::Result; /// Note that 10 is the default value for both error1 and error2 variance /// for both BFV and TRBFV (if not explicitly set). pub enum BfvParams { + // List parameter strings and variants here + // /// Standard BFV development parameters set (DO NOT USE IN PRODUCTION). /// - Degree: 2048 (polynomial ring size) /// - Plaintext modulus: 1032193 @@ -76,28 +78,48 @@ pub enum BfvParams { // Map for getters impl BfvParams { - /// Get the params for the current variant - pub fn params(self) -> BfvParamSet { - match self { - Self::InsecureSet2048_1032193_1 => BfvParamSet { + /// Return the given param set based on the input key &str. + pub fn get_params_by_str(key: &str) -> Result { + key.parse::() + .map(|k| k.into()) + .map_err(|_| Error::UnknownParamSet(key.to_string())) + } + + /// List all the available parameter keys + pub fn get_params_list() -> Vec { + BfvParams::iter() + .map(|key| { + let s: &'static str = key.into(); + s.to_string() + }) + .collect() + } +} + +impl From for BfvParamSet { + fn from(value: BfvParams) -> Self { + use BfvParams as B; + match value { + // List each new parameter set here + B::InsecureSet2048_1032193_1 => BfvParamSet { degree: 2048, plaintext_modulus: 1032193, moduli: &[0x3FFFFFFF000001], error2_variance: None, }, - Self::InsecureSet512_10_1 => BfvParamSet { + B::InsecureSet512_10_1 => BfvParamSet { degree: 512, moduli: &[0xffffee001, 0xffffc4001], plaintext_modulus: 10, error2_variance: Some("3"), }, - Self::InsecureSet512_0xffffee001_1 => BfvParamSet { + B::InsecureSet512_0xffffee001_1 => BfvParamSet { degree: 512, moduli: &[0x7fffffffe0001], plaintext_modulus: 0xffffee001, error2_variance: None, }, - Self::Set8192_1000_4 => BfvParamSet { + B::Set8192_1000_4 => BfvParamSet { degree: 8192, plaintext_modulus: 1000, moduli: &[ @@ -110,7 +132,7 @@ impl BfvParams { "52309181128222339698631578526730685514457152477762943514050560000", ), }, - Self::Set8192_144115188075855872_2 => BfvParamSet { + B::Set8192_144115188075855872_2 => BfvParamSet { degree: 8192, plaintext_modulus: 144115188075855872, moduli: &[288230376173076481, 288230376167047169], @@ -118,23 +140,6 @@ impl BfvParams { }, } } - - /// Return the given param set based on the input key &str. - pub fn get_params_by_str(key: &str) -> Result { - key.parse::() - .map(|k| k.params()) - .map_err(|_| Error::UnknownParamSet(key.to_string())) - } - - /// List all the available parameter keys - pub fn get_params_list() -> Vec { - BfvParams::iter() - .map(|key| { - let s: &'static str = key.into(); - s.to_string() - }) - .collect() - } } /// A consistent type representing a BFV parameter set. @@ -613,7 +618,7 @@ mod tests { #[test] fn test_params_constant() { - let param_set = BfvParams::InsecureSet2048_1032193_1.params(); + let param_set: BfvParamSet = BfvParams::InsecureSet2048_1032193_1.into(); assert_eq!(param_set.degree, 2048); assert_eq!(param_set.plaintext_modulus, 1032193); assert_eq!(param_set.moduli, &[0x3FFFFFFF000001]); @@ -621,7 +626,7 @@ mod tests { #[test] fn test_params_function() { - let param_set = BfvParams::InsecureSet2048_1032193_1.params(); + let param_set = BfvParams::InsecureSet2048_1032193_1.into(); let params = build_bfv_params_from_set(param_set); assert_eq!(params.degree(), param_set.degree); @@ -631,7 +636,7 @@ mod tests { #[test] fn test_params_arc_function() { - let param_set = BfvParams::InsecureSet2048_1032193_1.params(); + let param_set = BfvParams::InsecureSet2048_1032193_1.into(); let params = build_bfv_params_from_set_arc(param_set); assert_eq!(params.degree(), param_set.degree); @@ -641,7 +646,7 @@ mod tests { #[test] fn test_params_encoding_roundtrip() { - let param_set = BfvParams::InsecureSet2048_1032193_1.params(); + let param_set = BfvParams::InsecureSet2048_1032193_1.into(); let params = build_bfv_params_from_set(param_set); let encoded = encode_bfv_params(¶ms); let decoded = decode_bfv_params(&encoded); @@ -655,7 +660,7 @@ mod tests { #[test] fn test_params_arc_encoding_roundtrip() { - let param_set = BfvParams::InsecureSet2048_1032193_1.params(); + let param_set = BfvParams::InsecureSet2048_1032193_1.into(); let params = build_bfv_params_from_set_arc(param_set); let encoded = encode_bfv_params(¶ms); let decoded = decode_bfv_params_arc(&encoded); @@ -669,7 +674,7 @@ mod tests { #[test] fn test_params_trbfv_encoding_roundtrip() { - let param_set = BfvParams::Set8192_1000_4.params(); + let param_set = BfvParams::Set8192_1000_4.into(); let params = build_bfv_params_from_set(param_set); let encoded = encode_bfv_params(¶ms); let decoded = decode_bfv_params(&encoded); diff --git a/crates/test-helpers/src/bin/fake_encrypt.rs b/crates/test-helpers/src/bin/fake_encrypt.rs index 12be4448c3..ab5d84d044 100644 --- a/crates/test-helpers/src/bin/fake_encrypt.rs +++ b/crates/test-helpers/src/bin/fake_encrypt.rs @@ -55,7 +55,7 @@ fn main() -> Result<(), Box> { let params = if let Some(params_bytes) = args.params { Arc::new(decode_bfv_params(¶ms_bytes.0)) } else { - build_bfv_params_from_set_arc(BfvParams::InsecureSet2048_1032193_1.params()) + build_bfv_params_from_set_arc(BfvParams::InsecureSet2048_1032193_1.into()) }; let pubkey = PublicKey::from_bytes(&bytes, ¶ms)?; let raw_plaintext = args.plaintext; diff --git a/crates/test-helpers/src/lib.rs b/crates/test-helpers/src/lib.rs index a9e17d2c12..07d8456e81 100644 --- a/crates/test-helpers/src/lib.rs +++ b/crates/test-helpers/src/lib.rs @@ -87,7 +87,7 @@ pub fn get_common_setup( let rng = create_shared_rng_from_u64(42); let seed = create_seed_from_u64(123); - let param_set = param_set.unwrap_or(BfvParams::InsecureSet2048_1032193_1.params()); + let param_set = param_set.unwrap_or(BfvParams::InsecureSet2048_1032193_1.into()); let degree = param_set.degree; let plaintext_modulus = param_set.plaintext_modulus; let moduli = param_set.moduli; From 7a9d8a1e159ad3a272e9e86329a4997570cd1180 Mon Sep 17 00:00:00 2001 From: ryardley Date: Tue, 11 Nov 2025 16:42:36 -0300 Subject: [PATCH 06/22] use correct feature --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index dab0929cba..3b6b34e632 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -157,7 +157,7 @@ serde_yaml = "=0.9.34" sha2 = "=0.10.9" shellexpand = "=3.1.1" sled = "=0.34.7" -strum = "=0.27.2" +strum = { version = "=0.27.2", features = ["derive"] } tempfile = "=3.20.0" thiserror = { version = "=1.0.69" } tokio = { version = "=1.46.1", features = ["full"] } From 16d3be63e8373b27e6101a0cc09c7cafc5c47263 Mon Sep 17 00:00:00 2001 From: ryardley Date: Tue, 11 Nov 2025 18:01:50 -0300 Subject: [PATCH 07/22] update params --- examples/CRISP/Cargo.lock | 50 +------------------ examples/CRISP/server/src/cli/commands.rs | 7 ++- .../CRISP/server/src/server/routes/rounds.rs | 8 +-- 3 files changed, 8 insertions(+), 57 deletions(-) diff --git a/examples/CRISP/Cargo.lock b/examples/CRISP/Cargo.lock index 6f5539c401..ba3ae9d18e 100644 --- a/examples/CRISP/Cargo.lock +++ b/examples/CRISP/Cargo.lock @@ -2256,8 +2256,8 @@ dependencies = [ "fhe-traits", "fhe-util", "num-bigint", - "phf", "rand 0.8.5", + "strum", "thiserror 1.0.69", "zkfhe-greco", ] @@ -4117,48 +4117,6 @@ dependencies = [ "rustc_version 0.4.1", ] -[[package]] -name = "phf" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" -dependencies = [ - "phf_macros", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" -dependencies = [ - "phf_shared", - "rand 0.8.5", -] - -[[package]] -name = "phf_macros" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" -dependencies = [ - "phf_generator", - "phf_shared", - "proc-macro2 1.0.103", - "quote 1.0.42", - "syn 2.0.109", -] - -[[package]] -name = "phf_shared" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" -dependencies = [ - "siphasher", -] - [[package]] name = "pin-project" version = "1.1.10" @@ -5236,12 +5194,6 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" -[[package]] -name = "siphasher" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" - [[package]] name = "slab" version = "0.4.11" diff --git a/examples/CRISP/server/src/cli/commands.rs b/examples/CRISP/server/src/cli/commands.rs index e79c6245ad..5b509d033f 100644 --- a/examples/CRISP/server/src/cli/commands.rs +++ b/examples/CRISP/server/src/cli/commands.rs @@ -5,6 +5,7 @@ // or FITNESS FOR A PARTICULAR PURPOSE. use dialoguer::{theme::ColorfulTheme, FuzzySelect, Input}; +use e3_sdk::bfv_helpers::BfvParams; use log::info; use num_bigint::BigUint; use reqwest::Client; @@ -15,9 +16,7 @@ use super::CLI_DB; use alloy::primitives::{Address, Bytes, U256}; use alloy::providers::{Provider, ProviderBuilder}; use crisp::config::CONFIG; -use e3_sdk::bfv_helpers::{ - build_bfv_params_from_set_arc, encode_bfv_params, params::INSECURE_SET_2048_1032193_1, -}; +use e3_sdk::bfv_helpers::{build_bfv_params_from_set_arc, encode_bfv_params}; use e3_sdk::evm_helpers::contracts::{EnclaveContract, EnclaveRead, EnclaveWrite, E3}; use fhe::bfv::{BfvParameters, Ciphertext, Encoding, Plaintext, PublicKey, SecretKey}; use fhe_traits::{ @@ -329,7 +328,7 @@ pub async fn decrypt_and_publish_result( } fn generate_bfv_parameters() -> Arc { - build_bfv_params_from_set_arc(INSECURE_SET_2048_1032193_1) + build_bfv_params_from_set_arc(BfvParams::InsecureSet2048_1032193_1.into()) } fn generate_keys(params: &Arc) -> (SecretKey, PublicKey) { diff --git a/examples/CRISP/server/src/server/routes/rounds.rs b/examples/CRISP/server/src/server/routes/rounds.rs index db51867719..9bea7d8d1f 100644 --- a/examples/CRISP/server/src/server/routes/rounds.rs +++ b/examples/CRISP/server/src/server/routes/rounds.rs @@ -13,9 +13,7 @@ use crate::server::models::{ use actix_web::{web, HttpResponse, Responder}; use alloy::primitives::{Address, Bytes, U256}; use chrono::Utc; -use e3_sdk::bfv_helpers::{ - build_bfv_params_from_set_arc, encode_bfv_params, params::INSECURE_SET_2048_1032193_1, -}; +use e3_sdk::bfv_helpers::{build_bfv_params_from_set_arc, encode_bfv_params, BfvParams}; use e3_sdk::evm_helpers::contracts::{EnclaveContract, EnclaveRead, EnclaveWrite}; use log::{error, info}; use num_bigint::BigUint; @@ -181,7 +179,9 @@ pub async fn initialize_crisp_round( } info!("Generating parameters..."); - let params = encode_bfv_params(&build_bfv_params_from_set_arc(INSECURE_SET_2048_1032193_1)); + let params = encode_bfv_params(&build_bfv_params_from_set_arc( + BfvParams::InsecureSet2048_1032193_1.into(), + )); let token_address: Address = token_address.parse()?; let balance_threshold = BigUint::parse_bytes(balance_threshold.as_bytes(), 10) From 9671c764b134b1996f7f5858b5899336c0fffdcb Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 11:12:59 -0300 Subject: [PATCH 08/22] error2 -> error1 --- Cargo.lock | 160 +++++++++--------- crates/bfv-helpers/Cargo.toml | 2 +- crates/bfv-helpers/src/lib.rs | 114 ++++++------- crates/test-helpers/src/bin/pack_e3_params.rs | 6 +- crates/wasm/src/lib.rs | 6 +- packages/enclave-sdk/src/utils.ts | 10 +- templates/default/program/Cargo.toml | 4 +- 7 files changed, 151 insertions(+), 151 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 77c34b5209..c0561c7e13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -207,7 +207,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -218,7 +218,7 @@ checksum = "b6ac1e58cded18cb28ddc17143c4dea5345b3ad575e14f32f66e4054a56eb271" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -731,7 +731,7 @@ checksum = "64b728d511962dda67c1bc7ea7c03736ec275ed2cf4c35d9585298ac9ccf3b73" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -929,7 +929,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -946,7 +946,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "syn-solidity", "tiny-keccak", ] @@ -965,7 +965,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.109", + "syn 2.0.110", "syn-solidity", ] @@ -1093,7 +1093,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1292,7 +1292,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" dependencies = [ "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1330,7 +1330,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1460,7 +1460,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "synstructure", ] @@ -1472,7 +1472,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1574,7 +1574,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1623,7 +1623,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1640,7 +1640,7 @@ checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1701,7 +1701,7 @@ checksum = "ffdcb70bdbc4d478427380519163274ac86e52916e10f0a8889adf0f96d3fee7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2078,7 +2078,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2357,7 +2357,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2382,7 +2382,7 @@ dependencies = [ "quote", "serde", "strsim", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2393,7 +2393,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2433,7 +2433,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d162beedaa69905488a8da94f5ac3edb4dd4788b732fadb7bd120b2625c1976" dependencies = [ "data-encoding", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2498,7 +2498,7 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "unicode-xid", ] @@ -2595,7 +2595,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2968,7 +2968,7 @@ dependencies = [ "async-trait", "e3-fs", "git2", - "indicatif 0.18.2", + "indicatif 0.18.3", "regex", "serde", "serde_json", @@ -3303,7 +3303,7 @@ dependencies = [ "enum-ordinalize", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -3376,7 +3376,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -3396,7 +3396,7 @@ checksum = "8ca9601fb2d62598ee17836250842873a413586e5d7ed88b356e38ddbb0ec631" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -3499,7 +3499,7 @@ dependencies = [ [[package]] name = "fhe" version = "0.1.0-beta.7" -source = "git+https://github.com/gnosisguild/fhe.rs#837be950a453ffce5bbf35823344f08a65edb0ce" +source = "git+https://github.com/gnosisguild/fhe.rs#7692b954ce887ee78f0b6baae36447ca1aa74708" dependencies = [ "doc-comment", "fhe-math", @@ -3524,7 +3524,7 @@ dependencies = [ [[package]] name = "fhe-math" version = "0.1.0-beta.7" -source = "git+https://github.com/gnosisguild/fhe.rs#837be950a453ffce5bbf35823344f08a65edb0ce" +source = "git+https://github.com/gnosisguild/fhe.rs#7692b954ce887ee78f0b6baae36447ca1aa74708" dependencies = [ "ethnum", "fhe-traits", @@ -3546,7 +3546,7 @@ dependencies = [ [[package]] name = "fhe-traits" version = "0.1.0-beta.7" -source = "git+https://github.com/gnosisguild/fhe.rs#837be950a453ffce5bbf35823344f08a65edb0ce" +source = "git+https://github.com/gnosisguild/fhe.rs#7692b954ce887ee78f0b6baae36447ca1aa74708" dependencies = [ "rand 0.8.5", ] @@ -3554,7 +3554,7 @@ dependencies = [ [[package]] name = "fhe-util" version = "0.1.0-beta.7" -source = "git+https://github.com/gnosisguild/fhe.rs#837be950a453ffce5bbf35823344f08a65edb0ce" +source = "git+https://github.com/gnosisguild/fhe.rs#7692b954ce887ee78f0b6baae36447ca1aa74708" dependencies = [ "itertools 0.12.1", "num-bigint-dig", @@ -3764,7 +3764,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4206,9 +4206,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" +checksum = "1744436df46f0bde35af3eda22aeaba453aada65d8f1c171cd8a5f59030bd69f" dependencies = [ "atomic-waker", "bytes", @@ -4233,7 +4233,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" dependencies = [ "http 1.3.1", - "hyper 1.7.0", + "hyper 1.8.0", "hyper-util", "rustls", "rustls-pki-types", @@ -4249,7 +4249,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ - "hyper 1.7.0", + "hyper 1.8.0", "hyper-util", "pin-project-lite", "tokio", @@ -4264,7 +4264,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.7.0", + "hyper 1.8.0", "hyper-util", "native-tls", "tokio", @@ -4285,7 +4285,7 @@ dependencies = [ "futures-util", "http 1.3.1", "http-body 1.0.1", - "hyper 1.7.0", + "hyper 1.8.0", "ipnet", "libc", "percent-encoding", @@ -4505,7 +4505,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4552,9 +4552,9 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade6dfcba0dfb62ad59e59e7241ec8912af34fd29e0e743e3db992bd278e8b65" +checksum = "9375e112e4b463ec1b1c6c011953545c65a30164fbab5b581df32b3abf0dcb88" dependencies = [ "console 0.16.1", "portable-atomic", @@ -5111,7 +5111,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5309,7 +5309,7 @@ checksum = "1b27834086c65ec3f9387b096d66e99f221cf081c2b738042aa252bcd41204e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5695,7 +5695,7 @@ checksum = "ff32365de1b6743cb203b710788263c44a03de03802daf96092f2da4fe6ba4d7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5777,7 +5777,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5935,7 +5935,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6105,7 +6105,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6134,7 +6134,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6239,7 +6239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6292,7 +6292,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6324,7 +6324,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6383,7 +6383,7 @@ dependencies = [ "prost 0.12.6", "prost-types", "regex", - "syn 2.0.109", + "syn 2.0.110", "tempfile", ] @@ -6397,7 +6397,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6410,7 +6410,7 @@ dependencies = [ "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6709,7 +6709,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6778,7 +6778,7 @@ dependencies = [ "http 1.3.1", "http-body 1.0.1", "http-body-util", - "hyper 1.7.0", + "hyper 1.8.0", "hyper-rustls", "hyper-tls", "hyper-util", @@ -7234,7 +7234,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7299,7 +7299,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7347,7 +7347,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7600,7 +7600,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7622,9 +7622,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.109" +version = "2.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f17c7e013e88258aa9543dcbe81aca68a667a9ac37cd69c9fbc07858bfe0e2f" +checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" dependencies = [ "proc-macro2", "quote", @@ -7640,7 +7640,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7660,7 +7660,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7740,7 +7740,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7751,7 +7751,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -7865,7 +7865,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -8012,7 +8012,7 @@ dependencies = [ "http 1.3.1", "http-body 1.0.1", "http-body-util", - "hyper 1.7.0", + "hyper 1.8.0", "hyper-timeout", "hyper-util", "percent-encoding", @@ -8111,7 +8111,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -8190,7 +8190,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -8471,7 +8471,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "wasm-bindgen-shared", ] @@ -8605,7 +8605,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -8616,7 +8616,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -9047,7 +9047,7 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "synstructure", ] @@ -9068,7 +9068,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -9088,7 +9088,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", "synstructure", ] @@ -9109,7 +9109,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -9142,13 +9142,13 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] name = "zkfhe-greco" version = "0.1.0" -source = "git+https://github.com/gnosisguild/zkfhe-generator#1bb8019b8d9944ebf2fd293ec15d6cabc4e37da0" +source = "git+https://github.com/gnosisguild/zkfhe-generator?branch=fix%2Ferrors#fe97fa569c811b9b6a0b42903513de774ccbd97a" dependencies = [ "anyhow", "bigint-poly", @@ -9171,7 +9171,7 @@ dependencies = [ [[package]] name = "zkfhe-shared" version = "0.1.0" -source = "git+https://github.com/gnosisguild/zkfhe-generator#1bb8019b8d9944ebf2fd293ec15d6cabc4e37da0" +source = "git+https://github.com/gnosisguild/zkfhe-generator?branch=fix%2Ferrors#fe97fa569c811b9b6a0b42903513de774ccbd97a" dependencies = [ "anyhow", "bigint-poly", diff --git a/crates/bfv-helpers/Cargo.toml b/crates/bfv-helpers/Cargo.toml index ff4608be0f..23cd321cdb 100644 --- a/crates/bfv-helpers/Cargo.toml +++ b/crates/bfv-helpers/Cargo.toml @@ -14,7 +14,7 @@ fhe-math = { git = "https://github.com/gnosisguild/fhe.rs" } fhe-traits.workspace = true fhe-util = { git = "https://github.com/gnosisguild/fhe.rs" } fhe.workspace = true -greco = { package = "zkfhe-greco", git = "https://github.com/gnosisguild/zkfhe-generator" } +greco = { package = "zkfhe-greco", git = "https://github.com/gnosisguild/zkfhe-generator", branch="fix/errors" } num-bigint = { workspace = true } strum.workspace = true rand.workspace = true diff --git a/crates/bfv-helpers/src/lib.rs b/crates/bfv-helpers/src/lib.rs index 900e7fec5d..d2df9cbc2b 100644 --- a/crates/bfv-helpers/src/lib.rs +++ b/crates/bfv-helpers/src/lib.rs @@ -105,19 +105,19 @@ impl From for BfvParamSet { degree: 2048, plaintext_modulus: 1032193, moduli: &[0x3FFFFFFF000001], - error2_variance: None, + error1_variance: None, }, B::InsecureSet512_10_1 => BfvParamSet { degree: 512, moduli: &[0xffffee001, 0xffffc4001], plaintext_modulus: 10, - error2_variance: Some("3"), + error1_variance: Some("3"), }, B::InsecureSet512_0xffffee001_1 => BfvParamSet { degree: 512, moduli: &[0x7fffffffe0001], plaintext_modulus: 0xffffee001, - error2_variance: None, + error1_variance: None, }, B::Set8192_1000_4 => BfvParamSet { degree: 8192, @@ -128,7 +128,7 @@ impl From for BfvParamSet { 0x0080000002120001, 0x0080000001f60001, ], - error2_variance: Some( + error1_variance: Some( "52309181128222339698631578526730685514457152477762943514050560000", ), }, @@ -136,7 +136,7 @@ impl From for BfvParamSet { degree: 8192, plaintext_modulus: 144115188075855872, moduli: &[288230376173076481, 288230376167047169], - error2_variance: None, + error1_variance: None, }, } } @@ -155,7 +155,7 @@ pub struct BfvParamSet { /// The moduli for the ciphertext space pub moduli: &'static [u64], /// Optional error2 variance (as decimal string). If None, defaults to "10" - pub error2_variance: Option<&'static str>, + pub error1_variance: Option<&'static str>, } /// Builds BFV parameters from a `BfvParamSet`. @@ -175,7 +175,7 @@ pub fn build_bfv_params_from_set(param_set: BfvParamSet) -> BfvParameters { param_set.degree, param_set.plaintext_modulus, param_set.moduli, - param_set.error2_variance, + param_set.error1_variance, ) } @@ -196,14 +196,14 @@ pub fn build_bfv_params_from_set_arc(param_set: BfvParamSet) -> Arc Arc, + error1_variance: Option<&str>, ) -> BfvParameters { let mut builder = BfvParametersBuilder::new(); builder @@ -232,12 +232,12 @@ pub fn build_bfv_params( .set_plaintext_modulus(plaintext_modulus) .set_moduli(moduli); - if let Some(error2) = error2_variance { + if let Some(error1) = error1_variance { builder - .set_error2_variance_str(error2) - .unwrap_or_else(|e| panic!("Failed to set error2_variance: {}", e)); + .set_error1_variance_str(error1) + .unwrap_or_else(|e| panic!("Failed to set error1_variance: {}", e)); } - // If error2_variance is None, the builder defaults to 10 + // If error1_variance is None, the builder defaults to 10 builder .build() @@ -254,7 +254,7 @@ pub fn build_bfv_params( /// * `degree` - The degree of the polynomial ring, must be a power of 2 /// * `plaintext_modulus` - The modulus for the plaintext space /// * `moduli` - The moduli for the ciphertext space -/// * `error2_variance` - Optional error2 variance (as decimal string). Defaults to "10" if None. +/// * `error1_variance` - Optional error2 variance (as decimal string). Defaults to "10" if None. /// /// # Returns /// @@ -267,7 +267,7 @@ pub fn build_bfv_params_arc( degree: usize, plaintext_modulus: u64, moduli: &[u64], - error2_variance: Option<&str>, + error1_variance: Option<&str>, ) -> Arc { let mut builder = BfvParametersBuilder::new(); builder @@ -275,12 +275,12 @@ pub fn build_bfv_params_arc( .set_plaintext_modulus(plaintext_modulus) .set_moduli(moduli); - if let Some(error2) = error2_variance { + if let Some(error1) = error1_variance { builder - .set_error2_variance_str(error2) - .unwrap_or_else(|e| panic!("Failed to set error2_variance: {}", e)); + .set_error1_variance_str(error1) + .unwrap_or_else(|e| panic!("Failed to set error1_variance: {}", e)); } - // If error2_variance is None, the builder defaults to 10 + // If error1_variance is None, the builder defaults to 10 builder .build_arc() @@ -289,7 +289,7 @@ pub fn build_bfv_params_arc( /// Encodes BFV parameters into ABI-encoded bytes. /// -/// This function converts BFV parameters into a tuple structure of (degree, plaintext_modulus, moduli[], error2_variance) +/// This function converts BFV parameters into a tuple structure of (degree, plaintext_modulus, moduli[], error1_variance) /// and then ABI-encodes the tuple using Solidity ABI format. The resulting bytes can be used /// in smart contracts or for cross-platform serialization. /// # Arguments @@ -310,7 +310,7 @@ pub fn encode_bfv_params(params: &BfvParameters) -> Vec { .map(|val| DynSolValue::Uint(U256::from(*val), 256)) .collect(), ), - DynSolValue::String(params.get_error2_variance().to_string()), + DynSolValue::String(params.get_error1_variance().to_string()), ]); value.abi_encode() } @@ -319,7 +319,7 @@ pub fn encode_bfv_params(params: &BfvParameters) -> Vec { /// /// This function converts ABI-encoded bytes back into BFV parameters. /// The bytes should represent a tuple (uint256, uint256, uint256[], string) containing -/// (degree, plaintext_modulus, moduli[], error2_variance) as produced by `encode_bfv_params`. +/// (degree, plaintext_modulus, moduli[], error1_variance) as produced by `encode_bfv_params`. /// /// # Arguments /// @@ -338,7 +338,7 @@ pub fn decode_bfv_params(bytes: &[u8]) -> BfvParameters { DynSolType::Uint(256), // degree DynSolType::Uint(256), // plaintext_modulus DynSolType::Array(Box::new(DynSolType::Uint(256))), // moduli array - DynSolType::String, // error2_variance (as decimal string) + DynSolType::String, // error1_variance (as decimal string) ]); let decoded = tuple_type @@ -377,18 +377,18 @@ pub fn decode_bfv_params(bytes: &[u8]) -> BfvParameters { _ => panic!("Expected array for moduli"), }; - // Extract error2_variance (fourth element) - let error2_variance: String = match &inner_values[3] { + // Extract error1_variance (fourth element) + let error1_variance: String = match &inner_values[3] { DynSolValue::String(val) => val.clone(), - _ => panic!("Expected string for error2_variance"), + _ => panic!("Expected string for error1_variance"), }; let params = BfvParametersBuilder::new() .set_degree(degree as usize) .set_plaintext_modulus(plaintext) .set_moduli(&moduli) - .set_error2_variance_str(&error2_variance) - .unwrap_or_else(|e| panic!("Failed to set error2_variance: {}", e)) + .set_error1_variance_str(&error1_variance) + .unwrap_or_else(|e| panic!("Failed to set error1_variance: {}", e)) .build() .unwrap_or_else(|e| panic!("Failed to build BFV Parameters: {}", e)); @@ -403,7 +403,7 @@ pub fn decode_bfv_params(bytes: &[u8]) -> BfvParameters { /// This is a convenience function that combines `decode_bfv_params` with `Arc::new` /// to provide thread-safe shared ownership of the decoded parameters. /// The input bytes should represent a tuple (uint256, uint256, uint256[], string) containing -/// (degree, plaintext_modulus, moduli[], error2_variance) in ABI-encoded format. +/// (degree, plaintext_modulus, moduli[], error1_variance) in ABI-encoded format. /// /// # Arguments /// @@ -466,7 +466,7 @@ mod tests { assert_eq!(params.plaintext(), plaintext_modulus); assert_eq!(params.moduli(), moduli); assert_eq!(params.variance(), 10); - assert_eq!(params.get_error2_variance(), &BigUint::from(10u32)); + assert_eq!(params.get_error1_variance(), &BigUint::from(10u32)); } #[test] @@ -480,7 +480,7 @@ mod tests { assert_eq!(params.plaintext(), plaintext_modulus); assert_eq!(params.moduli(), moduli); assert_eq!(params.variance(), 10); - assert_eq!(params.get_error2_variance(), &BigUint::from(10u32)); + assert_eq!(params.get_error1_variance(), &BigUint::from(10u32)); } #[test] @@ -493,16 +493,16 @@ mod tests { 0x0080000002120001, 0x0080000001f60001, ]; - let error2_variance = "52309181128222339698631578526730685514457152477762943514050560000"; + let error1_variance = "52309181128222339698631578526730685514457152477762943514050560000"; - let params = build_bfv_params(degree, plaintext_modulus, &moduli, Some(error2_variance)); + let params = build_bfv_params(degree, plaintext_modulus, &moduli, Some(error1_variance)); assert_eq!(params.degree(), degree); assert_eq!(params.plaintext(), plaintext_modulus); assert_eq!(params.moduli(), moduli); assert_eq!(params.variance(), 10); assert_eq!( - params.get_error2_variance(), - &BigUint::from_str(error2_variance).unwrap() + params.get_error1_variance(), + &BigUint::from_str(error1_variance).unwrap() ); } @@ -516,17 +516,17 @@ mod tests { 0x0080000002120001, 0x0080000001f60001, ]; - let error2_variance = "52309181128222339698631578526730685514457152477762943514050560000"; + let error1_variance = "52309181128222339698631578526730685514457152477762943514050560000"; let params = - build_bfv_params_arc(degree, plaintext_modulus, &moduli, Some(error2_variance)); + build_bfv_params_arc(degree, plaintext_modulus, &moduli, Some(error1_variance)); assert_eq!(params.degree(), degree); assert_eq!(params.plaintext(), plaintext_modulus); assert_eq!(params.moduli(), moduli); assert_eq!(params.variance(), 10); assert_eq!( - params.get_error2_variance(), - &BigUint::from_str(error2_variance).unwrap() + params.get_error1_variance(), + &BigUint::from_str(error1_variance).unwrap() ); } @@ -543,8 +543,8 @@ mod tests { assert_eq!(decoded.degree(), degree); assert_eq!(decoded.plaintext(), plaintext_modulus); assert_eq!(decoded.moduli(), moduli.as_slice()); - // Verify error2_variance is preserved (defaults to 10 for standard BFV) - assert_eq!(decoded.get_error2_variance(), params.get_error2_variance()); + // Verify error1_variance is preserved (defaults to 10 for standard BFV) + assert_eq!(decoded.get_error1_variance(), params.get_error1_variance()); } #[test] @@ -575,8 +575,8 @@ mod tests { assert_eq!(decoded.degree(), degree); assert_eq!(decoded.plaintext(), plaintext_modulus); assert_eq!(decoded.moduli(), moduli.as_slice()); - // Verify error2_variance is preserved - assert_eq!(decoded.get_error2_variance(), params.get_error2_variance()); + // Verify error1_variance is preserved + assert_eq!(decoded.get_error1_variance(), params.get_error1_variance()); } #[test] @@ -589,19 +589,19 @@ mod tests { 0x0080000002120001, 0x0080000001f60001, ]; - let error2_variance = "52309181128222339698631578526730685514457152477762943514050560000"; + let error1_variance = "52309181128222339698631578526730685514457152477762943514050560000"; - let params = build_bfv_params(degree, plaintext_modulus, &moduli, Some(error2_variance)); + let params = build_bfv_params(degree, plaintext_modulus, &moduli, Some(error1_variance)); let encoded = encode_bfv_params(¶ms); let decoded = decode_bfv_params(&encoded); assert_eq!(decoded.degree(), degree); assert_eq!(decoded.plaintext(), plaintext_modulus); assert_eq!(decoded.moduli(), moduli); - // Verify error2_variance is preserved for trBFV + // Verify error1_variance is preserved for trBFV assert_eq!( - decoded.get_error2_variance(), - &BigUint::from_str(error2_variance).unwrap() + decoded.get_error1_variance(), + &BigUint::from_str(error1_variance).unwrap() ); } @@ -654,8 +654,8 @@ mod tests { assert_eq!(decoded.degree(), param_set.degree); assert_eq!(decoded.plaintext(), param_set.plaintext_modulus); assert_eq!(decoded.moduli(), param_set.moduli); - // Verify error2_variance is preserved - assert_eq!(decoded.get_error2_variance(), params.get_error2_variance()); + // Verify error1_variance is preserved + assert_eq!(decoded.get_error1_variance(), params.get_error1_variance()); } #[test] @@ -668,8 +668,8 @@ mod tests { assert_eq!(decoded.degree(), param_set.degree); assert_eq!(decoded.plaintext(), param_set.plaintext_modulus); assert_eq!(decoded.moduli(), param_set.moduli); - // Verify error2_variance is preserved - assert_eq!(decoded.get_error2_variance(), params.get_error2_variance()); + // Verify error1_variance is preserved + assert_eq!(decoded.get_error1_variance(), params.get_error1_variance()); } #[test] @@ -682,10 +682,10 @@ mod tests { assert_eq!(decoded.degree(), param_set.degree); assert_eq!(decoded.plaintext(), param_set.plaintext_modulus); assert_eq!(decoded.moduli(), param_set.moduli); - // Verify error2_variance is preserved for trBFV + // Verify error1_variance is preserved for trBFV assert_eq!( - decoded.get_error2_variance(), - &BigUint::from_str(param_set.error2_variance.unwrap()).unwrap() + decoded.get_error1_variance(), + &BigUint::from_str(param_set.error1_variance.unwrap()).unwrap() ); } } diff --git a/crates/test-helpers/src/bin/pack_e3_params.rs b/crates/test-helpers/src/bin/pack_e3_params.rs index b65da566cd..9b70b14abd 100644 --- a/crates/test-helpers/src/bin/pack_e3_params.rs +++ b/crates/test-helpers/src/bin/pack_e3_params.rs @@ -26,7 +26,7 @@ struct Args { plaintext_modulus: u64, #[arg(short, long = "error2-variance")] - error2_variance: Option, + error1_variance: Option, } fn main() -> Result<(), Box> { @@ -38,12 +38,12 @@ fn main() -> Result<(), Box> { process::exit(1); } - if let Some(error2_variance) = args.error2_variance { + if let Some(error1_variance) = args.error1_variance { params = build_bfv_params_arc( args.degree as usize, args.plaintext_modulus, &args.moduli, - Some(&error2_variance), + Some(&error1_variance), ); } else { params = build_bfv_params_arc( diff --git a/crates/wasm/src/lib.rs b/crates/wasm/src/lib.rs index 488a50b76c..2cce11fa47 100644 --- a/crates/wasm/src/lib.rs +++ b/crates/wasm/src/lib.rs @@ -156,7 +156,7 @@ pub fn bfv_verifiable_encrypt_vector( /// degree: number; // Polynomial degree (e.g., 8192) /// plaintext_modulus: number; // Plaintext modulus value (e.g., 1000) /// moduli: number[]; // Array of moduli -/// error2_variance: string | null; // Error variance as string or null +/// error1_variance: string | null; // Error variance as string or null /// } /// ``` /// @@ -186,7 +186,7 @@ pub struct BfvParamSetJs { pub degree: usize, pub plaintext_modulus: u64, pub moduli: Vec, - pub error2_variance: Option, + pub error1_variance: Option, } impl From<&BfvParamSet> for BfvParamSetJs { @@ -195,7 +195,7 @@ impl From<&BfvParamSet> for BfvParamSetJs { degree: params.degree, plaintext_modulus: params.plaintext_modulus, moduli: params.moduli.to_vec(), - error2_variance: params.error2_variance.map(|s| s.to_string()), + error1_variance: params.error1_variance.map(|s| s.to_string()), } } } diff --git a/packages/enclave-sdk/src/utils.ts b/packages/enclave-sdk/src/utils.ts index f0007e8f47..5ba45fcdbe 100644 --- a/packages/enclave-sdk/src/utils.ts +++ b/packages/enclave-sdk/src/utils.ts @@ -66,7 +66,7 @@ export const INSECURE_SET_2048_1032193_1 = { degree: 2048, plaintext_modulus: 1032193, moduli: [0x3fffffff000001n], // BigInt for the modulus - error2_variance: "10", + error1_variance: "10", } as const; // BFV parameter set matching the Rust SET_8192_1000_4 configuration @@ -79,7 +79,7 @@ export const SET_8192_1000_4 = { 0x0080000002120001n, 0x0080000001f60001n, ], - error2_variance: + error1_variance: "52309181128222339698631578526730685514457152477762943514050560000", }; @@ -117,7 +117,7 @@ export function encodeBfvParams( degree: number = BFV_PARAMS_SET.degree, plaintext_modulus: number = BFV_PARAMS_SET.plaintext_modulus, moduli: readonly bigint[] = BFV_PARAMS_SET.moduli, - error2_variance: string = BFV_PARAMS_SET.error2_variance, + error1_variance: string = BFV_PARAMS_SET.error1_variance, ): `0x${string}` { return encodeAbiParameters( [ @@ -128,7 +128,7 @@ export function encodeBfvParams( { name: "degree", type: "uint256" }, { name: "plaintext_modulus", type: "uint256" }, { name: "moduli", type: "uint256[]" }, - { name: "error2_variance", type: "string" }, + { name: "error1_variance", type: "string" }, ], }, ], @@ -137,7 +137,7 @@ export function encodeBfvParams( degree: BigInt(degree), plaintext_modulus: BigInt(plaintext_modulus), moduli: [...moduli], - error2_variance, + error1_variance, }, ], ); diff --git a/templates/default/program/Cargo.toml b/templates/default/program/Cargo.toml index 04acb15b61..f0bb25f77c 100644 --- a/templates/default/program/Cargo.toml +++ b/templates/default/program/Cargo.toml @@ -6,8 +6,8 @@ edition = "2024" [dependencies] fhe = { workspace = true } fhe-traits = { workspace = true } -e3-compute-provider = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } -e3-bfv-helpers = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } +e3-compute-provider = { path = "../../../crates/compute-provider" } +e3-bfv-helpers = { path = "../../../crates/bfv-helpers" } [dev-dependencies] rand = { workspace = true } From ade34139ff1cf3520c91506f7044650d614a1cdf Mon Sep 17 00:00:00 2001 From: Cedoor Date: Wed, 12 Nov 2025 12:25:28 +0100 Subject: [PATCH 09/22] chore: add static version of sdk in client (#994) --- examples/CRISP/client/package.json | 5 ++--- examples/CRISP/client/vite.config.ts | 10 +--------- pnpm-lock.yaml | 27 +++++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/examples/CRISP/client/package.json b/examples/CRISP/client/package.json index 4e624c5673..d273d47b2e 100644 --- a/examples/CRISP/client/package.json +++ b/examples/CRISP/client/package.json @@ -12,15 +12,14 @@ "cli": "pnpm sh ./scripts/cli.sh", "dev": "vite --no-open --host", "dev-static": "NO_HOT=1 vite --no-open --host", - "build:sdk": "pnpm -C ../packages/crisp-sdk build", - "build": "pnpm build:sdk && tsc && vite build", + "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview", "predeploy": "pnpm run build", "deploy": "gh-pages -d dist" }, "dependencies": { - "@crisp-e3/sdk": "workspace:*", + "@crisp-e3/sdk": "0.2.0-test", "@emotion/babel-plugin": "^11.11.0", "@emotion/react": "^11.11.4", "@phosphor-icons/react": "^2.1.4", diff --git a/examples/CRISP/client/vite.config.ts b/examples/CRISP/client/vite.config.ts index 9d1f5d68fe..9d811d384c 100644 --- a/examples/CRISP/client/vite.config.ts +++ b/examples/CRISP/client/vite.config.ts @@ -23,15 +23,7 @@ export default defineConfig({ }, optimizeDeps: { esbuildOptions: { target: 'esnext' }, - exclude: [ - '@rollup/browser', - '@crisp-e3/zk-inputs', - '@crisp-e3/sdk', - '@noir-lang/noirc_abi', - '@noir-lang/acvm_js', - '@noir-lang/noir_js', - '@aztec/bb.js', - ], + exclude: ['@rollup/browser', '@crisp-e3/zk-inputs', '@noir-lang/noirc_abi', '@noir-lang/acvm_js', '@noir-lang/noir_js', '@aztec/bb.js'], }, resolve: { alias: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c30a3dce9f..dd410e943e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -119,8 +119,8 @@ importers: examples/CRISP/client: dependencies: '@crisp-e3/sdk': - specifier: workspace:* - version: link:../packages/crisp-sdk + specifier: 0.2.0-test + version: 0.2.0-test(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10)(zod@4.1.12) '@emotion/babel-plugin': specifier: ^11.11.0 version: 11.13.5 @@ -1462,6 +1462,12 @@ packages: conventional-commits-parser: optional: true + '@crisp-e3/sdk@0.2.0-test': + resolution: {integrity: sha512-SgpwtV7G2onsf5yyDBrK+uV+PnyRvInR00YlG1rAxL8A6xjNNntTJzzx/92zgg6uWIsKY6c6iHF8EAVGgwqJpw==} + + '@crisp-e3/zk-inputs@0.2.0-test': + resolution: {integrity: sha512-MHJR9roV09I3Oq/MWd7+wQ6Z3sdC9opv/qzXy+kpQ8GSBrXGY0QoujbUG7INmjy5yLBgjebPWkeXhU8WGffXcA==} + '@cspotcode/source-map-support@0.8.1': resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} engines: {node: '>=12'} @@ -10992,6 +10998,23 @@ snapshots: conventional-commits-filter: 5.0.0 conventional-commits-parser: 6.2.1 + '@crisp-e3/sdk@0.2.0-test(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10)(zod@4.1.12)': + dependencies: + '@aztec/bb.js': 0.87.0 + '@crisp-e3/zk-inputs': 0.2.0-test + '@noir-lang/noir_js': 1.0.0-beta.9 + '@zk-kit/lean-imt': 2.2.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) + poseidon-lite: 0.3.0 + viem: 2.38.6(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10)(zod@4.1.12) + transitivePeerDependencies: + - bufferutil + - supports-color + - typescript + - utf-8-validate + - zod + + '@crisp-e3/zk-inputs@0.2.0-test': {} + '@cspotcode/source-map-support@0.8.1': dependencies: '@jridgewell/trace-mapping': 0.3.9 From 7eab944750f12075792e36f6107ebea5e8faf3e2 Mon Sep 17 00:00:00 2001 From: 0xjei Date: Wed, 12 Nov 2025 16:35:53 +0100 Subject: [PATCH 10/22] align to latest greco and generator --- Cargo.lock | 24 +++++++++---------- circuits/crates/libs/greco/src/lib.nr | 14 +++++------ crates/bfv-helpers/Cargo.toml | 2 +- examples/CRISP/circuits/src/main.nr | 4 ++-- .../crates/zk-inputs/src/serialization.rs | 8 +++---- .../CRISP/packages/crisp-sdk/src/types.ts | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c0561c7e13..fc10fc725e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -342,9 +342,9 @@ dependencies = [ [[package]] name = "alloy-chains" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6068f356948cd84b5ad9ac30c50478e433847f14a50714d2b68f15d052724049" +checksum = "bfaa9ea039a6f9304b4a593d780b1f23e1ae183acdee938b11b38795acacc9f1" dependencies = [ "alloy-primitives", "num_enum", @@ -2315,9 +2315,9 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "rand_core 0.6.4", @@ -3842,9 +3842,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.9" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -5193,9 +5193,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.22" +version = "1.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d" +checksum = "15d118bbf3771060e7311cc7bb0545b01d08a8b4a7de949198dec1fa0ca1c0f7" dependencies = [ "cc", "libc", @@ -5597,9 +5597,9 @@ dependencies = [ [[package]] name = "num-bigint-dig" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c79c15c05d4bf82b6f5ef163104cc81a760d8e874d38ac50ab67c8877b647b" +checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" dependencies = [ "lazy_static", "libm", @@ -9148,7 +9148,7 @@ dependencies = [ [[package]] name = "zkfhe-greco" version = "0.1.0" -source = "git+https://github.com/gnosisguild/zkfhe-generator?branch=fix%2Ferrors#fe97fa569c811b9b6a0b42903513de774ccbd97a" +source = "git+https://github.com/gnosisguild/zkfhe-generator#7314bed079b91ea6432864f30b991e4ef724a5c5" dependencies = [ "anyhow", "bigint-poly", @@ -9171,7 +9171,7 @@ dependencies = [ [[package]] name = "zkfhe-shared" version = "0.1.0" -source = "git+https://github.com/gnosisguild/zkfhe-generator?branch=fix%2Ferrors#fe97fa569c811b9b6a0b42903513de774ccbd97a" +source = "git+https://github.com/gnosisguild/zkfhe-generator#7314bed079b91ea6432864f30b991e4ef724a5c5" dependencies = [ "anyhow", "bigint-poly", diff --git a/circuits/crates/libs/greco/src/lib.nr b/circuits/crates/libs/greco/src/lib.nr index 1f2f772f46..2f8974567e 100644 --- a/circuits/crates/libs/greco/src/lib.nr +++ b/circuits/crates/libs/greco/src/lib.nr @@ -189,7 +189,7 @@ pub struct Greco, e0: Polynomial, e1: Polynomial, - e1is: [Polynomial; L], + e0is: [Polynomial; L], k1: Polynomial, r1is: [Polynomial<(2 * N) - 1>; L], r2is: [Polynomial; L], @@ -229,14 +229,14 @@ impl, e0: Polynomial, e1: Polynomial, - e1is: [Polynomial; L], + e0is: [Polynomial; L], k1: Polynomial, r1is: [Polynomial<2 * N - 1>; L], r2is: [Polynomial; L], p1is: [Polynomial<2 * N - 1>; L], p2is: [Polynomial; L], ) -> Greco { - Greco { params, pk0is, pk1is, ct0is, ct1is, u, e0, e1, e1is, k1, r1is, r2is, p1is, p2is } + Greco { params, pk0is, pk1is, ct0is, ct1is, u, e0, e1, e0is, k1, r1is, r2is, p1is, p2is } } /// Flattens all polynomials coefficients into a single array for challenge generation. @@ -399,7 +399,7 @@ impl, e0: Polynomial<2048>, e1: Polynomial<2048>, - e1is: [Polynomial<2048>; 1], + e0is: [Polynomial<2048>; 1], k1: Polynomial<2048>, r1is: [Polynomial<4095>; 1], r2is: [Polynomial<2047>; 1], @@ -81,7 +81,7 @@ fn main( u, e0, e1, - e1is, + e0is, k1, r1is, r2is, diff --git a/examples/CRISP/crates/zk-inputs/src/serialization.rs b/examples/CRISP/crates/zk-inputs/src/serialization.rs index a596de917a..36bd747652 100644 --- a/examples/CRISP/crates/zk-inputs/src/serialization.rs +++ b/examples/CRISP/crates/zk-inputs/src/serialization.rs @@ -36,7 +36,7 @@ pub struct ZKInputs { u: serde_json::Value, e0: serde_json::Value, e1: serde_json::Value, - e1is: Vec, + e0is: Vec, k1: serde_json::Value, } @@ -215,8 +215,8 @@ pub fn construct_inputs( }) }) .collect(), - e1is: vectors_standard - .e1is + e0is: vectors_standard + .e0is .iter() .map(|v| { serde_json::json!({ @@ -316,7 +316,7 @@ mod tests { vec![BigInt::from(33), BigInt::from(34)], vec![BigInt::from(35), BigInt::from(36)], ], - e1is: vec![ + e0is: vec![ vec![BigInt::from(43), BigInt::from(44)], vec![BigInt::from(45), BigInt::from(46)], ], diff --git a/examples/CRISP/packages/crisp-sdk/src/types.ts b/examples/CRISP/packages/crisp-sdk/src/types.ts index d8f31238da..33a85d94e8 100644 --- a/examples/CRISP/packages/crisp-sdk/src/types.ts +++ b/examples/CRISP/packages/crisp-sdk/src/types.ts @@ -153,7 +153,7 @@ export interface CRISPCircuitInputs { u: Polynomial e0: Polynomial e1: Polynomial - e1is: Polynomial[] + e0is: Polynomial[] k1: Polynomial // ECDSA Section. public_key_x: string[] From 700c2d8d720fc9a72b5b9bd1fe024809e2ed601b Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 12:48:16 -0300 Subject: [PATCH 11/22] update Cargo.lock in template but expect failure --- templates/default/Cargo.lock | 330 ++++++++++++++++++++++++++++++++--- 1 file changed, 305 insertions(+), 25 deletions(-) diff --git a/templates/default/Cargo.lock b/templates/default/Cargo.lock index 61c74595fd..1c45270baf 100644 --- a/templates/default/Cargo.lock +++ b/templates/default/Cargo.lock @@ -244,9 +244,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-dyn-abi" -version = "1.3.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f56873f3cac7a2c63d8e98a4314b8311aa96adb1a0f82ae923eb2119809d2c" +checksum = "d9e8a436f0aad7df8bb47f144095fba61202265d9f5f09a70b0e3227881a668e" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -260,9 +260,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "1.3.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125a1c373261b252e53e04d6e92c37d881833afc1315fceab53fd46045695640" +checksum = "459f98c6843f208856f338bfb25e65325467f7aff35dfeb0484d0a76e059134b" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -272,9 +272,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "1.3.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9485c56de23438127a731a6b4c87803d49faf1a7068dcd1d8768aca3a9edb9" +checksum = "3cfebde8c581a5d37b678d0a48a32decb51efd7a63a08ce2517ddec26db705c8" dependencies = [ "alloy-rlp", "bytes", @@ -367,9 +367,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "1.3.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5383d34ea00079e6dd89c652bcbdb764db160cef84e6250926961a0b2295d04" +checksum = "a285b46e3e0c177887028278f04cc8262b76fd3b8e0e20e93cea0a58c35f5ac5" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -377,6 +377,15 @@ dependencies = [ "serde", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.98" @@ -560,6 +569,12 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + [[package]] name = "arrayvec" version = "0.7.6" @@ -622,6 +637,17 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" +[[package]] +name = "bigint-poly" +version = "0.1.0" +source = "git+https://github.com/gnosisguild/bigint-poly#6b992dd81c65cc693b388e37edfd190749bfc3b3" +dependencies = [ + "num-bigint", + "num-traits", + "serde", + "thiserror 1.0.69", +] + [[package]] name = "bit-set" version = "0.8.0" @@ -655,6 +681,19 @@ dependencies = [ "wyz", ] +[[package]] +name = "blake3" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -739,6 +778,20 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" +[[package]] +name = "chrono" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link 0.2.1", +] + [[package]] name = "const-hex" version = "1.15.0" @@ -778,6 +831,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "constant_time_eq" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" + [[package]] name = "cookie" version = "0.16.2" @@ -973,15 +1032,20 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "e3-bfv-helpers" -version = "0.1.0" -source = "git+https://github.com/gnosisguild/enclave?rev=2ca0aa5f47dd962add5d1d0f74900d9bceb957e5#2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" +version = "0.1.5" dependencies = [ "alloy-dyn-abi", "alloy-primitives", "anyhow", "fhe", + "fhe-math", "fhe-traits", + "fhe-util", + "num-bigint", "rand 0.8.5", + "strum", + "thiserror 1.0.69", + "zkfhe-greco", ] [[package]] @@ -1001,6 +1065,22 @@ dependencies = [ "sha3", ] +[[package]] +name = "e3-compute-provider" +version = "0.1.5" +dependencies = [ + "ark-bn254", + "ark-ff 0.4.2", + "hex", + "lean-imt", + "light-poseidon", + "num-bigint", + "num-traits", + "rayon", + "serde", + "sha3", +] + [[package]] name = "e3-program-server" version = "0.1.0" @@ -1008,7 +1088,7 @@ source = "git+https://github.com/gnosisguild/enclave?rev=2ca0aa5f47dd962add5d1d0 dependencies = [ "actix-web", "anyhow", - "e3-compute-provider", + "e3-compute-provider 0.1.0", "hex", "reqwest", "serde", @@ -1021,7 +1101,7 @@ name = "e3-support-scripts-dev" version = "0.1.0" dependencies = [ "anyhow", - "e3-compute-provider", + "e3-compute-provider 0.1.0", "e3-program-server", "e3-user-program", "tokio", @@ -1033,7 +1113,7 @@ version = "0.1.0" dependencies = [ "anyhow", "e3-bfv-helpers", - "e3-compute-provider", + "e3-compute-provider 0.1.5", "fhe", "fhe-traits", "rand 0.8.5", @@ -1100,7 +1180,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1602,6 +1682,30 @@ dependencies = [ "windows-registry", ] +[[package]] +name = "iana-time-zone" +version = "0.1.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "icu_collections" version = "2.0.0" @@ -1791,6 +1895,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.15" @@ -2055,6 +2168,7 @@ dependencies = [ "num-integer", "num-traits", "rand 0.8.5", + "serde", ] [[package]] @@ -2800,7 +2914,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2938,18 +3052,28 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -2968,6 +3092,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3107,6 +3240,27 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strum" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "subtle" version = "2.6.1" @@ -3204,7 +3358,7 @@ dependencies = [ "getrandom 0.3.3", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3360,11 +3514,26 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + [[package]] name = "toml_datetime" version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -3373,10 +3542,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap", + "serde", + "serde_spanned", "toml_datetime", + "toml_write", "winnow", ] +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + [[package]] name = "tower" version = "0.5.2" @@ -3659,21 +3837,62 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "windows-link" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-registry" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" dependencies = [ - "windows-link", - "windows-result", - "windows-strings", + "windows-link 0.1.3", + "windows-result 0.3.4", + "windows-strings 0.4.2", ] [[package]] @@ -3682,7 +3901,16 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" dependencies = [ - "windows-link", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link 0.2.1", ] [[package]] @@ -3691,7 +3919,16 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" dependencies = [ - "windows-link", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link 0.2.1", ] [[package]] @@ -3924,6 +4161,49 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "zkfhe-greco" +version = "0.1.0" +source = "git+https://github.com/gnosisguild/zkfhe-generator#7314bed079b91ea6432864f30b991e4ef724a5c5" +dependencies = [ + "anyhow", + "bigint-poly", + "blake3", + "fhe", + "fhe-math", + "fhe-traits", + "itertools 0.14.0", + "num-bigint", + "num-traits", + "rand 0.8.5", + "rayon", + "serde", + "serde_json", + "tempfile", + "toml", + "zkfhe-shared", +] + +[[package]] +name = "zkfhe-shared" +version = "0.1.0" +source = "git+https://github.com/gnosisguild/zkfhe-generator#7314bed079b91ea6432864f30b991e4ef724a5c5" +dependencies = [ + "anyhow", + "bigint-poly", + "chrono", + "fhe", + "fhe-math", + "fhe-traits", + "num-bigint", + "num-traits", + "rand 0.8.5", + "serde", + "serde_json", + "thiserror 1.0.69", + "toml", +] + [[package]] name = "zstd" version = "0.13.3" From a2ad2388734e20dd2208d73ebe0872822e5afb65 Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 13:01:59 -0300 Subject: [PATCH 12/22] make template driven from template workspace --- crates/support-scripts/dev/Cargo.toml | 4 +- .../IBondingRegistry.json | 2 +- .../ICiphernodeRegistry.json | 2 +- .../interfaces/IEnclave.sol/IEnclave.json | 2 +- templates/default/Cargo.lock | 290 +----------------- templates/default/Cargo.toml | 4 + templates/default/program/Cargo.toml | 4 +- 7 files changed, 21 insertions(+), 287 deletions(-) diff --git a/crates/support-scripts/dev/Cargo.toml b/crates/support-scripts/dev/Cargo.toml index 7e5be10c38..3b5b9ae35d 100644 --- a/crates/support-scripts/dev/Cargo.toml +++ b/crates/support-scripts/dev/Cargo.toml @@ -8,8 +8,8 @@ name = "e3-support-scripts-dev" path = "src/main.rs" [dependencies] -e3-program-server = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } -e3-compute-provider = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } +e3-program-server = { workspace = true } +e3-compute-provider = { workspace = true } tokio = { version = "1.38", features = ["full"] } anyhow = "1.0.86" e3-user-program = { path = "../../../program" } diff --git a/packages/enclave-contracts/artifacts/contracts/interfaces/IBondingRegistry.sol/IBondingRegistry.json b/packages/enclave-contracts/artifacts/contracts/interfaces/IBondingRegistry.sol/IBondingRegistry.json index 0340498dd2..fad57ed6bf 100644 --- a/packages/enclave-contracts/artifacts/contracts/interfaces/IBondingRegistry.sol/IBondingRegistry.json +++ b/packages/enclave-contracts/artifacts/contracts/interfaces/IBondingRegistry.sol/IBondingRegistry.json @@ -851,5 +851,5 @@ "deployedLinkReferences": {}, "immutableReferences": {}, "inputSourceName": "project/contracts/interfaces/IBondingRegistry.sol", - "buildInfoId": "solc-0_8_28-c47ee779175143051b923f87373a821faabf4e01" + "buildInfoId": "solc-0_8_28-47e0db0804e3f0de0bf2198d3ad75eb1054de690" } \ No newline at end of file diff --git a/packages/enclave-contracts/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/ICiphernodeRegistry.json b/packages/enclave-contracts/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/ICiphernodeRegistry.json index 99f471a58b..80bb8bea50 100644 --- a/packages/enclave-contracts/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/ICiphernodeRegistry.json +++ b/packages/enclave-contracts/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/ICiphernodeRegistry.json @@ -535,5 +535,5 @@ "deployedLinkReferences": {}, "immutableReferences": {}, "inputSourceName": "project/contracts/interfaces/ICiphernodeRegistry.sol", - "buildInfoId": "solc-0_8_28-c47ee779175143051b923f87373a821faabf4e01" + "buildInfoId": "solc-0_8_28-47e0db0804e3f0de0bf2198d3ad75eb1054de690" } \ No newline at end of file diff --git a/packages/enclave-contracts/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.json b/packages/enclave-contracts/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.json index f7286213f5..356cd34911 100644 --- a/packages/enclave-contracts/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.json +++ b/packages/enclave-contracts/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.json @@ -977,5 +977,5 @@ "deployedLinkReferences": {}, "immutableReferences": {}, "inputSourceName": "project/contracts/interfaces/IEnclave.sol", - "buildInfoId": "solc-0_8_28-c47ee779175143051b923f87373a821faabf4e01" + "buildInfoId": "solc-0_8_28-47e0db0804e3f0de0bf2198d3ad75eb1054de690" } \ No newline at end of file diff --git a/templates/default/Cargo.lock b/templates/default/Cargo.lock index 1c45270baf..8d8e0e7f04 100644 --- a/templates/default/Cargo.lock +++ b/templates/default/Cargo.lock @@ -377,15 +377,6 @@ dependencies = [ "serde", ] -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "anyhow" version = "1.0.98" @@ -569,12 +560,6 @@ dependencies = [ "rand 0.8.5", ] -[[package]] -name = "arrayref" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" - [[package]] name = "arrayvec" version = "0.7.6" @@ -637,17 +622,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" -[[package]] -name = "bigint-poly" -version = "0.1.0" -source = "git+https://github.com/gnosisguild/bigint-poly#6b992dd81c65cc693b388e37edfd190749bfc3b3" -dependencies = [ - "num-bigint", - "num-traits", - "serde", - "thiserror 1.0.69", -] - [[package]] name = "bit-set" version = "0.8.0" @@ -681,19 +655,6 @@ dependencies = [ "wyz", ] -[[package]] -name = "blake3" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -778,20 +739,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" -[[package]] -name = "chrono" -version = "0.4.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-traits", - "serde", - "wasm-bindgen", - "windows-link 0.2.1", -] - [[package]] name = "const-hex" version = "1.15.0" @@ -831,12 +778,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "constant_time_eq" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" - [[package]] name = "cookie" version = "0.16.2" @@ -1032,20 +973,15 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "e3-bfv-helpers" -version = "0.1.5" +version = "0.1.0" +source = "git+https://github.com/gnosisguild/enclave?rev=2ca0aa5f47dd962add5d1d0f74900d9bceb957e5#2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" dependencies = [ "alloy-dyn-abi", "alloy-primitives", "anyhow", "fhe", - "fhe-math", "fhe-traits", - "fhe-util", - "num-bigint", "rand 0.8.5", - "strum", - "thiserror 1.0.69", - "zkfhe-greco", ] [[package]] @@ -1065,22 +1001,6 @@ dependencies = [ "sha3", ] -[[package]] -name = "e3-compute-provider" -version = "0.1.5" -dependencies = [ - "ark-bn254", - "ark-ff 0.4.2", - "hex", - "lean-imt", - "light-poseidon", - "num-bigint", - "num-traits", - "rayon", - "serde", - "sha3", -] - [[package]] name = "e3-program-server" version = "0.1.0" @@ -1088,7 +1008,7 @@ source = "git+https://github.com/gnosisguild/enclave?rev=2ca0aa5f47dd962add5d1d0 dependencies = [ "actix-web", "anyhow", - "e3-compute-provider 0.1.0", + "e3-compute-provider", "hex", "reqwest", "serde", @@ -1101,7 +1021,7 @@ name = "e3-support-scripts-dev" version = "0.1.0" dependencies = [ "anyhow", - "e3-compute-provider 0.1.0", + "e3-compute-provider", "e3-program-server", "e3-user-program", "tokio", @@ -1113,7 +1033,7 @@ version = "0.1.0" dependencies = [ "anyhow", "e3-bfv-helpers", - "e3-compute-provider 0.1.5", + "e3-compute-provider", "fhe", "fhe-traits", "rand 0.8.5", @@ -1682,30 +1602,6 @@ dependencies = [ "windows-registry", ] -[[package]] -name = "iana-time-zone" -version = "0.1.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "log", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - [[package]] name = "icu_collections" version = "2.0.0" @@ -1895,15 +1791,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.15" @@ -2168,7 +2055,6 @@ dependencies = [ "num-integer", "num-traits", "rand 0.8.5", - "serde", ] [[package]] @@ -3092,15 +2978,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_spanned" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" -dependencies = [ - "serde", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3240,27 +3117,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strum" -version = "0.27.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.27.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.106", -] - [[package]] name = "subtle" version = "2.6.1" @@ -3514,26 +3370,11 @@ dependencies = [ "tokio", ] -[[package]] -name = "toml" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - [[package]] name = "toml_datetime" version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" -dependencies = [ - "serde", -] [[package]] name = "toml_edit" @@ -3542,19 +3383,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap", - "serde", - "serde_spanned", "toml_datetime", - "toml_write", "winnow", ] -[[package]] -name = "toml_write" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" - [[package]] name = "tower" version = "0.5.2" @@ -3837,62 +3669,21 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "windows-core" -version = "0.62.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-link 0.2.1", - "windows-result 0.4.1", - "windows-strings 0.5.1", -] - -[[package]] -name = "windows-implement" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", -] - -[[package]] -name = "windows-interface" -version = "0.59.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", -] - [[package]] name = "windows-link" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" -[[package]] -name = "windows-link" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" - [[package]] name = "windows-registry" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" dependencies = [ - "windows-link 0.1.3", - "windows-result 0.3.4", - "windows-strings 0.4.2", + "windows-link", + "windows-result", + "windows-strings", ] [[package]] @@ -3901,16 +3692,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" dependencies = [ - "windows-link 0.1.3", -] - -[[package]] -name = "windows-result" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" -dependencies = [ - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -3919,16 +3701,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" dependencies = [ - "windows-link 0.1.3", -] - -[[package]] -name = "windows-strings" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" -dependencies = [ - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -4161,49 +3934,6 @@ dependencies = [ "syn 2.0.106", ] -[[package]] -name = "zkfhe-greco" -version = "0.1.0" -source = "git+https://github.com/gnosisguild/zkfhe-generator#7314bed079b91ea6432864f30b991e4ef724a5c5" -dependencies = [ - "anyhow", - "bigint-poly", - "blake3", - "fhe", - "fhe-math", - "fhe-traits", - "itertools 0.14.0", - "num-bigint", - "num-traits", - "rand 0.8.5", - "rayon", - "serde", - "serde_json", - "tempfile", - "toml", - "zkfhe-shared", -] - -[[package]] -name = "zkfhe-shared" -version = "0.1.0" -source = "git+https://github.com/gnosisguild/zkfhe-generator#7314bed079b91ea6432864f30b991e4ef724a5c5" -dependencies = [ - "anyhow", - "bigint-poly", - "chrono", - "fhe", - "fhe-math", - "fhe-traits", - "num-bigint", - "num-traits", - "rand 0.8.5", - "serde", - "serde_json", - "thiserror 1.0.69", - "toml", -] - [[package]] name = "zstd" version = "0.13.3" diff --git a/templates/default/Cargo.toml b/templates/default/Cargo.toml index 999922ab3b..f422924a66 100644 --- a/templates/default/Cargo.toml +++ b/templates/default/Cargo.toml @@ -6,7 +6,11 @@ members = [ ] [workspace.dependencies] +e3-user-program = { path = "./program" } fhe = { package = "fhe", git = "https://github.com/gnosisguild/fhe.rs" } fhe-traits = { git = "https://github.com/gnosisguild/fhe.rs" } +e3-program-server = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } +e3-bfv-helpers = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } +e3-compute-provider = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } rand = "0.8.5" anyhow = "1.0.86" diff --git a/templates/default/program/Cargo.toml b/templates/default/program/Cargo.toml index f0bb25f77c..48522176b6 100644 --- a/templates/default/program/Cargo.toml +++ b/templates/default/program/Cargo.toml @@ -6,8 +6,8 @@ edition = "2024" [dependencies] fhe = { workspace = true } fhe-traits = { workspace = true } -e3-compute-provider = { path = "../../../crates/compute-provider" } -e3-bfv-helpers = { path = "../../../crates/bfv-helpers" } +e3-compute-provider = { workspace = true } +e3-bfv-helpers = { workspace = true } [dev-dependencies] rand = { workspace = true } From 6d0b9fd04c0ffae7f1922d6f7a3c408394898905 Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 13:03:05 -0300 Subject: [PATCH 13/22] add comment --- templates/default/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/default/Cargo.toml b/templates/default/Cargo.toml index f422924a66..f06f5bd37e 100644 --- a/templates/default/Cargo.toml +++ b/templates/default/Cargo.toml @@ -9,6 +9,7 @@ members = [ e3-user-program = { path = "./program" } fhe = { package = "fhe", git = "https://github.com/gnosisguild/fhe.rs" } fhe-traits = { git = "https://github.com/gnosisguild/fhe.rs" } +# TODO: point the following to the monorepo paths (eg ../../crates/**) and overwrite them during enclave init e3-program-server = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } e3-bfv-helpers = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } e3-compute-provider = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } From 3bac269117ff81f66c2cdb95add8958b86be4023 Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 13:15:53 -0300 Subject: [PATCH 14/22] update paths to use workspace versions --- examples/CRISP/Cargo.lock | 8 ++++---- examples/CRISP/Cargo.toml | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/CRISP/Cargo.lock b/examples/CRISP/Cargo.lock index ba3ae9d18e..6bc3efb3aa 100644 --- a/examples/CRISP/Cargo.lock +++ b/examples/CRISP/Cargo.lock @@ -2324,12 +2324,12 @@ dependencies = [ [[package]] name = "e3-program-server" -version = "0.1.0" -source = "git+https://github.com/gnosisguild/enclave?rev=2ca0aa5f47dd962add5d1d0f74900d9bceb957e5#2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" +version = "0.1.5" dependencies = [ "actix-web", "anyhow", - "e3-compute-provider 0.1.0", + "derivative", + "e3-compute-provider 0.1.5", "hex", "reqwest", "serde", @@ -2351,7 +2351,7 @@ name = "e3-support-scripts-dev" version = "0.1.0" dependencies = [ "anyhow", - "e3-compute-provider 0.1.0", + "e3-compute-provider 0.1.5", "e3-program-server", "e3-user-program", "tokio", diff --git a/examples/CRISP/Cargo.toml b/examples/CRISP/Cargo.toml index 7cc68bf774..505e46365d 100644 --- a/examples/CRISP/Cargo.toml +++ b/examples/CRISP/Cargo.toml @@ -29,6 +29,8 @@ actix-web = "=4.11.0" bincode = { version = "=1.3.3" } bytemuck = { version = "=1.23.1" } derivative = "=2.2.0" +e3-compute-provider = { path = "../../crates/compute-provider" } +e3-program-server = { path = "../../crates/program-server" } eyre = "=0.6.12" env_logger = "=0.11.8" hex = { version = "=0.4.3" } From ca30274da34b1277531f419f48ffda61a1d65842 Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 13:31:58 -0300 Subject: [PATCH 15/22] pull everything back to workspace --- examples/CRISP/Cargo.lock | 153 +++++++++++++----------------- examples/CRISP/Cargo.toml | 2 + examples/CRISP/program/Cargo.toml | 4 +- examples/CRISP/server/Cargo.toml | 4 +- 4 files changed, 74 insertions(+), 89 deletions(-) diff --git a/examples/CRISP/Cargo.lock b/examples/CRISP/Cargo.lock index 6bc3efb3aa..765a36e38d 100644 --- a/examples/CRISP/Cargo.lock +++ b/examples/CRISP/Cargo.lock @@ -80,7 +80,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -197,7 +197,7 @@ dependencies = [ "actix-router", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -286,9 +286,9 @@ dependencies = [ [[package]] name = "alloy-chains" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6068f356948cd84b5ad9ac30c50478e433847f14a50714d2b68f15d052724049" +checksum = "bfaa9ea039a6f9304b4a593d780b1f23e1ae183acdee938b11b38795acacc9f1" dependencies = [ "alloy-primitives", "num_enum", @@ -675,7 +675,7 @@ checksum = "64b728d511962dda67c1bc7ea7c03736ec275ed2cf4c35d9585298ac9ccf3b73" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -873,7 +873,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -890,7 +890,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", "syn-solidity", "tiny-keccak", ] @@ -909,7 +909,7 @@ dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", "serde_json", - "syn 2.0.109", + "syn 2.0.110", "syn-solidity", ] @@ -1037,7 +1037,7 @@ dependencies = [ "darling", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1224,7 +1224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" dependencies = [ "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1262,7 +1262,7 @@ dependencies = [ "num-traits", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1387,7 +1387,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1398,7 +1398,7 @@ checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1426,7 +1426,7 @@ checksum = "ffdcb70bdbc4d478427380519163274ac86e52916e10f0a8889adf0f96d3fee7" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1753,7 +1753,7 @@ dependencies = [ "heck", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -1965,7 +1965,7 @@ dependencies = [ "derivative", "dialoguer", "dotenvy", - "e3-compute-provider 0.1.5", + "e3-compute-provider", "e3-sdk", "env_logger", "eyre", @@ -2073,7 +2073,7 @@ dependencies = [ "quote 1.0.42", "serde", "strsim", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2084,7 +2084,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2155,7 +2155,7 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", "unicode-xid 0.2.6", ] @@ -2202,7 +2202,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2262,23 +2262,6 @@ dependencies = [ "zkfhe-greco", ] -[[package]] -name = "e3-compute-provider" -version = "0.1.0" -source = "git+https://github.com/gnosisguild/enclave?rev=2ca0aa5f47dd962add5d1d0f74900d9bceb957e5#2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" -dependencies = [ - "ark-bn254", - "ark-ff 0.4.2", - "hex", - "lean-imt", - "light-poseidon 0.2.0", - "num-bigint", - "num-traits", - "rayon", - "serde", - "sha3", -] - [[package]] name = "e3-compute-provider" version = "0.1.5" @@ -2329,7 +2312,7 @@ dependencies = [ "actix-web", "anyhow", "derivative", - "e3-compute-provider 0.1.5", + "e3-compute-provider", "hex", "reqwest", "serde", @@ -2351,7 +2334,7 @@ name = "e3-support-scripts-dev" version = "0.1.0" dependencies = [ "anyhow", - "e3-compute-provider 0.1.5", + "e3-compute-provider", "e3-program-server", "e3-user-program", "tokio", @@ -2362,7 +2345,7 @@ name = "e3-user-program" version = "0.1.0" dependencies = [ "e3-bfv-helpers", - "e3-compute-provider 0.1.0", + "e3-compute-provider", "fhe", "fhe-traits", ] @@ -2391,7 +2374,7 @@ dependencies = [ "enum-ordinalize", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2455,7 +2438,7 @@ checksum = "8ca9601fb2d62598ee17836250842873a413586e5d7ed88b356e38ddbb0ec631" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -2554,7 +2537,7 @@ dependencies = [ [[package]] name = "fhe" version = "0.1.0-beta.7" -source = "git+https://github.com/gnosisguild/fhe.rs#837be950a453ffce5bbf35823344f08a65edb0ce" +source = "git+https://github.com/gnosisguild/fhe.rs#7692b954ce887ee78f0b6baae36447ca1aa74708" dependencies = [ "doc-comment", "fhe-math", @@ -2579,7 +2562,7 @@ dependencies = [ [[package]] name = "fhe-math" version = "0.1.0-beta.7" -source = "git+https://github.com/gnosisguild/fhe.rs#837be950a453ffce5bbf35823344f08a65edb0ce" +source = "git+https://github.com/gnosisguild/fhe.rs#7692b954ce887ee78f0b6baae36447ca1aa74708" dependencies = [ "ethnum", "fhe-traits", @@ -2601,7 +2584,7 @@ dependencies = [ [[package]] name = "fhe-traits" version = "0.1.0-beta.7" -source = "git+https://github.com/gnosisguild/fhe.rs#837be950a453ffce5bbf35823344f08a65edb0ce" +source = "git+https://github.com/gnosisguild/fhe.rs#7692b954ce887ee78f0b6baae36447ca1aa74708" dependencies = [ "rand 0.8.5", ] @@ -2609,7 +2592,7 @@ dependencies = [ [[package]] name = "fhe-util" version = "0.1.0-beta.7" -source = "git+https://github.com/gnosisguild/fhe.rs#837be950a453ffce5bbf35823344f08a65edb0ce" +source = "git+https://github.com/gnosisguild/fhe.rs#7692b954ce887ee78f0b6baae36447ca1aa74708" dependencies = [ "itertools 0.12.1", "num-bigint-dig", @@ -2768,7 +2751,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -3058,9 +3041,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" +checksum = "1744436df46f0bde35af3eda22aeaba453aada65d8f1c171cd8a5f59030bd69f" dependencies = [ "atomic-waker", "bytes", @@ -3292,7 +3275,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -3444,7 +3427,7 @@ checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -3643,7 +3626,7 @@ checksum = "1b27834086c65ec3f9387b096d66e99f221cf081c2b738042aa252bcd41204e3" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -3770,9 +3753,9 @@ dependencies = [ [[package]] name = "num-bigint-dig" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c79c15c05d4bf82b6f5ef163104cc81a760d8e874d38ac50ab67c8877b647b" +checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" dependencies = [ "lazy_static", "libm", @@ -3868,7 +3851,7 @@ checksum = "ff32365de1b6743cb203b710788263c44a03de03802daf96092f2da4fe6ba4d7" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -3929,7 +3912,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -3985,7 +3968,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4084,7 +4067,7 @@ dependencies = [ "pest_meta", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4134,7 +4117,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4211,7 +4194,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2 1.0.103", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4264,7 +4247,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4331,7 +4314,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.109", + "syn 2.0.110", "tempfile", ] @@ -4345,7 +4328,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -4596,7 +4579,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5037,7 +5020,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5102,7 +5085,7 @@ dependencies = [ "darling", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5297,7 +5280,7 @@ dependencies = [ "heck", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5319,9 +5302,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.109" +version = "2.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f17c7e013e88258aa9543dcbe81aca68a667a9ac37cd69c9fbc07858bfe0e2f" +checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", @@ -5337,7 +5320,7 @@ dependencies = [ "paste", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5357,7 +5340,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5426,7 +5409,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5437,7 +5420,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5551,7 +5534,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5751,7 +5734,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -5993,7 +5976,7 @@ dependencies = [ "bumpalo", "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", "wasm-bindgen-shared", ] @@ -6132,7 +6115,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6143,7 +6126,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6447,7 +6430,7 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", "synstructure", ] @@ -6468,7 +6451,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6488,7 +6471,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", "synstructure", ] @@ -6509,7 +6492,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6542,7 +6525,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2 1.0.103", "quote 1.0.42", - "syn 2.0.109", + "syn 2.0.110", ] [[package]] @@ -6570,7 +6553,7 @@ dependencies = [ [[package]] name = "zkfhe-greco" version = "0.1.0" -source = "git+https://github.com/gnosisguild/zkfhe-generator#1bb8019b8d9944ebf2fd293ec15d6cabc4e37da0" +source = "git+https://github.com/gnosisguild/zkfhe-generator#7314bed079b91ea6432864f30b991e4ef724a5c5" dependencies = [ "anyhow", "bigint-poly", @@ -6593,7 +6576,7 @@ dependencies = [ [[package]] name = "zkfhe-shared" version = "0.1.0" -source = "git+https://github.com/gnosisguild/zkfhe-generator#1bb8019b8d9944ebf2fd293ec15d6cabc4e37da0" +source = "git+https://github.com/gnosisguild/zkfhe-generator#7314bed079b91ea6432864f30b991e4ef724a5c5" dependencies = [ "anyhow", "bigint-poly", diff --git a/examples/CRISP/Cargo.toml b/examples/CRISP/Cargo.toml index 505e46365d..0a18fdc8d1 100644 --- a/examples/CRISP/Cargo.toml +++ b/examples/CRISP/Cargo.toml @@ -31,6 +31,8 @@ bytemuck = { version = "=1.23.1" } derivative = "=2.2.0" e3-compute-provider = { path = "../../crates/compute-provider" } e3-program-server = { path = "../../crates/program-server" } +e3-bfv-helpers = { path = "../../crates/bfv-helpers" } +e3-sdk = { path = "../../crates/sdk" } eyre = "=0.6.12" env_logger = "=0.11.8" hex = { version = "=0.4.3" } diff --git a/examples/CRISP/program/Cargo.toml b/examples/CRISP/program/Cargo.toml index c7f3c55a74..367c79bf9b 100644 --- a/examples/CRISP/program/Cargo.toml +++ b/examples/CRISP/program/Cargo.toml @@ -6,5 +6,5 @@ edition = { workspace = true } [dependencies] fhe = { workspace = true } fhe-traits = { workspace = true } -e3-compute-provider = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } -e3-bfv-helpers = { path = "../../../crates/bfv-helpers" } +e3-compute-provider = { workspace = true } +e3-bfv-helpers = { workspace = true } diff --git a/examples/CRISP/server/Cargo.toml b/examples/CRISP/server/Cargo.toml index 45e606b10f..1d19f3b457 100644 --- a/examples/CRISP/server/Cargo.toml +++ b/examples/CRISP/server/Cargo.toml @@ -42,8 +42,8 @@ num-bigint = "=0.4.6" lean-imt = "=0.1.2" # Local dependencies -e3-compute-provider = { path = "../../../crates/compute-provider" } -e3-sdk = { path = "../../../crates/sdk" } +e3-compute-provider.workspace = true +e3-sdk.workspace = true # CLI and user interaction dialoguer = { version = "=0.11.0", features = ["fuzzy-select"] } From a2b5c5689602b758f0dff2b0cf1954a24d03de5c Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 13:37:13 -0300 Subject: [PATCH 16/22] fix missing exclusion --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 3b6b34e632..20f37376a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ members = [ "crates/wasm", ] exclude = [ + "examples/CRISP", "examples/CRISP/server", "examples/CRISP/program", "examples/default/client/wasm", From ef616b8f566bafbe1fc2cc82707cdb9109f410fd Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 14:21:50 -0300 Subject: [PATCH 17/22] update lock --- pnpm-lock.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dd410e943e..2f4f19f131 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -663,7 +663,7 @@ importers: version: 5.3.0 '@risc0/ethereum': specifier: file:lib/risc0-ethereum - version: file:templates/default/lib/risc0-ethereum + version: risc0-ethereum@file:templates/default/lib/risc0-ethereum '@types/chai': specifier: ^4.2.0 version: 4.3.20 @@ -3005,9 +3005,6 @@ packages: '@reown/appkit@1.7.8': resolution: {integrity: sha512-51kTleozhA618T1UvMghkhKfaPcc9JlKwLJ5uV+riHyvSoWPKPRIa5A6M1Wano5puNyW0s3fwywhyqTHSilkaA==} - '@risc0/ethereum@file:templates/default/lib/risc0-ethereum': - resolution: {directory: templates/default/lib/risc0-ethereum, type: directory} - '@rolldown/pluginutils@1.0.0-beta.27': resolution: {integrity: sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==} @@ -8543,6 +8540,9 @@ packages: resolution: {integrity: sha512-5Di9UC0+8h1L6ZD2d7awM7E/T4uA1fJRlx6zk/NvdCCVEoAnFqvHmCuNeIKoCeIixBX/q8uM+6ycDvF8woqosA==} engines: {node: '>= 0.8'} + risc0-ethereum@file:templates/default/lib/risc0-ethereum: + resolution: {directory: templates/default/lib/risc0-ethereum, type: directory} + robust-predicates@3.0.2: resolution: {integrity: sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==} @@ -12964,8 +12964,6 @@ snapshots: - utf-8-validate - zod - '@risc0/ethereum@file:templates/default/lib/risc0-ethereum': {} - '@rolldown/pluginutils@1.0.0-beta.27': {} '@rollup/plugin-inject@5.0.5(rollup@4.52.5)': @@ -20507,6 +20505,8 @@ snapshots: hash-base: 3.1.2 inherits: 2.0.4 + risc0-ethereum@file:templates/default/lib/risc0-ethereum: {} + robust-predicates@3.0.2: {} rollup@4.52.5: From 7eefba1f34f214562f4b6a594ee0e19b15138378 Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 15:25:45 -0300 Subject: [PATCH 18/22] ensure test runs single threaded --- Cargo.toml | 5 +- templates/default/deployed_contracts.json | 53 +++++++++++---------- templates/default/scripts/dev_program.sh | 4 +- templates/default/tests/integration.spec.ts | 11 +++-- templates/default/vitest.config.ts | 13 +++++ 5 files changed, 52 insertions(+), 34 deletions(-) create mode 100644 templates/default/vitest.config.ts diff --git a/Cargo.toml b/Cargo.toml index 20f37376a7..0105cbedfa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,11 +36,10 @@ exclude = [ "examples/CRISP", "examples/CRISP/server", "examples/CRISP/program", - "examples/default/client/wasm", - "examples/default", # client needs to be able to build crates/support independently "crates/support", - "crates/support-scripts/dev" + "crates/support-scripts/dev", + "templates/default" ] resolver = "3" msrv = "1.86.0" diff --git a/templates/default/deployed_contracts.json b/templates/default/deployed_contracts.json index 67404b228a..81a3fe1c00 100644 --- a/templates/default/deployed_contracts.json +++ b/templates/default/deployed_contracts.json @@ -67,67 +67,70 @@ "minTicketBalance": "1", "exitDelay": "604800" }, - "blockNumber": 9, - "address": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853" + "blockNumber": 8, + "address": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6", + "implementationAddress": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853" }, "CiphernodeRegistryOwnable": { "constructorArgs": { "owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "enclaveAddress": "0x0000000000000000000000000000000000000001", - "submissionWindow": "3" + "submissionWindow": "10" }, - "blockNumber": 10, - "address": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6" + "blockNumber": 11, + "address": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788", + "implementationAddress": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318" }, "Enclave": { "constructorArgs": { "owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - "registry": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6", - "bondingRegistry": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853", + "registry": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788", + "bondingRegistry": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6", "feeToken": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0", "maxDuration": "2592000", "params": [ "0x000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000fc00100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000003fffffff000001" ] }, - "blockNumber": 11, - "address": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318" + "blockNumber": 13, + "address": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0", + "implementationAddress": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e" }, "MockComputeProvider": { - "blockNumber": 20, - "address": "0x68B1D87F95878fE05B998F19b66F4baba5De1aed" + "blockNumber": 23, + "address": "0x59b670e9fA9D0A427751Af201D676719a970857b" }, "MockDecryptionVerifier": { - "blockNumber": 21, - "address": "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c" + "blockNumber": 24, + "address": "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1" }, "MockInputValidator": { - "blockNumber": 22, - "address": "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d" + "blockNumber": 25, + "address": "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44" }, "MockE3Program": { "constructorArgs": { - "mockInputValidator": "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d" + "mockInputValidator": "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44" }, - "blockNumber": 23, - "address": "0x59b670e9fA9D0A427751Af201D676719a970857b" + "blockNumber": 26, + "address": "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f" }, "MockRISC0Verifier": { - "address": "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f" + "address": "0x09635F643e140090A9A8Dcd712eD6285858ceBef" }, "ImageID": { - "address": "0x4A679253410272dd5232B3Ff7cF5dbB88f295319" + "address": "0xc5a5C42992dECbae36851359345FE25997F5C42d" }, "InputValidator": { - "address": "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F" + "address": "0x67d269191c92Caf3cD7723F116c85e6E9bf55933" }, "MyProgram": { - "address": "0x09635F643e140090A9A8Dcd712eD6285858ceBef", + "address": "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E", "constructorArgs": { - "enclave": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318", - "verifier": "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f", + "enclave": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0", + "verifier": "0x09635F643e140090A9A8Dcd712eD6285858ceBef", "programId": "0xaf928ebf39fec4696c3f41f473a1a9473b67d723c6373149c6ab99ba4c1a76ef", - "inputValidator": "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F" + "inputValidator": "0x67d269191c92Caf3cD7723F116c85e6E9bf55933" } } } diff --git a/templates/default/scripts/dev_program.sh b/templates/default/scripts/dev_program.sh index 9fee0a6903..21d751bec9 100755 --- a/templates/default/scripts/dev_program.sh +++ b/templates/default/scripts/dev_program.sh @@ -3,6 +3,4 @@ set -euo pipefail echo "enclave rev = $(enclave rev)" echo "Waiting on ciphernodes to be ready..." -pnpm wait-on file:/tmp/enclave_ciphernodes_ready -echo "Ciphernodes are ready!" -enclave program start +pnpm wait-on file:/tmp/enclave_ciphernodes_ready && enclave program start diff --git a/templates/default/tests/integration.spec.ts b/templates/default/tests/integration.spec.ts index 5524302378..9149d73a3d 100644 --- a/templates/default/tests/integration.spec.ts +++ b/templates/default/tests/integration.spec.ts @@ -218,15 +218,16 @@ describe("Integration", () => { }); state = store.get(0n); - assert(state); + assert(state, "store should have E3State but it was falsey"); assert.strictEqual(state.e3Id, 0n); assert.strictEqual(state.type, "requested"); + console.log("E3 Sucessfully Requested!"); // Ciphernodes will publish a public key within the COMMITTEE_PUBLISHED event event = await waitForEvent(RegistryEventType.COMMITTEE_PUBLISHED); state = store.get(0n); - assert(state); + assert(state, "store should have E3State but it was falsey"); assert.strictEqual(state.type, "committee_published"); assert.strictEqual(state.publicKey, event.data.publicKey); @@ -238,13 +239,16 @@ describe("Integration", () => { }); state = store.get(0n); - assert(state); + assert(state, "store should have activated state but it was falsey"); assert.strictEqual(state.type, "activated"); // INPUT PUBLISHING phase + console.log("PUBLISHING PRIVATE INPUT"); const num1 = 12n; const num2 = 21n; const publicKeyBytes = hexToBytes(state.publicKey); + + console.log("ENCRYPTING NUMBERS"); const enc1 = await sdk.encryptNumber(num1, publicKeyBytes); const enc2 = await sdk.encryptNumber(num2, publicKeyBytes); @@ -272,5 +276,6 @@ describe("Integration", () => { const parsed = hexToUint8Array(plaintextEvent.data.plaintextOutput); expect(BigInt(parsed[0])).toBe(num1 + num2); + console.log("Answer was correct"); }, 9999999); }); diff --git a/templates/default/vitest.config.ts b/templates/default/vitest.config.ts new file mode 100644 index 0000000000..648aa37f26 --- /dev/null +++ b/templates/default/vitest.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + pool: "forks", + poolOptions: { + forks: { + singleFork: true, + }, + }, + testTimeout: 120_000, + }, +}); From f50b91336483364420c4e8a355b34f9783afeac6 Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 15:29:26 -0300 Subject: [PATCH 19/22] fix header --- templates/default/vitest.config.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/default/vitest.config.ts b/templates/default/vitest.config.ts index 648aa37f26..4e2d5be54a 100644 --- a/templates/default/vitest.config.ts +++ b/templates/default/vitest.config.ts @@ -1,3 +1,9 @@ +// SPDX-License-Identifier: LGPL-3.0-only +// +// This file is provided WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. + import { defineConfig } from "vitest/config"; export default defineConfig({ From f7790a5e8843cfb3676825331531e76c8c12ac45 Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 15:34:34 -0300 Subject: [PATCH 20/22] fix slow lint --- packages/enclave-contracts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/enclave-contracts/package.json b/packages/enclave-contracts/package.json index bb1dd69102..605933bf97 100644 --- a/packages/enclave-contracts/package.json +++ b/packages/enclave-contracts/package.json @@ -158,7 +158,7 @@ "ciphernode:siblings": "hardhat ciphernode:siblings", "committee:new": "hardhat committee:new", "lint": "pnpm lint:sol && pnpm lint:ts && pnpm prettier:check", - "lint:sol": "solhint --max-warnings 10 \"contracts/**/*.sol\"", + "lint:sol": "solhint --disc --max-warnings 10 \"contracts/**/*.sol\"", "lint:ts": "eslint --ignore-path ./.eslintignore --ext .js,.ts .", "prettier:check": "prettier --check \"**/*.{js,json,md,sol,ts,yml}\"", "prettier:write": "prettier --write \"**/*.{js,json,md,sol,ts,yml}\"", From 689afd8eee7fe62583d71bf798e8191ba3473fea Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 18:01:12 -0300 Subject: [PATCH 21/22] integrate bfvparams with sdk --- crates/wasm/src/lib.rs | 7 ++- packages/enclave-sdk/src/enclave-sdk.ts | 79 ++++++++++++++++--------- packages/enclave-sdk/src/types.ts | 23 +++++-- packages/enclave-sdk/tests/sdk.test.ts | 14 ++--- 4 files changed, 81 insertions(+), 42 deletions(-) diff --git a/crates/wasm/src/lib.rs b/crates/wasm/src/lib.rs index 2cce11fa47..0fc3e80afd 100644 --- a/crates/wasm/src/lib.rs +++ b/crates/wasm/src/lib.rs @@ -155,7 +155,7 @@ pub fn bfv_verifiable_encrypt_vector( /// { /// degree: number; // Polynomial degree (e.g., 8192) /// plaintext_modulus: number; // Plaintext modulus value (e.g., 1000) -/// moduli: number[]; // Array of moduli +/// moduli: bigint[]; // Array of moduli /// error1_variance: string | null; // Error variance as string or null /// } /// ``` @@ -166,7 +166,10 @@ pub fn get_bfv_params(name: &str) -> Result { let params = BfvParams::get_params_by_str(name).map_err(|e| JsValue::from_str(&e.to_string()))?; let js_params = BfvParamSetJs::from(¶ms); - serde_wasm_bindgen::to_value(&js_params) + let serializer = + serde_wasm_bindgen::Serializer::new().serialize_large_number_types_as_bigints(true); + js_params + .serialize(&serializer) .map_err(|e| JsValue::from_str(&format!("Serialization error: {}", e))) } diff --git a/packages/enclave-sdk/src/enclave-sdk.ts b/packages/enclave-sdk/src/enclave-sdk.ts index 98f36bebf5..57becbf28e 100644 --- a/packages/enclave-sdk/src/enclave-sdk.ts +++ b/packages/enclave-sdk/src/enclave-sdk.ts @@ -24,7 +24,7 @@ import { } from "@enclave-e3/contracts/types"; import { ContractClient } from "./contract-client"; import { EventListener } from "./event-listener"; -import { FheProtocol, EnclaveEventType, BfvProtocolParams } from "./types"; +import { FheProtocol, EnclaveEventType } from "./types"; import { SDKError, isValidAddress } from "./utils"; import type { @@ -35,12 +35,14 @@ import type { ProtocolParams, VerifiableEncryptionResult, EncryptedValueAndPublicInputs, + ProtocolParamsName, } from "./types"; import { bfv_encrypt_number, bfv_encrypt_vector, bfv_verifiable_encrypt_number, bfv_verifiable_encrypt_vector, + get_bfv_params, } from "@enclave-e3/wasm"; import { generateProof } from "./greco"; import { CompiledCircuit } from "@noir-lang/noir_js"; @@ -57,8 +59,9 @@ export class EnclaveSDK { private contractClient: ContractClient; private initialized = false; private protocol: FheProtocol; - private protocolParams: ProtocolParams; + private protocolParams?: ProtocolParams; + // TODO: use zod for config validation constructor(private config: SDKConfig) { if (!config.publicClient) { throw new SDKError("Public client is required", "MISSING_PUBLIC_CLIENT"); @@ -93,17 +96,6 @@ export class EnclaveSDK { if (config.protocolParams) { this.protocolParams = config.protocolParams; - } else { - switch (this.protocol) { - case FheProtocol.BFV: - this.protocolParams = BfvProtocolParams.BFV_NORMAL; - break; - case FheProtocol.TRBFV: - this.protocolParams = BfvProtocolParams.BFV_THRESHOLD; - break; - default: - throw new Error("Protocol not supported"); - } } } @@ -125,6 +117,33 @@ export class EnclaveSDK { } } + public async getBfvParamsSet( + name: ProtocolParamsName, + ): Promise { + await initializeWasm(); + let params = get_bfv_params(name as string); + return { + degree: Number(params.degree), // degree is returned as a bigint from wasm + plaintextModulus: params.plaintext_modulus as bigint, + moduli: params.moduli as bigint[], + error1Variance: params.error1_variance, + }; + } + + public async getProtocolParams(): Promise { + await initializeWasm(); + if (this.protocolParams) { + return this.protocolParams; + } + + switch (this.protocol) { + case FheProtocol.BFV: + return await this.getBfvParamsSet("INSECURE_SET_2048_1032193_1"); + case FheProtocol.TRBFV: + return await this.getBfvParamsSet("INSECURE_SET_512_10_1"); + } + } + /** * Encrypt a number using the configured protocol * @param data - The number to encrypt @@ -136,14 +155,15 @@ export class EnclaveSDK { publicKey: Uint8Array, ): Promise { await initializeWasm(); + const protocolParams = await this.getProtocolParams(); switch (this.protocol) { case FheProtocol.BFV: return bfv_encrypt_number( data, publicKey, - this.protocolParams.degree, - this.protocolParams.plaintextModulus, - BigUint64Array.from(this.protocolParams.moduli), + protocolParams.degree, + protocolParams.plaintextModulus, + BigUint64Array.from(protocolParams.moduli), ); default: throw new Error("Protocol not supported"); @@ -161,14 +181,15 @@ export class EnclaveSDK { publicKey: Uint8Array, ): Promise { await initializeWasm(); + const protocolParams = await this.getProtocolParams(); switch (this.protocol) { case FheProtocol.BFV: return bfv_encrypt_vector( data, publicKey, - this.protocolParams.degree, - this.protocolParams.plaintextModulus, - BigUint64Array.from(this.protocolParams.moduli), + protocolParams.degree, + protocolParams.plaintextModulus, + BigUint64Array.from(protocolParams.moduli), ); default: throw new Error("Protocol not supported"); @@ -187,14 +208,15 @@ export class EnclaveSDK { publicKey: Uint8Array, ): Promise { await initializeWasm(); + const protocolParams = await this.getProtocolParams(); switch (this.protocol) { case FheProtocol.BFV: const [encryptedData, circuitInputs] = bfv_verifiable_encrypt_number( data, publicKey, - this.protocolParams.degree, - this.protocolParams.plaintextModulus, - BigUint64Array.from(this.protocolParams.moduli), + protocolParams.degree, + protocolParams.plaintextModulus, + BigUint64Array.from(protocolParams.moduli), ); const publicInputs = JSON.parse(circuitInputs); @@ -240,14 +262,15 @@ export class EnclaveSDK { publicKey: Uint8Array, ): Promise { await initializeWasm(); + const protocolParams = await this.getProtocolParams(); switch (this.protocol) { case FheProtocol.BFV: const [encryptedData, circuitInputs] = bfv_verifiable_encrypt_vector( data, publicKey, - this.protocolParams.degree, - this.protocolParams.plaintextModulus, - BigUint64Array.from(this.protocolParams.moduli), + protocolParams.degree, + protocolParams.plaintextModulus, + BigUint64Array.from(protocolParams.moduli), ); const publicInputs = JSON.parse(circuitInputs); @@ -587,9 +610,9 @@ export class EnclaveSDK { options.rpcUrl.startsWith("ws://") || options.rpcUrl.startsWith("wss://"); const transport = isWebSocket ? webSocket(options.rpcUrl, { - keepAlive: { interval: 30_000 }, - reconnect: { attempts: 5, delay: 2_000 }, - }) + keepAlive: { interval: 30_000 }, + reconnect: { attempts: 5, delay: 2_000 }, + }) : http(options.rpcUrl); const publicClient = createPublicClient({ chain, diff --git a/packages/enclave-sdk/src/types.ts b/packages/enclave-sdk/src/types.ts index a07901a4f7..e3d1195a3d 100644 --- a/packages/enclave-sdk/src/types.ts +++ b/packages/enclave-sdk/src/types.ts @@ -242,10 +242,10 @@ export interface RegistryEventData { export interface EnclaveEvent { type: T; data: T extends EnclaveEventType - ? EnclaveEventData[T] - : T extends RegistryEventType - ? RegistryEventData[T] - : unknown; + ? EnclaveEventData[T] + : T extends RegistryEventType + ? RegistryEventData[T] + : unknown; log: Log; timestamp: Date; blockNumber: bigint; @@ -253,7 +253,7 @@ export interface EnclaveEvent { } export type EventCallback = ( - event: EnclaveEvent + event: EnclaveEvent, ) => void | Promise; export interface EventFilter { @@ -317,8 +317,19 @@ export interface ProtocolParams { * The moduli */ moduli: bigint[]; + /** + * error1 + */ + error1Variance: string | undefined; } +export type ProtocolParamsName = + | "INSECURE_SET_2048_1032193_1" + | "INSECURE_SET_512_10_1" + | "INSECURE_SET_512_0XFFFFEE001_1" + | "SET_8192_1000_4" + | "SET_8192_144115188075855872_2"; + /** * Parameters for the BFV protocol */ @@ -333,6 +344,7 @@ export const BfvProtocolParams = { degree: 2048, plaintextModulus: 1032193n, moduli: [0x3fffffff000001n], + error1Variance: "10", } as const satisfies ProtocolParams, /** @@ -350,6 +362,7 @@ export const BfvProtocolParams = { 0x0080000002120001n, 0x0080000001f60001n, ], + error1Variance: "10", } as const satisfies ProtocolParams, }; diff --git a/packages/enclave-sdk/tests/sdk.test.ts b/packages/enclave-sdk/tests/sdk.test.ts index 56cca7d7d3..31fc1baff5 100644 --- a/packages/enclave-sdk/tests/sdk.test.ts +++ b/packages/enclave-sdk/tests/sdk.test.ts @@ -32,7 +32,7 @@ describe("encryptNumber", () => { it("should encrypt a number without crashing in a node environent", async () => { const buffer = await fs.readFile( - path.resolve(__dirname, "./fixtures/pubkey.bin") + path.resolve(__dirname, "./fixtures/pubkey.bin"), ); const value = await sdk.encryptNumber(10n, Uint8Array.from(buffer)); expect(value).to.be.an.instanceof(Uint8Array); @@ -41,13 +41,13 @@ describe("encryptNumber", () => { }); it("should encrypt a number and generate a proof without crashing in a node environent", async () => { const buffer = await fs.readFile( - path.resolve(__dirname, "./fixtures/pubkey.bin") + path.resolve(__dirname, "./fixtures/pubkey.bin"), ); const value = await sdk.encryptNumberAndGenProof( 1n, Uint8Array.from(buffer), - demoCircuit as unknown as CompiledCircuit + demoCircuit as unknown as CompiledCircuit, ); expect(value).to.be.an.instanceof(Object); @@ -57,11 +57,11 @@ describe("encryptNumber", () => { it("should encrypt a vecor of numbers without crashing in a node environent", async () => { const buffer = await fs.readFile( - path.resolve(__dirname, "./fixtures/pubkey.bin") + path.resolve(__dirname, "./fixtures/pubkey.bin"), ); const value = await sdk.encryptVector( new BigUint64Array([1n, 2n]), - Uint8Array.from(buffer) + Uint8Array.from(buffer), ); expect(value).to.be.an.instanceof(Uint8Array); expect(value.length).to.equal(27_674); @@ -69,13 +69,13 @@ describe("encryptNumber", () => { it("should encrypt a vector and generate a proof without crashing in a node environent", async () => { const buffer = await fs.readFile( - path.resolve(__dirname, "./fixtures/pubkey.bin") + path.resolve(__dirname, "./fixtures/pubkey.bin"), ); const value = await sdk.encryptVectorAndGenProof( new BigUint64Array([1n, 2n]), Uint8Array.from(buffer), - demoCircuit as unknown as CompiledCircuit + demoCircuit as unknown as CompiledCircuit, ); expect(value).to.be.an.instanceof(Object); From 18381a0f66f9206263d944ecb7a44b1bba3e731f Mon Sep 17 00:00:00 2001 From: ryardley Date: Wed, 12 Nov 2025 18:16:29 -0300 Subject: [PATCH 22/22] unify cli and struct --- crates/test-helpers/src/bin/pack_e3_params.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/test-helpers/src/bin/pack_e3_params.rs b/crates/test-helpers/src/bin/pack_e3_params.rs index 9b70b14abd..f5ac101a35 100644 --- a/crates/test-helpers/src/bin/pack_e3_params.rs +++ b/crates/test-helpers/src/bin/pack_e3_params.rs @@ -25,7 +25,7 @@ struct Args { #[arg(short, long = "plaintext-modulus")] plaintext_modulus: u64, - #[arg(short, long = "error2-variance")] + #[arg(short, long = "error1-variance")] error1_variance: Option, }