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

fix: Bump k256 to ^0.13.3 (cherry-picking 9a6b365c352283119d78ed9f5ad715533fe8c3ae #341

Merged
merged 2 commits into from
Feb 2, 2024
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
524 changes: 278 additions & 246 deletions Cargo.lock

Large diffs are not rendered by default.

273 changes: 128 additions & 145 deletions contracts/burner/Cargo.lock

Large diffs are not rendered by default.

277 changes: 130 additions & 147 deletions contracts/crypto-verify/Cargo.lock

Large diffs are not rendered by default.

372 changes: 206 additions & 166 deletions contracts/cyberpunk/Cargo.lock

Large diffs are not rendered by default.

273 changes: 128 additions & 145 deletions contracts/floaty/Cargo.lock

Large diffs are not rendered by default.

273 changes: 128 additions & 145 deletions contracts/hackatom/Cargo.lock

Large diffs are not rendered by default.

273 changes: 128 additions & 145 deletions contracts/ibc-reflect-send/Cargo.lock

Large diffs are not rendered by default.

273 changes: 128 additions & 145 deletions contracts/ibc-reflect/Cargo.lock

Large diffs are not rendered by default.

457 changes: 206 additions & 251 deletions contracts/query-queue/Cargo.lock

Large diffs are not rendered by default.

273 changes: 128 additions & 145 deletions contracts/queue/Cargo.lock

Large diffs are not rendered by default.

259 changes: 121 additions & 138 deletions contracts/reflect/Cargo.lock

Large diffs are not rendered by default.

273 changes: 128 additions & 145 deletions contracts/staking/Cargo.lock

Large diffs are not rendered by default.

655 changes: 310 additions & 345 deletions contracts/virus/Cargo.lock

Large diffs are not rendered by default.

457 changes: 206 additions & 251 deletions contracts/voting-with-uuid/Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ backtraces = []
bench = false

[dependencies]
k256 = { version = "0.13.1", features = ["ecdsa"] }
k256 = { version = "0.13.3", features = ["ecdsa"] }
ed25519-zebra = "3"
digest = "0.10"
rand_core = { version = "0.6", features = ["getrandom"] }
Expand Down
10 changes: 8 additions & 2 deletions packages/crypto/src/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,24 @@ pub fn secp256k1_recover_pubkey(
let signature = read_signature(signature)?;

// params other than 0 and 1 are explicitly not supported
let id = match recovery_param {
let mut id = match recovery_param {
0 => RecoveryId::new(false, false),
1 => RecoveryId::new(true, false),
_ => return Err(CryptoError::invalid_recovery_param()),
};

// Compose extended signature
let signature = Signature::from_bytes(&signature.into())
let mut signature = Signature::from_bytes(&signature.into())
.map_err(|e| CryptoError::generic_err(e.to_string()))?;

// Recover
let message_digest = Identity256::new().chain(message_hash);

if let Some(normalized) = signature.normalize_s() {
signature = normalized;
id = RecoveryId::new(!id.is_y_odd(), id.is_x_reduced());
}

let pubkey = VerifyingKey::recover_from_digest(message_digest, &signature, id)
.map_err(|e| CryptoError::generic_err(e.to_string()))?;
let encoded: Vec<u8> = pubkey.to_encoded_point(false).as_bytes().into();
Expand Down
Loading