mirror of
https://github.com/mimblewimble/grin.git
synced 2025-05-09 10:41:17 +03:00
[1.1.0] Additional secp primitive serialization changes (#2669)
* serialize sig, not just option(sig) * rustfmt * serialise pubkeys in short form
This commit is contained in:
parent
1b3eaba302
commit
c3496b45dd
1 changed files with 5 additions and 9 deletions
|
@ -32,7 +32,7 @@ pub mod pubkey_serde {
|
|||
{
|
||||
let static_secp = static_secp_instance();
|
||||
let static_secp = static_secp.lock();
|
||||
serializer.serialize_str(&to_hex(key.serialize_vec(&static_secp, false).to_vec()))
|
||||
serializer.serialize_str(&to_hex(key.serialize_vec(&static_secp, true).to_vec()))
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -95,7 +95,6 @@ pub mod option_sig_serde {
|
|||
pub mod sig_serde {
|
||||
use crate::serde::{Deserialize, Deserializer, Serializer};
|
||||
use crate::util::secp;
|
||||
use crate::util::static_secp_instance;
|
||||
use crate::util::{from_hex, to_hex};
|
||||
use serde::de::Error;
|
||||
|
||||
|
@ -104,9 +103,7 @@ pub mod sig_serde {
|
|||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let static_secp = static_secp_instance();
|
||||
let static_secp = static_secp.lock();
|
||||
serializer.serialize_str(&to_hex(sig.serialize_der(&static_secp)))
|
||||
serializer.serialize_str(&to_hex(sig.to_raw_data().to_vec()))
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -114,13 +111,12 @@ pub mod sig_serde {
|
|||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let static_secp = static_secp_instance();
|
||||
let static_secp = static_secp.lock();
|
||||
String::deserialize(deserializer)
|
||||
.and_then(|string| from_hex(string).map_err(|err| Error::custom(err.to_string())))
|
||||
.and_then(|bytes: Vec<u8>| {
|
||||
secp::Signature::from_der(&static_secp, &bytes)
|
||||
.map_err(|err| Error::custom(err.to_string()))
|
||||
let mut b = [0u8; 64];
|
||||
b.copy_from_slice(&bytes[0..64]);
|
||||
secp::Signature::from_raw_data(&b).map_err(|err| Error::custom(err.to_string()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue