use curve25519_dalek::{constants::RISTRETTO_BASEPOINT_POINT, scalar::Scalar};
use rand::OsRng;
use Error::WiredScalarMalformed;
pub struct BlindSession {
k: Scalar,
}
impl BlindSession {
pub fn new() -> ::Result<([u8; 32], Self)> {
let mut rng = OsRng::new()?;
let k = Scalar::random(&mut rng);
let rp = (k * RISTRETTO_BASEPOINT_POINT).compress().to_bytes();
Ok((rp, Self { k }))
}
pub fn sign_ep(self, ep: &[u8; 32], xs: Scalar) -> ::Result<[u8; 32]> {
Ok(
(xs * Scalar::from_canonical_bytes(*ep).ok_or(WiredScalarMalformed)? + self.k)
.to_bytes(),
)
}
}