Skip to content

Commit 29e28d4

Browse files
committed
bump curve25519-dalek from 3.2.1 to 4.1.3
1 parent 4470f6d commit 29e28d4

40 files changed

+267
-209
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ 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/client/Cargo.toml
33+
sed -i "s/^curve25519-dalek =.*/curve25519-dalek = \"4.1.3\"/" token/confidential-transfer/proof-generation/Cargo.toml
34+
35+
# ignore these tests temporarily. see: https://github.com/anza-xyz/agave/pull/1693#issuecomment-2182615788
36+
sed -i 's/\([ \t]*\)async_trial!(confidential_transfer,/\1\/\/ async_trial!(confidential_transfer,/' token/cli/tests/command.rs
37+
sed -i '/async fn confidential_transfer_transfer_with_fee_and_split_proof_context_in_parallel(/i #[ignore]' token/program-2022-test/tests/confidential_transfer.rs

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ criterion-stats = "0.3.0"
220220
crossbeam-channel = "0.5.13"
221221
csv = "1.3.0"
222222
ctrlc = "3.4.5"
223-
curve25519-dalek = "3.2.1"
223+
curve25519-dalek = { version = "4.1.3", features = ["digest", "rand_core"] }
224224
dashmap = "5.5.3"
225225
derivation-path = { version = "0.2.0", default-features = false }
226226
derivative = "2.2.0"
@@ -543,39 +543,6 @@ solana-program = { path = "sdk/program" }
543543
solana-zk-sdk = { path = "zk-sdk" }
544544
solana-zk-token-sdk = { path = "zk-token-sdk" }
545545

546-
# Our dependency tree has `curve25519-dalek` v3.2.1. They have removed the
547-
# constraint in the next major release. The commit that removes the `zeroize`
548-
# constraint was added to multiple release branches, but not to the 3.2 branch.
549-
#
550-
# `curve25519-dalek` maintainers are saying they do not want to invest any more
551-
# time in the 3.2 release:
552-
#
553-
# https://github.com/dalek-cryptography/curve25519-dalek/issues/452#issuecomment-1749809428
554-
#
555-
# So we have to fork and create our own release, based on v3.2.1, with the
556-
# commit that removed `zeroize` constraint on the `main` branch cherry-picked on
557-
# top.
558-
#
559-
# `curve25519-dalek` v3.2.1 release:
560-
#
561-
# https://github.com/dalek-cryptography/curve25519-dalek/releases/tag/3.2.1
562-
#
563-
# Corresponds to commit
564-
#
565-
# https://github.com/dalek-cryptography/curve25519-dalek/commit/29e5c29b0e5c6821e4586af58b0d0891dd2ec639
566-
#
567-
# Comparison with `b500cdc2a920cd5bff9e2dd974d7b97349d61464`:
568-
#
569-
# https://github.com/dalek-cryptography/curve25519-dalek/compare/3.2.1...solana-labs:curve25519-dalek:b500cdc2a920cd5bff9e2dd974d7b97349d61464
570-
#
571-
# Or, using the branch name instead of the hash:
572-
#
573-
# https://github.com/dalek-cryptography/curve25519-dalek/compare/3.2.1...solana-labs:curve25519-dalek:3.2.1-unpin-zeroize
574-
#
575-
[patch.crates-io.curve25519-dalek]
576-
git = "https://github.com/anza-xyz/curve25519-dalek.git"
577-
rev = "b500cdc2a920cd5bff9e2dd974d7b97349d61464"
578-
579546
# Solana RPC nodes experience stalls when running with `tokio` containing this
580547
# commit:
581548
# https://github.com/tokio-rs/tokio/commit/4eed411519783ef6f58cbf74f886f91142b5cfa6

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
@@ -1276,7 +1276,7 @@ mod tests {
12761276
for _ in 0..1_000_000 {
12771277
thread_rng().fill(&mut input);
12781278
let ans = get_checked_scalar(&input);
1279-
let ref_ans = Scalar::from_canonical_bytes(input);
1279+
let ref_ans = Scalar::from_canonical_bytes(input).into_option();
12801280
if let Some(ref_ans) = ref_ans {
12811281
passed += 1;
12821282
assert_eq!(ans.unwrap(), ref_ans.to_bytes());
@@ -1311,7 +1311,7 @@ mod tests {
13111311
for _ in 0..1_000_000 {
13121312
thread_rng().fill(&mut input);
13131313
let ans = check_packed_ge_small_order(&input);
1314-
let ref_ge = CompressedEdwardsY::from_slice(&input);
1314+
let ref_ge = CompressedEdwardsY::from_slice(&input).unwrap();
13151315
if let Some(ref_element) = ref_ge.decompress() {
13161316
if ref_element.is_small_order() {
13171317
assert!(!ans);

0 commit comments

Comments
 (0)