Skip to content

Commit

Permalink
Rename kzg_prover to prover
Browse files Browse the repository at this point in the history
  • Loading branch information
sifnoc committed Mar 26, 2024
1 parent 1cc623b commit 64f4c9b
Show file tree
Hide file tree
Showing 43 changed files with 108 additions and 98 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

- name: Test KZG Prover
run: |
cd kzg_prover
cd prover
cargo test --release -- --nocapture
- name: Install Foundry
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions backend/scripts/update_verifier_contract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 24 additions & 21 deletions backend/src/contracts/generated/grandsum_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<M>(::ethers::contract::Contract<M>);
impl<M> ::core::clone::Clone for GrandSumVerifier<M> {
fn clone(&self) -> Self {
Expand All @@ -2636,9 +2640,7 @@ pub mod grand_sum_verifier {
}
impl<M> ::core::fmt::Debug for GrandSumVerifier<M> {
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<M: ::ethers::providers::Middleware> GrandSumVerifier<M> {
Expand All @@ -2648,11 +2650,13 @@ pub mod grand_sum_verifier {
address: T,
client: ::std::sync::Arc<M>,
) -> 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
Expand Down Expand Up @@ -2706,8 +2710,7 @@ pub mod grand_sum_verifier {
}
}
impl<M: ::ethers::providers::Middleware> From<::ethers::contract::Contract<M>>
for GrandSumVerifier<M>
{
for GrandSumVerifier<M> {
fn from(contract: ::ethers::contract::Contract<M>) -> Self {
Self::new(contract.address(), contract.client())
}
Expand All @@ -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 {
Expand All @@ -2738,7 +2741,7 @@ pub mod grand_sum_verifier {
Debug,
PartialEq,
Eq,
Hash,
Hash
)]
pub struct VerifyProofReturn(pub bool);
}
45 changes: 24 additions & 21 deletions backend/src/contracts/generated/inclusion_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<M>(::ethers::contract::Contract<M>);
impl<M> ::core::clone::Clone for InclusionVerifier<M> {
fn clone(&self) -> Self {
Expand All @@ -2306,9 +2310,7 @@ pub mod inclusion_verifier {
}
impl<M> ::core::fmt::Debug for InclusionVerifier<M> {
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<M: ::ethers::providers::Middleware> InclusionVerifier<M> {
Expand All @@ -2318,11 +2320,13 @@ pub mod inclusion_verifier {
address: T,
client: ::std::sync::Arc<M>,
) -> 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
Expand Down Expand Up @@ -2377,8 +2381,7 @@ pub mod inclusion_verifier {
}
}
impl<M: ::ethers::providers::Middleware> From<::ethers::contract::Contract<M>>
for InclusionVerifier<M>
{
for InclusionVerifier<M> {
fn from(contract: ::ethers::contract::Contract<M>) -> Self {
Self::new(contract.address(), contract.client())
}
Expand All @@ -2392,7 +2395,7 @@ pub mod inclusion_verifier {
Debug,
PartialEq,
Eq,
Hash,
Hash
)]
#[ethcall(
name = "verifyProof",
Expand All @@ -2413,7 +2416,7 @@ pub mod inclusion_verifier {
Debug,
PartialEq,
Eq,
Hash,
Hash
)]
pub struct VerifyProofReturn(pub bool);
}
41 changes: 21 additions & 20 deletions backend/src/contracts/generated/snark_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<M>(::ethers::contract::Contract<M>);
impl<M> ::core::clone::Clone for Verifier<M> {
fn clone(&self) -> Self {
Expand All @@ -17248,9 +17248,7 @@ pub mod verifier {
}
impl<M> ::core::fmt::Debug for Verifier<M> {
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<M: ::ethers::providers::Middleware> Verifier<M> {
Expand All @@ -17260,11 +17258,13 @@ pub mod verifier {
address: T,
client: ::std::sync::Arc<M>,
) -> 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
Expand Down Expand Up @@ -17317,7 +17317,8 @@ pub mod verifier {
.expect("method not found (this should never happen)")
}
}
impl<M: ::ethers::providers::Middleware> From<::ethers::contract::Contract<M>> for Verifier<M> {
impl<M: ::ethers::providers::Middleware> From<::ethers::contract::Contract<M>>
for Verifier<M> {
fn from(contract: ::ethers::contract::Contract<M>) -> Self {
Self::new(contract.address(), contract.client())
}
Expand All @@ -17331,7 +17332,7 @@ pub mod verifier {
Debug,
PartialEq,
Eq,
Hash,
Hash
)]
#[ethcall(name = "verifyProof", abi = "verifyProof(address,bytes,uint256[])")]
pub struct VerifyProofCall {
Expand All @@ -17348,7 +17349,7 @@ pub mod verifier {
Debug,
PartialEq,
Eq,
Hash,
Hash
)]
pub struct VerifyProofReturn(pub bool);
}
Loading

0 comments on commit 64f4c9b

Please sign in to comment.