@@ -5,19 +5,35 @@ use curve25519_dalek::ristretto::CompressedRistretto;
55use curve25519_dalek:: scalar:: Scalar ;
66use merlin:: Transcript ;
77
8+ use errors:: ProofError ;
9+
810pub trait TranscriptProtocol {
911 /// Commit a domain separator for an `n`-bit, `m`-party range proof.
1012 fn rangeproof_domain_sep ( & mut self , n : u64 , m : u64 ) ;
13+
1114 /// Commit a domain separator for a length-`n` inner product proof.
1215 fn innerproduct_domain_sep ( & mut self , n : u64 ) ;
16+
1317 /// Commit a domain separator for a constraint system.
1418 fn r1cs_domain_sep ( & mut self ) ;
19+
1520 /// Commit a 64-bit integer.
1621 fn commit_u64 ( & mut self , label : & ' static [ u8 ] , n : u64 ) ;
22+
1723 /// Commit a `scalar` with the given `label`.
1824 fn commit_scalar ( & mut self , label : & ' static [ u8 ] , scalar : & Scalar ) ;
25+
1926 /// Commit a `point` with the given `label`.
2027 fn commit_point ( & mut self , label : & ' static [ u8 ] , point : & CompressedRistretto ) ;
28+
29+ /// Check that a point is not the identity, then commit it to the
30+ /// transcript. Otherwise, return an error.
31+ fn validate_and_commit_point (
32+ & mut self ,
33+ label : & ' static [ u8 ] ,
34+ point : & CompressedRistretto ,
35+ ) -> Result < ( ) , ProofError > ;
36+
2137 /// Compute a `label`ed challenge variable.
2238 fn challenge_scalar ( & mut self , label : & ' static [ u8 ] ) -> Scalar ;
2339}
@@ -56,6 +72,20 @@ impl TranscriptProtocol for Transcript {
5672 self . commit_bytes ( label, point. as_bytes ( ) ) ;
5773 }
5874
75+ fn validate_and_commit_point (
76+ & mut self ,
77+ label : & ' static [ u8 ] ,
78+ point : & CompressedRistretto ,
79+ ) -> Result < ( ) , ProofError > {
80+ use curve25519_dalek:: traits:: IsIdentity ;
81+
82+ if point. is_identity ( ) {
83+ Err ( ProofError :: VerificationError )
84+ } else {
85+ Ok ( self . commit_bytes ( label, point. as_bytes ( ) ) )
86+ }
87+ }
88+
5989 fn challenge_scalar ( & mut self , label : & ' static [ u8 ] ) -> Scalar {
6090 let mut buf = [ 0u8 ; 64 ] ;
6191 self . challenge_bytes ( label, & mut buf) ;
0 commit comments