use mohan::dalek::{
ristretto::CompressedRistretto,
traits::IsIdentity
};
use bacteria::Transcript;
use crate::errors::{
ZeiError,
ProofError
};
pub trait TranscriptProtocol {
fn rangeproof_domain_sep(&mut self, n: u64, m: u64);
fn innerproduct_domain_sep(&mut self, n: u64);
fn validate_and_commit_point(
&mut self,
label: &'static [u8],
point: &CompressedRistretto,
) -> Result<(), ZeiError>;
}
impl TranscriptProtocol for Transcript {
fn rangeproof_domain_sep(&mut self, n: u64, m: u64) {
self.append_message(b"dom-sep", b"rangeproof v1");
self.append_u64(b"n", n);
self.append_u64(b"m", m);
}
fn innerproduct_domain_sep(&mut self, n: u64) {
self.append_message(b"dom-sep", b"ipp v1");
self.append_u64(b"n", n);
}
fn validate_and_commit_point(
&mut self,
label: &'static [u8],
point: &CompressedRistretto,
) -> Result<(), ZeiError> {
if point.is_identity() {
Err(ZeiError::from(ProofError::VerificationError))
} else {
Ok(self.append_message(label, point.as_bytes()))
}
}
}