mirror of
https://github.com/vacp2p/zerokit.git
synced 2026-01-09 14:38:01 -05:00
Cargo clippy fixes
This commit is contained in:
@@ -12,11 +12,7 @@ use rln::{
|
||||
hashers::{hash_to_field, poseidon_hash},
|
||||
protocol::{keygen, prepare_prove_input, prepare_verify_input},
|
||||
public::RLN,
|
||||
utils::{
|
||||
bytes_le_to_fr, fr_to_bytes_le,
|
||||
generate_input_buffer,
|
||||
IdSecret
|
||||
},
|
||||
utils::{bytes_le_to_fr, fr_to_bytes_le, generate_input_buffer, IdSecret},
|
||||
};
|
||||
|
||||
const MESSAGE_LIMIT: u32 = 1;
|
||||
@@ -141,7 +137,6 @@ impl RLNSystem {
|
||||
signal: &str,
|
||||
external_nullifier: Fr,
|
||||
) -> Result<Vec<u8>> {
|
||||
|
||||
let identity = match self.local_identities.get(&user_index) {
|
||||
Some(identity) => identity,
|
||||
None => return Err(eyre!("user index {user_index} not found")),
|
||||
|
||||
@@ -4,9 +4,7 @@ use ark_bn254::Fr;
|
||||
use ark_ff::AdditiveGroup;
|
||||
use ark_groth16::{prepare_verifying_key, Groth16, Proof as ArkProof, ProvingKey, VerifyingKey};
|
||||
use ark_relations::r1cs::ConstraintMatrices;
|
||||
use ark_serialize::{
|
||||
CanonicalDeserialize, CanonicalSerialize,
|
||||
};
|
||||
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
|
||||
use ark_std::{rand::thread_rng, UniformRand};
|
||||
use num_bigint::BigInt;
|
||||
use rand::{Rng, SeedableRng};
|
||||
@@ -20,10 +18,13 @@ use crate::error::{ComputeIdSecretError, ConversionError, ProofError, ProtocolEr
|
||||
use crate::hashers::{hash_to_field, poseidon_hash};
|
||||
use crate::poseidon_tree::{MerkleProof, PoseidonTree};
|
||||
use crate::public::RLN_IDENTIFIER;
|
||||
use crate::utils::{bytes_le_to_fr, bytes_le_to_vec_fr, bytes_le_to_vec_u8, fr_byte_size, fr_to_bytes_le, normalize_usize, to_bigint, vec_fr_to_bytes_le, vec_u8_to_bytes_le, IdSecret};
|
||||
use utils::{ZerokitMerkleProof, ZerokitMerkleTree};
|
||||
use crate::utils::{
|
||||
bytes_le_to_fr, bytes_le_to_vec_fr, bytes_le_to_vec_u8, fr_byte_size, fr_to_bytes_le,
|
||||
normalize_usize, to_bigint, vec_fr_to_bytes_le, vec_u8_to_bytes_le, IdSecret,
|
||||
};
|
||||
#[cfg(test)]
|
||||
use std::time::Instant;
|
||||
use utils::{ZerokitMerkleProof, ZerokitMerkleTree};
|
||||
///////////////////////////////////////////////////////
|
||||
// RLN Witness data structure and utility functions
|
||||
///////////////////////////////////////////////////////
|
||||
@@ -494,7 +495,7 @@ pub fn seeded_keygen(signal: &[u8]) -> (IdSecret, Fr) {
|
||||
let id_commitment = poseidon_hash(&[identity_secret_hash_]);
|
||||
let identity_secret_hash = IdSecret::from(identity_secret_hash_);
|
||||
identity_secret_hash_.zeroize();
|
||||
|
||||
|
||||
(identity_secret_hash, id_commitment)
|
||||
}
|
||||
|
||||
@@ -518,7 +519,8 @@ pub fn extended_seeded_keygen(signal: &[u8]) -> (Fr, Fr, IdSecret, Fr) {
|
||||
let mut identity_secret_hash_ = poseidon_hash(&[identity_trapdoor, identity_nullifier]);
|
||||
let id_commitment = poseidon_hash(&[identity_secret_hash_]);
|
||||
let identity_secret_hash = IdSecret::from(identity_secret_hash_);
|
||||
|
||||
identity_secret_hash_.zeroize();
|
||||
|
||||
(
|
||||
identity_trapdoor,
|
||||
identity_nullifier,
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
use crate::circuit::Fr;
|
||||
use crate::error::ConversionError;
|
||||
use ark_ff::PrimeField;
|
||||
use ark_serialize::{
|
||||
CanonicalDeserialize, CanonicalSerialize, Compress, SerializationError, Valid, Validate,
|
||||
};
|
||||
use derive_more::{Display, From, Into};
|
||||
use num_bigint::{BigInt, BigUint};
|
||||
use num_traits::Num;
|
||||
use serde_json::json;
|
||||
use std::io::{Cursor, Read, Write};
|
||||
use std::ops::Deref;
|
||||
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, Compress, SerializationError, Valid, Validate};
|
||||
use derive_more::{Display, From, Into};
|
||||
use zeroize::{Zeroize, ZeroizeOnDrop};
|
||||
|
||||
#[inline(always)]
|
||||
@@ -160,7 +162,7 @@ pub struct IdSecret(ark_bn254::Fr);
|
||||
|
||||
impl Deref for IdSecret {
|
||||
type Target = Fr;
|
||||
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
|
||||
@@ -720,7 +720,10 @@ mod test {
|
||||
|
||||
// We check if the recovered identity secret hash corresponds to the original one
|
||||
let (recovered_identity_secret_hash, _) = bytes_le_to_fr(&serialized_identity_secret_hash);
|
||||
assert_eq!(recovered_identity_secret_hash, identity_secret_hash.clone().into());
|
||||
assert_eq!(
|
||||
recovered_identity_secret_hash,
|
||||
identity_secret_hash.clone().into()
|
||||
);
|
||||
|
||||
// We now test that computing identity_secret_hash is unsuccessful if shares computed from two different identity secret hashes but within same epoch are passed
|
||||
|
||||
@@ -774,7 +777,10 @@ mod test {
|
||||
|
||||
// ensure that the recovered secret does not match with either of the
|
||||
// used secrets in proof generation
|
||||
assert_ne!(recovered_identity_secret_hash_new, identity_secret_hash_new.into());
|
||||
assert_ne!(
|
||||
recovered_identity_secret_hash_new,
|
||||
identity_secret_hash_new.into()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user