Skip to content

Commit

Permalink
REMOVEME: Update rust-secp256k1 to 0.29.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeandudey committed May 16, 2024
1 parent 0c9174c commit 4f79c5d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions extmod/foundation-rust/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 extmod/foundation-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ default-features = false
features = ["critical-section"]

[dependencies.secp256k1]
version = "0.27"
version = "0.29"
default-features = false
features = ["lowmemory", "rand"]

Expand Down
10 changes: 5 additions & 5 deletions extmod/foundation-rust/src/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use core::ptr;
use once_cell::sync::Lazy;
use secp256k1::{
ffi::types::AlignedType, AllPreallocated, KeyPair, Message, Secp256k1,
ffi::types::AlignedType, AllPreallocated, Keypair, Message, Secp256k1,
SecretKey,
};

Expand Down Expand Up @@ -35,7 +35,7 @@ pub extern "C" fn secp256k1_public_key_schnorr(
secret_key: &[u8; 32],
public_key: &mut [u8; 32],
) {
let keypair = KeyPair::from_seckey_slice(&PRE_ALLOCATED_CTX, secret_key)
let keypair = Keypair::from_seckey_slice(&PRE_ALLOCATED_CTX, secret_key)
.expect("invalid secret key");
let compressed_key = keypair.public_key().serialize();
public_key.copy_from_slice(&compressed_key[1..]);
Expand All @@ -55,7 +55,7 @@ pub extern "C" fn secp256k1_sign_ecdsa(
let secret_key =
SecretKey::from_slice(secret_key).expect("invalid secret key");

let msg = Message::from_slice(data).unwrap();
let msg = Message::from_digest_slice(data).unwrap();
let sig = PRE_ALLOCATED_CTX.sign_ecdsa(&msg, &secret_key);
signature.copy_from_slice(&sig.serialize_compact());
}
Expand All @@ -71,10 +71,10 @@ pub extern "C" fn secp256k1_sign_schnorr(
secret_key: &[u8; 32],
signature: &mut [u8; 64],
) {
let keypair = KeyPair::from_seckey_slice(&PRE_ALLOCATED_CTX, secret_key)
let keypair = Keypair::from_seckey_slice(&PRE_ALLOCATED_CTX, secret_key)
.expect("invalid secret key");

let msg = Message::from_slice(data).unwrap();
let msg = Message::from_digest_slice(data).unwrap();
let sig =
PRE_ALLOCATED_CTX.sign_schnorr_with_rng(&msg, &keypair, &mut rng());
signature.copy_from_slice(sig.as_ref());
Expand Down

0 comments on commit 4f79c5d

Please sign in to comment.