From dadf57b6ddbaf945a15d09cba8e4d641874a12d5 Mon Sep 17 00:00:00 2001 From: Sam Dealy Date: Wed, 1 Mar 2023 18:34:20 -0800 Subject: [PATCH 1/2] Add .idea/ to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 6aa10640..24891c09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target/ **/*.rs.bk Cargo.lock + +.idea/ From 9abfdc054d9ba65f1e185ea1e6eff3947ce879dc Mon Sep 17 00:00:00 2001 From: Sam Dealy Date: Wed, 1 Mar 2023 18:42:19 -0800 Subject: [PATCH 2/2] Fix build errors --- src/linear_proof.rs | 16 +++++++--------- tests/range_proof.rs | 24 ++++++++++++++++-------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/linear_proof.rs b/src/linear_proof.rs index 0f604f2d..91886e85 100644 --- a/src/linear_proof.rs +++ b/src/linear_proof.rs @@ -132,10 +132,8 @@ impl LinearProof { // b_L = b_L + x_j * b_R b_L[i] = b_L[i] + x_j * b_R[i]; // G_L = G_L + x_j * G_R - G_L[i] = RistrettoPoint::vartime_multiscalar_mul( - &[Scalar::one(), x_j], - &[G_L[i], G_R[i]], - ); + G_L[i] = + RistrettoPoint::vartime_multiscalar_mul(&[Scalar::ONE, x_j], &[G_L[i], G_R[i]]); } a = a_L; b = b_L; @@ -300,7 +298,7 @@ impl LinearProof { let lg_n = self.L_vec.len(); let mut s = Vec::with_capacity(n); - s.push(Scalar::one()); + s.push(Scalar::ONE); for i in 1..n { let lg_i = (32 - 1 - (i as u32).leading_zeros()) as usize; let k = 1 << lg_i; @@ -391,10 +389,10 @@ impl LinearProof { let pos = 2 * lg_n * 32; let S = CompressedRistretto(read32(&slice[pos..])); - let a = Scalar::from_canonical_bytes(read32(&slice[pos + 32..])) - .ok_or(ProofError::FormatError)?; - let r = Scalar::from_canonical_bytes(read32(&slice[pos + 64..])) - .ok_or(ProofError::FormatError)?; + let a = Scalar::from_canonical_bytes(read32(&slice[pos + 32..])); + let a = Option::from(a).ok_or(ProofError::FormatError)?; + let r = Scalar::from_canonical_bytes(read32(&slice[pos + 64..])); + let r = Option::from(r).ok_or(ProofError::FormatError)?; Ok(LinearProof { L_vec, diff --git a/tests/range_proof.rs b/tests/range_proof.rs index 61307e79..14d317fd 100644 --- a/tests/range_proof.rs +++ b/tests/range_proof.rs @@ -42,35 +42,43 @@ fn deserialize_and_verify() { CompressedRistretto::from_slice( &hex::decode("90b0c2fe57934dff9f5396e135e7d72b82b3c5393e1843178918eb2cf28a5f3c") .unwrap(), - ), + ) + .unwrap(), CompressedRistretto::from_slice( &hex::decode("74256a3e2a7fe948210c4095195ae4db3e3498c6c5fddc2afb226c0f1e97e468") .unwrap(), - ), + ) + .unwrap(), CompressedRistretto::from_slice( &hex::decode("7e348def6d03dc7bcbe7e03736ca2898e2efa9f6ff8ae4ed1cb5252ec1744075") .unwrap(), - ), + ) + .unwrap(), CompressedRistretto::from_slice( &hex::decode("861859f5d4c14f5d6d7ad88dcf43c9a98064a7d8702ffc9bad9eba2ed766702a") .unwrap(), - ), + ) + .unwrap(), CompressedRistretto::from_slice( &hex::decode("4c09b1260c833fefe25b1c3d3becc80979beca5e864d57fcb410bb15c7ba5c14") .unwrap(), - ), + ) + .unwrap(), CompressedRistretto::from_slice( &hex::decode("08cf26bfdf2e6b731536f5e48b4c0ac7b5fc846d36aaa3fe0d28f07c207f0814") .unwrap(), - ), + ) + .unwrap(), CompressedRistretto::from_slice( &hex::decode("a6e2d1c2770333c9a8a5ac10d9eb28e8609d5954428261335b2fd6ff0e0e8d69") .unwrap(), - ), + ) + .unwrap(), CompressedRistretto::from_slice( &hex::decode("30beef3b58fd2c18dde771d5c77e32f8dc01361e284aef517bce54a5c74c4665") .unwrap(), - ), + ) + .unwrap(), ]; let pc_gens = PedersenGens::default();