fork of https://github.com/poanetwork/threshold_crypto for the needs of nextgraph.org
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
573 B
20 lines
573 B
use super::Signature;
|
|
use pairing::bls12_381::G2Compressed;
|
|
use pairing::{CurveAffine, CurveProjective, EncodedPoint};
|
|
|
|
impl Signature {
|
|
pub fn to_vec(&self) -> Vec<u8> {
|
|
let comp = self.0.into_affine().into_compressed();
|
|
comp.as_ref().to_vec()
|
|
}
|
|
|
|
pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
|
|
let mut comp = G2Compressed::empty();
|
|
comp.as_mut().copy_from_slice(bytes);
|
|
if let Ok(affine) = comp.into_affine() {
|
|
Some(Signature(affine.into_projective()))
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
}
|
|
|