33use cbork_utils:: decode_helper:: decode_array_len;
44use minicbor:: { Decode , Decoder , Encode , Encoder , encode:: Write } ;
55
6- use crate :: elgamal_ristretto255_choice:: ElgamalRistretto255Choice ;
6+ use crate :: { elgamal_ristretto255_choice:: ElgamalRistretto255Choice , row_proof :: RowProof } ;
77
88/// Voters Choices.
99///
@@ -34,32 +34,6 @@ pub enum Choices {
3434 } ,
3535}
3636
37- /// A universal encrypted row proof.
38- ///
39- /// The CDDL schema:
40- /// ```cddl
41- /// row-proof = [0, zkproof-elgamal-ristretto255-unit-vector-with-single-selection ]
42- ///
43- /// zkproof-elgamal-ristretto255-unit-vector-with-single-selection = [ +zkproof-elgamal-ristretto255-unit-vector-with-single-selection-item, zkproof-ed25519-scalar ]
44- ///
45- /// zkproof-elgamal-ristretto255-unit-vector-with-single-selection-item = ( zkproof-elgamal-announcement, ~elgamal-ristretto255-encrypted-choice, zkproof-ed25519-r-response )
46- ///
47- /// zkproof-elgamal-announcement = ( zkproof-elgamal-group-element, zkproof-elgamal-group-element, zkproof-elgamal-group-element )
48- ///
49- /// zkproof-elgamal-group-element = bytes .size 32
50- ///
51- /// zkproof-ed25519-r-response = ( zkproof-ed25519-scalar, zkproof-ed25519-scalar, zkproof-ed25519-scalar )
52- ///
53- /// zkproof-ed25519-scalar = bytes .size 32
54- /// ```
55- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
56- pub struct RowProof {
57- /// A list of a single selection proofs.
58- selections : Vec < ( ) > ,
59- /// An individual Ed25519 scalar used in ZK proofs.
60- scalar : ( ) ,
61- }
62-
6337impl Decode < ' _ , ( ) > for Choices {
6438 fn decode (
6539 d : & mut Decoder < ' _ > ,
@@ -124,33 +98,12 @@ impl Encode<()> for Choices {
12498 }
12599}
126100
127- impl Decode < ' _ , ( ) > for RowProof {
128- fn decode (
129- d : & mut Decoder < ' _ > ,
130- ctx : & mut ( ) ,
131- ) -> Result < Self , minicbor:: decode:: Error > {
132- // TODO: FIXME:
133- todo ! ( )
134- }
135- }
136-
137- impl Encode < ( ) > for RowProof {
138- fn encode < W : Write > (
139- & self ,
140- e : & mut Encoder < W > ,
141- ctx : & mut ( ) ,
142- ) -> Result < ( ) , minicbor:: encode:: Error < W :: Error > > {
143- // TODO: FIXME:
144- todo ! ( )
145- }
146- }
147-
148101#[ cfg( test) ]
149102mod tests {
150103 use super :: * ;
151104
152105 #[ test]
153- fn clear_choices_roundtrip ( ) {
106+ fn clear_roundtrip ( ) {
154107 let original = Choices :: Clear ( vec ! [ 1 , 2 , 3 ] ) ;
155108 let mut buffer = Vec :: new ( ) ;
156109 original
@@ -161,7 +114,7 @@ mod tests {
161114 }
162115
163116 #[ test]
164- fn elgamal_ristretto255_choices_roundtrip ( ) {
117+ fn elgamal_ristretto255_roundtrip ( ) {
165118 let original = Choices :: ElgamalRistretto255 {
166119 choices : vec ! [ ] ,
167120 row_proof : Some ( RowProof { } ) ,
@@ -173,15 +126,4 @@ mod tests {
173126 let decoded = Choices :: decode ( & mut Decoder :: new ( & buffer) , & mut ( ) ) . unwrap ( ) ;
174127 assert_eq ! ( original, decoded) ;
175128 }
176-
177- #[ test]
178- fn row_proof_roundtrip ( ) {
179- let original = RowProof { } ;
180- let mut buffer = Vec :: new ( ) ;
181- original
182- . encode ( & mut Encoder :: new ( & mut buffer) , & mut ( ) )
183- . unwrap ( ) ;
184- let decoded = RowProof :: decode ( & mut Decoder :: new ( & buffer) , & mut ( ) ) . unwrap ( ) ;
185- assert_eq ! ( original, decoded) ;
186- }
187129}
0 commit comments