@@ -18,6 +18,7 @@ use crate::compound_proof::{CircuitComponent, CompoundProof};
1818use crate :: crypto:: pedersen:: JJ_PARAMS ;
1919use crate :: drgraph;
2020use crate :: election_post:: { self , ElectionPoSt } ;
21+ use crate :: error:: Result ;
2122use crate :: fr32:: fr_into_bytes;
2223use crate :: hasher:: Hasher ;
2324use crate :: merklepor;
7576 pub_inputs : & <ElectionPoSt < ' a , H > as ProofScheme < ' a > >:: PublicInputs ,
7677 pub_params : & <ElectionPoSt < ' a , H > as ProofScheme < ' a > >:: PublicParams ,
7778 _partition_k : Option < usize > ,
78- ) -> Vec < Fr > {
79+ ) -> Result < Vec < Fr > > {
7980 let mut inputs = Vec :: new ( ) ;
8081
8182 let por_pub_params = merklepor:: PublicParams {
9596 pub_inputs. sector_challenge_index ,
9697 n as u64 ,
9798 pub_params. sector_size ,
98- ) ;
99+ ) ? ;
99100 for i in 0 ..election_post:: POST_CHALLENGED_NODES {
100101 let por_pub_inputs = merklepor:: PublicInputs {
101102 commitment : None ,
@@ -105,7 +106,7 @@ where
105106 & por_pub_inputs,
106107 & por_pub_params,
107108 None ,
108- ) ;
109+ ) ? ;
109110
110111 inputs. extend ( por_inputs) ;
111112 }
@@ -114,15 +115,15 @@ where
114115 // 3. Inputs for verifying partial_ticket generation
115116 inputs. push ( pub_inputs. partial_ticket ) ;
116117
117- inputs
118+ Ok ( inputs)
118119 }
119120
120121 fn circuit (
121122 pub_in : & <ElectionPoSt < ' a , H > as ProofScheme < ' a > >:: PublicInputs ,
122123 _priv_in : <ElectionPoStCircuit < ' a , Bls12 , H > as CircuitComponent >:: ComponentPrivateInputs ,
123124 vanilla_proof : & <ElectionPoSt < ' a , H > as ProofScheme < ' a > >:: Proof ,
124125 _pub_params : & <ElectionPoSt < ' a , H > as ProofScheme < ' a > >:: PublicParams ,
125- ) -> ElectionPoStCircuit < ' a , Bls12 , H > {
126+ ) -> Result < ElectionPoStCircuit < ' a , Bls12 , H > > {
126127 let comm_r = pub_in. comm_r . into ( ) ;
127128 let comm_c = vanilla_proof. comm_c . into ( ) ;
128129 let comm_q = vanilla_proof. comm_q . into ( ) ;
@@ -140,7 +141,7 @@ where
140141 . map ( |v| v. iter ( ) . map ( |p| Some ( ( ( * p) . 0 . into ( ) , p. 1 ) ) ) . collect ( ) )
141142 . collect ( ) ;
142143
143- ElectionPoStCircuit {
144+ Ok ( ElectionPoStCircuit {
144145 params : & * JJ_PARAMS ,
145146 leafs,
146147 comm_r : Some ( comm_r) ,
@@ -153,7 +154,7 @@ where
153154 prover_id : bytes_into_bits_opt ( & pub_in. prover_id [ ..] ) ,
154155 sector_id : Some ( u64:: from ( pub_in. sector_id ) ) ,
155156 _h : PhantomData ,
156- }
157+ } )
157158 }
158159
159160 fn blank_circuit (
@@ -388,7 +389,7 @@ mod tests {
388389 . flat_map ( |_| fr_into_bytes :: < Bls12 > ( & Fr :: random ( rng) ) )
389390 . collect ( ) ;
390391
391- let graph = BucketGraph :: < PedersenHasher > :: new ( 32 , BASE_DEGREE , 0 , new_seed ( ) ) ;
392+ let graph = BucketGraph :: < PedersenHasher > :: new ( 32 , BASE_DEGREE , 0 , new_seed ( ) ) . unwrap ( ) ;
392393 let tree = graph. merkle_tree ( data. as_slice ( ) ) . unwrap ( ) ;
393394 trees. insert ( i. into ( ) , tree) ;
394395 }
@@ -476,7 +477,8 @@ mod tests {
476477 & pub_inputs,
477478 & pub_params,
478479 None ,
479- ) ;
480+ )
481+ . unwrap ( ) ;
480482 let expected_inputs = cs. get_inputs ( ) ;
481483
482484 for ( ( input, label) , generated_input) in
@@ -515,7 +517,7 @@ mod tests {
515517 . flat_map ( |_| fr_into_bytes :: < Bls12 > ( & Fr :: random ( rng) ) )
516518 . collect ( ) ;
517519
518- let graph = BucketGraph :: < PedersenHasher > :: new ( 32 , BASE_DEGREE , 0 , new_seed ( ) ) ;
520+ let graph = BucketGraph :: < PedersenHasher > :: new ( 32 , BASE_DEGREE , 0 , new_seed ( ) ) . unwrap ( ) ;
519521 let tree = graph. merkle_tree ( data. as_slice ( ) ) . unwrap ( ) ;
520522 trees. insert ( i. into ( ) , tree) ;
521523 }
@@ -557,7 +559,8 @@ mod tests {
557559
558560 {
559561 let ( circuit, inputs) =
560- ElectionPoStCompound :: circuit_for_test ( & pub_params, & pub_inputs, & priv_inputs) ;
562+ ElectionPoStCompound :: circuit_for_test ( & pub_params, & pub_inputs, & priv_inputs)
563+ . unwrap ( ) ;
561564
562565 let mut cs = TestConstraintSystem :: new ( ) ;
563566
@@ -578,7 +581,8 @@ mod tests {
578581 // Use this to debug differences between blank and regular circuit generation.
579582 {
580583 let ( circuit1, _inputs) =
581- ElectionPoStCompound :: circuit_for_test ( & pub_params, & pub_inputs, & priv_inputs) ;
584+ ElectionPoStCompound :: circuit_for_test ( & pub_params, & pub_inputs, & priv_inputs)
585+ . unwrap ( ) ;
582586 let blank_circuit =
583587 ElectionPoStCompound :: < PedersenHasher > :: blank_circuit ( & pub_params. vanilla_params ) ;
584588
0 commit comments