1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::commitment_scheme::kzg10::Commitment;
use dusk_bls12_381::Scalar;
use merlin::Transcript;
pub trait TranscriptProtocol {
fn append_commitment(&mut self, label: &'static [u8], comm: &Commitment);
fn append_scalar(&mut self, label: &'static [u8], s: &Scalar);
fn challenge_scalar(&mut self, label: &'static [u8]) -> Scalar;
fn circuit_domain_sep(&mut self, n: u64);
}
impl TranscriptProtocol for Transcript {
fn append_commitment(&mut self, label: &'static [u8], comm: &Commitment) {
self.append_message(label, &comm.0.to_compressed());
}
fn append_scalar(&mut self, label: &'static [u8], s: &Scalar) {
self.append_message(label, &s.to_bytes())
}
fn challenge_scalar(&mut self, label: &'static [u8]) -> Scalar {
let mut buf = [0u8; 64];
self.challenge_bytes(label, &mut buf);
Scalar::from_bytes_wide(&buf)
}
fn circuit_domain_sep(&mut self, n: u64) {
self.append_message(b"dom-sep", b"circuit_size");
self.append_u64(b"n", n);
}
}