forked from summa-dev/summa-solvency
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mst
efficiency improvement (summa-dev#188)
* feat: tree building rules * feat: add `get_middle_node_hash_preimage` and `get_middle_node_hash_preimage` methods * feat: update `generate_proof` * fix: `generate_proof` * fix: modify middle nodes hashing logic in circuit * feat: update `MerkleProof` * feat: add further constraint on `MstInclusionCircuit` * feat: rm `test_balance_not_in_range` * refactor: update `MerkleProof` * chore: fix `backend` * test: fix `backend` * fix: testing * fix: modify `MstInclusionCircuit` struct * Revert "fix: modify `MstInclusionCircuit` struct" This reverts commit e3ba8e6. * chore: update `benches` * fix: move poseidon hasher APIs to `Node` * chore: add guide on `MerkleProof ` * chore: update `where` clause in backend * chore: update comments * chore: move `generate_leaf_hash` outside of `zk_prover` * chore: add `ethers` legacy feature * chore: update verifier contract * fix: removed minting erc20 on the backend test * chore: rm unused imports * feat: remove `Node::leaf()` * feat: rm `Node::middle()` * Revert "feat: remove `Node::leaf()`" This reverts commit ae539a2. * chore: DRY code --------- Co-authored-by: sifnoc <[email protected]>
- Loading branch information
1 parent
2bb8bff
commit a734d94
Showing
32 changed files
with
2,605 additions
and
2,448 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
pub mod address_ownership; | ||
pub mod csv_parser; | ||
pub mod round; | ||
|
||
use ethers::types::U256; | ||
use num_bigint::BigUint; | ||
use num_traits::Num; | ||
use summa_solvency::merkle_sum_tree::Entry; | ||
|
||
pub fn leaf_hash_from_inputs<const N_ASSETS: usize>(username: String, balances: Vec<String>) -> U256 | ||
where | ||
[usize; N_ASSETS + 1]: Sized, | ||
{ | ||
// Convert balances to BigUint | ||
let balances: Vec<BigUint> = balances | ||
.iter() | ||
.map(|balance| BigUint::from_str_radix(balance, 10).unwrap()) | ||
.collect(); | ||
|
||
let entry: Entry<N_ASSETS> = Entry::new(username, balances.try_into().unwrap()).unwrap(); | ||
|
||
// Convert Fp to U256 | ||
let hash_str = format!("{:?}", entry.compute_leaf().hash); | ||
U256::from_str_radix(&hash_str, 16).unwrap() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"31337":{"address":"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9"}} | ||
{"31337":{"address":"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"}} |
Oops, something went wrong.