Skip to content

Commit

Permalink
Bump curve25519-dalek from 3.2.1 to 4.1.2
Browse files Browse the repository at this point in the history
Fix bump rand to 0.8.5
  • Loading branch information
dependabot[bot] authored and andreisilviudragnea committed May 23, 2024
1 parent 097aa8e commit 96ccc79
Show file tree
Hide file tree
Showing 39 changed files with 180 additions and 124 deletions.
90 changes: 56 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ criterion-stats = "0.3.0"
crossbeam-channel = "0.5.13"
csv = "1.3.0"
ctrlc = "3.4.4"
curve25519-dalek = "3.2.1"
curve25519-dalek = { version = "4.1.2", features = ["digest", "rand_core"] }
dashmap = "5.5.3"
derivation-path = { version = "0.2.0", default-features = false }
derivative = "2.2.0"
Expand Down
5 changes: 3 additions & 2 deletions perf/src/sigverify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ mod tests {
for _ in 0..1_000_000 {
thread_rng().fill(&mut input);
let ans = get_checked_scalar(&input);
let ref_ans = Scalar::from_canonical_bytes(input);
let ref_ans = Option::<Scalar>::from(Scalar::from_canonical_bytes(input));
if let Some(ref_ans) = ref_ans {
passed += 1;
assert_eq!(ans.unwrap(), ref_ans.to_bytes());
Expand Down Expand Up @@ -1315,7 +1315,8 @@ mod tests {
for _ in 0..1_000_000 {
thread_rng().fill(&mut input);
let ans = check_packed_ge_small_order(&input);
let ref_ge = CompressedEdwardsY::from_slice(&input);
let ref_ge = CompressedEdwardsY::from_slice(&input)
.expect("Input slice should have a length of 32");
if let Some(ref_element) = ref_ge.decompress() {
if ref_element.is_small_order() {
assert!(!ans);
Expand Down
2 changes: 2 additions & 0 deletions sdk/program/src/pubkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ pub fn bytes_are_curve_point<T: AsRef<[u8]>>(_bytes: T) -> bool {
#[cfg(not(target_os = "solana"))]
{
curve25519_dalek::edwards::CompressedEdwardsY::from_slice(_bytes.as_ref())
.expect("Input slice should have a length of 32")
.decompress()
.is_some()
}
Expand Down Expand Up @@ -941,6 +942,7 @@ mod tests {
let is_on_curve = curve25519_dalek::edwards::CompressedEdwardsY::from_slice(
&program_address.to_bytes(),
)
.expect("Input slice should have a length of 32")
.decompress()
.is_some();
assert!(!is_on_curve);
Expand Down
4 changes: 2 additions & 2 deletions zk-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ bincode = { workspace = true }
curve25519-dalek = { workspace = true, features = ["serde"] }
itertools = { workspace = true }
lazy_static = { workspace = true }
rand = { version = "0.7" }
rand = { workspace = true }
serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { workspace = true }
sha3 = "0.9"
sha3 = { workspace = true }
solana-sdk = { workspace = true }
subtle = { workspace = true }
zeroize = { workspace = true, features = ["zeroize_derive"] }
Expand Down
9 changes: 6 additions & 3 deletions zk-sdk/src/encryption/elgamal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl ElGamalPubkey {
#[allow(non_snake_case)]
pub fn new(secret: &ElGamalSecretKey) -> Self {
let s = &secret.0;
assert!(s != &Scalar::zero());
assert!(s != &Scalar::ZERO);

ElGamalPubkey(s.invert() * &(*H))
}
Expand Down Expand Up @@ -375,6 +375,7 @@ impl TryFrom<&[u8]> for ElGamalPubkey {

Ok(ElGamalPubkey(
CompressedRistretto::from_slice(bytes)
.expect("Input slice should have a length of 32")
.decompress()
.ok_or(ElGamalError::PubkeyDeserialization)?,
))
Expand Down Expand Up @@ -530,7 +531,7 @@ impl TryFrom<&[u8]> for ElGamalSecretKey {
fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
match bytes.try_into() {
Ok(bytes) => Ok(ElGamalSecretKey::from(
Scalar::from_canonical_bytes(bytes)
Option::<Scalar>::from(Scalar::from_canonical_bytes(bytes))
.ok_or(ElGamalError::SecretKeyDeserialization)?,
)),
_ => Err(ElGamalError::SecretKeyDeserialization),
Expand Down Expand Up @@ -720,7 +721,9 @@ impl DecryptHandle {
}

Some(DecryptHandle(
CompressedRistretto::from_slice(bytes).decompress()?,
CompressedRistretto::from_slice(bytes)
.expect("Input slice should have a length of 32")
.decompress()?,
))
}
}
Expand Down
6 changes: 4 additions & 2 deletions zk-sdk/src/encryption/pedersen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl PedersenOpening {

pub fn from_bytes(bytes: &[u8]) -> Option<PedersenOpening> {
match bytes.try_into() {
Ok(bytes) => Scalar::from_canonical_bytes(bytes).map(PedersenOpening),
Ok(bytes) => Option::from(Scalar::from_canonical_bytes(bytes)).map(PedersenOpening),
_ => None,
}
}
Expand Down Expand Up @@ -185,7 +185,9 @@ impl PedersenCommitment {
}

Some(PedersenCommitment(
CompressedRistretto::from_slice(bytes).decompress()?,
CompressedRistretto::from_slice(bytes)
.expect("Input slice should have a length of 32")
.decompress()?,
))
}
}
Expand Down
4 changes: 2 additions & 2 deletions zk-sdk/src/range_proof/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use {
digest::{ExtendableOutput, Update, XofReader},
ristretto::RistrettoPoint,
},
sha3::{Sha3XofReader, Shake256},
sha3::{Shake256, Shake256Reader},
};

const MAX_GENERATOR_LENGTH: usize = u32::MAX as usize;

/// Generators for Pedersen vector commitments that are used for inner-product proofs.
struct GeneratorsChain {
reader: Sha3XofReader,
reader: Shake256Reader,
}

impl GeneratorsChain {
Expand Down
Loading

0 comments on commit 96ccc79

Please sign in to comment.