Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump secp256k1 from 0.24.3 to 0.28.0 #2357

Merged
merged 6 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 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 substrate/primitives/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ blake2 = { version = "0.10.4", default-features = false, optional = true }
libsecp256k1 = { version = "0.7", default-features = false, features = ["static-context"], optional = true }
schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated", "u64_backend"], default-features = false }
merlin = { version = "2.0", default-features = false }
secp256k1 = { version = "0.24.0", default-features = false, features = ["recovery", "alloc"], optional = true }
secp256k1 = { version = "0.28.0", default-features = false, features = ["recovery", "alloc"], optional = true }
sp-core-hashing = { path = "hashing", default-features = false, optional = true }
sp-runtime-interface = { path = "../runtime-interface", default-features = false}

Expand Down
13 changes: 4 additions & 9 deletions substrate/primitives/core/src/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl Signature {
pub fn recover_prehashed(&self, message: &[u8; 32]) -> Option<Public> {
let rid = RecoveryId::from_i32(self.0[64] as i32).ok()?;
let sig = RecoverableSignature::from_compact(&self.0[..64], rid).ok()?;
let message = Message::from_slice(message).expect("Message is 32 bytes; qed");
let message = Message::from_digest_slice(message).expect("Message is 32 bytes; qed");

#[cfg(feature = "std")]
let context = SECP256K1;
Expand Down Expand Up @@ -458,7 +458,7 @@ impl Pair {

/// Sign a pre-hashed message
pub fn sign_prehashed(&self, message: &[u8; 32]) -> Signature {
let message = Message::from_slice(message).expect("Message is 32 bytes; qed");
let message = Message::from_digest_slice(message).expect("Message is 32 bytes; qed");

#[cfg(feature = "std")]
let context = SECP256K1;
Expand Down Expand Up @@ -508,12 +508,7 @@ impl Pair {
#[cfg(feature = "full_crypto")]
impl Drop for Pair {
fn drop(&mut self) {
let ptr = self.secret.as_mut_ptr();
for off in 0..self.secret.len() {
unsafe {
core::ptr::write_volatile(ptr.add(off), 0);
}
}
self.secret.non_secure_erase()
}
}

Expand Down Expand Up @@ -760,7 +755,7 @@ mod test {
let msg = [0u8; 32];
let sig1 = pair.sign_prehashed(&msg);
let sig2: Signature = {
let message = Message::from_slice(&msg).unwrap();
let message = Message::from_digest_slice(&msg).unwrap();
SECP256K1.sign_ecdsa_recoverable(&message, &pair.secret).into()
};
assert_eq!(sig1, sig2);
Expand Down
2 changes: 1 addition & 1 deletion substrate/primitives/io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sp-trie = { path = "../trie", default-features = false, optional = true}
sp-externalities = { path = "../externalities", default-features = false}
sp-tracing = { path = "../tracing", default-features = false}
log = { version = "0.4.17", optional = true }
secp256k1 = { version = "0.24.0", features = ["recovery", "global-context"], optional = true }
secp256k1 = { version = "0.28.0", features = ["recovery", "global-context"], optional = true }
tracing = { version = "0.1.29", default-features = false }
tracing-core = { version = "0.1.28", default-features = false}

Expand Down
4 changes: 2 additions & 2 deletions substrate/primitives/io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ pub trait Crypto {
.map_err(|_| EcdsaVerifyError::BadV)?;
let sig = RecoverableSignature::from_compact(&sig[..64], rid)
.map_err(|_| EcdsaVerifyError::BadRS)?;
let msg = Message::from_slice(msg).expect("Message is 32 bytes; qed");
let msg = Message::from_digest_slice(msg).expect("Message is 32 bytes; qed");
let pubkey = SECP256K1
.recover_ecdsa(&msg, &sig)
.map_err(|_| EcdsaVerifyError::BadSignature)?;
Expand Down Expand Up @@ -1185,7 +1185,7 @@ pub trait Crypto {
.map_err(|_| EcdsaVerifyError::BadV)?;
let sig = RecoverableSignature::from_compact(&sig[..64], rid)
.map_err(|_| EcdsaVerifyError::BadRS)?;
let msg = Message::from_slice(msg).expect("Message is 32 bytes; qed");
let msg = Message::from_digest_slice(msg).expect("Message is 32 bytes; qed");
let pubkey = SECP256K1
.recover_ecdsa(&msg, &sig)
.map_err(|_| EcdsaVerifyError::BadSignature)?;
Expand Down