Skip to content
Permalink
Browse files

remove need for the expected size (this is done by expecting the corr…

…ect value)
  • Loading branch information...
NicolasDP committed May 14, 2019
1 parent 5a472aa commit a93096185bc89e76d347cc1909953b7952aa397f
Showing with 4 additions and 7 deletions.
  1. +4 −7 utils/src/serde.rs
@@ -130,12 +130,12 @@ pub mod witness {
pub mod crypto {
use super::*;
use ::bech32::{Bech32 as Bech32Data, FromBase32 as _};
use chain_crypto::{AsymmetricKey, Blake2b256, PublicKey, SecretKey, SecretKeySizeStatic};
use chain_crypto::{AsymmetricKey, Blake2b256, PublicKey, SecretKey};

pub fn deserialize_secret<'de, D, A>(deserializer: D) -> Result<SecretKey<A>, D::Error>
where
D: Deserializer<'de>,
A: SecretKeySizeStatic,
A: AsymmetricKey,
{
let secret_key_visitor = SecretKeyVisitor::new();
if deserializer.is_human_readable() {
@@ -244,7 +244,7 @@ pub mod crypto {

impl<'de, A> Visitor<'de> for SecretKeyVisitor<A>
where
A: SecretKeySizeStatic,
A: AsymmetricKey,
{
type Value = SecretKey<A>;

@@ -282,10 +282,7 @@ pub mod crypto {
{
use chain_crypto::SecretKeyError;
match Self::Value::from_binary(v) {
Err(SecretKeyError::SizeInvalid) => Err(E::custom(format!(
"Invalid size (expected: {}bytes)",
A::SECRET_KEY_SIZE
))),
Err(SecretKeyError::SizeInvalid) => Err(E::custom("Invalid size")),
Err(SecretKeyError::StructureInvalid) => Err(E::custom("Invalid structure")),
Ok(key) => Ok(key),
}

0 comments on commit a930961

Please sign in to comment.
You can’t perform that action at this time.