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 5, 2024
1 parent 8b6b2a4 commit c5a943b
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 62 deletions.
128 changes: 88 additions & 40 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions packages/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ default = []
bench = false

[dependencies]
k256 = { version = "0.13.3", 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"

Expand Down
3 changes: 1 addition & 2 deletions packages/crypto/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use hex_literal::hex;
use serde::Deserialize;

// Crypto stuff
use digest::Digest;
use k256::ecdsa::SigningKey; // type alias
use sha2::Sha256;
use sha2::{Digest, Sha256};

use cosmwasm_crypto::{
ed25519_batch_verify, ed25519_verify, secp256k1_recover_pubkey, secp256k1_verify,
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 c5a943b

Please sign in to comment.