diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 01d4be0a..bbb1f6f5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -29,7 +29,6 @@ jobs: - name: Test backend env: - COVALENT_API_KEY: ${{ secrets.COVALENT_API_KEY }} SIGNATURE_VERIFICATION_MESSAGE: "Summa proof of solvency for CryptoExchange" run: | cd backend diff --git a/backend/README.md b/backend/README.md index f7ce5463..f8fb068f 100644 --- a/backend/README.md +++ b/backend/README.md @@ -12,42 +12,63 @@ Furthermore, the `Snapshot` struct contains the following methods: - `generate_solvency_verifier` -> write the Solidity Verifier contract (for the `SolvencyProof`) to a file - `generate_proof_of_solvency` -> generate the `SolvencyProof` for the current snapshot to be verified on-chain -- `generate_inclusion_proof` -> generate the `MstInclusionProof` for a specific user for the current snapshot to be verified off-chain -- `get_account_onwership_proof` -> generate the `AccountOwnership` for a specific user for the current snapshot to be verified off-chain +- `generate_proof_of_inclusion` -> generate the `MstInclusionProof` for a specific user for the current snapshot to be verified off-chain +- `get_proof_of_account_ownership` -> generate the `AccountOwnership` for a specific user for the current snapshot to be verified off-chain ## Prerequisites -In order to initialize the Snapshot, you need to download the Powers of Tau files. These are the trusted setup parameters needed to build the zk circuits. You can find such files at https://github.com/han0110/halo2-kzg-srs, download it +The `ptau` file, containing the Powers of Tau trusted setup parameters needed to build the zk circuits, is already included. However, if you wish to test or run the code with a higher number of entries, you may choose to download a different `ptau` file. + +You can find the necessary files at https://github.com/han0110/halo2-kzg-srs. To download a specific file, you can use: ``` wget https://trusted-setup-halo2kzg.s3.eu-central-1.amazonaws.com/hermez-raw-11 ``` -and pass the path to the file to the `Snapshot::new` method. +After downloading, pass the path to the desired file to the `Snapshot::new` method. If you are using the included `ptau` file, no additional steps are necessary. -Furthermore, the `generate_proof_of_solvency` method requires to fetch data about the balances of the wallets of the CEX. This data is fetched using the Covalent API. In order to use this method, you need to create an `.env` file and store the `COVALENT_API_KEY` there. You can get an API key at https://www.covalenthq.com/platform/. +## Important Notices -## Usage +### For Proof of Solvency -To build the binary executable and test it +As of the current implementation, the `generate_proof_of_solvency` method does not directly fetch data about the balances of the wallets of the CEX. Instead, you can use the `fetch_asset_sums` function to retrieve balance information from the blockchain. Here's an example of how you might utilize it: +```Rust +let asset_sums = fetch_asset_sums(client, token_contracts, exchange_addresses).await?; ``` -cargo build -SIGNATURE_VERIFICATION_MESSAGE="Summa proof of solvency for CryptoExchange" cargo test --release -- --nocapture + +Please note that the first element in the `asset_sums` array represents the ETH balance. + +Alternatively, you can create your own custom fetcher to retrieve the balances. + +### For Proof of Ownership + +To generate a signed message, you must first initialize the `SummaSigner` and use the `generate_signatures` method: + +```Rust +let signatures = signer.generate_signatures().await.unwrap(); ``` -The contract Rust interfaces are built by the [buildscript](./build.rs) from the JSON ABI. The [Summa contract ABI json](./src/contracts/Summa.json) is updated when the contract is deployed from the [contracts subproject](./../contracts/README.md). +The content of the message can be specified with the local variable `SIGNATURE_VERIFICATION_MESSAGE`. -## Example +### For Generating Solvency Verifier -In the `example/verifying_inclusion.rs`, you can find code for verifying the `inclusion_proof` on the user side. On top of that the user has to verify that: -- the public input `leaf_hash` matches the combination `H(username, balances[])` -- the public input `root_hash` matches the commited by the CEX +The provided verifier found at `src/contracts/Verifier.json` is based on the trusted setup, `hermez-raw-11`. If you are working with a higher number of entries, you will need to generate a new verifier contract by using the `generate_solvency_verifier` method. -You can run the command like this: +Here's a brief example of how you might invoke this method: +```Rust +Snapshot::generate_solvency_verifier("SolvencyVerifier.yul", "SolvencyVerifier.sol"); +``` + +This method creates two files, `SolvencyVerifier.yul` and `SolvencyVerifier.sol`, which will be used in `Summa.sol`. -`> cargo run --release --example verifying_inclusion` +## Usage + +To build the binary executable and test it -The example will generate a proof for the user at index 0, and then it will pass only the `proof_inclusion` data to the user side (within the same example file). +``` +cargo build +SIGNATURE_VERIFICATION_MESSAGE="Summa proof of solvency for CryptoExchange" cargo test --release -- --nocapture +``` -On the user side, the proof is verified using as public input the `leaf_hash` that is generated by the user themselves. +The contract Rust interfaces are built by the [buildscript](./build.rs) from the JSON ABI. The [Summa contract ABI json](./src/contracts/Summa.json) is updated when the contract is deployed from the [contracts subproject](./../contracts/README.md). diff --git a/backend/build.rs b/backend/build.rs index 0bfe14ce..96d4eca6 100644 --- a/backend/build.rs +++ b/backend/build.rs @@ -7,7 +7,7 @@ fn main() { .unwrap() .join("src/contracts/generated/summa_contract.rs"); if contract_out_file.exists() { - std::fs::remove_file(&contract_out_file); + std::fs::remove_file(&contract_out_file).unwrap(); } Abigen::new("Summa", "./src/contracts/Summa.json") @@ -15,13 +15,14 @@ fn main() { .format(true) .generate() .unwrap() - .write_to_file(contract_out_file); + .write_to_file(contract_out_file) + .unwrap(); let mod_out_file: PathBuf = std::env::current_dir() .unwrap() .join("src/contracts/generated/mod.rs"); if mod_out_file.exists() { - std::fs::remove_file(&mod_out_file); + std::fs::remove_file(&mod_out_file).unwrap(); } let mut mod_file = OpenOptions::new() @@ -38,7 +39,7 @@ fn main() { .unwrap() .join("src/contracts/generated/mock_erc20.rs"); if contract_out_file.exists() { - std::fs::remove_file(&contract_out_file); + std::fs::remove_file(&contract_out_file).unwrap(); } Abigen::new("MockERC20", "./src/contracts/MockERC20.json") @@ -46,13 +47,14 @@ fn main() { .format(true) .generate() .unwrap() - .write_to_file(contract_out_file); + .write_to_file(contract_out_file) + .unwrap(); let contract_out_file = std::env::current_dir() .unwrap() .join("src/contracts/generated/verifier.rs"); if contract_out_file.exists() { - std::fs::remove_file(&contract_out_file); + std::fs::remove_file(&contract_out_file).unwrap(); } Abigen::new("SolvencyVerifier", "./src/contracts/Verifier.json") @@ -60,5 +62,6 @@ fn main() { .format(true) .generate() .unwrap() - .write_to_file(contract_out_file); + .write_to_file(contract_out_file) + .unwrap(); } diff --git a/backend/src/apis/fetch.rs b/backend/src/apis/fetch.rs index dc39407f..00ce122e 100644 --- a/backend/src/apis/fetch.rs +++ b/backend/src/apis/fetch.rs @@ -1,151 +1,85 @@ -use base64::encode; -use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION, CONTENT_TYPE}; -use serde::Deserialize; -use std::error::Error; - -#[derive(Deserialize, Debug)] -/// This is the root level of the JSON response. It contains a data field, which corresponds to the "data" field in the JSON. -struct Response { - data: Data, -} -/// This struct represents the "data" field of the JSON. It contains an items field, which corresponds to the "items" array in the JSON. -#[derive(Deserialize, Debug)] -struct Data { - items: Vec, -} - -/// This struct represents each object in the "items" array. It contains a balance field and a contract_address field. These fields correspond to the "balance" and "contract_address" fields in each item of the "items" array in the JSON. -#[derive(Deserialize, Debug)] -struct Item { - balance: String, - contract_address: String, +use futures::future::try_join_all; +use std::{error::Error, sync::Arc}; + +use ethers::{ + abi::Address, + contract::builders::ContractCall, + prelude::SignerMiddleware, + providers::{Http, Middleware, Provider}, + signers::LocalWallet, + types::{H160, U256}, +}; + +use crate::contracts; + +pub trait TokenBalance { + fn get_token_balance(&self, account: Address) -> ContractCall; } -/// This function takes a list of asset contracts addresses, a list of addresses and returns the aggregated balance of these address PER EACH asset -pub fn fetch_asset_sums( - addresses: Vec, - asset_contract_addresses: Vec, -) -> Result, Box> { - // create asset sums vector - let mut asset_sums: Vec = Vec::new(); - - // for each address in addresses vector call fetch_balances_per_addr and increment the asset_sums vector - for address in addresses { - let balances = fetch_balances_per_addr(address.clone(), asset_contract_addresses.clone())?; - for (i, balance) in balances.iter().enumerate() { - if asset_sums.len() <= i { - asset_sums.push(*balance); - } else { - let sum = asset_sums[i] + balance; - asset_sums[i] = sum; - } - } +/// This function takes a list of token contracts, addresses and returns the balances of that address for the queried contracts. +/// The first balance returned is the Ether (ETH) balance, followed by the balances of other specified token contracts. +/// +pub async fn fetch_asset_sums<'a, M: Middleware + 'a>( + client: Arc, LocalWallet>>, + token_contracts: Vec + Send>>, + exchange_addresses: Vec, +) -> Result, Box> { + let mut result: Vec = Vec::new(); + + let mut get_balance_futures = Vec::new(); + for addr in exchange_addresses.clone() { + get_balance_futures.push(client.get_balance(addr, None)); } - - Ok(asset_sums) -} - -/// This function takes a list of token contracts, an address and returns the balances of that address for the queried contracts. -#[tokio::main] -async fn fetch_balances_per_addr( - address: String, - asset_contract_addresses: Vec, -) -> Result, Box> { - // Create a header map - let mut headers = HeaderMap::new(); - - // Load .env file - dotenv::dotenv().ok(); - - // Access API key from the environment - let api_key = std::env::var("COVALENT_API_KEY").unwrap(); - - // Add `Content-Type` header - headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); - - // Add `Authorization` header - let auth_value = format!("Basic {}", encode(api_key)); - headers.insert(AUTHORIZATION, HeaderValue::from_str(&auth_value)?); - - // Form URL - let url = format!( - "https://api.covalenthq.com/v1/eth-mainnet/address/{}/balances_v2/", - address - ); - - // Send a GET request to the API - let res = reqwest::Client::new() - .get(&url) - .headers(headers) - .send() - .await? - .json::() - .await?; - - // Get balances for the specific tokens - let filtered_balances = - filter_balances_by_token_contracts(asset_contract_addresses, &res).unwrap(); - - Ok(filtered_balances) -} - -/// This function filters out only the balances corresponding to an asset listed in asset_contract_addresses. -fn filter_balances_by_token_contracts( - asset_contract_addresses: Vec, - response: &Response, -) -> Result, &'static str> { - let mut balances = Vec::new(); - for contract_adddress in asset_contract_addresses { - if let Some(item) = response.data.items.iter().find(|&item| { - item.contract_address.to_ascii_lowercase() == contract_adddress.to_ascii_lowercase() - }) { - match item.balance.parse::() { - Ok(num) => balances.push(num), - Err(e) => println!("Failed to parse string: {}", e), - } - } else { - balances.push(0 as u64); + let get_balances = try_join_all(get_balance_futures).await?; + let sum_eth_balance = get_balances + .into_iter() + .reduce(|acc, balance| acc + balance) + .unwrap(); + result.push(sum_eth_balance); + + // Most in case, the number of contracts is less than the number of asset addresses + // Iterating over contracts first is more efficient + let mut sum_token_balance = U256::zero(); + for contract in &token_contracts { + for addr in exchange_addresses.clone() { + let token_balance = contract.get_token_balance(addr).call().await.unwrap(); + sum_token_balance = sum_token_balance + token_balance; } + result.push(sum_token_balance) } - Ok(balances) + + Ok(result) } #[cfg(test)] mod tests { use super::*; - #[test] - #[ignore] - fn test_fetch_balances_per_addr() { - // this is an address with 0 usdc and 0.010910762665574143 ETH - let address = "0xe4D9621321e77B499392801d08Ed68Ec5175f204".to_string(); + use crate::contracts::tests::initialize_anvil; + use contracts::generated::mock_erc20::MockERC20; - let usdc_contract = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48".to_string(); - let eth_contract = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee".to_string(); - - let balances = - fetch_balances_per_addr(address, [usdc_contract, eth_contract].to_vec()).unwrap(); - - assert_eq!(balances[0], 0); // balance for usdc - assert_eq!(balances[1], 10910762665574143); // balance for wei - } - - #[test] - #[ignore] - fn test_fetch_asset_sums() { - let address_1 = "0xe4D9621321e77B499392801d08Ed68Ec5175f204".to_string(); // this is an address with 0 usdc and 0.010910762665574143 ETH - let address_2 = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1".to_string(); // this is an address with 0.000001 USDC usdc and 1 wei + #[tokio::test] + async fn test_fetch_asset_sums() { + // Necessary to implement `get_balance_from_contract` for the `contracts` parameter by following trait + impl TokenBalance for MockERC20 { + fn get_token_balance(&self, account: Address) -> ContractCall { + self.balance_of(account) + } + } - let usdc_contract = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48".to_string(); - let eth_contract = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee".to_string(); + let (anvil, cex_addr_1, cex_addr_2, client, mock_erc20) = initialize_anvil().await; let asset_sums = fetch_asset_sums( - [address_1, address_2].to_vec(), - [usdc_contract, eth_contract].to_vec(), + client.clone(), + vec![Box::new(mock_erc20)], + [cex_addr_1, cex_addr_2].to_vec(), ) + .await .unwrap(); - assert_eq!(asset_sums[0], 1); // asset sum for usdc - assert_eq!(asset_sums[1], 10910762665574144); // asset sum for wei + assert_eq!(asset_sums[0], U256::from(556864)); + assert_eq!(asset_sums[1], U256::from(556863)); + + drop(anvil); } } diff --git a/backend/src/apis/snapshot.rs b/backend/src/apis/snapshot.rs index c41e292c..b6d5719f 100644 --- a/backend/src/apis/snapshot.rs +++ b/backend/src/apis/snapshot.rs @@ -159,27 +159,8 @@ impl, - asset_sum: Option<[Fp; N_ASSETS]>, + asset_sums: [Fp; N_ASSETS], ) -> Result<(SolvencyProof, Vec), &'static str> { - // For each asset, identified by its contract address, fetch the sum of all balances owned by the accounts contained in the snapshot - let asset_sums: [Fp; N_ASSETS] = match asset_sum { - Some(sum) => sum, - None => { - let fetched_asset_sums = fetch_asset_sums( - self.proof_of_account_ownership.addresses.clone(), - asset_contract_addresses.clone(), - ) - .map_err(|_| "Could not fetch asset sums")?; - - fetched_asset_sums - .iter() - .map(|x| Fp::from(*x)) - .collect::>() - .try_into() - .map_err(|_| "Failed to convert asset sums to Fp")? - } - }; - let circuit = SolvencyCircuit::::init(self.mst.clone(), asset_sums); let calldata = gen_proof_solidity_calldata( @@ -273,7 +254,6 @@ mod tests { } #[test] - #[ignore] fn test_generate_solvency_proof() { let snapshot = initialize_snapshot(); @@ -282,8 +262,13 @@ mod tests { "0x220b71671b649c03714da9c621285943f3cbcdc6".to_string(), // ERC20 token address ]; - let calldata = snapshot - .generate_proof_of_solvency(asset_addresses.clone(), None) + // In this test, we assume that the balances of the accounts in the snapshot are 556863 for both assets + // In a live environment, Should fetch balances from on-chain via `fetch_asset_sums` method in `fetch.rs`. + let calldata: (SolvencyProof, Vec) = snapshot + .generate_proof_of_solvency( + asset_addresses.clone(), + [Fp::from(556863), Fp::from(556863)], + ) .unwrap(); assert_eq!(calldata.0.public_inputs.len(), 1 + N_ASSETS); diff --git a/backend/src/contracts/Summa.json b/backend/src/contracts/Summa.json index bd19e0ba..afa3de4e 100644 --- a/backend/src/contracts/Summa.json +++ b/backend/src/contracts/Summa.json @@ -1,150 +1 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "Summa", - "sourceName": "src/Summa.sol", - "abi": [ - { - "inputs": [ - { - "internalType": "contract IVerifier", - "name": "_verifier", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address[]", - "name": "cexAddresses", - "type": "address[]" - } - ], - "name": "ExchangeAddressesSubmitted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "mstRoot", - "type": "uint256" - } - ], - "name": "ProofOfSolvencySubmitted", - "type": "event" - }, - { - "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "name": "cexAddresses", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "_cexAddresses", - "type": "address[]" - }, - { - "internalType": "bytes[]", - "name": "cexSignatures", - "type": "bytes[]" - }, - { "internalType": "string", "name": "message", "type": "string" } - ], - "name": "submitProofOfAccountOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "erc20ContractAddresses", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "assetSums", - "type": "uint256[]" - }, - { "internalType": "uint256", "name": "mstRoot", "type": "uint256" }, - { "internalType": "bytes", "name": "proof", "type": "bytes" } - ], - "name": "submitProofOfSolvency", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "newOwner", "type": "address" } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes", "name": "proof", "type": "bytes" }, - { - "internalType": "uint256[]", - "name": "publicInputs", - "type": "uint256[]" - } - ], - "name": "verifyZkProof", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - } - ], - "bytecode": "0x60a060405234801561001057600080fd5b5060405161146638038061146683398101604081905261002f91610099565b61003833610049565b6001600160a01b03166080526100c9565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100ab57600080fd5b81516001600160a01b03811681146100c257600080fd5b9392505050565b6080516113826100e460003960006104c001526113826000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100cf578063e691ad33146100e0578063ed18348f14610103578063f2fde38b1461011657600080fd5b806312b91181146100825780636a5650e114610097578063715018a6146100c7575b600080fd5b610095610090366004610ef7565b610129565b005b6100aa6100a5366004610fee565b610468565b6040516001600160a01b0390911681526020015b60405180910390f35b610095610492565b6000546001600160a01b03166100aa565b6100f36100ee366004611062565b6104a6565b60405190151581526020016100be565b6100956101113660046110c6565b610541565b610095610124366004611158565b6109f4565b8151835114801561013b575060008351115b6101a05760405162461bcd60e51b815260206004820152602b60248201527f4345582061646472657373657320616e64207369676e61747572657320636f7560448201526a0dce840dad2e6dac2e8c6d60ab1b60648201526084015b60405180910390fd5b60005b83518110156103cb5760015481106102095760018482815181106101c9576101c9611173565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790556102ba565b6001818154811061021c5761021c611173565b60009182526020909120015484516001600160a01b039091169085908390811061024857610248611173565b60200260200101516001600160a01b0316146102ba5783818151811061027057610270611173565b60200260200101516001828154811061028b5761028b611173565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b600061033c8483815181106102d1576102d1611173565b6020026020010151610336856040516020016102ed91906111cf565b604051602081830303815290604052805190602001207f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b90610a6d565b9050806001600160a01b031685838151811061035a5761035a611173565b60200260200101516001600160a01b0316146103b85760405162461bcd60e51b815260206004820152601e60248201527f496e76616c6964207369676e657220666f7220455448206164647265737300006044820152606401610197565b50806103c3816111f8565b9150506101a3565b506001548351101561042b5782515b6001548110156104295760018054806103f5576103f5611211565b600082815260209020810160001990810180546001600160a01b031916905501905580610421816111f8565b9150506103da565b505b7f98eb3798cf76f91b917cbd9b06e682e42d54899d45623bbb3b81f213d58a9bf0600160405161045b9190611227565b60405180910390a1505050565b6001818154811061047857600080fd5b6000918252602090912001546001600160a01b0316905081565b61049a610a91565b6104a46000610aeb565b565b604051630bd205a960e41b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063bd205a90906104f79085908790600401611277565b602060405180830381865afa158015610514573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053891906112ce565b90505b92915050565b6001835161054f91906112f7565b845114801561055f575060008451115b6105bf5760405162461bcd60e51b815260206004820152602b60248201527f45524332302061646472657373657320616e642062616c616e63657320636f7560448201526a0dce840dad2e6dac2e8c6d60ab1b6064820152608401610197565b600080855167ffffffffffffffff8111156105dc576105dc610d8e565b604051908082528060200260200182016040528015610605578160200160208202803683370190505b50905060005b600154811015610753576001818154811061062857610628611173565b600091825260209091200154610648906001600160a01b0316318461130a565b925060005b87518110156107405787818151811061066857610668611173565b60200260200101516001600160a01b03166370a082316001848154811061069157610691611173565b60009182526020909120015460405160e083901b6001600160e01b03191681526001600160a01b039091166004820152602401602060405180830381865afa1580156106e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610705919061131d565b83828151811061071757610717611173565b6020026020010181815161072b919061130a565b90525080610738816111f8565b91505061064d565b508061074b816111f8565b91505061060b565b508460008151811061076757610767611173565b60200260200101518210156107d95760405162461bcd60e51b815260206004820152603260248201527f41637475616c204554482062616c616e6365206973206c657373207468616e206044820152717468652070726f76656e2062616c616e636560701b6064820152608401610197565b60005b86518110156108a057856107f182600161130a565b8151811061080157610801611173565b602002602001015182828151811061081b5761081b611173565b6020026020010151101561088e5760405162461bcd60e51b815260206004820152603460248201527f41637475616c2045524332302062616c616e6365206973206c657373207468616044820152736e207468652070726f76656e2062616c616e636560601b6064820152608401610197565b80610898816111f8565b9150506107dc565b506000855160016108b1919061130a565b67ffffffffffffffff8111156108c9576108c9610d8e565b6040519080825280602002602001820160405280156108f2578160200160208202803683370190505b509050848160008151811061090957610909611173565b60200260200101818152505060005b86518110156109765786818151811061093357610933611173565b602002602001015182826001610949919061130a565b8151811061095957610959611173565b60209081029190910101528061096e816111f8565b915050610918565b5061098184826104a6565b6109c05760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b2103d3590383937b7b360811b6044820152606401610197565b60405185907f08367c9e7de6aba412334c7e8a02be4c57a63f268945497c9d693772c7f3969390600090a250505050505050565b6109fc610a91565b6001600160a01b038116610a615760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610197565b610a6a81610aeb565b50565b6000806000610a7c8585610b3b565b91509150610a8981610b80565b509392505050565b6000546001600160a01b031633146104a45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610197565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000808251604103610b715760208301516040840151606085015160001a610b6587828585610cca565b94509450505050610b79565b506000905060025b9250929050565b6000816004811115610b9457610b94611336565b03610b9c5750565b6001816004811115610bb057610bb0611336565b03610bfd5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610197565b6002816004811115610c1157610c11611336565b03610c5e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610197565b6003816004811115610c7257610c72611336565b03610a6a5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610197565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115610d015750600090506003610d85565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610d55573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610d7e57600060019250925050610d85565b9150600090505b94509492505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610dcd57610dcd610d8e565b604052919050565b600067ffffffffffffffff821115610def57610def610d8e565b5060051b60200190565b80356001600160a01b0381168114610e1057600080fd5b919050565b600082601f830112610e2657600080fd5b81356020610e3b610e3683610dd5565b610da4565b82815260059290921b84018101918181019086841115610e5a57600080fd5b8286015b84811015610e7c57610e6f81610df9565b8352918301918301610e5e565b509695505050505050565b600082601f830112610e9857600080fd5b813567ffffffffffffffff811115610eb257610eb2610d8e565b610ec5601f8201601f1916602001610da4565b818152846020838601011115610eda57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600060608486031215610f0c57600080fd5b833567ffffffffffffffff80821115610f2457600080fd5b610f3087838801610e15565b9450602091508186013581811115610f4757600080fd5b8601601f81018813610f5857600080fd5b8035610f66610e3682610dd5565b81815260059190911b8201840190848101908a831115610f8557600080fd5b8584015b83811015610fbd57803586811115610fa15760008081fd5b610faf8d8983890101610e87565b845250918601918601610f89565b5096505050506040860135915080821115610fd757600080fd5b50610fe486828701610e87565b9150509250925092565b60006020828403121561100057600080fd5b5035919050565b600082601f83011261101857600080fd5b81356020611028610e3683610dd5565b82815260059290921b8401810191818101908684111561104757600080fd5b8286015b84811015610e7c578035835291830191830161104b565b6000806040838503121561107557600080fd5b823567ffffffffffffffff8082111561108d57600080fd5b61109986838701610e87565b935060208501359150808211156110af57600080fd5b506110bc85828601611007565b9150509250929050565b600080600080608085870312156110dc57600080fd5b843567ffffffffffffffff808211156110f457600080fd5b61110088838901610e15565b9550602087013591508082111561111657600080fd5b61112288838901611007565b945060408701359350606087013591508082111561113f57600080fd5b5061114c87828801610e87565b91505092959194509250565b60006020828403121561116a57600080fd5b61053882610df9565b634e487b7160e01b600052603260045260246000fd5b6000815180845260005b818110156111af57602081850181015186830182015201611193565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006105386020830184611189565b634e487b7160e01b600052601160045260246000fd5b60006001820161120a5761120a6111e2565b5060010190565b634e487b7160e01b600052603160045260246000fd5b6020808252825482820181905260008481528281209092916040850190845b8181101561126b5783546001600160a01b031683526001938401939285019201611246565b50909695505050505050565b604080825283519082018190526000906020906060840190828701845b828110156112b057815184529284019290840190600101611294565b505050838103828501526112c48186611189565b9695505050505050565b6000602082840312156112e057600080fd5b815180151581146112f057600080fd5b9392505050565b8181038181111561053b5761053b6111e2565b8082018082111561053b5761053b6111e2565b60006020828403121561132f57600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220e63231e04770b926abd63bea5c14fc2bfc517ab85aab9a32ab20483b97bb6ce264736f6c63430008120033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100cf578063e691ad33146100e0578063ed18348f14610103578063f2fde38b1461011657600080fd5b806312b91181146100825780636a5650e114610097578063715018a6146100c7575b600080fd5b610095610090366004610ef7565b610129565b005b6100aa6100a5366004610fee565b610468565b6040516001600160a01b0390911681526020015b60405180910390f35b610095610492565b6000546001600160a01b03166100aa565b6100f36100ee366004611062565b6104a6565b60405190151581526020016100be565b6100956101113660046110c6565b610541565b610095610124366004611158565b6109f4565b8151835114801561013b575060008351115b6101a05760405162461bcd60e51b815260206004820152602b60248201527f4345582061646472657373657320616e64207369676e61747572657320636f7560448201526a0dce840dad2e6dac2e8c6d60ab1b60648201526084015b60405180910390fd5b60005b83518110156103cb5760015481106102095760018482815181106101c9576101c9611173565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790556102ba565b6001818154811061021c5761021c611173565b60009182526020909120015484516001600160a01b039091169085908390811061024857610248611173565b60200260200101516001600160a01b0316146102ba5783818151811061027057610270611173565b60200260200101516001828154811061028b5761028b611173565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b600061033c8483815181106102d1576102d1611173565b6020026020010151610336856040516020016102ed91906111cf565b604051602081830303815290604052805190602001207f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b90610a6d565b9050806001600160a01b031685838151811061035a5761035a611173565b60200260200101516001600160a01b0316146103b85760405162461bcd60e51b815260206004820152601e60248201527f496e76616c6964207369676e657220666f7220455448206164647265737300006044820152606401610197565b50806103c3816111f8565b9150506101a3565b506001548351101561042b5782515b6001548110156104295760018054806103f5576103f5611211565b600082815260209020810160001990810180546001600160a01b031916905501905580610421816111f8565b9150506103da565b505b7f98eb3798cf76f91b917cbd9b06e682e42d54899d45623bbb3b81f213d58a9bf0600160405161045b9190611227565b60405180910390a1505050565b6001818154811061047857600080fd5b6000918252602090912001546001600160a01b0316905081565b61049a610a91565b6104a46000610aeb565b565b604051630bd205a960e41b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063bd205a90906104f79085908790600401611277565b602060405180830381865afa158015610514573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053891906112ce565b90505b92915050565b6001835161054f91906112f7565b845114801561055f575060008451115b6105bf5760405162461bcd60e51b815260206004820152602b60248201527f45524332302061646472657373657320616e642062616c616e63657320636f7560448201526a0dce840dad2e6dac2e8c6d60ab1b6064820152608401610197565b600080855167ffffffffffffffff8111156105dc576105dc610d8e565b604051908082528060200260200182016040528015610605578160200160208202803683370190505b50905060005b600154811015610753576001818154811061062857610628611173565b600091825260209091200154610648906001600160a01b0316318461130a565b925060005b87518110156107405787818151811061066857610668611173565b60200260200101516001600160a01b03166370a082316001848154811061069157610691611173565b60009182526020909120015460405160e083901b6001600160e01b03191681526001600160a01b039091166004820152602401602060405180830381865afa1580156106e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610705919061131d565b83828151811061071757610717611173565b6020026020010181815161072b919061130a565b90525080610738816111f8565b91505061064d565b508061074b816111f8565b91505061060b565b508460008151811061076757610767611173565b60200260200101518210156107d95760405162461bcd60e51b815260206004820152603260248201527f41637475616c204554482062616c616e6365206973206c657373207468616e206044820152717468652070726f76656e2062616c616e636560701b6064820152608401610197565b60005b86518110156108a057856107f182600161130a565b8151811061080157610801611173565b602002602001015182828151811061081b5761081b611173565b6020026020010151101561088e5760405162461bcd60e51b815260206004820152603460248201527f41637475616c2045524332302062616c616e6365206973206c657373207468616044820152736e207468652070726f76656e2062616c616e636560601b6064820152608401610197565b80610898816111f8565b9150506107dc565b506000855160016108b1919061130a565b67ffffffffffffffff8111156108c9576108c9610d8e565b6040519080825280602002602001820160405280156108f2578160200160208202803683370190505b509050848160008151811061090957610909611173565b60200260200101818152505060005b86518110156109765786818151811061093357610933611173565b602002602001015182826001610949919061130a565b8151811061095957610959611173565b60209081029190910101528061096e816111f8565b915050610918565b5061098184826104a6565b6109c05760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b2103d3590383937b7b360811b6044820152606401610197565b60405185907f08367c9e7de6aba412334c7e8a02be4c57a63f268945497c9d693772c7f3969390600090a250505050505050565b6109fc610a91565b6001600160a01b038116610a615760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610197565b610a6a81610aeb565b50565b6000806000610a7c8585610b3b565b91509150610a8981610b80565b509392505050565b6000546001600160a01b031633146104a45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610197565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000808251604103610b715760208301516040840151606085015160001a610b6587828585610cca565b94509450505050610b79565b506000905060025b9250929050565b6000816004811115610b9457610b94611336565b03610b9c5750565b6001816004811115610bb057610bb0611336565b03610bfd5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610197565b6002816004811115610c1157610c11611336565b03610c5e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610197565b6003816004811115610c7257610c72611336565b03610a6a5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610197565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115610d015750600090506003610d85565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610d55573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610d7e57600060019250925050610d85565b9150600090505b94509492505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610dcd57610dcd610d8e565b604052919050565b600067ffffffffffffffff821115610def57610def610d8e565b5060051b60200190565b80356001600160a01b0381168114610e1057600080fd5b919050565b600082601f830112610e2657600080fd5b81356020610e3b610e3683610dd5565b610da4565b82815260059290921b84018101918181019086841115610e5a57600080fd5b8286015b84811015610e7c57610e6f81610df9565b8352918301918301610e5e565b509695505050505050565b600082601f830112610e9857600080fd5b813567ffffffffffffffff811115610eb257610eb2610d8e565b610ec5601f8201601f1916602001610da4565b818152846020838601011115610eda57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600060608486031215610f0c57600080fd5b833567ffffffffffffffff80821115610f2457600080fd5b610f3087838801610e15565b9450602091508186013581811115610f4757600080fd5b8601601f81018813610f5857600080fd5b8035610f66610e3682610dd5565b81815260059190911b8201840190848101908a831115610f8557600080fd5b8584015b83811015610fbd57803586811115610fa15760008081fd5b610faf8d8983890101610e87565b845250918601918601610f89565b5096505050506040860135915080821115610fd757600080fd5b50610fe486828701610e87565b9150509250925092565b60006020828403121561100057600080fd5b5035919050565b600082601f83011261101857600080fd5b81356020611028610e3683610dd5565b82815260059290921b8401810191818101908684111561104757600080fd5b8286015b84811015610e7c578035835291830191830161104b565b6000806040838503121561107557600080fd5b823567ffffffffffffffff8082111561108d57600080fd5b61109986838701610e87565b935060208501359150808211156110af57600080fd5b506110bc85828601611007565b9150509250929050565b600080600080608085870312156110dc57600080fd5b843567ffffffffffffffff808211156110f457600080fd5b61110088838901610e15565b9550602087013591508082111561111657600080fd5b61112288838901611007565b945060408701359350606087013591508082111561113f57600080fd5b5061114c87828801610e87565b91505092959194509250565b60006020828403121561116a57600080fd5b61053882610df9565b634e487b7160e01b600052603260045260246000fd5b6000815180845260005b818110156111af57602081850181015186830182015201611193565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006105386020830184611189565b634e487b7160e01b600052601160045260246000fd5b60006001820161120a5761120a6111e2565b5060010190565b634e487b7160e01b600052603160045260246000fd5b6020808252825482820181905260008481528281209092916040850190845b8181101561126b5783546001600160a01b031683526001938401939285019201611246565b50909695505050505050565b604080825283519082018190526000906020906060840190828701845b828110156112b057815184529284019290840190600101611294565b505050838103828501526112c48186611189565b9695505050505050565b6000602082840312156112e057600080fd5b815180151581146112f057600080fd5b9392505050565b8181038181111561053b5761053b6111e2565b8082018082111561053b5761053b6111e2565b60006020828403121561132f57600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220e63231e04770b926abd63bea5c14fc2bfc517ab85aab9a32ab20483b97bb6ce264736f6c63430008120033", - "linkReferences": {}, - "deployedLinkReferences": {} -} +{"_format":"hh-sol-artifact-1","contractName":"Summa","sourceName":"src/Summa.sol","abi":[{"inputs":[{"internalType":"contract IVerifier","name":"_verifier","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"cexAddresses","type":"address[]"}],"name":"ExchangeAddressesSubmitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"mstRoot","type":"uint256"}],"name":"ProofOfSolvencySubmitted","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cexAddresses","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_cexAddresses","type":"address[]"},{"internalType":"bytes[]","name":"cexSignatures","type":"bytes[]"},{"internalType":"string","name":"message","type":"string"}],"name":"submitProofOfAccountOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"erc20ContractAddresses","type":"address[]"},{"internalType":"uint256[]","name":"assetSums","type":"uint256[]"},{"internalType":"uint256","name":"mstRoot","type":"uint256"},{"internalType":"bytes","name":"proof","type":"bytes"}],"name":"submitProofOfSolvency","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"proof","type":"bytes"},{"internalType":"uint256[]","name":"publicInputs","type":"uint256[]"}],"name":"verifyZkProof","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"bytecode":"0x60a060405234801561001057600080fd5b5060405161146638038061146683398101604081905261002f91610099565b61003833610049565b6001600160a01b03166080526100c9565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100ab57600080fd5b81516001600160a01b03811681146100c257600080fd5b9392505050565b6080516113826100e460003960006104c001526113826000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100cf578063e691ad33146100e0578063ed18348f14610103578063f2fde38b1461011657600080fd5b806312b91181146100825780636a5650e114610097578063715018a6146100c7575b600080fd5b610095610090366004610ef7565b610129565b005b6100aa6100a5366004610fee565b610468565b6040516001600160a01b0390911681526020015b60405180910390f35b610095610492565b6000546001600160a01b03166100aa565b6100f36100ee366004611062565b6104a6565b60405190151581526020016100be565b6100956101113660046110c6565b610541565b610095610124366004611158565b6109f4565b8151835114801561013b575060008351115b6101a05760405162461bcd60e51b815260206004820152602b60248201527f4345582061646472657373657320616e64207369676e61747572657320636f7560448201526a0dce840dad2e6dac2e8c6d60ab1b60648201526084015b60405180910390fd5b60005b83518110156103cb5760015481106102095760018482815181106101c9576101c9611173565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790556102ba565b6001818154811061021c5761021c611173565b60009182526020909120015484516001600160a01b039091169085908390811061024857610248611173565b60200260200101516001600160a01b0316146102ba5783818151811061027057610270611173565b60200260200101516001828154811061028b5761028b611173565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b600061033c8483815181106102d1576102d1611173565b6020026020010151610336856040516020016102ed91906111cf565b604051602081830303815290604052805190602001207f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b90610a6d565b9050806001600160a01b031685838151811061035a5761035a611173565b60200260200101516001600160a01b0316146103b85760405162461bcd60e51b815260206004820152601e60248201527f496e76616c6964207369676e657220666f7220455448206164647265737300006044820152606401610197565b50806103c3816111f8565b9150506101a3565b506001548351101561042b5782515b6001548110156104295760018054806103f5576103f5611211565b600082815260209020810160001990810180546001600160a01b031916905501905580610421816111f8565b9150506103da565b505b7f98eb3798cf76f91b917cbd9b06e682e42d54899d45623bbb3b81f213d58a9bf0600160405161045b9190611227565b60405180910390a1505050565b6001818154811061047857600080fd5b6000918252602090912001546001600160a01b0316905081565b61049a610a91565b6104a46000610aeb565b565b604051630bd205a960e41b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063bd205a90906104f79085908790600401611277565b602060405180830381865afa158015610514573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053891906112ce565b90505b92915050565b6001835161054f91906112f7565b845114801561055f575060008451115b6105bf5760405162461bcd60e51b815260206004820152602b60248201527f45524332302061646472657373657320616e642062616c616e63657320636f7560448201526a0dce840dad2e6dac2e8c6d60ab1b6064820152608401610197565b600080855167ffffffffffffffff8111156105dc576105dc610d8e565b604051908082528060200260200182016040528015610605578160200160208202803683370190505b50905060005b600154811015610753576001818154811061062857610628611173565b600091825260209091200154610648906001600160a01b0316318461130a565b925060005b87518110156107405787818151811061066857610668611173565b60200260200101516001600160a01b03166370a082316001848154811061069157610691611173565b60009182526020909120015460405160e083901b6001600160e01b03191681526001600160a01b039091166004820152602401602060405180830381865afa1580156106e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610705919061131d565b83828151811061071757610717611173565b6020026020010181815161072b919061130a565b90525080610738816111f8565b91505061064d565b508061074b816111f8565b91505061060b565b508460008151811061076757610767611173565b60200260200101518210156107d95760405162461bcd60e51b815260206004820152603260248201527f41637475616c204554482062616c616e6365206973206c657373207468616e206044820152717468652070726f76656e2062616c616e636560701b6064820152608401610197565b60005b86518110156108a057856107f182600161130a565b8151811061080157610801611173565b602002602001015182828151811061081b5761081b611173565b6020026020010151101561088e5760405162461bcd60e51b815260206004820152603460248201527f41637475616c2045524332302062616c616e6365206973206c657373207468616044820152736e207468652070726f76656e2062616c616e636560601b6064820152608401610197565b80610898816111f8565b9150506107dc565b506000855160016108b1919061130a565b67ffffffffffffffff8111156108c9576108c9610d8e565b6040519080825280602002602001820160405280156108f2578160200160208202803683370190505b509050848160008151811061090957610909611173565b60200260200101818152505060005b86518110156109765786818151811061093357610933611173565b602002602001015182826001610949919061130a565b8151811061095957610959611173565b60209081029190910101528061096e816111f8565b915050610918565b5061098184826104a6565b6109c05760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b2103d3590383937b7b360811b6044820152606401610197565b60405185907f08367c9e7de6aba412334c7e8a02be4c57a63f268945497c9d693772c7f3969390600090a250505050505050565b6109fc610a91565b6001600160a01b038116610a615760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610197565b610a6a81610aeb565b50565b6000806000610a7c8585610b3b565b91509150610a8981610b80565b509392505050565b6000546001600160a01b031633146104a45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610197565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000808251604103610b715760208301516040840151606085015160001a610b6587828585610cca565b94509450505050610b79565b506000905060025b9250929050565b6000816004811115610b9457610b94611336565b03610b9c5750565b6001816004811115610bb057610bb0611336565b03610bfd5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610197565b6002816004811115610c1157610c11611336565b03610c5e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610197565b6003816004811115610c7257610c72611336565b03610a6a5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610197565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115610d015750600090506003610d85565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610d55573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610d7e57600060019250925050610d85565b9150600090505b94509492505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610dcd57610dcd610d8e565b604052919050565b600067ffffffffffffffff821115610def57610def610d8e565b5060051b60200190565b80356001600160a01b0381168114610e1057600080fd5b919050565b600082601f830112610e2657600080fd5b81356020610e3b610e3683610dd5565b610da4565b82815260059290921b84018101918181019086841115610e5a57600080fd5b8286015b84811015610e7c57610e6f81610df9565b8352918301918301610e5e565b509695505050505050565b600082601f830112610e9857600080fd5b813567ffffffffffffffff811115610eb257610eb2610d8e565b610ec5601f8201601f1916602001610da4565b818152846020838601011115610eda57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600060608486031215610f0c57600080fd5b833567ffffffffffffffff80821115610f2457600080fd5b610f3087838801610e15565b9450602091508186013581811115610f4757600080fd5b8601601f81018813610f5857600080fd5b8035610f66610e3682610dd5565b81815260059190911b8201840190848101908a831115610f8557600080fd5b8584015b83811015610fbd57803586811115610fa15760008081fd5b610faf8d8983890101610e87565b845250918601918601610f89565b5096505050506040860135915080821115610fd757600080fd5b50610fe486828701610e87565b9150509250925092565b60006020828403121561100057600080fd5b5035919050565b600082601f83011261101857600080fd5b81356020611028610e3683610dd5565b82815260059290921b8401810191818101908684111561104757600080fd5b8286015b84811015610e7c578035835291830191830161104b565b6000806040838503121561107557600080fd5b823567ffffffffffffffff8082111561108d57600080fd5b61109986838701610e87565b935060208501359150808211156110af57600080fd5b506110bc85828601611007565b9150509250929050565b600080600080608085870312156110dc57600080fd5b843567ffffffffffffffff808211156110f457600080fd5b61110088838901610e15565b9550602087013591508082111561111657600080fd5b61112288838901611007565b945060408701359350606087013591508082111561113f57600080fd5b5061114c87828801610e87565b91505092959194509250565b60006020828403121561116a57600080fd5b61053882610df9565b634e487b7160e01b600052603260045260246000fd5b6000815180845260005b818110156111af57602081850181015186830182015201611193565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006105386020830184611189565b634e487b7160e01b600052601160045260246000fd5b60006001820161120a5761120a6111e2565b5060010190565b634e487b7160e01b600052603160045260246000fd5b6020808252825482820181905260008481528281209092916040850190845b8181101561126b5783546001600160a01b031683526001938401939285019201611246565b50909695505050505050565b604080825283519082018190526000906020906060840190828701845b828110156112b057815184529284019290840190600101611294565b505050838103828501526112c48186611189565b9695505050505050565b6000602082840312156112e057600080fd5b815180151581146112f057600080fd5b9392505050565b8181038181111561053b5761053b6111e2565b8082018082111561053b5761053b6111e2565b60006020828403121561132f57600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220e63231e04770b926abd63bea5c14fc2bfc517ab85aab9a32ab20483b97bb6ce264736f6c63430008120033","deployedBytecode":"0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100cf578063e691ad33146100e0578063ed18348f14610103578063f2fde38b1461011657600080fd5b806312b91181146100825780636a5650e114610097578063715018a6146100c7575b600080fd5b610095610090366004610ef7565b610129565b005b6100aa6100a5366004610fee565b610468565b6040516001600160a01b0390911681526020015b60405180910390f35b610095610492565b6000546001600160a01b03166100aa565b6100f36100ee366004611062565b6104a6565b60405190151581526020016100be565b6100956101113660046110c6565b610541565b610095610124366004611158565b6109f4565b8151835114801561013b575060008351115b6101a05760405162461bcd60e51b815260206004820152602b60248201527f4345582061646472657373657320616e64207369676e61747572657320636f7560448201526a0dce840dad2e6dac2e8c6d60ab1b60648201526084015b60405180910390fd5b60005b83518110156103cb5760015481106102095760018482815181106101c9576101c9611173565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790556102ba565b6001818154811061021c5761021c611173565b60009182526020909120015484516001600160a01b039091169085908390811061024857610248611173565b60200260200101516001600160a01b0316146102ba5783818151811061027057610270611173565b60200260200101516001828154811061028b5761028b611173565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b600061033c8483815181106102d1576102d1611173565b6020026020010151610336856040516020016102ed91906111cf565b604051602081830303815290604052805190602001207f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b90610a6d565b9050806001600160a01b031685838151811061035a5761035a611173565b60200260200101516001600160a01b0316146103b85760405162461bcd60e51b815260206004820152601e60248201527f496e76616c6964207369676e657220666f7220455448206164647265737300006044820152606401610197565b50806103c3816111f8565b9150506101a3565b506001548351101561042b5782515b6001548110156104295760018054806103f5576103f5611211565b600082815260209020810160001990810180546001600160a01b031916905501905580610421816111f8565b9150506103da565b505b7f98eb3798cf76f91b917cbd9b06e682e42d54899d45623bbb3b81f213d58a9bf0600160405161045b9190611227565b60405180910390a1505050565b6001818154811061047857600080fd5b6000918252602090912001546001600160a01b0316905081565b61049a610a91565b6104a46000610aeb565b565b604051630bd205a960e41b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063bd205a90906104f79085908790600401611277565b602060405180830381865afa158015610514573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053891906112ce565b90505b92915050565b6001835161054f91906112f7565b845114801561055f575060008451115b6105bf5760405162461bcd60e51b815260206004820152602b60248201527f45524332302061646472657373657320616e642062616c616e63657320636f7560448201526a0dce840dad2e6dac2e8c6d60ab1b6064820152608401610197565b600080855167ffffffffffffffff8111156105dc576105dc610d8e565b604051908082528060200260200182016040528015610605578160200160208202803683370190505b50905060005b600154811015610753576001818154811061062857610628611173565b600091825260209091200154610648906001600160a01b0316318461130a565b925060005b87518110156107405787818151811061066857610668611173565b60200260200101516001600160a01b03166370a082316001848154811061069157610691611173565b60009182526020909120015460405160e083901b6001600160e01b03191681526001600160a01b039091166004820152602401602060405180830381865afa1580156106e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610705919061131d565b83828151811061071757610717611173565b6020026020010181815161072b919061130a565b90525080610738816111f8565b91505061064d565b508061074b816111f8565b91505061060b565b508460008151811061076757610767611173565b60200260200101518210156107d95760405162461bcd60e51b815260206004820152603260248201527f41637475616c204554482062616c616e6365206973206c657373207468616e206044820152717468652070726f76656e2062616c616e636560701b6064820152608401610197565b60005b86518110156108a057856107f182600161130a565b8151811061080157610801611173565b602002602001015182828151811061081b5761081b611173565b6020026020010151101561088e5760405162461bcd60e51b815260206004820152603460248201527f41637475616c2045524332302062616c616e6365206973206c657373207468616044820152736e207468652070726f76656e2062616c616e636560601b6064820152608401610197565b80610898816111f8565b9150506107dc565b506000855160016108b1919061130a565b67ffffffffffffffff8111156108c9576108c9610d8e565b6040519080825280602002602001820160405280156108f2578160200160208202803683370190505b509050848160008151811061090957610909611173565b60200260200101818152505060005b86518110156109765786818151811061093357610933611173565b602002602001015182826001610949919061130a565b8151811061095957610959611173565b60209081029190910101528061096e816111f8565b915050610918565b5061098184826104a6565b6109c05760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b2103d3590383937b7b360811b6044820152606401610197565b60405185907f08367c9e7de6aba412334c7e8a02be4c57a63f268945497c9d693772c7f3969390600090a250505050505050565b6109fc610a91565b6001600160a01b038116610a615760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610197565b610a6a81610aeb565b50565b6000806000610a7c8585610b3b565b91509150610a8981610b80565b509392505050565b6000546001600160a01b031633146104a45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610197565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000808251604103610b715760208301516040840151606085015160001a610b6587828585610cca565b94509450505050610b79565b506000905060025b9250929050565b6000816004811115610b9457610b94611336565b03610b9c5750565b6001816004811115610bb057610bb0611336565b03610bfd5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610197565b6002816004811115610c1157610c11611336565b03610c5e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610197565b6003816004811115610c7257610c72611336565b03610a6a5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610197565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115610d015750600090506003610d85565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610d55573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610d7e57600060019250925050610d85565b9150600090505b94509492505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610dcd57610dcd610d8e565b604052919050565b600067ffffffffffffffff821115610def57610def610d8e565b5060051b60200190565b80356001600160a01b0381168114610e1057600080fd5b919050565b600082601f830112610e2657600080fd5b81356020610e3b610e3683610dd5565b610da4565b82815260059290921b84018101918181019086841115610e5a57600080fd5b8286015b84811015610e7c57610e6f81610df9565b8352918301918301610e5e565b509695505050505050565b600082601f830112610e9857600080fd5b813567ffffffffffffffff811115610eb257610eb2610d8e565b610ec5601f8201601f1916602001610da4565b818152846020838601011115610eda57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600060608486031215610f0c57600080fd5b833567ffffffffffffffff80821115610f2457600080fd5b610f3087838801610e15565b9450602091508186013581811115610f4757600080fd5b8601601f81018813610f5857600080fd5b8035610f66610e3682610dd5565b81815260059190911b8201840190848101908a831115610f8557600080fd5b8584015b83811015610fbd57803586811115610fa15760008081fd5b610faf8d8983890101610e87565b845250918601918601610f89565b5096505050506040860135915080821115610fd757600080fd5b50610fe486828701610e87565b9150509250925092565b60006020828403121561100057600080fd5b5035919050565b600082601f83011261101857600080fd5b81356020611028610e3683610dd5565b82815260059290921b8401810191818101908684111561104757600080fd5b8286015b84811015610e7c578035835291830191830161104b565b6000806040838503121561107557600080fd5b823567ffffffffffffffff8082111561108d57600080fd5b61109986838701610e87565b935060208501359150808211156110af57600080fd5b506110bc85828601611007565b9150509250929050565b600080600080608085870312156110dc57600080fd5b843567ffffffffffffffff808211156110f457600080fd5b61110088838901610e15565b9550602087013591508082111561111657600080fd5b61112288838901611007565b945060408701359350606087013591508082111561113f57600080fd5b5061114c87828801610e87565b91505092959194509250565b60006020828403121561116a57600080fd5b61053882610df9565b634e487b7160e01b600052603260045260246000fd5b6000815180845260005b818110156111af57602081850181015186830182015201611193565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006105386020830184611189565b634e487b7160e01b600052601160045260246000fd5b60006001820161120a5761120a6111e2565b5060010190565b634e487b7160e01b600052603160045260246000fd5b6020808252825482820181905260008481528281209092916040850190845b8181101561126b5783546001600160a01b031683526001938401939285019201611246565b50909695505050505050565b604080825283519082018190526000906020906060840190828701845b828110156112b057815184529284019290840190600101611294565b505050838103828501526112c48186611189565b9695505050505050565b6000602082840312156112e057600080fd5b815180151581146112f057600080fd5b9392505050565b8181038181111561053b5761053b6111e2565b8082018082111561053b5761053b6111e2565b60006020828403121561132f57600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220e63231e04770b926abd63bea5c14fc2bfc517ab85aab9a32ab20483b97bb6ce264736f6c63430008120033","linkReferences":{},"deployedLinkReferences":{}} \ No newline at end of file diff --git a/backend/src/contracts/deployments.json b/backend/src/contracts/deployments.json index e2d0ec7d..6896ec0c 100644 --- a/backend/src/contracts/deployments.json +++ b/backend/src/contracts/deployments.json @@ -1 +1 @@ -{"31337":{"address":"0xa513E6E4b8f2a923D98304ec87F64353C4D5C853"}} \ No newline at end of file +{"31337":{"address":"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"}} \ No newline at end of file diff --git a/backend/src/contracts/mod.rs b/backend/src/contracts/mod.rs index d365696e..8086c83b 100644 --- a/backend/src/contracts/mod.rs +++ b/backend/src/contracts/mod.rs @@ -1,3 +1,3 @@ pub mod generated; pub(crate) mod signer; -mod tests; +pub(crate) mod tests; diff --git a/backend/src/contracts/signer.rs b/backend/src/contracts/signer.rs index 43e136cd..63d7bdae 100644 --- a/backend/src/contracts/signer.rs +++ b/backend/src/contracts/signer.rs @@ -9,7 +9,9 @@ use ethers::{ }; use futures::future::join_all; use serde_json::Value; -use std::{error::Error, fs::File, io::BufReader, path::Path, str::FromStr, sync::Arc}; +use std::{ + error::Error, fs::File, io::BufReader, path::Path, str::FromStr, sync::Arc, time::Duration, +}; #[derive(Debug)] pub struct SummaSigner { @@ -34,7 +36,9 @@ impl SummaSigner { ) -> Self { let wallet: LocalWallet = LocalWallet::from_str(main_signer_key).unwrap(); - let provider = Provider::::try_from(rpc_url).unwrap(); + let provider = Provider::::try_from(rpc_url) + .unwrap() + .interval(Duration::from_millis(10u64)); let client = Arc::new(SignerMiddleware::new( provider, wallet.with_chain_id(chain_id), diff --git a/backend/src/contracts/tests.rs b/backend/src/contracts/tests.rs index 0720dc79..e08fe2e2 100644 --- a/backend/src/contracts/tests.rs +++ b/backend/src/contracts/tests.rs @@ -1,24 +1,95 @@ -mod test { +use std::{sync::Arc, time::Duration}; + +use ethers::{ + prelude::{ContractFactory, SignerMiddleware}, + providers::{Http, Middleware, Provider}, + signers::{LocalWallet, Signer}, + types::{H160, U256}, + utils::{Anvil, AnvilInstance}, +}; +use tokio::time; + +use crate::contracts::generated::mock_erc20::{MockERC20, MOCKERC20_ABI, MOCKERC20_BYTECODE}; + +// Setup test conditions on the anvil instance +pub async fn initialize_anvil() -> ( + AnvilInstance, + H160, + H160, + Arc, LocalWallet>>, + MockERC20, LocalWallet>>, +) { + let anvil: ethers::utils::AnvilInstance = Anvil::new() + .mnemonic("test test test test test test test test test test test junk") + .spawn(); + + // Extracting two exchange addresses from the Anvil instance + let cex_addr_1 = anvil.addresses()[1]; + let cex_addr_2 = anvil.addresses()[2]; + + // Setup wallet from the first key in the Anvil and an HTTP provider with a 10ms interval from the Anvil endpoint + let wallet: LocalWallet = anvil.keys()[0].clone().into(); + let provider = Provider::::try_from(anvil.endpoint()) + .unwrap() + .interval(Duration::from_millis(10u64)); + + // Creating a client by wrapping the provider with a signing middleware and the Anvil chainid + let client = Arc::new(SignerMiddleware::new( + provider, + wallet.with_chain_id(anvil.chain_id()), + )); + + // Creating a factory to deploy a mock ERC20 contract + let factory = ContractFactory::new( + MOCKERC20_ABI.to_owned(), + MOCKERC20_BYTECODE.to_owned(), + Arc::clone(&client), + ); + + // Send RPC requests with `anvil_setBalance` method via provider to set ETH balance of `cex_addr_1` and `cex_addr_2` + // This is for meeting `proof_of_solvency` test conditions + for addr in [cex_addr_1, cex_addr_2].to_vec() { + let _res = client + .provider() + .request::<(H160, U256), ()>("anvil_setBalance", (addr, U256::from(278432))) + .await; + } + + // Deploy Mock ERC20 contract + let mock_erc20_deployment = factory.deploy(()).unwrap().send().await.unwrap(); + + // Creating an interface for the deployed mock ERC20 contract + let mock_erc20 = MockERC20::new(mock_erc20_deployment.address(), Arc::clone(&client)); + + // Mint some token to `cex_addr_2` + let mint_call = mock_erc20.mint(cex_addr_2, U256::from(556863)); + assert!(mint_call.send().await.is_ok()); - use std::{time::Duration, sync::Arc}; + time::sleep(Duration::from_millis(500)).await; + + return (anvil, cex_addr_1, cex_addr_2, client, mock_erc20); +} + +mod test { + use std::sync::Arc; use ethers::{ - prelude::{ContractFactory, SignerMiddleware}, - providers::{Http, Middleware, Provider, StreamExt}, - signers::{LocalWallet, Signer}, - types::{U256, Filter, Address}, - utils::{Anvil}, + providers::Middleware, + types::{Address, Filter, U256}, + utils::Anvil, }; - use crate::{ - contracts::{generated::{ - mock_erc20::{self, MockERC20, MOCKERC20_ABI, MOCKERC20_BYTECODE}, - summa_contract::{ProofOfSolvencySubmittedFilter, Summa, ExchangeAddressesSubmittedFilter}, + use crate::contracts::{ + generated::{ + summa_contract::{ + ExchangeAddressesSubmittedFilter, ProofOfSolvencySubmittedFilter, Summa, + }, verifier::SolvencyVerifier, - }, signer::SummaSigner}, + }, + signer::SummaSigner, + tests::initialize_anvil, }; - #[tokio::test] async fn test_sign_message() { let anvil = Anvil::new().spawn(); @@ -42,31 +113,7 @@ mod test { #[tokio::test] async fn test_submit_proof_of_solvency() { - let anvil: ethers::utils::AnvilInstance = Anvil::new() - .mnemonic("test test test test test test test test test test test junk") - .spawn(); - - let cex_addr_1 = anvil.addresses()[1]; - let cex_addr_2 = anvil.addresses()[2]; - let wallet: LocalWallet = anvil.keys()[0].clone().into(); - let provider = Provider::::try_from(anvil.endpoint()) - .unwrap() - .interval(Duration::from_millis(10u64)); - - let client = Arc::new(SignerMiddleware::new( - provider, - wallet.with_chain_id(anvil.chain_id()), - )); - - let factory = ContractFactory::new( - MOCKERC20_ABI.to_owned(), - MOCKERC20_BYTECODE.to_owned(), - Arc::clone(&client), - ); - - let mock_erc20_deployment = factory.deploy(()).unwrap().send().await.unwrap(); - - let mock_erc20 = MockERC20::new(mock_erc20_deployment.address(),Arc::clone(&client)); + let (anvil, cex_addr_1, cex_addr_2, client, mock_erc20) = initialize_anvil().await; let verifer_contract = SolvencyVerifier::deploy(Arc::clone(&client), ()) .unwrap() @@ -80,12 +127,6 @@ mod test { .await .unwrap(); - let whole_amount: u64 = 556863; - let decimals = mock_erc20.decimals().call().await.unwrap(); - let decimal_amount = U256::from(whole_amount) * U256::exp10(decimals as usize); - let mint_call = mock_erc20.mint(cex_addr_2, decimal_amount); - assert!(mint_call.send().await.is_ok()); - let summa_signer = SummaSigner::new( &vec![ "0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e", @@ -96,7 +137,8 @@ mod test { anvil.endpoint().as_str(), summa_contract.address(), ); - let result = summa_signer.submit_proof_of_address_ownership( + + let result = summa_signer.submit_proof_of_address_ownership( vec![cex_addr_1, cex_addr_2], vec![ ("0x089b32327d332c295dc3b8873c205b72153211de6dc1c51235782b091cefb9d06d6df2661b86a7d441cd322f125b84901486b150e684221a7b7636eb8182af551b").parse().unwrap(), @@ -114,15 +156,18 @@ mod test { .unwrap(); assert_eq!(logs.len(), 1); - assert_eq!(logs[0], ExchangeAddressesSubmittedFilter { - cex_addresses: vec![cex_addr_1, cex_addr_2], - }); + assert_eq!( + logs[0], + ExchangeAddressesSubmittedFilter { + cex_addresses: vec![cex_addr_1, cex_addr_2], + } + ); - let result = summa_signer.submit_proof_of_solvency( + let result = summa_signer.submit_proof_of_solvency( vec![mock_erc20.address()], - vec![U256::from(556863),U256::from(556863)], - serde_json::from_str::("\"0x2E021D9BF99C5BD7267488B6A7A5CF5F7D00222A41B6A9B971899C44089E0C5\"").unwrap(), - ( "0x095ccd79cf0fef9757faed74485f7ded9dce7a67490773630adce50112f1e13907f894b25e6ad9bfd5e88c4fbd01327976e70c8fb83016c4d2f21930f72278e2240e9e1d49eca19e6ae06e8f500442e69354c6855299ab806984971c07e935ed1aa8d7c3d3ec19f7a65df38ec899aa085e9d917b51781e2c89a57e4d033306be04c1ec6a7265dd96431fd06f59a7c10cdd1b2c17bb8a259ea1f0aa473990a7fd2633b8fa4d3395806dd22cb52edc43f313f6bafc368c151eb2110e20bab9f23f0c9d2d2aac1c6035695f8087fc70a5bb7440bc9dc9073f74b155756b61e9734d05260ef5fa80036420528a209e0c767e1726f8e64ebcfb5ee9a59d12edb50cfb042e43a2bda4bfdc02fad894ea18981ddc58c80af745f67b5ff97ef04f9b37c90b9eaedb194eda4d7abc8c49097304d2a8515f18620b9ff59bbc56e0dcbe377c1308f11d72d983e263fc440811d6e9f193b0a0fa264f38e67f4f431eceb8470920b263648501bd10d7ee87b1ac413ff080ceb691f53e95791e2a1e39deb1b1e72d2968566eebef50f4f2e79a91221eed08f4ac57f07cdfb3780001f73f5ea89f0066094b22cc19559c81b898193816359039435a69f34b9245b6db8c8f76e1aa075939e23db318371e7ee4f4ea41b548551457cb4131280794621ca72ba2cef007cffcf5ceb934bc9a69f2c80c0625b667842428081b74920e603957e172806f29dc85bd03199aad1988eba070e2bfc8a0a37f9984701d8857a84a65a64dbfa61ba6b830fa5047ad4be4bc6b3357481b8d83d677e03f27db83a147aa49218c1401533188c87da56d4b7871964fad13103bd5125e33ee3ac41d241dff20b4be5d0304a46b3f973064c76b9999207f0606b0dbf417fb8362e7f29773713764326e27d44618a59c7b2b741f2f9e5a225fd63482113795b81f3476224e4be55e89280cee3e773320d85b175670273a14c8e9b4821bf2069ef5254ebba4fe2ed7b744020fdef85cebaa478f34eddc114701de9d9f4c6318dd3e55349bc92f837bf01a0afaa3e07561e8a281898f69981a1505370aeb063a61a29cb713debbe4ca6cac2cf40034fc6faeeba1f31b78730521ec6b6de6e2d0ae2f4a0781b130680120131bbf8bffe56f5baa7556a0b846b2a827e8eb55ac207a528810a975281329cb7a04c5d064170e42cdf6c9d9291edc8c3373f9f73fc50f7ab8dec245bc155b27f7174f87f87670016ab8763f1121f05745c7d6f70114e81db2eb822a94f28ff29318de1f4fc21f8d3502fb0806ace655edcb2e68c57f841f186c834e306ca07f9c04d33d11ffe15f71eff3076d0ef01c6d434dc2fe13ae3d4536fff415613f5b5f13c5bcc11c5569651b58f300abcc1e4e8692f36adc21149d5989a494e1544ba6111b57c7d0dd823ab53191e7aded3e96e11a88546419d409a164708b0777a2ca2bef4a705d7e2048efdd9c5978e6fc3a23302547a082a3d0893d3500b8b6c1ac1ac376ec9ebe367b3f852c6eac7aa70b396985826e83e9cadb6e8bd9c889997907ca30a75797e24fd52db5ae01fee5bb60ad0a26e39f73bee7c319703e7a45c403fe6104fa01c8ee86bc5cd4d6ac229ec9d0a7151b10dc91309302e4113870841c786a41a9090004afaa14ef347429a29097f837ed9fa88cd8a0cfa158e2766c2926033bf5649846a3503a4f6cfe081e5f2a20df844428bef230df79ec079c8525304f246b6cb90e3616ca07a8b0e11ad5f8de084aa125a498890cc7a8ca3d530f2c1df65a6e163c4373efa7766b7cf76b87270c8493d6d54abcde7b1c15507008370cc980d7ad3828e204cd7ae65db8538c6f742d8d0f0de08450617dfe4b3a05fbd7c73836de16e166caf0a0996e42793c6ddf0945014b310e4ad9ee64a22a2a2f5df921226f31d81322e8cf26c6da09b1dffdb42942b3c24c717dfd09a0831e1d7ffd20f43a21f07051449bef2d7e7fa662233fe493191ae6960e70ed7b9027eaafe9e42c49d8bf01988eb6cbb5352248ecae0a7fd31f9784522738675b8b219d95479c69e4e4061cc059c6dc935a678799c05e25c6f3ff445758399d80ea30388310ae65091c556d902ccfe2c55dc0d36b5c650c9ff907a51c695fe04ced186033d72daa6a5e90b651a7c4439d8376c82d0b4e5a5bd55c4075c9cbeabbfc1831c82d27556c6a21805e37ee343af28d5b155dd4df511a7cfd61a23c3e883729e8faf874e65e49ca84d76af5a0f8c36229212fe5ce6c69b4f268095cb4e1da01e8ed9374da2a7caf40b42ae0aa8bddc477911bd6aeb3376620a9d177779f420577660b7f457c168b6d7c953649545b2bbb8f8f4f2a089f1add2dba02f745672ca2e8b6936aded6139df497ddf2c9580a0f6e4a215332b209c372b87bc02df4207906f52996194c8b90203c249c8e94120fd24c514d0534d6adb3b1432b9b9b0fe71c1e4e41d4fd7f4f38f8092da15093d64791cfa1989efb096b3bbcd6a28b08468788cb1496329e5a771e9ba6589798bc355479dc82982e2b586182ee47121aad284cdf04ea85714ea3c2a6d4c4a229ec4efb37f819d4ff7dc7be4c37d5cf0cb3a85190d269f5ed86568959c77016cfde4b625168a9d423c00d5b3468c9402087ce7b8f1d60561cae28355278302a80cbf41f6f5cb825cdb86848f5c612490b4f6a46f6e1ce405b3f2a5bb47fc41093b5a71bed6edcc26ba4774d62ae2a3c243d1449d88a62ecc9ad3b9cd3c75769a799c39e614773c60301adbf068a28152d360fa6f5bc0c28e6bbab10bcc5e7489a42479b7fe818839c480c6111f0093d11361f1e64cd5ad836ed5447b04d723bff21d8c532a8c5171a6052e8f715416b10a7350ee05209d05c89a38647c472a9cc3340bc297bab55d412b55e903b1ab020b8fb2ddba3489e975afd45001ab45d1da25c74c2dc63ec4a4c71542c05aa7c0c03e33520ae22819ac1610c83146f1293f75e9a3d570d98e2b1a6a7ba4480ee299ee59065eb72fe388128bf5a435cb31ed75a2703426ee79eb3224538f7acb009642910ff7f8f851c4e15ec89dcca116cffb699be25d16326ce3bb9cf00f763062b0b5dab0673b3e1c97e32a3a292d18dd3df69e223369ec988a586c3d4ec2c1bc914b6dd72b8d50ac2c8ac5375016e0f8f0deb2213f9836cbe0bb76fd238ab22b3dd71c800b022cb90e4984ecf2149b6940850ceec181e65d2e6c1cfbe378f") + vec![U256::from(556863),U256::from(556863)], + serde_json::from_str::("\"0x2E021D9BF99C5BD7267488B6A7A5CF5F7D00222A41B6A9B971899C44089E0C5\"").unwrap(), + ( "0x095ccd79cf0fef9757faed74485f7ded9dce7a67490773630adce50112f1e13907f894b25e6ad9bfd5e88c4fbd01327976e70c8fb83016c4d2f21930f72278e2240e9e1d49eca19e6ae06e8f500442e69354c6855299ab806984971c07e935ed1aa8d7c3d3ec19f7a65df38ec899aa085e9d917b51781e2c89a57e4d033306be04c1ec6a7265dd96431fd06f59a7c10cdd1b2c17bb8a259ea1f0aa473990a7fd2633b8fa4d3395806dd22cb52edc43f313f6bafc368c151eb2110e20bab9f23f0c9d2d2aac1c6035695f8087fc70a5bb7440bc9dc9073f74b155756b61e9734d05260ef5fa80036420528a209e0c767e1726f8e64ebcfb5ee9a59d12edb50cfb042e43a2bda4bfdc02fad894ea18981ddc58c80af745f67b5ff97ef04f9b37c90b9eaedb194eda4d7abc8c49097304d2a8515f18620b9ff59bbc56e0dcbe377c1308f11d72d983e263fc440811d6e9f193b0a0fa264f38e67f4f431eceb8470920b263648501bd10d7ee87b1ac413ff080ceb691f53e95791e2a1e39deb1b1e72d2968566eebef50f4f2e79a91221eed08f4ac57f07cdfb3780001f73f5ea89f0066094b22cc19559c81b898193816359039435a69f34b9245b6db8c8f76e1aa075939e23db318371e7ee4f4ea41b548551457cb4131280794621ca72ba2cef007cffcf5ceb934bc9a69f2c80c0625b667842428081b74920e603957e172806f29dc85bd03199aad1988eba070e2bfc8a0a37f9984701d8857a84a65a64dbfa61ba6b830fa5047ad4be4bc6b3357481b8d83d677e03f27db83a147aa49218c1401533188c87da56d4b7871964fad13103bd5125e33ee3ac41d241dff20b4be5d0304a46b3f973064c76b9999207f0606b0dbf417fb8362e7f29773713764326e27d44618a59c7b2b741f2f9e5a225fd63482113795b81f3476224e4be55e89280cee3e773320d85b175670273a14c8e9b4821bf2069ef5254ebba4fe2ed7b744020fdef85cebaa478f34eddc114701de9d9f4c6318dd3e55349bc92f837bf01a0afaa3e07561e8a281898f69981a1505370aeb063a61a29cb713debbe4ca6cac2cf40034fc6faeeba1f31b78730521ec6b6de6e2d0ae2f4a0781b130680120131bbf8bffe56f5baa7556a0b846b2a827e8eb55ac207a528810a975281329cb7a04c5d064170e42cdf6c9d9291edc8c3373f9f73fc50f7ab8dec245bc155b27f7174f87f87670016ab8763f1121f05745c7d6f70114e81db2eb822a94f28ff29318de1f4fc21f8d3502fb0806ace655edcb2e68c57f841f186c834e306ca07f9c04d33d11ffe15f71eff3076d0ef01c6d434dc2fe13ae3d4536fff415613f5b5f13c5bcc11c5569651b58f300abcc1e4e8692f36adc21149d5989a494e1544ba6111b57c7d0dd823ab53191e7aded3e96e11a88546419d409a164708b0777a2ca2bef4a705d7e2048efdd9c5978e6fc3a23302547a082a3d0893d3500b8b6c1ac1ac376ec9ebe367b3f852c6eac7aa70b396985826e83e9cadb6e8bd9c889997907ca30a75797e24fd52db5ae01fee5bb60ad0a26e39f73bee7c319703e7a45c403fe6104fa01c8ee86bc5cd4d6ac229ec9d0a7151b10dc91309302e4113870841c786a41a9090004afaa14ef347429a29097f837ed9fa88cd8a0cfa158e2766c2926033bf5649846a3503a4f6cfe081e5f2a20df844428bef230df79ec079c8525304f246b6cb90e3616ca07a8b0e11ad5f8de084aa125a498890cc7a8ca3d530f2c1df65a6e163c4373efa7766b7cf76b87270c8493d6d54abcde7b1c15507008370cc980d7ad3828e204cd7ae65db8538c6f742d8d0f0de08450617dfe4b3a05fbd7c73836de16e166caf0a0996e42793c6ddf0945014b310e4ad9ee64a22a2a2f5df921226f31d81322e8cf26c6da09b1dffdb42942b3c24c717dfd09a0831e1d7ffd20f43a21f07051449bef2d7e7fa662233fe493191ae6960e70ed7b9027eaafe9e42c49d8bf01988eb6cbb5352248ecae0a7fd31f9784522738675b8b219d95479c69e4e4061cc059c6dc935a678799c05e25c6f3ff445758399d80ea30388310ae65091c556d902ccfe2c55dc0d36b5c650c9ff907a51c695fe04ced186033d72daa6a5e90b651a7c4439d8376c82d0b4e5a5bd55c4075c9cbeabbfc1831c82d27556c6a21805e37ee343af28d5b155dd4df511a7cfd61a23c3e883729e8faf874e65e49ca84d76af5a0f8c36229212fe5ce6c69b4f268095cb4e1da01e8ed9374da2a7caf40b42ae0aa8bddc477911bd6aeb3376620a9d177779f420577660b7f457c168b6d7c953649545b2bbb8f8f4f2a089f1add2dba02f745672ca2e8b6936aded6139df497ddf2c9580a0f6e4a215332b209c372b87bc02df4207906f52996194c8b90203c249c8e94120fd24c514d0534d6adb3b1432b9b9b0fe71c1e4e41d4fd7f4f38f8092da15093d64791cfa1989efb096b3bbcd6a28b08468788cb1496329e5a771e9ba6589798bc355479dc82982e2b586182ee47121aad284cdf04ea85714ea3c2a6d4c4a229ec4efb37f819d4ff7dc7be4c37d5cf0cb3a85190d269f5ed86568959c77016cfde4b625168a9d423c00d5b3468c9402087ce7b8f1d60561cae28355278302a80cbf41f6f5cb825cdb86848f5c612490b4f6a46f6e1ce405b3f2a5bb47fc41093b5a71bed6edcc26ba4774d62ae2a3c243d1449d88a62ecc9ad3b9cd3c75769a799c39e614773c60301adbf068a28152d360fa6f5bc0c28e6bbab10bcc5e7489a42479b7fe818839c480c6111f0093d11361f1e64cd5ad836ed5447b04d723bff21d8c532a8c5171a6052e8f715416b10a7350ee05209d05c89a38647c472a9cc3340bc297bab55d412b55e903b1ab020b8fb2ddba3489e975afd45001ab45d1da25c74c2dc63ec4a4c71542c05aa7c0c03e33520ae22819ac1610c83146f1293f75e9a3d570d98e2b1a6a7ba4480ee299ee59065eb72fe388128bf5a435cb31ed75a2703426ee79eb3224538f7acb009642910ff7f8f851c4e15ec89dcca116cffb699be25d16326ce3bb9cf00f763062b0b5dab0673b3e1c97e32a3a292d18dd3df69e223369ec988a586c3d4ec2c1bc914b6dd72b8d50ac2c8ac5375016e0f8f0deb2213f9836cbe0bb76fd238ab22b3dd71c800b022cb90e4984ecf2149b6940850ceec181e65d2e6c1cfbe378f") .parse().unwrap() ).await; @@ -135,11 +180,15 @@ mod test { .unwrap(); assert_eq!(logs.len(), 1); - assert_eq!(logs[0], ProofOfSolvencySubmittedFilter { - mst_root: "0x2E021D9BF99C5BD7267488B6A7A5CF5F7D00222A41B6A9B971899C44089E0C5".parse().unwrap(), - }); + assert_eq!( + logs[0], + ProofOfSolvencySubmittedFilter { + mst_root: "0x2E021D9BF99C5BD7267488B6A7A5CF5F7D00222A41B6A9B971899C44089E0C5" + .parse() + .unwrap(), + } + ); drop(anvil); } - } diff --git a/contracts/scripts/deploy.ts b/contracts/scripts/deploy.ts index 89a7fb42..988a6788 100644 --- a/contracts/scripts/deploy.ts +++ b/contracts/scripts/deploy.ts @@ -20,7 +20,7 @@ async function main() { await summa.deployed(); console.log(`Summa deployed to ${summa.address}`); - + let deploymentsJson: Deployments = {}; const fs = require("fs"); try { diff --git a/zk_prover/src/circuits/ecdsa.rs b/zk_prover/src/circuits/ecdsa.rs index 05c72101..3a1caa73 100644 --- a/zk_prover/src/circuits/ecdsa.rs +++ b/zk_prover/src/circuits/ecdsa.rs @@ -28,7 +28,7 @@ const NUMBER_OF_LIMBS: usize = 4; /// * `public_key`: The public key of the signer /// * `signature`: The signature to be verified (r, s) /// * `msg_hash`: The hash of the message to be verified -/// * `aux_generator`: The auxiliary generator point +/// * `aux_generator`: The auxiliary generator point /// * `window_size`: The window size used when assigning the auxiliary generator point #[derive(Default, Clone)]