From cc067a9b216241e12584954eac77a5fc375e7d08 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Fri, 27 Sep 2019 11:05:37 +0800 Subject: [PATCH 1/2] Update libsecp256k1 dep to 0.3.0 --- core/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index d8f44e4365b..01012c6d0f7 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -27,7 +27,7 @@ protobuf = "2.3" quick-error = "1.2" rand = "0.6" rw-stream-sink = { version = "0.1.1", path = "../misc/rw-stream-sink" } -libsecp256k1 = { version = "0.2.2", optional = true } +libsecp256k1 = { version = "0.3.0", optional = true } sha2 = "0.8.0" smallvec = "0.6" tokio-executor = "0.1.4" @@ -56,4 +56,3 @@ tokio-mock-task = "0.1" [features] default = ["secp256k1"] secp256k1 = ["libsecp256k1"] - From a29c48ad7995a561872d5c4fc7e821934d4cceda Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Fri, 27 Sep 2019 11:11:52 +0800 Subject: [PATCH 2/2] Sign now cannot fail --- core/src/identity/secp256k1.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/src/identity/secp256k1.rs b/core/src/identity/secp256k1.rs index 9bc5a5796c0..5b6ef6b5bc6 100644 --- a/core/src/identity/secp256k1.rs +++ b/core/src/identity/secp256k1.rs @@ -133,9 +133,7 @@ impl SecretKey { pub fn sign_hash(&self, msg: &[u8]) -> Result, SigningError> { let m = Message::parse_slice(msg) .map_err(|_| SigningError::new("failed to parse secp256k1 digest"))?; - secp256k1::sign(&m, &self.0) - .map(|s| s.0.serialize_der().as_ref().into()) - .map_err(|_| SigningError::new("failed to create secp256k1 signature")) + Ok(secp256k1::sign(&m, &self.0).0.serialize_der().as_ref().into()) } } @@ -190,4 +188,3 @@ mod tests { assert_eq!(sk_bytes, [0; 32]); } } -