Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
samkim-crypto committed Nov 15, 2023
1 parent a70e33b commit dcaa33b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions zk-token-sdk/src/range_proof/inner_product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ impl InnerProductProof {
if lg_n >= 32 {
// 4 billion multiplications should be enough for anyone
// and this check prevents overflow in 1<<lg_n below.
return Err(RangeProofVerificationError::InvalidBitSize.into());
return Err(RangeProofVerificationError::InvalidBitSize);
}
if n != (1 << lg_n) {
return Err(RangeProofVerificationError::InvalidBitSize.into());
return Err(RangeProofVerificationError::InvalidBitSize);
}

transcript.innerproduct_domain_separator(n as u64);
Expand Down Expand Up @@ -329,7 +329,7 @@ impl InnerProductProof {
if expect_P == *P {
Ok(())
} else {
Err(RangeProofVerificationError::AlgebraicRelation.into())
Err(RangeProofVerificationError::AlgebraicRelation)
}
}

Expand Down Expand Up @@ -366,18 +366,18 @@ impl InnerProductProof {
pub fn from_bytes(slice: &[u8]) -> Result<InnerProductProof, RangeProofVerificationError> {
let b = slice.len();
if b % 32 != 0 {
return Err(RangeProofVerificationError::Deserialization.into());
return Err(RangeProofVerificationError::Deserialization);
}
let num_elements = b / 32;
if num_elements < 2 {
return Err(RangeProofVerificationError::Deserialization.into());
return Err(RangeProofVerificationError::Deserialization);
}
if (num_elements - 2) % 2 != 0 {
return Err(RangeProofVerificationError::Deserialization.into());
return Err(RangeProofVerificationError::Deserialization);
}
let lg_n = (num_elements - 2) / 2;
if lg_n >= 32 {
return Err(RangeProofVerificationError::Deserialization.into());
return Err(RangeProofVerificationError::Deserialization);
}

let mut L_vec: Vec<CompressedRistretto> = Vec::with_capacity(lg_n);
Expand Down
8 changes: 4 additions & 4 deletions zk-token-sdk/src/range_proof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl RangeProof {
let bp_gens = BulletproofGens::new(nm);

if !nm.is_power_of_two() {
return Err(RangeProofVerificationError::InvalidBitSize.into());
return Err(RangeProofVerificationError::InvalidBitSize);
}

// append proof data to transcript and derive appropriate challenge scalars
Expand Down Expand Up @@ -326,7 +326,7 @@ impl RangeProof {
if mega_check.is_identity() {
Ok(())
} else {
Err(RangeProofVerificationError::AlgebraicRelation.into())
Err(RangeProofVerificationError::AlgebraicRelation)
}
}

Expand All @@ -349,10 +349,10 @@ impl RangeProof {
// changed.
pub fn from_bytes(slice: &[u8]) -> Result<RangeProof, RangeProofVerificationError> {
if slice.len() % 32 != 0 {
return Err(RangeProofVerificationError::Deserialization.into());
return Err(RangeProofVerificationError::Deserialization);
}
if slice.len() < 7 * 32 {
return Err(RangeProofVerificationError::Deserialization.into());
return Err(RangeProofVerificationError::Deserialization);
}

let A = CompressedRistretto(util::read32(&slice[0..]));
Expand Down
6 changes: 3 additions & 3 deletions zk-token-sdk/src/zk_token_elgamal/pod/range_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl TryFrom<decoded::RangeProof> for RangeProofU64 {

fn try_from(decoded_proof: decoded::RangeProof) -> Result<Self, Self::Error> {
if decoded_proof.ipp_proof.serialized_size() != INNER_PRODUCT_PROOF_U64_LEN {
return Err(RangeProofVerificationError::Deserialization.into());
return Err(RangeProofVerificationError::Deserialization);
}

let mut buf = [0_u8; RANGE_PROOF_U64_LEN];
Expand Down Expand Up @@ -76,7 +76,7 @@ impl TryFrom<decoded::RangeProof> for RangeProofU128 {

fn try_from(decoded_proof: decoded::RangeProof) -> Result<Self, Self::Error> {
if decoded_proof.ipp_proof.serialized_size() != INNER_PRODUCT_PROOF_U128_LEN {
return Err(RangeProofVerificationError::Deserialization.into());
return Err(RangeProofVerificationError::Deserialization);
}

let mut buf = [0_u8; RANGE_PROOF_U128_LEN];
Expand Down Expand Up @@ -107,7 +107,7 @@ impl TryFrom<decoded::RangeProof> for RangeProofU256 {

fn try_from(decoded_proof: decoded::RangeProof) -> Result<Self, Self::Error> {
if decoded_proof.ipp_proof.serialized_size() != INNER_PRODUCT_PROOF_U256_LEN {
return Err(RangeProofVerificationError::Deserialization.into());
return Err(RangeProofVerificationError::Deserialization);
}

let mut buf = [0_u8; RANGE_PROOF_U256_LEN];
Expand Down

0 comments on commit dcaa33b

Please sign in to comment.