diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index e610daf7..6843de34 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -37,11 +37,11 @@ jobs: - name: Run Benchmark Tests run: | - cd kzg_prover + cd prover cargo bench - name: Upload Benchmark Results uses: actions/upload-artifact@v2 with: name: benchmark-results - path: kzg_prover/target/criterion + path: prover/target/criterion diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7bec7e8e..4dd38496 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -48,7 +48,7 @@ jobs: - name: Test KZG Prover run: | - cd kzg_prover + cd prover cargo test --release -- --nocapture - name: Install Foundry diff --git a/README.md b/README.md index 112dc7eb..a1b4a1d5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A monorepo for Summa, zk proof of solvency protocol ### Subdirectories -- `kzg_prover`: Halo2 based zk prover and KZG polynomial interpolation for Summa +- `prover`: Halo2 based zk prover and KZG polynomial interpolation for Summa - `contracts`: Solidity smart contracts for Summa - `backend` : Rust API to interact with Summa diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 1f4fa877..b6b902e0 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -summa-solvency = { path = "../kzg_prover" } +summa-solvency = { path = "../prover" } halo2_proofs = { git = "https://github.com/summa-dev/halo2"} csv = "1.2.2" futures = "0.3.28" diff --git a/backend/README.md b/backend/README.md index 1bb4075c..59905f15 100644 --- a/backend/README.md +++ b/backend/README.md @@ -50,7 +50,7 @@ cargo test --release -- --nocapture ### Generating and updating verifier contract for Backend -The verifier contract in the backend were generated using a predefined set of parameters: `N_CURRENCIES = 2`, `N_USERS = 16` and `K = 17` as indicated [here](../kzg_prover/bin/gen_verifier.rs#L26-L28) +The verifier contract in the backend were generated using a predefined set of parameters: `N_CURRENCIES = 2`, `N_USERS = 16` and `K = 17` as indicated [here](../prover/bin/gen_verifier.rs#L26-L28) If you intend to work with different parameters, you'll need to adjust these hard-coded values and then generate new verifier contract. The process described below assists in both generating the verifier and updating the Summa contract, which integrates the new verifier as constructors. diff --git a/backend/scripts/update_verifier_contract.sh b/backend/scripts/update_verifier_contract.sh index 9cd61f0e..91a70a93 100755 --- a/backend/scripts/update_verifier_contract.sh +++ b/backend/scripts/update_verifier_contract.sh @@ -3,12 +3,12 @@ set -e # Build the verifier contract echo "1. Building verifier contracts" -cd ../kzg_prover +cd ../prover cargo run --release --bin generate_verifier # Generate Commitment and Proofs for Encoded Polynomials echo "2. Generate Commitment and Proofs for Encoded Polynomials" -cd ../kzg_prover +cd ../prover cargo run --release --bin generate_commitment_and_proofs # Deploy contracts to local environment diff --git a/backend/src/contracts/generated/grandsum_verifier.rs b/backend/src/contracts/generated/grandsum_verifier.rs index 59faa68d..8b6f7014 100644 --- a/backend/src/contracts/generated/grandsum_verifier.rs +++ b/backend/src/contracts/generated/grandsum_verifier.rs @@ -7,16 +7,18 @@ pub use grand_sum_verifier::*; clippy::upper_case_acronyms, clippy::type_complexity, dead_code, - non_camel_case_types + non_camel_case_types, )] pub mod grand_sum_verifier { #[rustfmt::skip] const __ABI: &str = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vk\",\"type\":\"address\",\"components\":[]},{\"internalType\":\"bytes\",\"name\":\"proof\",\"type\":\"bytes\",\"components\":[]},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\",\"components\":[]}],\"stateMutability\":\"nonpayable\",\"type\":\"function\",\"name\":\"verifyProof\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\",\"components\":[]}]}]"; ///The parsed JSON ABI of the contract. - pub static GRANDSUMVERIFIER_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = - ::ethers::contract::Lazy::new(|| { - ::ethers::core::utils::__serde_json::from_str(__ABI).expect("ABI is always valid") - }); + pub static GRANDSUMVERIFIER_ABI: ::ethers::contract::Lazy< + ::ethers::core::abi::Abi, + > = ::ethers::contract::Lazy::new(|| { + ::ethers::core::utils::__serde_json::from_str(__ABI) + .expect("ABI is always valid") + }); #[rustfmt::skip] const __BYTECODE: &[u8] = &[ 96, @@ -1331,8 +1333,9 @@ pub mod grand_sum_verifier { 51, ]; ///The bytecode of the contract. - pub static GRANDSUMVERIFIER_BYTECODE: ::ethers::core::types::Bytes = - ::ethers::core::types::Bytes::from_static(__BYTECODE); + pub static GRANDSUMVERIFIER_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static( + __BYTECODE, + ); #[rustfmt::skip] const __DEPLOYED_BYTECODE: &[u8] = &[ 96, @@ -2615,8 +2618,9 @@ pub mod grand_sum_verifier { 51, ]; ///The deployed bytecode of the contract. - pub static GRANDSUMVERIFIER_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes = - ::ethers::core::types::Bytes::from_static(__DEPLOYED_BYTECODE); + pub static GRANDSUMVERIFIER_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static( + __DEPLOYED_BYTECODE, + ); pub struct GrandSumVerifier(::ethers::contract::Contract); impl ::core::clone::Clone for GrandSumVerifier { fn clone(&self) -> Self { @@ -2636,9 +2640,7 @@ pub mod grand_sum_verifier { } impl ::core::fmt::Debug for GrandSumVerifier { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_tuple(stringify!(GrandSumVerifier)) - .field(&self.address()) - .finish() + f.debug_tuple(stringify!(GrandSumVerifier)).field(&self.address()).finish() } } impl GrandSumVerifier { @@ -2648,11 +2650,13 @@ pub mod grand_sum_verifier { address: T, client: ::std::sync::Arc, ) -> Self { - Self(::ethers::contract::Contract::new( - address.into(), - GRANDSUMVERIFIER_ABI.clone(), - client, - )) + Self( + ::ethers::contract::Contract::new( + address.into(), + GRANDSUMVERIFIER_ABI.clone(), + client, + ), + ) } /// Constructs the general purpose `Deployer` instance based on the provided constructor arguments and sends it. /// Returns a new instance of a deployer that returns an instance of this contract after sending the transaction @@ -2706,8 +2710,7 @@ pub mod grand_sum_verifier { } } impl From<::ethers::contract::Contract> - for GrandSumVerifier - { + for GrandSumVerifier { fn from(contract: ::ethers::contract::Contract) -> Self { Self::new(contract.address(), contract.client()) } @@ -2721,7 +2724,7 @@ pub mod grand_sum_verifier { Debug, PartialEq, Eq, - Hash, + Hash )] #[ethcall(name = "verifyProof", abi = "verifyProof(address,bytes,uint256[])")] pub struct VerifyProofCall { @@ -2738,7 +2741,7 @@ pub mod grand_sum_verifier { Debug, PartialEq, Eq, - Hash, + Hash )] pub struct VerifyProofReturn(pub bool); } diff --git a/backend/src/contracts/generated/inclusion_verifier.rs b/backend/src/contracts/generated/inclusion_verifier.rs index a06a1bd1..32ad6740 100644 --- a/backend/src/contracts/generated/inclusion_verifier.rs +++ b/backend/src/contracts/generated/inclusion_verifier.rs @@ -7,16 +7,18 @@ pub use inclusion_verifier::*; clippy::upper_case_acronyms, clippy::type_complexity, dead_code, - non_camel_case_types + non_camel_case_types, )] pub mod inclusion_verifier { #[rustfmt::skip] const __ABI: &str = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vk\",\"type\":\"address\",\"components\":[]},{\"internalType\":\"bytes\",\"name\":\"proofs\",\"type\":\"bytes\",\"components\":[]},{\"internalType\":\"uint256[]\",\"name\":\"challenges\",\"type\":\"uint256[]\",\"components\":[]},{\"internalType\":\"uint256[]\",\"name\":\"values\",\"type\":\"uint256[]\",\"components\":[]}],\"stateMutability\":\"view\",\"type\":\"function\",\"name\":\"verifyProof\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\",\"components\":[]}]}]"; ///The parsed JSON ABI of the contract. - pub static INCLUSIONVERIFIER_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = - ::ethers::contract::Lazy::new(|| { - ::ethers::core::utils::__serde_json::from_str(__ABI).expect("ABI is always valid") - }); + pub static INCLUSIONVERIFIER_ABI: ::ethers::contract::Lazy< + ::ethers::core::abi::Abi, + > = ::ethers::contract::Lazy::new(|| { + ::ethers::core::utils::__serde_json::from_str(__ABI) + .expect("ABI is always valid") + }); #[rustfmt::skip] const __BYTECODE: &[u8] = &[ 96, @@ -1166,8 +1168,9 @@ pub mod inclusion_verifier { 51, ]; ///The bytecode of the contract. - pub static INCLUSIONVERIFIER_BYTECODE: ::ethers::core::types::Bytes = - ::ethers::core::types::Bytes::from_static(__BYTECODE); + pub static INCLUSIONVERIFIER_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static( + __BYTECODE, + ); #[rustfmt::skip] const __DEPLOYED_BYTECODE: &[u8] = &[ 96, @@ -2285,8 +2288,9 @@ pub mod inclusion_verifier { 51, ]; ///The deployed bytecode of the contract. - pub static INCLUSIONVERIFIER_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes = - ::ethers::core::types::Bytes::from_static(__DEPLOYED_BYTECODE); + pub static INCLUSIONVERIFIER_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static( + __DEPLOYED_BYTECODE, + ); pub struct InclusionVerifier(::ethers::contract::Contract); impl ::core::clone::Clone for InclusionVerifier { fn clone(&self) -> Self { @@ -2306,9 +2310,7 @@ pub mod inclusion_verifier { } impl ::core::fmt::Debug for InclusionVerifier { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_tuple(stringify!(InclusionVerifier)) - .field(&self.address()) - .finish() + f.debug_tuple(stringify!(InclusionVerifier)).field(&self.address()).finish() } } impl InclusionVerifier { @@ -2318,11 +2320,13 @@ pub mod inclusion_verifier { address: T, client: ::std::sync::Arc, ) -> Self { - Self(::ethers::contract::Contract::new( - address.into(), - INCLUSIONVERIFIER_ABI.clone(), - client, - )) + Self( + ::ethers::contract::Contract::new( + address.into(), + INCLUSIONVERIFIER_ABI.clone(), + client, + ), + ) } /// Constructs the general purpose `Deployer` instance based on the provided constructor arguments and sends it. /// Returns a new instance of a deployer that returns an instance of this contract after sending the transaction @@ -2377,8 +2381,7 @@ pub mod inclusion_verifier { } } impl From<::ethers::contract::Contract> - for InclusionVerifier - { + for InclusionVerifier { fn from(contract: ::ethers::contract::Contract) -> Self { Self::new(contract.address(), contract.client()) } @@ -2392,7 +2395,7 @@ pub mod inclusion_verifier { Debug, PartialEq, Eq, - Hash, + Hash )] #[ethcall( name = "verifyProof", @@ -2413,7 +2416,7 @@ pub mod inclusion_verifier { Debug, PartialEq, Eq, - Hash, + Hash )] pub struct VerifyProofReturn(pub bool); } diff --git a/backend/src/contracts/generated/snark_verifier.rs b/backend/src/contracts/generated/snark_verifier.rs index ffa7a9a5..26adebbb 100644 --- a/backend/src/contracts/generated/snark_verifier.rs +++ b/backend/src/contracts/generated/snark_verifier.rs @@ -7,16 +7,14 @@ pub use verifier::*; clippy::upper_case_acronyms, clippy::type_complexity, dead_code, - non_camel_case_types + non_camel_case_types, )] pub mod verifier { #[rustfmt::skip] const __ABI: &str = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vk\",\"type\":\"address\",\"components\":[]},{\"internalType\":\"bytes\",\"name\":\"proof\",\"type\":\"bytes\",\"components\":[]},{\"internalType\":\"uint256[]\",\"name\":\"instances\",\"type\":\"uint256[]\",\"components\":[]}],\"stateMutability\":\"view\",\"type\":\"function\",\"name\":\"verifyProof\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\",\"components\":[]}]}]"; ///The parsed JSON ABI of the contract. - pub static VERIFIER_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = - ::ethers::contract::Lazy::new(|| { - ::ethers::core::utils::__serde_json::from_str(__ABI).expect("ABI is always valid") - }); + pub static VERIFIER_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = ::ethers::contract::Lazy::new(|| + ::ethers::core::utils::__serde_json::from_str(__ABI).expect("ABI is always valid")); #[rustfmt::skip] const __BYTECODE: &[u8] = &[ 96, @@ -8637,8 +8635,9 @@ pub mod verifier { 51, ]; ///The bytecode of the contract. - pub static VERIFIER_BYTECODE: ::ethers::core::types::Bytes = - ::ethers::core::types::Bytes::from_static(__BYTECODE); + pub static VERIFIER_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static( + __BYTECODE, + ); #[rustfmt::skip] const __DEPLOYED_BYTECODE: &[u8] = &[ 96, @@ -17227,8 +17226,9 @@ pub mod verifier { 51, ]; ///The deployed bytecode of the contract. - pub static VERIFIER_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes = - ::ethers::core::types::Bytes::from_static(__DEPLOYED_BYTECODE); + pub static VERIFIER_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static( + __DEPLOYED_BYTECODE, + ); pub struct Verifier(::ethers::contract::Contract); impl ::core::clone::Clone for Verifier { fn clone(&self) -> Self { @@ -17248,9 +17248,7 @@ pub mod verifier { } impl ::core::fmt::Debug for Verifier { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_tuple(stringify!(Verifier)) - .field(&self.address()) - .finish() + f.debug_tuple(stringify!(Verifier)).field(&self.address()).finish() } } impl Verifier { @@ -17260,11 +17258,13 @@ pub mod verifier { address: T, client: ::std::sync::Arc, ) -> Self { - Self(::ethers::contract::Contract::new( - address.into(), - VERIFIER_ABI.clone(), - client, - )) + Self( + ::ethers::contract::Contract::new( + address.into(), + VERIFIER_ABI.clone(), + client, + ), + ) } /// Constructs the general purpose `Deployer` instance based on the provided constructor arguments and sends it. /// Returns a new instance of a deployer that returns an instance of this contract after sending the transaction @@ -17317,7 +17317,8 @@ pub mod verifier { .expect("method not found (this should never happen)") } } - impl From<::ethers::contract::Contract> for Verifier { + impl From<::ethers::contract::Contract> + for Verifier { fn from(contract: ::ethers::contract::Contract) -> Self { Self::new(contract.address(), contract.client()) } @@ -17331,7 +17332,7 @@ pub mod verifier { Debug, PartialEq, Eq, - Hash, + Hash )] #[ethcall(name = "verifyProof", abi = "verifyProof(address,bytes,uint256[])")] pub struct VerifyProofCall { @@ -17348,7 +17349,7 @@ pub mod verifier { Debug, PartialEq, Eq, - Hash, + Hash )] pub struct VerifyProofReturn(pub bool); } diff --git a/backend/src/contracts/generated/verifying_key.rs b/backend/src/contracts/generated/verifying_key.rs index 28b64659..3c0c6b6c 100644 --- a/backend/src/contracts/generated/verifying_key.rs +++ b/backend/src/contracts/generated/verifying_key.rs @@ -7,16 +7,18 @@ pub use halo_2_verifying_key::*; clippy::upper_case_acronyms, clippy::type_complexity, dead_code, - non_camel_case_types + non_camel_case_types, )] pub mod halo_2_verifying_key { #[rustfmt::skip] const __ABI: &str = "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\",\"outputs\":[]}]"; ///The parsed JSON ABI of the contract. - pub static HALO2VERIFYINGKEY_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = - ::ethers::contract::Lazy::new(|| { - ::ethers::core::utils::__serde_json::from_str(__ABI).expect("ABI is always valid") - }); + pub static HALO2VERIFYINGKEY_ABI: ::ethers::contract::Lazy< + ::ethers::core::abi::Abi, + > = ::ethers::contract::Lazy::new(|| { + ::ethers::core::utils::__serde_json::from_str(__ABI) + .expect("ABI is always valid") + }); #[rustfmt::skip] const __BYTECODE: &[u8] = &[ 96, @@ -1376,8 +1378,9 @@ pub mod halo_2_verifying_key { 254, ]; ///The bytecode of the contract. - pub static HALO2VERIFYINGKEY_BYTECODE: ::ethers::core::types::Bytes = - ::ethers::core::types::Bytes::from_static(__BYTECODE); + pub static HALO2VERIFYINGKEY_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static( + __BYTECODE, + ); #[rustfmt::skip] const __DEPLOYED_BYTECODE: &[u8] = &[ 96, @@ -1445,8 +1448,9 @@ pub mod halo_2_verifying_key { 51, ]; ///The deployed bytecode of the contract. - pub static HALO2VERIFYINGKEY_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes = - ::ethers::core::types::Bytes::from_static(__DEPLOYED_BYTECODE); + pub static HALO2VERIFYINGKEY_DEPLOYED_BYTECODE: ::ethers::core::types::Bytes = ::ethers::core::types::Bytes::from_static( + __DEPLOYED_BYTECODE, + ); pub struct Halo2VerifyingKey(::ethers::contract::Contract); impl ::core::clone::Clone for Halo2VerifyingKey { fn clone(&self) -> Self { @@ -1466,9 +1470,7 @@ pub mod halo_2_verifying_key { } impl ::core::fmt::Debug for Halo2VerifyingKey { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_tuple(stringify!(Halo2VerifyingKey)) - .field(&self.address()) - .finish() + f.debug_tuple(stringify!(Halo2VerifyingKey)).field(&self.address()).finish() } } impl Halo2VerifyingKey { @@ -1478,11 +1480,13 @@ pub mod halo_2_verifying_key { address: T, client: ::std::sync::Arc, ) -> Self { - Self(::ethers::contract::Contract::new( - address.into(), - HALO2VERIFYINGKEY_ABI.clone(), - client, - )) + Self( + ::ethers::contract::Contract::new( + address.into(), + HALO2VERIFYINGKEY_ABI.clone(), + client, + ), + ) } /// Constructs the general purpose `Deployer` instance based on the provided constructor arguments and sends it. /// Returns a new instance of a deployer that returns an instance of this contract after sending the transaction @@ -1525,8 +1529,7 @@ pub mod halo_2_verifying_key { } } impl From<::ethers::contract::Contract> - for Halo2VerifyingKey - { + for Halo2VerifyingKey { fn from(contract: ::ethers::contract::Contract) -> Self { Self::new(contract.address(), contract.client()) } diff --git a/contracts/README.md b/contracts/README.md index 989ce792..584e3ff8 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -9,7 +9,7 @@ The [Summa smart contract](src/Summa.sol) serves as a registrar for Custodians t - **Liabilities Commitments**: Custodians can commit to their liabilities in the form of polynomial commitments and the corresponding total sums representing snapshots of the liabilities at a given timestamp through the `submitCommitment` function. -- **Inclusion Verification**: Users can verify the polynomial commitment of their balances into the liabilities using the `verifyInclusionProof` function. This function calls the underlying smart contract [InclusionVerifier](src/InclusionVerifier.sol) module. refer to the module's [readme](./../kzg_prover/README.md) for details. +- **Inclusion Verification**: Users can verify the polynomial commitment of their balances into the liabilities using the `verifyInclusionProof` function. This function calls the underlying smart contract [InclusionVerifier](src/InclusionVerifier.sol) module. refer to the module's [readme](./../prover/README.md) for details. ## Installation diff --git a/contracts/test/Summa.ts b/contracts/test/Summa.ts index 8b542df4..5b014dfc 100644 --- a/contracts/test/Summa.ts +++ b/contracts/test/Summa.ts @@ -384,7 +384,7 @@ describe("Summa Contract", () => { const commitmentCalldataJson = fs.readFileSync( path.resolve( __dirname, - "../../kzg_prover/bin/commitment_solidity_calldata.json" + "../../prover/bin/commitment_solidity_calldata.json" ), "utf-8" ); @@ -444,7 +444,7 @@ describe("Summa Contract", () => { const commitmentCalldataJson = fs.readFileSync( path.resolve( __dirname, - "../../kzg_prover/bin/commitment_solidity_calldata.json" + "../../prover/bin/commitment_solidity_calldata.json" ), "utf-8" ); @@ -457,7 +457,7 @@ describe("Summa Contract", () => { const inclusionCalldataJson = fs.readFileSync( path.resolve( __dirname, - "../../kzg_prover/bin/inclusion_proof_solidity_calldata.json" + "../../prover/bin/inclusion_proof_solidity_calldata.json" ), "utf-8" ); diff --git a/contracts/test/Verifiers.ts b/contracts/test/Verifiers.ts index 4056107f..b6329e2e 100644 --- a/contracts/test/Verifiers.ts +++ b/contracts/test/Verifiers.ts @@ -14,7 +14,7 @@ describe("Verifier Contracts", () => { "src/VerifyingKey.sol:Halo2VerifyingKey", ) as Halo2VerifyingKey; - const commitmentJson = fs.readFileSync(path.resolve(__dirname, "../../kzg_prover/bin/commitment_solidity_calldata.json"), "utf-8"); + const commitmentJson = fs.readFileSync(path.resolve(__dirname, "../../prover/bin/commitment_solidity_calldata.json"), "utf-8"); const commitmentCalldata = JSON.parse(commitmentJson); return { @@ -127,7 +127,7 @@ describe("Verifier Contracts", () => { const inclusionJson = fs.readFileSync( path.resolve( __dirname, - "../../kzg_prover/bin/inclusion_proof_solidity_calldata.json" + "../../prover/bin/inclusion_proof_solidity_calldata.json" ), "utf-8" ); diff --git a/kzg_prover/.gitignore b/prover/.gitignore similarity index 100% rename from kzg_prover/.gitignore rename to prover/.gitignore diff --git a/kzg_prover/Cargo.lock b/prover/Cargo.lock similarity index 100% rename from kzg_prover/Cargo.lock rename to prover/Cargo.lock diff --git a/kzg_prover/Cargo.toml b/prover/Cargo.toml similarity index 100% rename from kzg_prover/Cargo.toml rename to prover/Cargo.toml diff --git a/kzg_prover/README.md b/prover/README.md similarity index 91% rename from kzg_prover/README.md rename to prover/README.md index 7e87544d..31a3fc79 100644 --- a/kzg_prover/README.md +++ b/prover/README.md @@ -25,7 +25,7 @@ Halo2 allows to efficiently implement the described algorithm for the following The algorithm works as follows: -1. Assign all the user balances to an unblinded advice column of the [circuit](../kzg_prover/src/circuits/univariate_grand_sum.rs). The unblinded advice column is a special kind of advice column without the random values (blinding factors) added at the bottom. The constant term of such polynomial correctly yields the grand total of user balances according to (1) because the polynomial only interpolates the user balances but not the blinding factors (as in the case with a normal advice column). +1. Assign all the user balances to an unblinded advice column of the [circuit](../prover/src/circuits/univariate_grand_sum.rs). The unblinded advice column is a special kind of advice column without the random values (blinding factors) added at the bottom. The constant term of such polynomial correctly yields the grand total of user balances according to (1) because the polynomial only interpolates the user balances but not the blinding factors (as in the case with a normal advice column). 2. Assign the user IDs (e.g., hashes of user emails) to another (normal) advice column. 3. Generate the ZK-SNARK proof for the circuit, effectively interpolating the balance values into a polynomial and performing a KZG commitment to this polynomial. 4. Perform a KZG opening proof of the polynomial at $x=0$ and publicly reveal the constant term $a_0$ of the polynomial. The public can then calculate the liabilities by multiplying the $a_0$ by $d + 1$ where $d$ is the polynomial degree. @@ -54,7 +54,7 @@ To generate commitments and proofs with the sample data located in `entry_16.csv cargo run --bin generate_commitment_and_proofs ``` -This script will generate `commitment_solidity_calldata.json` and `inclusion_proof_solidity_calldata.json` in the `kzg_prover/bin`.
+This script will generate `commitment_solidity_calldata.json` and `inclusion_proof_solidity_calldata.json` in the `prover/bin`.
These two JSON files will be used for testing in the `contracts`. ## Documentation @@ -109,7 +109,7 @@ the following technique is proposed to further improve the performance of the un Step 4 of the algorithm establishes the relation between the chunks containing individual user liabilities and the grand sum of all user liabilities. The proof of inclusion generation in step 3 should be carried out using the amortized KZG approach in the similar fashion as in the non-chunked version of Summa. -The proof of concept implementation of the suggested approach can be found in the [example file](kzg_prover/examples/chunked_univariate_grand_sum.rs). To execute the example, use the command: +The proof of concept implementation of the suggested approach can be found in the [example file](prover/examples/chunked_univariate_grand_sum.rs). To execute the example, use the command: ```shell cargo run --release --example chunked_univariate_grand_sum diff --git a/kzg_prover/benches/kzg.rs b/prover/benches/kzg.rs similarity index 100% rename from kzg_prover/benches/kzg.rs rename to prover/benches/kzg.rs diff --git a/kzg_prover/bin/commitment_solidity_calldata.json b/prover/bin/commitment_solidity_calldata.json similarity index 100% rename from kzg_prover/bin/commitment_solidity_calldata.json rename to prover/bin/commitment_solidity_calldata.json diff --git a/kzg_prover/bin/gen_commit_and_proofs.rs b/prover/bin/gen_commit_and_proofs.rs similarity index 100% rename from kzg_prover/bin/gen_commit_and_proofs.rs rename to prover/bin/gen_commit_and_proofs.rs diff --git a/kzg_prover/bin/gen_verifier.rs b/prover/bin/gen_verifier.rs similarity index 100% rename from kzg_prover/bin/gen_verifier.rs rename to prover/bin/gen_verifier.rs diff --git a/kzg_prover/bin/inclusion_proof_solidity_calldata.json b/prover/bin/inclusion_proof_solidity_calldata.json similarity index 100% rename from kzg_prover/bin/inclusion_proof_solidity_calldata.json rename to prover/bin/inclusion_proof_solidity_calldata.json diff --git a/kzg_prover/examples/chunked_univariate_grand_sum.rs b/prover/examples/chunked_univariate_grand_sum.rs similarity index 100% rename from kzg_prover/examples/chunked_univariate_grand_sum.rs rename to prover/examples/chunked_univariate_grand_sum.rs diff --git a/kzg_prover/prints/range-check-layout.png b/prover/prints/range-check-layout.png similarity index 100% rename from kzg_prover/prints/range-check-layout.png rename to prover/prints/range-check-layout.png diff --git a/kzg_prover/prints/univariate-grand-sum-layout.png b/prover/prints/univariate-grand-sum-layout.png similarity index 100% rename from kzg_prover/prints/univariate-grand-sum-layout.png rename to prover/prints/univariate-grand-sum-layout.png diff --git a/kzg_prover/rust-toolchain b/prover/rust-toolchain similarity index 100% rename from kzg_prover/rust-toolchain rename to prover/rust-toolchain diff --git a/kzg_prover/src/chips/mod.rs b/prover/src/chips/mod.rs similarity index 100% rename from kzg_prover/src/chips/mod.rs rename to prover/src/chips/mod.rs diff --git a/kzg_prover/src/chips/range/mod.rs b/prover/src/chips/range/mod.rs similarity index 100% rename from kzg_prover/src/chips/range/mod.rs rename to prover/src/chips/range/mod.rs diff --git a/kzg_prover/src/chips/range/range_check.rs b/prover/src/chips/range/range_check.rs similarity index 100% rename from kzg_prover/src/chips/range/range_check.rs rename to prover/src/chips/range/range_check.rs diff --git a/kzg_prover/src/chips/range/tests.rs b/prover/src/chips/range/tests.rs similarity index 100% rename from kzg_prover/src/chips/range/tests.rs rename to prover/src/chips/range/tests.rs diff --git a/kzg_prover/src/chips/range/utils.rs b/prover/src/chips/range/utils.rs similarity index 100% rename from kzg_prover/src/chips/range/utils.rs rename to prover/src/chips/range/utils.rs diff --git a/kzg_prover/src/circuits/mod.rs b/prover/src/circuits/mod.rs similarity index 100% rename from kzg_prover/src/circuits/mod.rs rename to prover/src/circuits/mod.rs diff --git a/kzg_prover/src/circuits/tests.rs b/prover/src/circuits/tests.rs similarity index 100% rename from kzg_prover/src/circuits/tests.rs rename to prover/src/circuits/tests.rs diff --git a/kzg_prover/src/circuits/univariate_grand_sum.rs b/prover/src/circuits/univariate_grand_sum.rs similarity index 100% rename from kzg_prover/src/circuits/univariate_grand_sum.rs rename to prover/src/circuits/univariate_grand_sum.rs diff --git a/kzg_prover/src/circuits/utils.rs b/prover/src/circuits/utils.rs similarity index 100% rename from kzg_prover/src/circuits/utils.rs rename to prover/src/circuits/utils.rs diff --git a/kzg_prover/src/cryptocurrency.rs b/prover/src/cryptocurrency.rs similarity index 100% rename from kzg_prover/src/cryptocurrency.rs rename to prover/src/cryptocurrency.rs diff --git a/kzg_prover/src/entry.rs b/prover/src/entry.rs similarity index 100% rename from kzg_prover/src/entry.rs rename to prover/src/entry.rs diff --git a/kzg_prover/src/lib.rs b/prover/src/lib.rs similarity index 100% rename from kzg_prover/src/lib.rs rename to prover/src/lib.rs diff --git a/kzg_prover/src/utils/amortized_kzg.rs b/prover/src/utils/amortized_kzg.rs similarity index 100% rename from kzg_prover/src/utils/amortized_kzg.rs rename to prover/src/utils/amortized_kzg.rs diff --git a/kzg_prover/src/utils/csv_parser.rs b/prover/src/utils/csv_parser.rs similarity index 100% rename from kzg_prover/src/utils/csv_parser.rs rename to prover/src/utils/csv_parser.rs diff --git a/kzg_prover/src/utils/dummy_entries.rs b/prover/src/utils/dummy_entries.rs similarity index 100% rename from kzg_prover/src/utils/dummy_entries.rs rename to prover/src/utils/dummy_entries.rs diff --git a/kzg_prover/src/utils/mod.rs b/prover/src/utils/mod.rs similarity index 100% rename from kzg_prover/src/utils/mod.rs rename to prover/src/utils/mod.rs diff --git a/kzg_prover/src/utils/operation_helpers.rs b/prover/src/utils/operation_helpers.rs similarity index 100% rename from kzg_prover/src/utils/operation_helpers.rs rename to prover/src/utils/operation_helpers.rs