diff --git a/Cargo.toml b/Cargo.toml index 29c6446..d100908 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] wasm-bindgen = { version = "0.2" } wasm-bindgen-test = { version = "0.2" } sha2 = { version = "0.8"} -schnorrkel = { git = "https://github.com/w3f/schnorrkel.git", features = ["nightly"]} +schnorrkel = { version = "0.0", features = ["nightly"]} [dev-dependencies] rand = { version = "0.6.5", features = ["wasm-bindgen"] } \ No newline at end of file diff --git a/src/wrapper.rs b/src/wrapper.rs index c1a86ee..9247add 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -7,12 +7,11 @@ use schnorrkel::SignatureError; // We must make sure that this is the same as declared in the substrate source code. const SIGNING_CTX: &'static [u8] = b"substrate transaction"; - -pub fn __sign(secret: &[u8], message: &[u8]) -> [u8; SIGNATURE_LENGTH] { - let secret_key = SecretKey::from_bytes(secret).unwrap(); +pub fn __sign(secret: &[u8], message: &[u8]) -> Result<[u8; SIGNATURE_LENGTH], SignatureError> { + let secret_key = SecretKey::from_bytes(secret)?; let kp = secret_key.to_keypair(); let context = signing_context(SIGNING_CTX); - kp.sign(context.bytes(message)).to_bytes() + Ok(kp.sign(context.bytes(message)).to_bytes()) } pub fn __verify(signature: &[u8], message: &[u8], pubkey: &[u8]) -> bool {