Skip to content

Commit

Permalink
formatting and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
signorecello committed Jul 10, 2024
1 parent b20f800 commit 185a057
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ jobs:
- uses: actions/checkout@v4
- uses: noir-lang/[email protected]
with:
toolchain: 0.26.0
toolchain: 0.30.0
- run: nargo test
13 changes: 10 additions & 3 deletions packages/merkle-trees/src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ trait Calculator<T> {
}

trait SMT_Creator {
fn default(root: Field, leaf_hasher: fn([Field; 3]) -> Field, hasher: fn([Field; 2]) -> Field) -> Self;
fn default(
root: Field,
leaf_hasher: fn([Field; 3]) -> Field,
hasher: fn([Field; 2]) -> Field,
) -> Self;

/**
* Imports an existing Sparse Merkle Tree (SparseMerkleTree) instance.
* @param hasher The hash function that is used to hash the nodes of the tree
* @param root The root of the tree
*/
fn from(root: Field, leaf_hasher: fn([Field; 3]) -> Field, hasher: fn([Field; 2]) -> Field) -> Self {
fn from(
root: Field,
leaf_hasher: fn([Field; 3]) -> Field,
hasher: fn([Field; 2]) -> Field,
) -> Self {
Self::default(root, leaf_hasher, hasher)
}

Expand All @@ -28,7 +36,6 @@ trait SMT_Creator {
}
}


trait MT_Creator {
fn default(root: Field, hasher: fn([Field; 2]) -> Field) -> Self;

Expand Down
16 changes: 12 additions & 4 deletions packages/merkle-trees/src/sparse_merkle.nr
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
use crate::{SMT_Creator, MembershipProver, Modifier, NonMembershipProver};
use crate::{MembershipProver, Modifier, NonMembershipProver, SMT_Creator};

mod tests;
mod tree;

struct SparseMerkleTree {
root: Field,
leaf_hasher: fn([Field; 3]) -> Field,
hasher: fn([Field; 2]) -> Field
hasher: fn([Field; 2]) -> Field,
}

impl SMT_Creator for SparseMerkleTree {
fn default(root: Field, leaf_hasher: fn([Field; 3]) -> Field, hasher: fn([Field; 2]) -> Field) -> Self {
Self { root, leaf_hasher, hasher }
fn default(
root: Field,
leaf_hasher: fn([Field; 3]) -> Field,
hasher: fn([Field; 2]) -> Field,
) -> Self {
Self {
root,
leaf_hasher,
hasher,
}
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/merkle-trees/src/sparse_merkle/tests/poseidon.nr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ fn poseidon_hasher(leaves: [Field; 2]) -> Field {
hash_2([leaves[0], leaves[1]])
}


fn leaf_poseidon_hasher(leaves: [Field; 3]) -> Field {
hash_3([leaves[0], leaves[1], leaves[2]])
}
Expand Down

0 comments on commit 185a057

Please sign in to comment.