@@ -7,8 +7,14 @@ use circuit_std_rs::{
77use expander_compiler:: {
88 field:: { BN254Fr , Goldilocks } ,
99 frontend:: * ,
10- zkcuda:: { context:: * , kernel:: * , proving_system:: * , shape:: Reshape } ,
10+ zkcuda:: {
11+ context:: * ,
12+ kernel:: * ,
13+ proving_system:: { expander:: config:: ZKCudaBN254Hyrax , * } ,
14+ shape:: Reshape ,
15+ } ,
1116} ;
17+ use serdes:: ExpSerde ;
1218
1319#[ test]
1420fn logup_test ( ) {
@@ -196,3 +202,31 @@ fn rangeproof_zkcuda_test_fail() {
196202 ) ;
197203 assert ! ( P :: verify( & verifier_setup, & computation_graph, & proof) ) ;
198204}
205+
206+ #[ test]
207+ fn rangeproof_zkcuda_no_oversubscribe_test ( ) {
208+ let mut hint_registry = HintRegistry :: < BN254Fr > :: new ( ) ;
209+ hint_registry. register ( "myhint.querycounthint" , query_count_hint) ;
210+ hint_registry. register ( "myhint.rangeproofhint" , rangeproof_hint) ;
211+ //compile and test
212+ let kernel: KernelPrimitive < BN254Config > = compile_rangeproof_test_kernel ( ) . unwrap ( ) ;
213+ let mut ctx: Context < BN254Config , _ > = Context :: new ( hint_registry) ;
214+
215+ let a = BN254Fr :: from ( ( 1 << 9 ) as u32 ) ;
216+ let a = ctx. copy_to_device ( & a) ;
217+ let a = a. reshape ( & [ 1 ] ) ;
218+ call_kernel ! ( ctx, kernel, 1 , a) . unwrap ( ) ;
219+
220+ let computation_graph = ctx. compile_computation_graph ( ) . unwrap ( ) ;
221+ ctx. solve_witness ( ) . unwrap ( ) ;
222+ let ( prover_setup, _) = ExpanderNoOverSubscribe :: < ZKCudaBN254Hyrax > :: setup ( & computation_graph) ;
223+ let proof = ExpanderNoOverSubscribe :: < ZKCudaBN254Hyrax > :: prove (
224+ & prover_setup,
225+ & computation_graph,
226+ ctx. export_device_memories ( ) ,
227+ ) ;
228+ let file = std:: fs:: File :: create ( "proof.txt" ) . unwrap ( ) ;
229+ let writer = std:: io:: BufWriter :: new ( file) ;
230+ proof. serialize_into ( writer) . expect ( "serialize failed" ) ;
231+ <ExpanderNoOverSubscribe < ZKCudaBN254Hyrax > as ProvingSystem < BN254Config > >:: post_process ( ) ;
232+ }
0 commit comments