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

Upgrade libsecp256k1 from 0.3.5 ➔ 0.7.0 #967

Merged
merged 22 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion crates/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sha3 = { version = "0.9" }
blake2 = { version = "0.9" }

# ECDSA for the off-chain environment.
libsecp256k1 = { version = "0.3.5", default-features = false }
libsecp256k1 = { version = "0.7.0", default-features = false, features = ["static-context"] }

[features]
default = ["std"]
Expand Down
4 changes: 2 additions & 2 deletions crates/engine/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ impl Engine {
message_hash: &[u8; 32],
output: &mut [u8; 33],
) -> Result {
use secp256k1::{
use libsecp256k1::{
recover,
Message,
RecoveryId,
Expand All @@ -443,7 +443,7 @@ impl Engine {
signature[64]
};
let message = Message::parse(message_hash);
let signature = Signature::parse_slice(&signature[0..64])
let signature = Signature::parse_standard_slice(&signature[0..64])
.unwrap_or_else(|error| panic!("Unable to parse the signature: {}", error));

let recovery_id = RecoveryId::parse(recovery_byte)
Expand Down
6 changes: 2 additions & 4 deletions crates/env/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@ arrayref = "0.3"
static_assertions = "1.1"
sp-arithmetic = { version = "3.0", default-features = false }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# Hashes for the off-chain environment.
sha2 = { version = "0.9", optional = true }
sha3 = { version = "0.9", optional = true }
blake2 = { version = "0.9", optional = true }

# ECDSA for the off-chain environment.
libsecp256k1 = { version = "0.3.5", default-features = false }
libsecp256k1 = { version = "0.7.0", default-features = false, features = ["static-context"] }

# Only used in the off-chain environment.
#
# Sadly couldn't be marked as dev-dependency.
# Never use this crate outside the off-chain environment!
rand = { version = "0.8", default-features = false, features = ["alloc"], optional = true }
scale-info = { version = "1.0", default-features = false, features = ["derive"], optional = true }

Expand Down
4 changes: 2 additions & 2 deletions crates/env/src/engine/experimental_off_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl EnvBackend for EnvInstance {
message_hash: &[u8; 32],
output: &mut [u8; 33],
) -> Result<()> {
use secp256k1::{
use libsecp256k1::{
recover,
Message,
RecoveryId,
Expand All @@ -270,7 +270,7 @@ impl EnvBackend for EnvInstance {
signature[64]
};
let message = Message::parse(message_hash);
let signature = Signature::parse_slice(&signature[0..64])
let signature = Signature::parse_standard_slice(&signature[0..64])
.unwrap_or_else(|error| panic!("Unable to parse the signature: {}", error));

let recovery_id = RecoveryId::parse(recovery_byte)
Expand Down
4 changes: 2 additions & 2 deletions crates/env/src/engine/off_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl EnvBackend for EnvInstance {
message_hash: &[u8; 32],
output: &mut [u8; 33],
) -> Result<()> {
use secp256k1::{
use libsecp256k1::{
recover,
Message,
RecoveryId,
Expand All @@ -216,7 +216,7 @@ impl EnvBackend for EnvInstance {
signature[64]
};
let message = Message::parse(message_hash);
let signature = Signature::parse_slice(&signature[0..64])
let signature = Signature::parse_standard_slice(&signature[0..64])
.unwrap_or_else(|error| panic!("Unable to parse the signature: {}", error));

let recovery_id = RecoveryId::parse(recovery_byte)
Expand Down
4 changes: 3 additions & 1 deletion crates/eth_compatibility/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ include = ["Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]

[dependencies]
ink_env = { version = "3.0.0-rc6", path = "../env", default-features = false }
libsecp256k1 = { version = "0.3.5", default-features = false }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
libsecp256k1 = { version = "0.7.0", default-features = false, features = ["static-context"] }

[features]
default = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion crates/eth_compatibility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl ECDSAPublicKey {
/// ```
pub fn to_eth_address(&self) -> EthereumAddress {
use ink_env::hash;
use secp256k1::PublicKey;
use libsecp256k1::PublicKey;

// Transform compressed public key into uncompressed.
let pub_key = PublicKey::parse_compressed(&self.0)
Expand Down
1 change: 1 addition & 0 deletions crates/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ scale-info = { version = "1.0", default-features = false, features = ["derive"],
cfg-if = "1.0"
array-init = { version = "2.0", default-features = false }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# Workaround: we actually just need criterion as a dev-dependency, but
# there is an issue with a doubly included std lib when executing
# `cargo check --no-default-features --target wasm32-unknown-unknown`.
Expand Down