-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move
generate_leaf_hash
outside of zk_prover
- Loading branch information
1 parent
1775ca7
commit 06a15e4
Showing
6 changed files
with
28 additions
and
24 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
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 was deleted.
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,9 +1,7 @@ | ||
mod build_tree; | ||
mod csv_parser; | ||
mod generate_leaf_hash; | ||
mod operation_helpers; | ||
|
||
pub use build_tree::{build_leaves_from_entries, build_merkle_tree_from_leaves}; | ||
pub use csv_parser::parse_csv_to_entries; | ||
pub use generate_leaf_hash::generate_leaf_hash; | ||
pub use operation_helpers::*; |