Skip to content

Commit

Permalink
feature: range check added
Browse files Browse the repository at this point in the history
  • Loading branch information
tyshko-rostyslav committed Aug 28, 2023
1 parent ea1ac53 commit 5493bd8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rln/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,11 @@ pub fn generate_proof_with_witness(
Ok(proof)
}

/// Formats inputs for witness calculation
///
/// # Errors
///
/// Returns an error if `rln_witness.message_id` is not within `rln_witness.user_message_limit`.
pub fn inputs_for_witness_calculation(
rln_witness: &RLNWitnessInput,
) -> Result<[(&str, Vec<BigInt>); 8]> {
Expand All @@ -643,6 +648,10 @@ pub fn inputs_for_witness_calculation(
.iter()
.for_each(|v| identity_path_index.push(BigInt::from(*v)));

if rln_witness.message_id > rln_witness.user_message_limit {
return Err(color_eyre::Report::msg("message_id is not within user_message_limit"))
}

Ok([
(
"identity_secret",
Expand Down

0 comments on commit 5493bd8

Please sign in to comment.