Skip to content

Commit

Permalink
Update to k256 pre-release to allow high-S in recover pubkey
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Feb 2, 2024
1 parent fa92691 commit 3b6f279
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 60 deletions.
137 changes: 92 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions packages/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ bench = false

[dependencies]
# Version pinned due to https://github.com/CosmWasm/cosmwasm/issues/2010
k256 = { version = "=0.13.1", features = ["ecdsa"] }
k256 = { git = "https://github.com/RustCrypto/elliptic-curves.git", features = ["ecdsa"] }
ed25519-zebra = "3"
digest = "0.10"
digest = "0.11.0-pre.8"
rand_core = { version = "0.6", features = ["getrandom"] }
thiserror = "1.0.38"
# Not used directly, but needed to bump transitive dependency, see: https://github.com/CosmWasm/cosmwasm/pull/1899 for details.
ecdsa = "0.16.2"

[dev-dependencies]
criterion = "0.5.1"
Expand Down
9 changes: 4 additions & 5 deletions packages/crypto/src/identity_digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
//!
//! Adapted from `sha2` [sha256.rs](https://github.com/RustCrypto/hashes/blob/master/sha2/src/sha256.rs)
use digest::consts::U32;
use digest::generic_array::GenericArray;
use digest::{FixedOutput, HashMarker, Output, OutputSizeUser, Reset, Update};

/// The 256-bits identity container
#[derive(Clone, Default)]
pub struct Identity256 {
array: GenericArray<u8, U32>,
array: [u8; 32],
}

impl Update for Identity256 {
fn update(&mut self, hash: &[u8]) {
assert_eq!(hash.as_ref().len(), 32);
self.array = *GenericArray::from_slice(hash);
// copy_from_slice panicks if input is not 32 bytes long
self.array.copy_from_slice(hash);
}
}

Expand All @@ -26,7 +25,7 @@ impl OutputSizeUser for Identity256 {

impl FixedOutput for Identity256 {
fn finalize_into(self, out: &mut Output<Self>) {
*out = self.array;
*out = self.array.into();
}
}

Expand Down
Loading

0 comments on commit 3b6f279

Please sign in to comment.