generated from recmo/rust-service-template
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor - move tree initializer to its own module.
- Loading branch information
Showing
11 changed files
with
462 additions
and
393 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod validator; |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use ruint::uint; | ||
use semaphore::Field; | ||
|
||
use crate::identity_tree::Hash; | ||
|
||
// See <https://docs.rs/ark-bn254/latest/ark_bn254> | ||
pub const MODULUS: Field = | ||
uint!(21888242871839275222246405745257275088548364400416034343698204186575808495617_U256); | ||
|
||
pub struct IdentityValidator { | ||
snark_scalar_field: Hash, | ||
} | ||
|
||
// TODO Export the reduced-ness check that this is enabling from the | ||
// `semaphore-rs` library when we bump the version. | ||
impl IdentityValidator { | ||
pub fn new() -> Self { | ||
Self { | ||
snark_scalar_field: Hash::from(MODULUS), | ||
} | ||
} | ||
|
||
pub fn identity_is_reduced(&self, commitment: Hash) -> bool { | ||
commitment.lt(&self.snark_scalar_field) | ||
} | ||
} | ||
|
||
impl Default for IdentityValidator { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} |
Oops, something went wrong.