diff --git a/Cargo.toml b/Cargo.toml index 3f0caeb..145532c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ generic-array = "0.13.2" tiny-keccak = "1.5" rustc-hex = "1.0.0" mimc-rs = "0.0.2" -poseidon-rs = "0.0.3" +poseidon-rs = "0.0.4" arrayref = "0.3.5" lazy_static = "1.4.0" diff --git a/src/lib.rs b/src/lib.rs index 2d8e4ba..c19e39f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,6 +73,7 @@ lazy_static! { ) .unwrap() >> 3; + static ref poseidon: poseidon_rs::Poseidon = Poseidon::new(); } #[derive(Clone, Debug)] @@ -306,7 +307,6 @@ impl PrivateKey { let a = &self.public()?; let hm_input = vec![r8.x.clone(), r8.y.clone(), a.x.clone(), a.y.clone(), msgFr]; - let poseidon = Poseidon::new(); let hm = poseidon.hash(hm_input)?; let mut s = &self.key << 3; @@ -345,7 +345,6 @@ pub fn schnorr_hash(pk: &Point, msg: BigInt, c: &Point) -> Result bool { if msg > Q.clone() { return false; } - let (_, msg_bytes) = msg.to_bytes_be(); let msgFr: Fr = Fr::from_str(&msg.to_string()).unwrap(); let hm_input = vec![ sig.r_b8.x.clone(), @@ -396,7 +394,6 @@ pub fn verify(pk: Point, sig: Signature, msg: BigInt) -> bool { pk.y.clone(), msgFr, ]; - let poseidon = Poseidon::new(); let hm = match poseidon.hash(hm_input) { Result::Err(_) => return false, Result::Ok(hm) => hm,