Skip to content

Commit

Permalink
chore(rln): infallible conversions (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Jan 23, 2024
1 parent 7669d72 commit ccd2ead
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rln/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub fn circom_from_folder(resources_folder: &str) -> Result<&'static Mutex<Witne

// Utilities to convert a json verification key in a groth16::VerificationKey
fn fq_from_str(s: &str) -> Result<Fq> {
Ok(Fq::try_from(BigUint::from_str(s)?)?)
Ok(Fq::from(BigUint::from_str(s)?))
}

// Extracts the element in G1 corresponding to its JSON serialization
Expand Down
6 changes: 3 additions & 3 deletions rln/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use num_traits::Num;
use std::iter::Extend;

pub fn to_bigint(el: &Fr) -> Result<BigInt> {
let res: BigUint = (*el).try_into()?;
let res: BigUint = (*el).into();
Ok(res.into())
}

Expand All @@ -28,10 +28,10 @@ pub fn str_to_fr(input: &str, radix: u32) -> Result<Fr> {
input_clean = input_clean.trim().to_string();

if radix == 10 {
Ok(BigUint::from_str_radix(&input_clean, radix)?.try_into()?)
Ok(BigUint::from_str_radix(&input_clean, radix)?.into())
} else {
input_clean = input_clean.replace("0x", "");
Ok(BigUint::from_str_radix(&input_clean, radix)?.try_into()?)
Ok(BigUint::from_str_radix(&input_clean, radix)?.into())
}
}

Expand Down

0 comments on commit ccd2ead

Please sign in to comment.