diff --git a/crates/evm-helpers/src/contracts.rs b/crates/evm-helpers/src/contracts.rs index 91d2768280..a9d0c3533d 100644 --- a/crates/evm-helpers/src/contracts.rs +++ b/crates/evm-helpers/src/contracts.rs @@ -75,13 +75,13 @@ sol! { mapping(uint256 e3Id => bytes params) public e3Params; mapping(address e3Program => bool allowed) public e3Programs; function request(E3RequestParams memory request) external payable returns (uint256 e3Id, E3 memory e3); - function activate(uint256 e3Id,bytes memory publicKey) external returns (bool success); + function activate(uint256 e3Id,bytes calldata publicKey) external returns (bool success); function enableE3Program(address e3Program) public onlyOwner returns (bool success); - function publishInput(uint256 e3Id, bytes memory data) external returns (bool success); - function publishCiphertextOutput(uint256 e3Id, bytes memory ciphertextOutput, bytes memory proof) external returns (bool success); - function publishPlaintextOutput(uint256 e3Id, bytes memory data) external returns (bool success); + function publishInput(uint256 e3Id, bytes calldata data) external returns (bool success); + function publishCiphertextOutput(uint256 e3Id, bytes calldata ciphertextOutput, bytes calldata proof) external returns (bool success); + function publishPlaintextOutput(uint256 e3Id, bytes calldata data, bytes calldata proof) external returns (bool success); function getE3(uint256 e3Id) external view returns (E3 memory e3); - function getRoot(uint256 id) public view returns (uint256); + function getInputRoot(uint256 e3Id) public view returns (uint256); } } @@ -101,7 +101,7 @@ pub trait EnclaveRead { async fn get_latest_block(&self) -> Result; /// Get the root for a specific ID - async fn get_root(&self, id: U256) -> Result; + async fn get_input_root(&self, id: U256) -> Result; /// Get E3 parameters for a specific E3 ID async fn get_e3_params(&self, e3_id: U256) -> Result; @@ -147,6 +147,7 @@ pub trait EnclaveWrite { &self, e3_id: U256, data: Bytes, + proof: Bytes, ) -> Result; } @@ -313,9 +314,9 @@ where Ok(block) } - async fn get_root(&self, id: U256) -> Result { + async fn get_input_root(&self, id: U256) -> Result { let contract = Enclave::new(self.contract_address, &self.provider); - let root = contract.getRoot(id).call().await?; + let root = contract.getInputRoot(id).call().await?; Ok(root) } @@ -423,12 +424,15 @@ impl EnclaveWrite for EnclaveContract { &self, e3_id: U256, data: Bytes, + proof: Bytes, ) -> Result { let _guard = NONCE_LOCK.lock().await; let nonce = next_pending_nonce(&*self.provider).await?; let contract = Enclave::new(self.contract_address, &self.provider); - let builder = contract.publishPlaintextOutput(e3_id, data).nonce(nonce); + let builder = contract + .publishPlaintextOutput(e3_id, data, proof) + .nonce(nonce); let receipt = builder.send().await?.get_receipt().await?; Ok(receipt) diff --git a/crates/support/Cargo.lock b/crates/support/Cargo.lock index e85481de4c..30bd9f2fb3 100644 --- a/crates/support/Cargo.lock +++ b/crates/support/Cargo.lock @@ -252,14 +252,9 @@ dependencies = [ "alloy-contract", "alloy-core", "alloy-eips", - "alloy-genesis", "alloy-network", "alloy-provider", "alloy-rpc-client", - "alloy-rpc-types", - "alloy-serde", - "alloy-signer", - "alloy-signer-local", "alloy-transport", "alloy-transport-http", ] @@ -272,7 +267,7 @@ checksum = "4195a29a4b87137b2bb02105e746102873bc03561805cf45c0e510c961f160e6" dependencies = [ "alloy-primitives", "num_enum", - "strum 0.27.2", + "strum", ] [[package]] @@ -345,7 +340,6 @@ dependencies = [ "alloy-dyn-abi", "alloy-json-abi", "alloy-primitives", - "alloy-rlp", "alloy-sol-types", ] @@ -421,20 +415,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "alloy-genesis" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51b4c13e02a8104170a4de02ccf006d7c233e6c10ab290ee16e7041e6ac221d" -dependencies = [ - "alloy-eips", - "alloy-primitives", - "alloy-serde", - "alloy-trie", - "serde", - "serde_with", -] - [[package]] name = "alloy-json-abi" version = "1.3.0" @@ -546,7 +526,6 @@ dependencies = [ "alloy-signer", "alloy-sol-types", "alloy-transport", - "alloy-transport-http", "async-stream", "async-trait", "auto_impl", @@ -558,13 +537,11 @@ dependencies = [ "lru", "parking_lot", "pin-project", - "reqwest", "serde", "serde_json", "thiserror 2.0.12", "tokio", "tracing", - "url", "wasmtimer", ] @@ -599,32 +576,17 @@ dependencies = [ "alloy-json-rpc", "alloy-primitives", "alloy-transport", - "alloy-transport-http", "futures", "pin-project", - "reqwest", "serde", "serde_json", "tokio", "tokio-stream", "tower", "tracing", - "url", "wasmtimer", ] -[[package]] -name = "alloy-rpc-types" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d47b637369245d2dafef84b223b1ff5ea59e6cd3a98d2d3516e32788a0b216df" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types-eth", - "alloy-serde", - "serde", -] - [[package]] name = "alloy-rpc-types-any" version = "1.0.23" @@ -683,22 +645,6 @@ dependencies = [ "thiserror 2.0.12", ] -[[package]] -name = "alloy-signer-local" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad7094c39cd41b03ed642145b0bd37251e31a9cf2ed19e1ce761f089867356a6" -dependencies = [ - "alloy-consensus", - "alloy-network", - "alloy-primitives", - "alloy-signer", - "async-trait", - "k256", - "rand 0.8.5", - "thiserror 2.0.12", -] - [[package]] name = "alloy-sol-macro" version = "1.3.0" @@ -722,7 +668,7 @@ dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", "const-hex", - "heck 0.5.0", + "heck", "indexmap 2.10.0", "proc-macro-error2", "proc-macro2", @@ -741,7 +687,7 @@ dependencies = [ "alloy-json-abi", "const-hex", "dunce", - "heck 0.5.0", + "heck", "macro-string", "proc-macro2", "quote", @@ -801,12 +747,7 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d3615ec64d775fec840f4e9d5c8e1f739eb1854d8d28db093fb3d4805e0cb53" dependencies = [ - "alloy-json-rpc", "alloy-transport", - "reqwest", - "serde_json", - "tower", - "tracing", "url", ] @@ -1507,15 +1448,15 @@ dependencies = [ [[package]] name = "bonsai-sdk" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bce8d6acc5286a16e94c29e9c885d1869358885e08a6feeb6bc54e36fe20055" +checksum = "21055e2f49cbbdbfe9f8f96d597c5527b0c6ab7933341fdc2f147180e48a988e" dependencies = [ "duplicate", "maybe-async", "reqwest", "serde", - "thiserror 1.0.69", + "thiserror 2.0.12", ] [[package]] @@ -1935,6 +1876,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ "const-oid", + "pem-rfc7468", "zeroize", ] @@ -2034,23 +1976,23 @@ dependencies = [ [[package]] name = "dirs" -version = "5.0.1" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys 0.48.0", + "windows-sys 0.60.2", ] [[package]] @@ -2090,12 +2032,13 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "duplicate" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de78e66ac9061e030587b2a2e75cc88f22304913c907b11307bca737141230cb" +checksum = "97af9b5f014e228b33e77d75ee0e6e87960124f0f4b16337b586a6bec91867b1" dependencies = [ - "heck 0.4.1", - "proc-macro-error", + "heck", + "proc-macro2", + "proc-macro2-diagnostics", ] [[package]] @@ -2761,9 +2704,6 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] [[package]] name = "hashbrown" @@ -2779,19 +2719,13 @@ dependencies = [ [[package]] name = "hashlink" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" dependencies = [ - "hashbrown 0.14.5", + "hashbrown 0.15.4", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -3672,6 +3606,7 @@ dependencies = [ "rand 0.8.5", "serde", "smallvec", + "zeroize", ] [[package]] @@ -3918,6 +3853,15 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -3977,6 +3921,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + [[package]] name = "pkcs8" version = "0.10.2" @@ -4085,30 +4040,6 @@ dependencies = [ "toml_edit", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro-error-attr2" version = "2.0.0" @@ -4140,6 +4071,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", + "version_check", + "yansi", +] + [[package]] name = "proptest" version = "1.7.0" @@ -4187,7 +4131,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", - "heck 0.5.0", + "heck", "itertools 0.12.1", "log", "multimap", @@ -4436,13 +4380,13 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.6" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ "getrandom 0.2.16", "libredox", - "thiserror 1.0.69", + "thiserror 2.0.12", ] [[package]] @@ -4589,18 +4533,21 @@ dependencies = [ [[package]] name = "risc0-binfmt" -version = "2.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fe7599ac55ad77515608ec42a9727001559fe4f579c533cb7c973b54800c05" +checksum = "1c8f97f81bcdead4101bca06469ecef481a2695cd04e7e877b49dea56a7f6f2a" dependencies = [ "anyhow", "borsh", + "bytemuck", "derive_more", "elf", "lazy_static", "postcard", + "rand 0.9.2", "risc0-zkp", "risc0-zkvm-platform", + "ruint", "semver 1.0.26", "serde", "tracing", @@ -4608,9 +4555,9 @@ dependencies = [ [[package]] name = "risc0-build" -version = "2.1.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17d6657b1fb615c0482bd4b57aae7850911ed7dbdc8e783df20e93f33209a8f" +checksum = "1bbb512d728e011d03ce0958ca7954624ee13a215bcafd859623b3c63b2a3f60" dependencies = [ "anyhow", "cargo_metadata", @@ -4632,22 +4579,18 @@ dependencies = [ [[package]] name = "risc0-build-ethereum" -version = "2.2.0" -source = "git+https://github.com/risc0/risc0-ethereum?tag=v2.2.0#382d76a8040068243a5d13e3de50fcca4224b0d6" +version = "3.0.0" +source = "git+https://github.com/risc0/risc0-ethereum?tag=v3.0.0#32aa0b6f23ddd02dd93fc71717667606e5c7db86" dependencies = [ "anyhow", - "bytemuck", - "hex", "risc0-build", - "risc0-zkp", - "risc0-zkvm", ] [[package]] name = "risc0-circuit-keccak" -version = "2.0.2" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d339c65b0e011677404bd6bdfe1b0f29748187a568fb2f74df7fb650590181a" +checksum = "5f195f865ac1afdc21a172d7756fdcc21be18e13eb01d78d3d7f2b128fa881ba" dependencies = [ "anyhow", "bytemuck", @@ -4661,9 +4604,9 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" -version = "2.0.2" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c6501fd3936aea2dd3e55915f34328fe96e6ca25ef00320242f837ae668785b" +checksum = "dca8f15c8abc0fd8c097aa7459879110334d191c63dd51d4c28881c4a497279e" dependencies = [ "anyhow", "bytemuck", @@ -4676,9 +4619,9 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" -version = "2.0.4" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c80e0a8f0f56106295bb682dbc27093438e163a5f6384a79e877ab895a11d9ae" +checksum = "ae1b0689f4a270a2f247b04397ebb431b8f64fe5170e98ee4f9d71bd04825205" dependencies = [ "anyhow", "bit-vec", @@ -4694,19 +4637,18 @@ dependencies = [ [[package]] name = "risc0-core" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317bbf70a8750b64d4fd7a2bdc9d7d5f30d8bb305cae486962c797ef35c8d08e" +checksum = "80f2723fedace48c6c5a505bd8f97ac4e1712bc4cb769083e10536d862b66987" dependencies = [ "bytemuck", - "bytemuck_derive", - "rand_core 0.6.4", + "rand_core 0.9.3", ] [[package]] name = "risc0-ethereum-contracts" -version = "2.2.0" -source = "git+https://github.com/risc0/risc0-ethereum?tag=v2.2.0#382d76a8040068243a5d13e3de50fcca4224b0d6" +version = "3.0.0" +source = "git+https://github.com/risc0/risc0-ethereum?tag=v3.0.0#32aa0b6f23ddd02dd93fc71717667606e5c7db86" dependencies = [ "alloy", "alloy-sol-types", @@ -4719,13 +4661,14 @@ dependencies = [ [[package]] name = "risc0-groth16" -version = "2.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b31cb7b2a46f0cdaf71803ea7e0389af9f5bc1aea2531106f2972b241f26e98" +checksum = "724285dc79604abfb2d40feaefe3e335420a6b293511661f77d6af62f1f5fae9" dependencies = [ "anyhow", "ark-bn254 0.5.0", "ark-ec 0.5.0", + "ark-ff 0.5.0", "ark-groth16", "ark-serialize 0.5.0", "bytemuck", @@ -4735,24 +4678,24 @@ dependencies = [ "risc0-binfmt", "risc0-zkp", "serde", - "stability", ] [[package]] name = "risc0-zkos-v1compat" -version = "2.0.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76c479b69d1987cb54ac72dcc017197296fdcd6daf78fafc10cbbd3a167a7de" +checksum = "840c2228803557a8b7dc035a8f196516b6fd68c9dc6ac092f0c86241b5b1bafb" dependencies = [ "include_bytes_aligned", "no_std_strings", + "risc0-zkvm-platform", ] [[package]] name = "risc0-zkp" -version = "2.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa210a232361fd671b30918469856b64d715f2564956d0a5df97ab6cb116d28b" +checksum = "ffb6bf356f469bb8744f72a07a37134c5812c1d55d6271bba80e87bdb7a58c8e" dependencies = [ "anyhow", "blake2", @@ -4764,7 +4707,7 @@ dependencies = [ "hex-literal", "metal", "paste", - "rand_core 0.6.4", + "rand_core 0.9.3", "risc0-core", "risc0-zkvm-platform", "serde", @@ -4775,9 +4718,9 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "2.1.0" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1014d2efcb3b359aff878c9aeb6aa949a6d91f091a2ffb5ffd8d928a1ab7f3" +checksum = "3fcce11648a9ff60b8e7af2f0ce7fbf8d25275ab6d414cc91b9da69ee75bc978" dependencies = [ "anyhow", "bincode", @@ -4786,7 +4729,6 @@ dependencies = [ "bytemuck", "bytes", "derive_more", - "getrandom 0.2.16", "hex", "lazy-regex", "prost 0.13.5", @@ -4812,15 +4754,17 @@ dependencies = [ [[package]] name = "risc0-zkvm-platform" -version = "2.0.3" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cae9cb2c2f6cab2dfa395ea6e2576713929040c7fb0c5f4150d13e1119d18686" +checksum = "cfaa10feba15828c788837ddde84b994393936d8f5715228627cfe8625122a40" dependencies = [ "bytemuck", "cfg-if", "getrandom 0.2.16", "getrandom 0.3.3", "libm", + "num_enum", + "paste", "stability", ] @@ -4844,6 +4788,26 @@ dependencies = [ "paste", ] +[[package]] +name = "rsa" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b" +dependencies = [ + "const-oid", + "digest 0.10.7", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "ruint" version = "1.15.0" @@ -4853,6 +4817,7 @@ dependencies = [ "alloy-rlp", "ark-ff 0.3.0", "ark-ff 0.4.2", + "borsh", "bytes", "fastrlp 0.3.1", "fastrlp 0.4.0", @@ -4987,13 +4952,17 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "rzup" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "400558bf12d4292a7804093b60a437ba8b0219ea7d53716b2c010a0d31e5f4a8" +checksum = "5d2aed296f203fa64bcb4b52069356dd86d6ec578593985b919b6995bee1f0ae" dependencies = [ + "hex", + "rsa", "semver 1.0.26", "serde", - "strum 0.26.3", + "serde_with", + "sha2", + "strum", "tempfile", "thiserror 2.0.12", "toml", @@ -5375,35 +5344,13 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "strum" -version = "0.26.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" -dependencies = [ - "strum_macros 0.26.4", -] - [[package]] name = "strum" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" dependencies = [ - "strum_macros 0.27.2", -] - -[[package]] -name = "strum_macros" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" -dependencies = [ - "heck 0.5.0", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.104", + "strum_macros", ] [[package]] @@ -5412,7 +5359,7 @@ version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn 2.0.104", @@ -6221,15 +6168,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" @@ -6257,21 +6195,6 @@ dependencies = [ "windows-targets 0.53.2", ] -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - [[package]] name = "windows-targets" version = "0.52.6" @@ -6304,12 +6227,6 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -6322,12 +6239,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" @@ -6340,12 +6251,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -6370,12 +6275,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" @@ -6388,12 +6287,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -6406,12 +6299,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" @@ -6424,12 +6311,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -6477,15 +6358,21 @@ dependencies = [ [[package]] name = "yaml-rust2" -version = "0.9.0" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a1a1c0bc9823338a3bdf8c61f994f23ac004c6fa32c08cd152984499b445e8d" +checksum = "2462ea039c445496d8793d052e13787f2b90e750b833afee748e601c17621ed9" dependencies = [ "arraydeque", "encoding_rs", "hashlink", ] +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + [[package]] name = "yoke" version = "0.8.0" diff --git a/crates/support/Cargo.toml b/crates/support/Cargo.toml index 598426257f..1df48edb4a 100644 --- a/crates/support/Cargo.toml +++ b/crates/support/Cargo.toml @@ -28,11 +28,11 @@ env_logger = "=0.11.8" hex = { version = "=0.4.3" } log = { version = "=0.4.27" } reqwest = { version = "=0.12.22", features = ["json"] } -risc0-build = { version = "=2.1.2", features = ["docker"] } -risc0-build-ethereum = { git = "https://github.com/risc0/risc0-ethereum", tag = "v2.2.0" } -risc0-ethereum-contracts = { git = "https://github.com/risc0/risc0-ethereum", tag = "v2.2.0" } -risc0-zkvm = { version = "=2.1.0" } -risc0-zkp = { version = "=2.0.1", default-features = false } +risc0-build = { version = "=3.0.3", features = ["docker"] } +risc0-build-ethereum = { git = "https://github.com/risc0/risc0-ethereum", tag = "v3.0.0" } +risc0-ethereum-contracts = { git = "https://github.com/risc0/risc0-ethereum", tag = "v3.0.0" } +risc0-zkvm = { version = "=3.0.3" } +risc0-zkp = { version = "=3.0.2", default-features = false } serde = { version = "=1.0.219", features = ["derive", "std"] } serde_json = "=1.0.141" fhe_rs = { package = "fhe", git = "https://github.com/gnosisguild/fhe.rs" } diff --git a/crates/support/Dockerfile b/crates/support/Dockerfile index 603509cf73..c624ff607f 100644 --- a/crates/support/Dockerfile +++ b/crates/support/Dockerfile @@ -1,6 +1,6 @@ ARG RUST_VERSION=1.86.0 -ARG RISC0_VERSION=2.1.0 -ARG RISC0_TOOLCHAIN=1.85.0 +ARG RISC0_VERSION=3.0.3 +ARG RISC0_TOOLCHAIN=1.88.0 ARG SKIP_SOLIDITY=0 FROM rust:${RUST_VERSION}-slim-bookworm AS base-dev diff --git a/crates/support/contracts/ImageID.sol b/crates/support/contracts/ImageID.sol index c479af11eb..192c94c9e6 100644 --- a/crates/support/contracts/ImageID.sol +++ b/crates/support/contracts/ImageID.sol @@ -1,9 +1,3 @@ -// 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. - // Copyright 2024 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,5 +19,5 @@ pragma solidity ^0.8.20; library ImageID { - bytes32 public constant PROGRAM_ID = bytes32(0x915f4f08e9ebdecd75618d7bd902f04612f901840717693a7aea756a91ccb0d2); + bytes32 public constant PROGRAM_ID = bytes32(0x281708e32ec4018495d0efb9e6c5e36c238927c23afc9743fd4f20c67f47b489); } diff --git a/crates/support/host/src/lib.rs b/crates/support/host/src/lib.rs index c53b116b81..b63c2e0dfd 100644 --- a/crates/support/host/src/lib.rs +++ b/crates/support/host/src/lib.rs @@ -53,12 +53,16 @@ impl ComputeProvider for Risc0Provider { let decoded_journal = receipt.journal.decode().unwrap(); - let seal = if !std::env::var("RISC0_DEV_MODE") - .unwrap_or_default() - .is_empty() - { + // Check if RISC0_DEV_MODE is set to "1" (dev mode) + // If dev mode: return empty seal (fake proof) + // Otherwise: return real groth16 proof + let is_dev_mode = std::env::var("RISC0_DEV_MODE").unwrap_or_default() == "1"; + + let seal = if is_dev_mode { + println!("RISC0_DEV_MODE=1: Using fake proof (empty seal)"); vec![] } else { + println!("RISC0_DEV_MODE=0 or unset: Generating real Groth16 proof"); groth16::encode(receipt.inner.groth16().unwrap().seal.clone()).unwrap() }; diff --git a/crates/support/methods/guest/Cargo.lock b/crates/support/methods/guest/Cargo.lock index e076d523c0..f59647c03c 100644 --- a/crates/support/methods/guest/Cargo.lock +++ b/crates/support/methods/guest/Cargo.lock @@ -1737,6 +1737,27 @@ dependencies = [ "libm", ] +[[package]] +name = "num_enum" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "objc" version = "0.2.7" @@ -2163,18 +2184,21 @@ dependencies = [ [[package]] name = "risc0-binfmt" -version = "2.0.2" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62eb7025356a233c1bc267c458a2ce56fcfc89b136d813c8a77be14ef1eaf2b1" +checksum = "1c8f97f81bcdead4101bca06469ecef481a2695cd04e7e877b49dea56a7f6f2a" dependencies = [ "anyhow", "borsh", + "bytemuck", "derive_more", "elf", "lazy_static", "postcard", + "rand 0.9.2", "risc0-zkp", "risc0-zkvm-platform", + "ruint", "semver 1.0.26", "serde", "tracing", @@ -2182,9 +2206,9 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak" -version = "2.0.2" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d339c65b0e011677404bd6bdfe1b0f29748187a568fb2f74df7fb650590181a" +checksum = "5f195f865ac1afdc21a172d7756fdcc21be18e13eb01d78d3d7f2b128fa881ba" dependencies = [ "anyhow", "bytemuck", @@ -2198,9 +2222,9 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" -version = "2.0.2" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c6501fd3936aea2dd3e55915f34328fe96e6ca25ef00320242f837ae668785b" +checksum = "dca8f15c8abc0fd8c097aa7459879110334d191c63dd51d4c28881c4a497279e" dependencies = [ "anyhow", "bytemuck", @@ -2213,9 +2237,9 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" -version = "2.0.4" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c80e0a8f0f56106295bb682dbc27093438e163a5f6384a79e877ab895a11d9ae" +checksum = "ae1b0689f4a270a2f247b04397ebb431b8f64fe5170e98ee4f9d71bd04825205" dependencies = [ "anyhow", "bit-vec", @@ -2231,24 +2255,24 @@ dependencies = [ [[package]] name = "risc0-core" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317bbf70a8750b64d4fd7a2bdc9d7d5f30d8bb305cae486962c797ef35c8d08e" +checksum = "80f2723fedace48c6c5a505bd8f97ac4e1712bc4cb769083e10536d862b66987" dependencies = [ "bytemuck", - "bytemuck_derive", - "rand_core 0.6.4", + "rand_core 0.9.3", ] [[package]] name = "risc0-groth16" -version = "2.0.2" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cf5d0b673d5fc67a89147c2e9c53134707dcc8137a43d1ef06b4ff68e99b74f" +checksum = "724285dc79604abfb2d40feaefe3e335420a6b293511661f77d6af62f1f5fae9" dependencies = [ "anyhow", "ark-bn254 0.5.0", "ark-ec 0.5.0", + "ark-ff 0.5.0", "ark-groth16", "ark-serialize 0.5.0", "bytemuck", @@ -2258,24 +2282,24 @@ dependencies = [ "risc0-binfmt", "risc0-zkp", "serde", - "stability", ] [[package]] name = "risc0-zkos-v1compat" -version = "2.0.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76c479b69d1987cb54ac72dcc017197296fdcd6daf78fafc10cbbd3a167a7de" +checksum = "840c2228803557a8b7dc035a8f196516b6fd68c9dc6ac092f0c86241b5b1bafb" dependencies = [ "include_bytes_aligned", "no_std_strings", + "risc0-zkvm-platform", ] [[package]] name = "risc0-zkp" -version = "2.0.2" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a287e9cd6d7b3b38eeb49c62090c46a1935922309fbd997a9143ed8c43c8f3cb" +checksum = "ffb6bf356f469bb8744f72a07a37134c5812c1d55d6271bba80e87bdb7a58c8e" dependencies = [ "anyhow", "blake2", @@ -2287,7 +2311,7 @@ dependencies = [ "hex-literal", "metal", "paste", - "rand_core 0.6.4", + "rand_core 0.9.3", "risc0-core", "risc0-zkvm-platform", "serde", @@ -2298,15 +2322,14 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "2.1.0" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1014d2efcb3b359aff878c9aeb6aa949a6d91f091a2ffb5ffd8d928a1ab7f3" +checksum = "3fcce11648a9ff60b8e7af2f0ce7fbf8d25275ab6d414cc91b9da69ee75bc978" dependencies = [ "anyhow", "borsh", "bytemuck", "derive_more", - "getrandom 0.2.16", "hex", "risc0-binfmt", "risc0-circuit-keccak", @@ -2327,15 +2350,17 @@ dependencies = [ [[package]] name = "risc0-zkvm-platform" -version = "2.0.3" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cae9cb2c2f6cab2dfa395ea6e2576713929040c7fb0c5f4150d13e1119d18686" +checksum = "cfaa10feba15828c788837ddde84b994393936d8f5715228627cfe8625122a40" dependencies = [ "bytemuck", "cfg-if", "getrandom 0.2.16", "getrandom 0.3.3", "libm", + "num_enum", + "paste", "stability", ] @@ -2368,6 +2393,7 @@ dependencies = [ "alloy-rlp", "ark-ff 0.3.0", "ark-ff 0.4.2", + "borsh", "bytes", "fastrlp 0.3.1", "fastrlp 0.4.0", diff --git a/crates/support/methods/guest/Cargo.toml b/crates/support/methods/guest/Cargo.toml index a8ffa0d28f..c3487c16e3 100644 --- a/crates/support/methods/guest/Cargo.toml +++ b/crates/support/methods/guest/Cargo.toml @@ -14,7 +14,7 @@ path = "src/bin/program.rs" [dependencies] alloy-primitives = { version = "=1.3.0", default-features = false, features = ["rlp", "serde", "std"] } alloy-sol-types = "=1.3.0" -risc0-zkvm = { version = "=2.1.0", default-features = false, features = ['std'] } +risc0-zkvm = { version = "=3.0.3", default-features = false, features = ['std'] } e3-compute-provider = { git = "https://github.com/gnosisguild/enclave", rev = "2ca0aa5f47dd962add5d1d0f74900d9bceb957e5" } e3-user-program = { path = "../../program" } bincode = "=1.3.3" diff --git a/crates/support/tests/Elf.sol b/crates/support/tests/Elf.sol index 99342844b7..4647a56f75 100644 --- a/crates/support/tests/Elf.sol +++ b/crates/support/tests/Elf.sol @@ -1,9 +1,3 @@ -// 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. - // Copyright 2024 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/examples/CRISP/.gitignore b/examples/CRISP/.gitignore index 52fddf399e..d79ca3535e 100644 --- a/examples/CRISP/.gitignore +++ b/examples/CRISP/.gitignore @@ -46,4 +46,5 @@ playwright-report/ .cache-synpress/ .enclave/data/ .enclave/config/ +.enclave/caches/ cache_hardhat/ \ No newline at end of file diff --git a/examples/CRISP/Cargo.lock b/examples/CRISP/Cargo.lock index 5dfa56b307..eb414a7d56 100644 --- a/examples/CRISP/Cargo.lock +++ b/examples/CRISP/Cargo.lock @@ -1850,7 +1850,7 @@ dependencies = [ "config", "dialoguer", "dotenvy", - "e3-compute-provider 0.1.3", + "e3-compute-provider 0.1.4", "e3-sdk", "env_logger", "eyre", @@ -2151,7 +2151,7 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "e3-bfv-helpers" -version = "0.1.3" +version = "0.1.4" dependencies = [ "alloy-dyn-abi", "alloy-primitives", @@ -2184,7 +2184,7 @@ dependencies = [ [[package]] name = "e3-compute-provider" -version = "0.1.3" +version = "0.1.4" dependencies = [ "ark-bn254", "ark-ff 0.4.2", @@ -2200,7 +2200,7 @@ dependencies = [ [[package]] name = "e3-evm-helpers" -version = "0.1.3" +version = "0.1.4" dependencies = [ "alloy", "async-trait", @@ -2244,7 +2244,7 @@ dependencies = [ [[package]] name = "e3-indexer" -version = "0.1.3" +version = "0.1.4" dependencies = [ "alloy", "async-trait", @@ -2273,7 +2273,7 @@ dependencies = [ [[package]] name = "e3-sdk" -version = "0.1.3" +version = "0.1.4" dependencies = [ "e3-bfv-helpers", "e3-evm-helpers", diff --git a/examples/CRISP/Cargo.toml b/examples/CRISP/Cargo.toml index b8db39d7c8..5abfdc76c7 100644 --- a/examples/CRISP/Cargo.toml +++ b/examples/CRISP/Cargo.toml @@ -30,11 +30,6 @@ env_logger = "=0.11.8" hex = { version = "=0.4.3" } log = { version = "=0.4.27" } reqwest = { version = "=0.12.22", features = ["json"] } -risc0-build = { version = "=2.2.0", features = ["docker"] } -risc0-build-ethereum = { git = "https://github.com/risc0/risc0-ethereum", tag = "v2.2.0" } -risc0-ethereum-contracts = { git = "https://github.com/risc0/risc0-ethereum", tag = "v2.2.0" } -risc0-zkvm = { version = "=2.2.0" } -risc0-zkp = { version = "=2.0.2", default-features = false } serde = { version = "=1.0.219", features = ["derive", "std"] } serde_json = "=1.0.141" fhe_rs = { package = "fhe", git = "https://github.com/gnosisguild/fhe.rs" } diff --git a/examples/CRISP/client/.env.example b/examples/CRISP/client/.env.example index 6d6aac6760..9296e8aa99 100644 --- a/examples/CRISP/client/.env.example +++ b/examples/CRISP/client/.env.example @@ -1,5 +1,5 @@ VITE_ENCLAVE_API=http://127.0.0.1:4000 VITE_TWITTER_SERVERLESS_API= VITE_WALLETCONNECT_PROJECT_ID= -VITE_E3_PROGRAM_ADDRESS=0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1 # Default E3 program address from anvil +VITE_E3_PROGRAM_ADDRESS=0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44 # Default E3 program address from anvil VITE_SEMAPHORE_ADDRESS=0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE diff --git a/examples/CRISP/contracts/CRISPInputValidatorFactory.sol b/examples/CRISP/contracts/CRISPInputValidatorFactory.sol index e578127eaf..7c5350fe51 100644 --- a/examples/CRISP/contracts/CRISPInputValidatorFactory.sol +++ b/examples/CRISP/contracts/CRISPInputValidatorFactory.sol @@ -12,7 +12,7 @@ import {CRISPInputValidator} from "./CRISPInputValidator.sol"; /// @notice Factory for deploying minimal proxy instances of CRISPInputValidator. contract CRISPInputValidatorFactory is Factory { /// @notice Initializes the factory with the CRISPInputValidator implementation. - constructor() Factory(address(new CRISPInputValidator())) {} + constructor(address inputValidator) Factory(inputValidator) {} /// @notice Deploys a new CRISPInputValidator clone. /// @param _policyAddr Address of the associated policy contract. diff --git a/examples/CRISP/contracts/ImageID.sol b/examples/CRISP/contracts/ImageID.sol index bf721522bf..43853038a2 100755 --- a/examples/CRISP/contracts/ImageID.sol +++ b/examples/CRISP/contracts/ImageID.sol @@ -19,5 +19,8 @@ pragma solidity ^0.8.20; library ImageID { - bytes32 public constant VOTING_ID = bytes32(0xd7e78dcd9985618f010fc6608a62858e09f308fdc18219b72a543219b04e4173); + bytes32 public constant PROGRAM_ID = + bytes32( + 0x281708e32ec4018495d0efb9e6c5e36c238927c23afc9743fd4f20c67f47b489 + ); } diff --git a/examples/CRISP/contracts/Mocks/MockCRISPInputValidator.sol b/examples/CRISP/contracts/Mocks/MockCRISPInputValidator.sol new file mode 100644 index 0000000000..8f7bf67077 --- /dev/null +++ b/examples/CRISP/contracts/Mocks/MockCRISPInputValidator.sol @@ -0,0 +1,49 @@ +// 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. +pragma solidity >=0.8.27; + +import {IInputValidator} from "@enclave-e3/contracts/contracts/interfaces/IInputValidator.sol"; +import {IBasePolicy} from "@excubiae/contracts/interfaces/IBasePolicy.sol"; +import {Clone} from "@excubiae/contracts/proxy/Clone.sol"; +import {IVerifier} from "../CRISPVerifier.sol"; + +/// @title MockCRISPInputValidator. +/// @notice Mock Enclave Input Validator +contract MockCRISPInputValidator is IInputValidator, Clone { + /// @notice The policy that will be used to validate the input. + IBasePolicy internal policy; + + /// @notice The verifier that will be used to validate the input. + IVerifier internal noirVerifier; + + /// @notice The error emitted when the input data is empty. + error EmptyInputData(); + /// @notice The error emitted when the input data is invalid. + error InvalidInputData(bytes reason); + /// @notice The error emitted when the Noir proof is invalid. + error InvalidNoirProof(); + + /// @notice Initializes the contract with appended bytes data for configuration. + function _initialize() internal virtual override(Clone) { + super._initialize(); + + (address policyAddr, address verifierAddr) = abi.decode(_getAppendedBytes(), (address, address)); + policy = IBasePolicy(policyAddr); + noirVerifier = IVerifier(verifierAddr); + } + + /// @notice Validates input + /// @param sender The account that is submitting the input. + /// @param data The input to be verified. + /// @return input The decoded, policy-approved application payload. + function validate(address sender, bytes memory data) external returns (bytes memory input) { + if (data.length == 0) revert EmptyInputData(); + + (,,, bytes memory vote) = abi.decode(data, (bytes, bytes, bytes32[], bytes)); + + input = vote; + } +} diff --git a/examples/CRISP/deploy/Deploy.s.sol b/examples/CRISP/deploy/Deploy.s.sol index 7dc1dff08f..b9da39c3d1 100644 --- a/examples/CRISP/deploy/Deploy.s.sol +++ b/examples/CRISP/deploy/Deploy.s.sol @@ -32,6 +32,8 @@ import {IE3Program} from "@enclave-e3/contracts/contracts/interfaces/IE3Program. import {IEnclave} from "@enclave-e3/contracts/contracts/interfaces/IEnclave.sol"; import {CRISPCheckerFactory} from "../contracts/CRISPCheckerFactory.sol"; import {CRISPPolicyFactory} from "../contracts/CRISPPolicyFactory.sol"; +import {CRISPInputValidator} from "../contracts/CRISPInputValidator.sol"; +import {MockCRISPInputValidator} from "../contracts/Mocks/MockCRISPInputValidator.sol"; import {CRISPInputValidatorFactory} from "../contracts/CRISPInputValidatorFactory.sol"; import {HonkVerifier} from "../contracts/CRISPVerifier.sol"; import {MockRISC0Verifier} from "../contracts/Mocks/MockRISC0Verifier.sol"; @@ -179,7 +181,21 @@ contract CRISPProgramDeploy is Script { CRISPPolicyFactory policyFactory = new CRISPPolicyFactory(); console2.log("Deployed CRISPPolicyFactory to", address(policyFactory)); - CRISPInputValidatorFactory inputValidatorFactory = new CRISPInputValidatorFactory(); + bool useMockIV = vm.envOr("USE_MOCK_INPUT_VALIDATOR", false); + address inputValidatorAddress; + if (useMockIV) { + console2.log("Using MockCRISPInputValidator"); + inputValidatorAddress = address(new MockCRISPInputValidator()); + } else { + console2.log("Using CRISPInputValidator"); + inputValidatorAddress = address(new CRISPInputValidator()); + } + + console2.log("Deployed InputValidator to: ", inputValidatorAddress); + + CRISPInputValidatorFactory inputValidatorFactory = new CRISPInputValidatorFactory( + inputValidatorAddress + ); console2.log( "Deployed CRISPInputValidatorFactory to", address(inputValidatorFactory) @@ -196,7 +212,7 @@ contract CRISPProgramDeploy is Script { policyFactory, inputValidatorFactory, honkVerifier, - ImageID.VOTING_ID + ImageID.PROGRAM_ID ); console2.log("Deployed CRISPProgram to", address(crisp)); diff --git a/examples/CRISP/enclave.config.yaml b/examples/CRISP/enclave.config.yaml index 611cd14fc1..fe4b5321c3 100644 --- a/examples/CRISP/enclave.config.yaml +++ b/examples/CRISP/enclave.config.yaml @@ -5,14 +5,14 @@ chains: enclave: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" ciphernode_registry: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9" filter_registry: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" - + program: dev: true # risc0: - # risc0_dev_mode: 1 + # risc0_dev_mode: 1 # 0 = real groth16 proofs, 1 = fake proofs (dev mode) # bonsai_api_key: xxxxxxxxxxxxxxxx # bonsai_api_url: xxxxxxxxxxxxxxxx - + nodes: cn1: address: "0xbDA5747bFD65F08deb54cb465eB87D40e51B197E" diff --git a/examples/CRISP/lib/risc0-ethereum b/examples/CRISP/lib/risc0-ethereum index c09ee29b38..32aa0b6f23 160000 --- a/examples/CRISP/lib/risc0-ethereum +++ b/examples/CRISP/lib/risc0-ethereum @@ -1 +1 @@ -Subproject commit c09ee29b386d2b1486724509868d1115db36929f +Subproject commit 32aa0b6f23ddd02dd93fc71717667606e5c7db86 diff --git a/examples/CRISP/server/.env.example b/examples/CRISP/server/.env.example index e25bfab57f..5275eeb47d 100644 --- a/examples/CRISP/server/.env.example +++ b/examples/CRISP/server/.env.example @@ -13,7 +13,7 @@ CRON_API_KEY=1234567890 ENCLAVE_ADDRESS="0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" CIPHERNODE_REGISTRY_ADDRESS="0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9" NAIVE_REGISTRY_FILTER_ADDRESS="0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" -E3_PROGRAM_ADDRESS="0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1" # CRISPProgram Contract Address +E3_PROGRAM_ADDRESS="0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44" # CRISPProgram Contract Address # E3 Config E3_WINDOW_SIZE=40 diff --git a/examples/CRISP/server/src/cli/commands.rs b/examples/CRISP/server/src/cli/commands.rs index 2abbf7fd64..928ca44423 100644 --- a/examples/CRISP/server/src/cli/commands.rs +++ b/examples/CRISP/server/src/cli/commands.rs @@ -10,9 +10,9 @@ use log::info; use reqwest::Client; use serde::{Deserialize, Serialize}; -use super::{CLI_DB}; +use super::CLI_DB; use alloy::primitives::{Address, Bytes, U256}; -use crisp::config::CONFIG; +use crisp::config::CONFIG; use e3_sdk::bfv_helpers::{build_bfv_params_arc, encode_bfv_params, params::SET_2048_1032193_1}; use e3_sdk::evm_helpers::contracts::{EnclaveContract, EnclaveRead, EnclaveWrite}; use fhe_rs::bfv::{BfvParameters, Ciphertext, Encoding, Plaintext, PublicKey, SecretKey}; @@ -209,6 +209,8 @@ pub async fn decrypt_and_publish_result( let votes = Vec::::try_decode(&pt, Encoding::poly())?[0]; info!("Vote count: {:?}", votes); + let proof = Bytes::from(vec![0]); + let contract = EnclaveContract::new( &CONFIG.http_rpc_url, &CONFIG.private_key, @@ -216,7 +218,11 @@ pub async fn decrypt_and_publish_result( ) .await?; let res = contract - .publish_plaintext_output(U256::from(input_crisp_id), Bytes::from(votes.to_be_bytes())) + .publish_plaintext_output( + U256::from(input_crisp_id), + Bytes::from(votes.to_be_bytes()), + proof, + ) .await?; info!("Vote broadcast. TxHash: {:?}", res.transaction_hash); 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 63ec1552b3..6fcabb0550 100644 --- a/packages/enclave-contracts/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/ICiphernodeRegistry.json +++ b/packages/enclave-contracts/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/ICiphernodeRegistry.json @@ -219,5 +219,5 @@ "deployedLinkReferences": {}, "immutableReferences": {}, "inputSourceName": "project/contracts/interfaces/ICiphernodeRegistry.sol", - "buildInfoId": "solc-0_8_27-8287ebf5be05227965814498ddef24fc9009e2f0" + "buildInfoId": "solc-0_8_27-9aea5e3f6e25811e781e96c22e8edaf1eb1a01c5" } \ 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 524089c238..7af0578553 100644 --- a/packages/enclave-contracts/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.json +++ b/packages/enclave-contracts/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.json @@ -704,5 +704,5 @@ "deployedLinkReferences": {}, "immutableReferences": {}, "inputSourceName": "project/contracts/interfaces/IEnclave.sol", - "buildInfoId": "solc-0_8_27-8287ebf5be05227965814498ddef24fc9009e2f0" -} \ No newline at end of file + "buildInfoId": "solc-0_8_27-9aea5e3f6e25811e781e96c22e8edaf1eb1a01c5" +} diff --git a/packages/enclave-contracts/artifacts/contracts/registry/NaiveRegistryFilter.sol/NaiveRegistryFilter.json b/packages/enclave-contracts/artifacts/contracts/registry/NaiveRegistryFilter.sol/NaiveRegistryFilter.json index e41dbde5d7..88b78ae36f 100644 --- a/packages/enclave-contracts/artifacts/contracts/registry/NaiveRegistryFilter.sol/NaiveRegistryFilter.json +++ b/packages/enclave-contracts/artifacts/contracts/registry/NaiveRegistryFilter.sol/NaiveRegistryFilter.json @@ -305,5 +305,5 @@ "deployedLinkReferences": {}, "immutableReferences": {}, "inputSourceName": "project/contracts/registry/NaiveRegistryFilter.sol", - "buildInfoId": "solc-0_8_27-e09265851ba98e1f1077468e6dbf08ff116b5fb9" -} + "buildInfoId": "solc-0_8_27-9aea5e3f6e25811e781e96c22e8edaf1eb1a01c5" +} \ No newline at end of file diff --git a/packages/enclave-contracts/contracts/interfaces/IEnclave.sol b/packages/enclave-contracts/contracts/interfaces/IEnclave.sol index 7f3feeb8ff..f00cdbae88 100644 --- a/packages/enclave-contracts/contracts/interfaces/IEnclave.sol +++ b/packages/enclave-contracts/contracts/interfaces/IEnclave.sol @@ -138,7 +138,7 @@ interface IEnclave { /// @return success True if the E3 was successfully activated. function activate( uint256 e3Id, - bytes memory publicKey + bytes calldata publicKey ) external returns (bool success); /// @notice This function should be called to publish input data for Encrypted Execution Environment (E3). @@ -160,8 +160,8 @@ interface IEnclave { /// @return success True if the output was successfully published. function publishCiphertextOutput( uint256 e3Id, - bytes memory ciphertextOutput, - bytes memory proof + bytes calldata ciphertextOutput, + bytes calldata proof ) external returns (bool success); /// @notice This function publishes the plaintext output of an Encrypted Execution Environment (E3). @@ -172,8 +172,8 @@ interface IEnclave { /// @param proof ABI encoded data to verify the plaintextOutput. function publishPlaintextOutput( uint256 e3Id, - bytes memory plaintextOutput, - bytes memory proof + bytes calldata plaintextOutput, + bytes calldata proof ) external returns (bool success); //////////////////////////////////////////////////////////// diff --git a/packages/enclave-contracts/scripts/deployEnclave.ts b/packages/enclave-contracts/scripts/deployEnclave.ts index de9d52c166..ead1aea1b6 100644 --- a/packages/enclave-contracts/scripts/deployEnclave.ts +++ b/packages/enclave-contracts/scripts/deployEnclave.ts @@ -42,8 +42,6 @@ export const deployEnclave = async (withMocks?: boolean) => { const enclaveAddress = await enclave.getAddress(); - console.log("Enclave deployed to: ", enclaveAddress); - const { ciphernodeRegistry } = await deployAndSaveCiphernodeRegistryOwnable({ enclaveAddress: enclaveAddress, owner: ownerAddress, @@ -52,8 +50,6 @@ export const deployEnclave = async (withMocks?: boolean) => { const ciphernodeRegistryAddress = await ciphernodeRegistry.getAddress(); - console.log("CiphernodeRegistry deployed to: ", ciphernodeRegistryAddress); - const { naiveRegistryFilter } = await deployAndSaveNaiveRegistryFilter({ ciphernodeRegistryAddress: ciphernodeRegistryAddress, owner: ownerAddress, @@ -62,8 +58,6 @@ export const deployEnclave = async (withMocks?: boolean) => { const naiveRegistryFilterAddress = await naiveRegistryFilter.getAddress(); - console.log("NaiveRegistryFilter deployed to: ", naiveRegistryFilterAddress); - const registryAddress = await enclave.ciphernodeRegistry(); if (registryAddress === ciphernodeRegistryAddress) { @@ -75,6 +69,14 @@ export const deployEnclave = async (withMocks?: boolean) => { console.log(`Enclave contract updated with registry`); } + console.log(` + Deployments: + ---------------------------------------------------------------------- + Enclave: ${enclaveAddress} + CiphernodeRegistry: ${ciphernodeRegistryAddress} + NaiveRegistryFilter: ${naiveRegistryFilterAddress} + `); + // Deploy mocks only if specified const shouldDeployMocks = process.env.DEPLOY_MOCKS === "true" || withMocks; diff --git a/templates/default/enclave.config.yaml b/templates/default/enclave.config.yaml index 20a95d91b4..127927a8b4 100644 --- a/templates/default/enclave.config.yaml +++ b/templates/default/enclave.config.yaml @@ -10,7 +10,7 @@ chains: program: dev: true # risc0: - # risc0_dev_mode: 1 + # risc0_dev_mode: 1 # 0 = real groth16 proofs, 1 = fake proofs (dev mode) # bonsai_api_key: xxxxxxxxxxxxxxxx # bonsai_api_url: xxxxxxxxxxxxxxxx