Skip to content

Commit fa0eb04

Browse files
yihaumergify[bot]
authored andcommitted
chore: bump curve25519-dalek from 3.2.1 to 4.1.3 (#2252)
* bump curve25519-dalek from 3.2.1 to 4.1.3 * Update .github/scripts/downstream-project-spl-common.sh Co-authored-by: samkim-crypto <[email protected]> * Update .github/scripts/downstream-project-spl-common.sh Co-authored-by: samkim-crypto <[email protected]> * Update .github/scripts/downstream-project-spl-common.sh Co-authored-by: samkim-crypto <[email protected]> * Update Cargo.toml Co-authored-by: samkim-crypto <[email protected]> * remove opt level hack * add comment for opt level --------- Co-authored-by: samkim-crypto <[email protected]> (cherry picked from commit 6e23e69) # Conflicts: # Cargo.lock # Cargo.toml # programs/sbf/Cargo.lock
1 parent ea2634f commit fa0eb04

40 files changed

+291
-205
lines changed

.github/scripts/downstream-project-spl-common.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ fi
2727

2828
# anza migration stopgap. can be removed when agave is fully recommended for public usage.
2929
sed -i 's/solana-geyser-plugin-interface/agave-geyser-plugin-interface/g' ./Cargo.toml
30+
31+
# should be removed when spl bump their curve25519-dalek
32+
sed -i "s/^curve25519-dalek =.*/curve25519-dalek = \"4.1.3\"/" token/confidential-transfer/proof-generation/Cargo.toml

Cargo.lock

Lines changed: 58 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,13 @@ criterion = "0.5.1"
193193
criterion-stats = "0.3.0"
194194
crossbeam-channel = "0.5.13"
195195
csv = "1.3.0"
196+
<<<<<<< HEAD
196197
ctrlc = "3.4.4"
197198
curve25519-dalek = "3.2.1"
199+
=======
200+
ctrlc = "3.4.5"
201+
curve25519-dalek = { version = "4.1.3", features = ["digest", "rand_core"] }
202+
>>>>>>> 6e23e69f09 (chore: bump curve25519-dalek from 3.2.1 to 4.1.3 (#2252))
198203
dashmap = "5.5.3"
199204
derivation-path = { version = "0.2.0", default-features = false }
200205
derivative = "2.2.0"
@@ -499,38 +504,16 @@ solana-program = { path = "sdk/program" }
499504
solana-zk-sdk = { path = "zk-sdk" }
500505
solana-zk-token-sdk = { path = "zk-token-sdk" }
501506

502-
# Our dependency tree has `curve25519-dalek` v3.2.1. They have removed the
503-
# constraint in the next major release. The commit that removes the `zeroize`
504-
# constraint was added to multiple release branches, but not to the 3.2 branch.
505-
#
506-
# `curve25519-dalek` maintainers are saying they do not want to invest any more
507-
# time in the 3.2 release:
508-
#
509-
# https://github.com/dalek-cryptography/curve25519-dalek/issues/452#issuecomment-1749809428
510-
#
511-
# So we have to fork and create our own release, based on v3.2.1, with the
512-
# commit that removed `zeroize` constraint on the `main` branch cherry-picked on
513-
# top.
514-
#
515-
# `curve25519-dalek` v3.2.1 release:
516-
#
517-
# https://github.com/dalek-cryptography/curve25519-dalek/releases/tag/3.2.1
518-
#
519-
# Corresponds to commit
520-
#
521-
# https://github.com/dalek-cryptography/curve25519-dalek/commit/29e5c29b0e5c6821e4586af58b0d0891dd2ec639
522-
#
523-
# Comparison with `b500cdc2a920cd5bff9e2dd974d7b97349d61464`:
524-
#
525-
# https://github.com/dalek-cryptography/curve25519-dalek/compare/3.2.1...solana-labs:curve25519-dalek:b500cdc2a920cd5bff9e2dd974d7b97349d61464
526-
#
527-
# Or, using the branch name instead of the hash:
528-
#
529-
# https://github.com/dalek-cryptography/curve25519-dalek/compare/3.2.1...solana-labs:curve25519-dalek:3.2.1-unpin-zeroize
530-
#
531-
[patch.crates-io.curve25519-dalek]
532-
git = "https://github.com/anza-xyz/curve25519-dalek.git"
533-
rev = "b500cdc2a920cd5bff9e2dd974d7b97349d61464"
507+
# curve25519-dalek uses the simd backend by default in v4 if possible,
508+
# which has very slow performance on some platforms with opt-level 0,
509+
# which is the default for dev and test builds.
510+
# This slowdown causes certain interactions in the solana-test-validator,
511+
# such as verifying ZK proofs in transactions, to take much more than 400ms,
512+
# creating problems in the testing environment.
513+
# To enable better performance in solana-test-validator during tests and dev builds,
514+
# we override the opt-level to 3 for the crate.
515+
[profile.dev.package.curve25519-dalek]
516+
opt-level = 3
534517

535518
# Solana RPC nodes experience stalls when running with `tokio` containing this
536519
# commit:

curves/curve25519/src/edwards.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ mod target_arch {
6363
type Error = Curve25519Error;
6464

6565
fn try_from(pod: &PodEdwardsPoint) -> Result<Self, Self::Error> {
66-
CompressedEdwardsY::from_slice(&pod.0)
66+
let Ok(compressed_edwards_y) = CompressedEdwardsY::from_slice(&pod.0) else {
67+
return Err(Curve25519Error::PodConversion);
68+
};
69+
compressed_edwards_y
6770
.decompress()
6871
.ok_or(Curve25519Error::PodConversion)
6972
}
@@ -73,9 +76,10 @@ mod target_arch {
7376
type Point = Self;
7477

7578
fn validate_point(&self) -> bool {
76-
CompressedEdwardsY::from_slice(&self.0)
77-
.decompress()
78-
.is_some()
79+
let Ok(compressed_edwards_y) = CompressedEdwardsY::from_slice(&self.0) else {
80+
return false;
81+
};
82+
compressed_edwards_y.decompress().is_some()
7983
}
8084
}
8185

curves/curve25519/src/ristretto.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ mod target_arch {
6363
type Error = Curve25519Error;
6464

6565
fn try_from(pod: &PodRistrettoPoint) -> Result<Self, Self::Error> {
66-
CompressedRistretto::from_slice(&pod.0)
66+
let Ok(compressed_ristretto) = CompressedRistretto::from_slice(&pod.0) else {
67+
return Err(Curve25519Error::PodConversion);
68+
};
69+
compressed_ristretto
6770
.decompress()
6871
.ok_or(Curve25519Error::PodConversion)
6972
}
@@ -73,9 +76,10 @@ mod target_arch {
7376
type Point = Self;
7477

7578
fn validate_point(&self) -> bool {
76-
CompressedRistretto::from_slice(&self.0)
77-
.decompress()
78-
.is_some()
79+
let Ok(compressed_ristretto) = CompressedRistretto::from_slice(&self.0) else {
80+
return false;
81+
};
82+
compressed_ristretto.decompress().is_some()
7983
}
8084
}
8185

curves/curve25519/src/scalar.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ mod target_arch {
1818
type Error = Curve25519Error;
1919

2020
fn try_from(pod: &PodScalar) -> Result<Self, Self::Error> {
21-
Scalar::from_canonical_bytes(pod.0).ok_or(Curve25519Error::PodConversion)
21+
Scalar::from_canonical_bytes(pod.0)
22+
.into_option()
23+
.ok_or(Curve25519Error::PodConversion)
2224
}
2325
}
2426

@@ -32,7 +34,9 @@ mod target_arch {
3234
type Error = Curve25519Error;
3335

3436
fn try_from(pod: PodScalar) -> Result<Self, Self::Error> {
35-
Scalar::from_canonical_bytes(pod.0).ok_or(Curve25519Error::PodConversion)
37+
Scalar::from_canonical_bytes(pod.0)
38+
.into_option()
39+
.ok_or(Curve25519Error::PodConversion)
3640
}
3741
}
3842
}

perf/src/sigverify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ mod tests {
12801280
for _ in 0..1_000_000 {
12811281
thread_rng().fill(&mut input);
12821282
let ans = get_checked_scalar(&input);
1283-
let ref_ans = Scalar::from_canonical_bytes(input);
1283+
let ref_ans = Scalar::from_canonical_bytes(input).into_option();
12841284
if let Some(ref_ans) = ref_ans {
12851285
passed += 1;
12861286
assert_eq!(ans.unwrap(), ref_ans.to_bytes());
@@ -1315,7 +1315,7 @@ mod tests {
13151315
for _ in 0..1_000_000 {
13161316
thread_rng().fill(&mut input);
13171317
let ans = check_packed_ge_small_order(&input);
1318-
let ref_ge = CompressedEdwardsY::from_slice(&input);
1318+
let ref_ge = CompressedEdwardsY::from_slice(&input).unwrap();
13191319
if let Some(ref_element) = ref_ge.decompress() {
13201320
if ref_element.is_small_order() {
13211321
assert!(!ans);

0 commit comments

Comments
 (0)