1
+ use ark_ec:: { AffineCurve , ProjectiveCurve } ;
2
+ use ark_ff:: { BigInteger , BitIteratorLE , Field , One , PrimeField , UniformRand , Zero } ;
3
+ use array_init:: array_init;
1
4
use colored:: Colorize ;
2
5
use commitment_dlog:: {
3
- commitment:: { b_poly_coefficients , ceil_log2 , CommitmentCurve } ,
6
+ commitment:: CommitmentCurve ,
4
7
srs:: { endos, SRS } ,
5
8
} ;
6
- use ark_ec:: { AffineCurve , ProjectiveCurve } ;
7
- use ark_ff:: { BigInteger , Field , PrimeField , BitIteratorLE , UniformRand , Zero , One } ;
8
- use ark_poly:: { univariate:: DensePolynomial , Radix2EvaluationDomain as D , EvaluationDomain } ;
9
- use plonk_15_wires_circuits:: {
10
- polynomials:: varbasemul,
11
- gate:: { CircuitGate , GateType , LookupInfo , LookupsUsed } ,
12
- expr:: { PolishToken , Constants , Expr , Column , Linearization } ,
13
- gates:: poseidon:: ROUNDS_PER_ROW ,
14
- nolookup:: constraints:: { zk_w3, ConstraintSystem } ,
15
- nolookup:: scalars:: { ProofEvaluations , LookupEvaluations } ,
16
- wires:: * ,
17
- } ;
9
+ use groupmap:: GroupMap ;
18
10
use mina_curves:: pasta:: {
19
- fp:: { Fp as F } ,
20
- pallas:: { Affine as Other , Projective as OtherProjective } ,
11
+ fp:: Fp as F ,
12
+ pallas:: Affine as Other ,
21
13
vesta:: { Affine , VestaParameters } ,
22
14
} ;
23
- use plonk_15_wires_protocol_dlog:: {
24
- index:: { Index } ,
25
- prover:: ProverProof ,
26
- } ;
27
- use rand:: { rngs:: StdRng , SeedableRng } ;
28
- use array_init:: array_init;
29
- use std:: fmt:: { Formatter , Display } ;
30
- use groupmap:: GroupMap ;
31
15
use oracle:: {
32
- poseidon:: { ArithmeticSponge , PlonkSpongeConstants15W , Sponge , SpongeConstants } ,
16
+ poseidon:: PlonkSpongeConstants15W ,
33
17
sponge:: { DefaultFqSponge , DefaultFrSponge } ,
34
18
} ;
19
+ use plonk_15_wires_circuits:: {
20
+ gate:: { CircuitGate , GateType } ,
21
+ nolookup:: constraints:: ConstraintSystem ,
22
+ polynomials:: varbasemul,
23
+ wires:: * ,
24
+ } ;
25
+ use plonk_15_wires_protocol_dlog:: { index:: Index , prover:: ProverProof } ;
26
+ use rand:: { rngs:: StdRng , SeedableRng } ;
35
27
use std:: { rc:: Rc , time:: Instant } ;
36
28
37
29
const PUBLIC : usize = 0 ;
@@ -55,24 +47,21 @@ fn varbase_mul_test() {
55
47
56
48
for i in 0 ..( chunks * num_scalars) {
57
49
let row = 2 * i;
58
- gates. push (
59
- CircuitGate {
60
- row,
61
- typ : GateType :: Vbmul ,
62
- wires : Wire :: new ( row) ,
63
- c : vec ! [ ] ,
64
- } ) ;
65
- gates. push (
66
- CircuitGate {
67
- row : row + 1 ,
68
- typ : GateType :: Zero ,
69
- wires : Wire :: new ( row + 1 ) ,
70
- c : vec ! [ ]
71
- } ) ;
50
+ gates. push ( CircuitGate {
51
+ row,
52
+ typ : GateType :: Vbmul ,
53
+ wires : Wire :: new ( row) ,
54
+ c : vec ! [ ] ,
55
+ } ) ;
56
+ gates. push ( CircuitGate {
57
+ row : row + 1 ,
58
+ typ : GateType :: Zero ,
59
+ wires : Wire :: new ( row + 1 ) ,
60
+ c : vec ! [ ] ,
61
+ } ) ;
72
62
}
73
63
74
- let cs = ConstraintSystem :: < F > :: create (
75
- gates, vec ! [ ] , fp_sponge_params, PUBLIC ) . unwrap ( ) ;
64
+ let cs = ConstraintSystem :: < F > :: create ( gates, vec ! [ ] , fp_sponge_params, PUBLIC ) . unwrap ( ) ;
76
65
let n = cs. domain . d1 . size as usize ;
77
66
78
67
let mut srs = SRS :: create ( cs. domain . d1 . size as usize ) ;
@@ -98,41 +87,44 @@ fn varbase_mul_test() {
98
87
for i in 0 ..num_scalars {
99
88
let x = F :: rand ( rng) ;
100
89
let bits_lsb: Vec < _ > = BitIteratorLE :: new ( x. into_repr ( ) ) . take ( num_bits) . collect ( ) ;
101
- let x_ = <Other as AffineCurve >:: ScalarField :: from_repr ( <F as PrimeField >:: BigInt :: from_bits_le ( & bits_lsb[ ..] ) ) . unwrap ( ) ;
90
+ let x_ = <Other as AffineCurve >:: ScalarField :: from_repr (
91
+ <F as PrimeField >:: BigInt :: from_bits_le ( & bits_lsb[ ..] ) ,
92
+ )
93
+ . unwrap ( ) ;
102
94
103
95
let base = Other :: prime_subgroup_generator ( ) ;
104
96
let g = Other :: prime_subgroup_generator ( ) . into_projective ( ) ;
105
97
let acc = ( g + g) . into_affine ( ) ;
106
98
let acc = ( acc. x , acc. y ) ;
107
99
108
- let bits_msb: Vec < _ > =
109
- bits_lsb. iter ( ) . take ( num_bits) . map ( |x| * x) . rev ( ) . collect ( ) ;
100
+ let bits_msb: Vec < _ > = bits_lsb. iter ( ) . take ( num_bits) . map ( |x| * x) . rev ( ) . collect ( ) ;
110
101
111
- let res =
112
- varbasemul :: witness (
113
- & mut witness ,
114
- i * rows_per_scalar ,
115
- ( base . x , base . y ) ,
116
- & bits_msb ,
117
- acc ) ;
102
+ let res = varbasemul :: witness (
103
+ & mut witness,
104
+ i * rows_per_scalar ,
105
+ ( base . x , base . y ) ,
106
+ & bits_msb ,
107
+ acc ,
108
+ ) ;
118
109
119
110
let shift = <Other as AffineCurve >:: ScalarField :: from ( 2 ) . pow ( & [ ( bits_msb. len ( ) ) as u64 ] ) ;
120
- let expected =
121
- g . mul ( ( <Other as AffineCurve >:: ScalarField :: one ( ) + shift + x_. double ( ) ) . into_repr ( ) )
111
+ let expected = g
112
+ . mul ( ( <Other as AffineCurve >:: ScalarField :: one ( ) + shift + x_. double ( ) ) . into_repr ( ) )
122
113
. into_affine ( ) ;
123
114
124
115
assert_eq ! ( x_. into_repr( ) , res. n. into_repr( ) ) ;
125
116
assert_eq ! ( ( expected. x, expected. y) , res. acc) ;
126
117
}
127
- println ! ( "{}{:?}" , "Witness generation time: " . yellow( ) , start. elapsed( ) ) ;
118
+ println ! (
119
+ "{}{:?}" ,
120
+ "Witness generation time: " . yellow( ) ,
121
+ start. elapsed( )
122
+ ) ;
128
123
129
124
let start = Instant :: now ( ) ;
130
125
let proof =
131
- ProverProof :: create :: < BaseSponge , ScalarSponge > (
132
- & group_map,
133
- & witness,
134
- & index,
135
- vec ! [ ] ) . unwrap ( ) ;
126
+ ProverProof :: create :: < BaseSponge , ScalarSponge > ( & group_map, & witness, & index, vec ! [ ] )
127
+ . unwrap ( ) ;
136
128
println ! ( "{}{:?}" , "Prover time: " . yellow( ) , start. elapsed( ) ) ;
137
129
138
130
let batch: Vec < _ > = vec ! [ ( & verifier_index, & lgr_comms, & proof) ] ;
0 commit comments