use crate::inner_types::*;
use crate::util::*;
#[cfg(feature = "wasm")]
use core::convert::TryFrom;
use serde::{Deserialize, Serialize};
use subtle::CtOption;
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
pub struct Blinding(pub(crate) G1Projective);
impl Default for Blinding {
fn default() -> Self {
Self(G1Projective::IDENTITY)
}
}
#[cfg(feature = "wasm")]
wasm_slice_impl!(Blinding);
impl Blinding {
pub const BYTES: usize = 48;
pub fn new(data: &[u8]) -> Self {
Self(hash_to_curve(data))
}
pub fn to_bytes(&self) -> [u8; Self::BYTES] {
self.0.to_affine().to_compressed()
}
pub fn from_bytes(data: &[u8; 48]) -> CtOption<Self> {
G1Affine::from_compressed(data).map(|p| Self(G1Projective::from(p)))
}
}