Replace secp256k1 crate with libsecp256k1. (#1029)

* Replace `secp256k1` crate with `libsecp256k1`.

Unfortunately we could not implement `AsRef<[u8]>` for `SecretKey`
as the crate does not provide a means to do so.

* Fix `DecodingError` invocation.

* Remove the cc for wasm

* Revert "Remove the cc for wasm"

This reverts commit 3a19db35e62931c6e9ffbff6c21f9b0d7ae5403a.

* Fix CircleCI build
This commit is contained in:
Toralf Wittner
2019-05-14 19:33:30 +02:00
committed by Pierre Krieger
parent 43d9084735
commit 057b379541
8 changed files with 60 additions and 64 deletions

View File

@ -100,7 +100,7 @@ impl Keypair {
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
Rsa(ref pair) => pair.sign(msg),
#[cfg(feature = "secp256k1")]
Secp256k1(ref pair) => Ok(pair.secret().sign(msg)),
Secp256k1(ref pair) => pair.secret().sign(msg)
}
}
@ -178,7 +178,7 @@ impl PublicKey {
pub fn from_protobuf_encoding(bytes: &[u8]) -> Result<PublicKey, DecodingError> {
#[allow(unused_mut)] // Due to conditional compilation.
let mut pubkey = protobuf::parse_from_bytes::<keys_proto::PublicKey>(bytes)
.map_err(|e| DecodingError::new("Protobuf", e))?;
.map_err(|e| DecodingError::new("Protobuf").source(e))?;
match pubkey.get_Type() {
keys_proto::KeyType::Ed25519 => {
@ -193,7 +193,7 @@ impl PublicKey {
#[cfg(any(target_os = "emscripten", target_os = "unknown"))]
keys_proto::KeyType::RSA => {
log::debug!("support for RSA was disabled at compile-time");
Err("Unsupported".to_string().into())
Err(DecodingError::new("Unsupported"))
},
#[cfg(feature = "secp256k1")]
keys_proto::KeyType::Secp256k1 => {