1
+ use crate :: { ShaDigestColsRefMut , ShaRoundColsRef , ShaRoundColsRefMut } ;
1
2
use std:: { borrow:: BorrowMut , cmp:: max, sync:: Arc } ;
2
- use crate :: { ShaDigestColsRefMut , ShaRoundColsRefMut , ShaRoundColsRef } ;
3
3
4
4
use openvm_circuit:: arch:: {
5
5
instructions:: riscv:: RV32_CELL_BITS ,
@@ -22,9 +22,7 @@ use openvm_stark_backend::{
22
22
use openvm_stark_sdk:: utils:: create_seeded_rng;
23
23
use rand:: Rng ;
24
24
25
- use crate :: {
26
- compose, small_sig0_field, Sha256Config , Sha512Config , ShaAir , ShaConfig ,
27
- } ;
25
+ use crate :: { compose, small_sig0_field, Sha256Config , Sha512Config , ShaAir , ShaConfig } ;
28
26
29
27
// A wrapper AIR purely for testing purposes
30
28
#[ derive( Clone , Debug ) ]
@@ -125,14 +123,13 @@ fn rand_sha512_test() {
125
123
126
124
// A wrapper Chip to test that the final_hash is properly constrained.
127
125
// This chip implements a malicious trace gen that violates the final_hash constraints.
128
- pub struct ShaTestBadFinalHashChip < C : ShaConfig + ShaPrecomputedValues < C :: Word > > {
126
+ pub struct ShaTestBadFinalHashChip < C : ShaConfig > {
129
127
pub air : ShaTestAir < C > ,
130
128
pub bitwise_lookup_chip : SharedBitwiseOperationLookupChip < 8 > ,
131
129
pub records : Vec < ( Vec < u8 > , bool ) > , // length of inner vec should be C::BLOCK_U8S
132
130
}
133
131
134
- impl < SC : StarkGenericConfig , C : ShaConfig + ShaPrecomputedValues < C :: Word > + ' static > Chip < SC >
135
- for ShaTestBadFinalHashChip < C >
132
+ impl < SC : StarkGenericConfig , C : ShaConfig + ' static > Chip < SC > for ShaTestBadFinalHashChip < C >
136
133
where
137
134
Val < SC > : PrimeField32 ,
138
135
{
@@ -170,7 +167,10 @@ where
170
167
let mut last_digest_row: crate :: ShaRoundColsRefMut < Val < SC > > =
171
168
ShaRoundColsRefMut :: from :: < C > ( last_digest_row. borrow_mut ( ) ) ;
172
169
// fix the intermed_4 for the digest row
173
- generate_intermed_4 :: < Val < SC > , C > ( & ShaRoundColsRef :: from_mut :: < C > ( & last_round_row) , & mut last_digest_row) ;
170
+ generate_intermed_4 :: < Val < SC > , C > (
171
+ & ShaRoundColsRef :: from_mut :: < C > ( & last_round_row) ,
172
+ & mut last_digest_row,
173
+ ) ;
174
174
}
175
175
}
176
176
@@ -190,7 +190,7 @@ where
190
190
191
191
// Copy of private method in Sha256Air used for testing
192
192
/// Puts the correct intermed_4 in the `next_row`
193
- fn generate_intermed_4 < F : PrimeField32 , C : ShaConfig + ShaPrecomputedValues < C :: Word > > (
193
+ fn generate_intermed_4 < F : PrimeField32 , C : ShaConfig > (
194
194
local_cols : & ShaRoundColsRef < F > ,
195
195
next_cols : & mut ShaRoundColsRefMut < F > ,
196
196
) {
@@ -209,10 +209,9 @@ fn generate_intermed_4<F: PrimeField32, C: ShaConfig + ShaPrecomputedValues<C::W
209
209
. collect :: < Vec < _ > > ( ) ,
210
210
]
211
211
. concat ( ) ;
212
-
213
-
212
+
214
213
// length of inner vec is C::WORD_U16S
215
- let w_limbs: Vec < Vec < F > > = w
214
+ let w_limbs: Vec < Vec < F > > = w
216
215
. iter ( )
217
216
. map ( |x| {
218
217
( 0 ..C :: WORD_U16S )
@@ -231,7 +230,7 @@ fn generate_intermed_4<F: PrimeField32, C: ShaConfig + ShaPrecomputedValues<C::W
231
230
}
232
231
}
233
232
234
- impl < C : ShaConfig + ShaPrecomputedValues < C :: Word > > ChipUsageGetter for ShaTestBadFinalHashChip < C > {
233
+ impl < C : ShaConfig > ChipUsageGetter for ShaTestBadFinalHashChip < C > {
235
234
fn air_name ( & self ) -> String {
236
235
get_air_name ( & self . air )
237
236
}
@@ -244,14 +243,21 @@ impl<C: ShaConfig + ShaPrecomputedValues<C::Word>> ChipUsageGetter for ShaTestBa
244
243
}
245
244
}
246
245
247
- fn test_sha_final_hash_constraints < C : ShaConfig + ShaPrecomputedValues < C :: Word > + ' static > ( ) {
246
+ fn test_sha_final_hash_constraints < C : ShaConfig + ' static > ( ) {
248
247
let mut rng = create_seeded_rng ( ) ;
249
248
let tester = VmChipTestBuilder :: default ( ) ;
250
249
let bitwise_bus = BitwiseOperationLookupBus :: new ( BITWISE_OP_LOOKUP_BUS ) ;
251
250
let bitwise_chip = SharedBitwiseOperationLookupChip :: < RV32_CELL_BITS > :: new ( bitwise_bus) ;
252
251
let len = rng. gen_range ( 1 ..100 ) ;
253
252
let random_records: Vec < _ > = ( 0 ..len)
254
- . map ( |_| ( ( 0 ..C :: BLOCK_U8S ) . map ( |_| rng. gen :: < u8 > ( ) ) . collect :: < Vec < _ > > ( ) , true ) )
253
+ . map ( |_| {
254
+ (
255
+ ( 0 ..C :: BLOCK_U8S )
256
+ . map ( |_| rng. gen :: < u8 > ( ) )
257
+ . collect :: < Vec < _ > > ( ) ,
258
+ true ,
259
+ )
260
+ } )
255
261
. collect ( ) ;
256
262
let chip = ShaTestBadFinalHashChip {
257
263
air : ShaTestAir {
0 commit comments