Skip to content

Commit

Permalink
deps: switch to use libseck256k1 to k256
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Sep 29, 2023
1 parent 8635da4 commit 22e7f5e
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 309 deletions.
77 changes: 18 additions & 59 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 @@ -85,10 +85,10 @@ git2 = "0.13.25"
ics23 = "0.9.0"
index-set = {git = "https://github.com/heliaxdev/index-set", tag = "v0.7.1", features = ["serialize-borsh", "serialize-serde"]}
itertools = "0.10.0"
k256 = { version = "0.13.0", default-features = false, features = ["ecdsa", "pkcs8", "precomputed-tables", "serde", "std"]}
lazy_static = "1.4.0"
libc = "0.2.97"
libloading = "0.7.2"
libsecp256k1 = {git = "https://github.com/heliaxdev/libsecp256k1", rev = "bbb3bd44a49db361f21d9db80f9a087c194c0ae9", default-features = false, features = ["std", "static-context"]}
# branch = "murisi/namada-integration"
masp_primitives = { git = "https://github.com/anoma/masp", rev = "50acc5028fbcd52a05970fe7991c7850ab04358e" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "50acc5028fbcd52a05970fe7991c7850ab04358e", default-features = false, features = ["local-prover"] }
Expand Down
6 changes: 3 additions & 3 deletions apps/src/lib/node/ledger/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1612,11 +1612,11 @@ mod test_utils {
ref sig,
ref recovery_id,
)) => {
let mut sig_bytes = sig.serialize();
let recovery_id_bytes = recovery_id.serialize();
let mut sig_bytes = sig.to_vec();
let recovery_id_bytes = recovery_id.to_byte();
sig_bytes[0] = sig_bytes[0].wrapping_add(1);
let bytes: [u8; 65] =
[sig_bytes.as_slice(), [recovery_id_bytes].as_slice()]
[sig_bytes.as_slice(), &[recovery_id_bytes]]
.concat()
.try_into()
.unwrap();
Expand Down
8 changes: 1 addition & 7 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ ferveo-tpke = [
wasm-runtime = [
"rayon",
]
# secp256k1 key signing, disabled in WASM build by default as it bloats the
# build a lot
secp256k1-sign = [
"libsecp256k1/hmac",
]

abciplus = [
"ibc",
Expand Down Expand Up @@ -78,7 +73,7 @@ ics23.workspace = true
impl-num-traits = "0.1.2"
index-set.workspace = true
itertools.workspace = true
libsecp256k1.workspace = true
k256.workspace = true
masp_primitives.workspace = true
num256.workspace = true
num-integer = "0.1.45"
Expand All @@ -104,7 +99,6 @@ zeroize.workspace = true

[dev-dependencies]
assert_matches.workspace = true
libsecp256k1 = {workspace = true, features = ["hmac"]}
pretty_assertions.workspace = true
proptest.workspace = true
rand.workspace = true
Expand Down
16 changes: 7 additions & 9 deletions core/src/types/key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,17 +692,15 @@ mod more_tests {
fn zeroize_keypair_secp256k1() {
use rand::thread_rng;

let mut sk = secp256k1::SigScheme::generate(&mut thread_rng());
let sk_scalar = sk.0.to_scalar_ref();
let len = sk_scalar.0.len();
let ptr = sk_scalar.0.as_ref().as_ptr();

let original_data = sk_scalar.0;

let sk = secp256k1::SigScheme::generate(&mut thread_rng());
let (ptr, original_data) = {
let sk_scalar = sk.0.as_scalar_primitive().as_ref();
(sk_scalar.as_ptr(), sk_scalar.to_owned())
};
drop(sk);

assert_ne!(&original_data, unsafe {
core::slice::from_raw_parts(ptr, len)
assert_ne!(original_data.as_slice(), unsafe {
core::slice::from_raw_parts(ptr, secp256k1::SECRET_KEY_SIZE)
});
}
}
Loading

0 comments on commit 22e7f5e

Please sign in to comment.