@@ -27,13 +27,11 @@ use circuit_mersenne_field::{
27
27
} ;
28
28
use std:: mem:: MaybeUninit ;
29
29
30
- use crate :: wrapper_inner_verifier:: imports:: {
31
- FINAL_RISC_CIRCUIT_AUX_REGISTERS_VALUES , FINAL_RISC_CIRCUIT_END_PARAMS ,
32
- } ;
33
- use crate :: wrapper_inner_verifier:: skeleton:: {
34
- WrappedProofSkeletonInstance , WrappedQueryValuesInstance ,
35
- } ;
36
30
use crate :: wrapper_inner_verifier:: * ;
31
+ use crate :: wrapper_inner_verifier:: {
32
+ imports:: { FINAL_RISC_CIRCUIT_AUX_REGISTERS_VALUES , FINAL_RISC_CIRCUIT_END_PARAMS } ,
33
+ skeleton:: { WrappedProofSkeletonInstance , WrappedQueryValuesInstance } ,
34
+ } ;
37
35
use crate :: wrapper_utils:: prover_structs:: * ;
38
36
use crate :: wrapper_utils:: verifier_traits:: { CircuitLeafInclusionVerifier , PlaceholderSource } ;
39
37
use risc_verifier:: blake2s_u32:: * ;
@@ -62,8 +60,28 @@ pub struct RiscWrapperWitness {
62
60
pub proof : RiscProof ,
63
61
}
64
62
63
+ #[ derive( Clone , Debug ) ]
64
+ pub struct BinaryCommitment {
65
+ pub end_params : [ u32 ; 8 ] ,
66
+ pub aux_params : [ u32 ; 8 ] ,
67
+ }
68
+
69
+ impl BinaryCommitment {
70
+ // Uses the binary information that was provided by wrapper generator.
71
+ // In future, this will be the 'active' boojumos binary, but for now this is an example fibonacci code.
72
+ pub fn from_default_binary ( ) -> Self {
73
+ Self {
74
+ end_params : FINAL_RISC_CIRCUIT_END_PARAMS ,
75
+ aux_params : FINAL_RISC_CIRCUIT_AUX_REGISTERS_VALUES ,
76
+ }
77
+ }
78
+ }
79
+
65
80
impl RiscWrapperWitness {
66
- pub fn from_full_proof ( full_proof : execution_utils:: ProgramProof ) -> Self {
81
+ pub fn from_full_proof (
82
+ full_proof : execution_utils:: ProgramProof ,
83
+ binary_commitment : & BinaryCommitment ,
84
+ ) -> Self {
67
85
let execution_utils:: ProgramProof {
68
86
base_layer_proofs,
69
87
delegation_proofs,
@@ -76,7 +94,7 @@ impl RiscWrapperWitness {
76
94
assert ! ( base_layer_proofs. len( ) == 1 ) ;
77
95
assert ! ( delegation_proofs. is_empty( ) ) ;
78
96
assert ! ( register_final_values. len( ) == NUM_REGISTERS ) ;
79
- assert_eq ! ( end_params, FINAL_RISC_CIRCUIT_END_PARAMS ) ;
97
+ assert_eq ! ( end_params, binary_commitment . end_params ) ;
80
98
81
99
assert ! ( recursion_chain_preimage. is_some( ) ) ;
82
100
let mut result_hasher = Blake2sBufferingTranscript :: new ( ) ;
@@ -87,10 +105,7 @@ impl RiscWrapperWitness {
87
105
recursion_chain_hash. unwrap( ) ,
88
106
result_hasher. finalize_reset( ) . 0
89
107
) ;
90
- assert_eq ! (
91
- recursion_chain_hash. unwrap( ) ,
92
- FINAL_RISC_CIRCUIT_AUX_REGISTERS_VALUES
93
- ) ;
108
+ assert_eq ! ( recursion_chain_hash. unwrap( ) , binary_commitment. aux_params) ;
94
109
95
110
let final_registers_state: Vec < _ > = register_final_values
96
111
. into_iter ( )
@@ -113,6 +128,7 @@ impl RiscWrapperWitness {
113
128
114
129
pub struct RiscWrapperCircuit < F : SmallField , V : CircuitLeafInclusionVerifier < F > > {
115
130
pub witness : Option < RiscWrapperWitness > ,
131
+ pub binary_commitment : BinaryCommitment ,
116
132
_phantom : std:: marker:: PhantomData < ( F , V ) > ,
117
133
}
118
134
@@ -199,7 +215,11 @@ impl<F: SmallField, V: CircuitLeafInclusionVerifier<F>> CircuitBuilder<F>
199
215
}
200
216
201
217
impl < F : SmallField , V : CircuitLeafInclusionVerifier < F > > RiscWrapperCircuit < F , V > {
202
- pub fn new ( witness : Option < RiscWrapperWitness > , verify_inner_proof : bool ) -> Self {
218
+ pub fn new (
219
+ witness : Option < RiscWrapperWitness > ,
220
+ verify_inner_proof : bool ,
221
+ binary_commitment : BinaryCommitment ,
222
+ ) -> Self {
203
223
if verify_inner_proof {
204
224
if let Some ( witness) = & witness {
205
225
verify_risc_proof :: < V :: OutOfCircuitImpl > ( & witness. proof ) ;
@@ -210,6 +230,7 @@ impl<F: SmallField, V: CircuitLeafInclusionVerifier<F>> RiscWrapperCircuit<F, V>
210
230
211
231
Self {
212
232
witness,
233
+ binary_commitment,
213
234
_phantom : std:: marker:: PhantomData ,
214
235
}
215
236
}
@@ -283,7 +304,13 @@ impl<F: SmallField, V: CircuitLeafInclusionVerifier<F>> RiscWrapperCircuit<F, V>
283
304
let ( proof_state, proof_input) =
284
305
crate :: wrapper_inner_verifier:: verify ( cs, skeleton, queries) ;
285
306
286
- check_proof_state ( cs, final_registers_state, & proof_state, & proof_input) ;
307
+ check_proof_state (
308
+ cs,
309
+ final_registers_state,
310
+ & proof_state,
311
+ & proof_input,
312
+ & self . binary_commitment ,
313
+ ) ;
287
314
288
315
// we carry registers 10-17 to the next layer - those are the output of the base program
289
316
let output_registers_values: Vec < _ > = final_registers_state
@@ -405,6 +432,7 @@ pub(crate) fn check_proof_state<F: SmallField, CS: ConstraintSystem<F>>(
405
432
NUM_AUX_BOUNDARY_VALUES ,
406
433
> ,
407
434
public_input : & WrappedProofPublicInputs < F , NUM_STATE_ELEMENTS > ,
435
+ binary_commitment : & BinaryCommitment ,
408
436
) {
409
437
let mut transcript = Blake2sWrappedBufferingTranscript :: new ( cs) ;
410
438
@@ -502,7 +530,7 @@ pub(crate) fn check_proof_state<F: SmallField, CS: ConstraintSystem<F>>(
502
530
503
531
for i in 0 ..8 {
504
532
let end_params_word = UInt32 :: from_le_bytes ( cs, end_params_output. 0 [ i] . inner ) ;
505
- let expected_word = UInt32 :: allocate_constant ( cs, FINAL_RISC_CIRCUIT_END_PARAMS [ i] ) ;
533
+ let expected_word = UInt32 :: allocate_constant ( cs, binary_commitment . end_params [ i] ) ;
506
534
Num :: enforce_equal ( cs, & expected_word. into_num ( ) , & end_params_word. into_num ( ) ) ;
507
535
}
508
536
@@ -512,8 +540,7 @@ pub(crate) fn check_proof_state<F: SmallField, CS: ConstraintSystem<F>>(
512
540
for i in 0 ..8 {
513
541
let aux_register_idx = ( i + 18 ) * 3 ;
514
542
let aux_register = final_registers_state[ aux_register_idx] ;
515
- let expected_word =
516
- UInt32 :: allocate_constant ( cs, FINAL_RISC_CIRCUIT_AUX_REGISTERS_VALUES [ i] ) ;
543
+ let expected_word = UInt32 :: allocate_constant ( cs, binary_commitment. aux_params [ i] ) ;
517
544
Num :: enforce_equal ( cs, & expected_word. into_num ( ) , & aux_register. into_num ( ) ) ;
518
545
}
519
546
}
0 commit comments