Update libsecp256k1 dep to 0.3.0 (#1258)

* Update libsecp256k1 dep to 0.3.0

* Sign now cannot fail
This commit is contained in:
Wei Tang
2019-10-01 17:37:02 +08:00
committed by Pierre Krieger
parent cf585d568b
commit 8be73c2245
2 changed files with 2 additions and 6 deletions

View File

@ -27,7 +27,7 @@ protobuf = "2.3"
quick-error = "1.2" quick-error = "1.2"
rand = "0.6" rand = "0.6"
rw-stream-sink = { version = "0.1.1", path = "../misc/rw-stream-sink" } 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" sha2 = "0.8.0"
smallvec = "0.6" smallvec = "0.6"
tokio-executor = "0.1.4" tokio-executor = "0.1.4"
@ -56,4 +56,3 @@ tokio-mock-task = "0.1"
[features] [features]
default = ["secp256k1"] default = ["secp256k1"]
secp256k1 = ["libsecp256k1"] secp256k1 = ["libsecp256k1"]

View File

@ -133,9 +133,7 @@ impl SecretKey {
pub fn sign_hash(&self, msg: &[u8]) -> Result<Vec<u8>, SigningError> { pub fn sign_hash(&self, msg: &[u8]) -> Result<Vec<u8>, SigningError> {
let m = Message::parse_slice(msg) let m = Message::parse_slice(msg)
.map_err(|_| SigningError::new("failed to parse secp256k1 digest"))?; .map_err(|_| SigningError::new("failed to parse secp256k1 digest"))?;
secp256k1::sign(&m, &self.0) Ok(secp256k1::sign(&m, &self.0).0.serialize_der().as_ref().into())
.map(|s| s.0.serialize_der().as_ref().into())
.map_err(|_| SigningError::new("failed to create secp256k1 signature"))
} }
} }
@ -190,4 +188,3 @@ mod tests {
assert_eq!(sk_bytes, [0; 32]); assert_eq!(sk_bytes, [0; 32]);
} }
} }