File tree Expand file tree Collapse file tree 5 files changed +8
-8
lines changed Expand file tree Collapse file tree 5 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -7,5 +7,4 @@ supported_modulus = ["1157920892373161954235709850086879078532699846656405640394
77[[app_vm_config .ecc .supported_curves ]]
88modulus = " 115792089237316195423570985008687907853269984665640564039457584007908834671663"
99scalar = " 115792089237316195423570985008687907852837564279074904382605163141518161494337"
10- a = " 0"
11- b = " 7"
10+ coeffs = { SwCurve = { a = " 0" , b = " 7" } }
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ pub struct CurveConfig {
3737 #[ serde_as( as = "DisplayFromStr" ) ]
3838 pub scalar : BigUint ,
3939 // curve-specific coefficients
40+ #[ serde_as( as = "_" ) ]
4041 pub coeffs : CurveCoeffs ,
4142}
4243
Original file line number Diff line number Diff line change @@ -107,14 +107,16 @@ pub fn te_declare(input: TokenStream) -> TokenStream {
107107 fn add_chip( p1: & #struct_name, p2: & #struct_name) -> #struct_name {
108108 #[ cfg( not( target_os = "zkvm" ) ) ]
109109 {
110+ use openvm_algebra_guest:: DivUnsafe ;
111+
110112 let x1y2 = p1. x( ) * p2. y( ) ;
111113 let y1x2 = p1. y( ) * p2. x( ) ;
112114 let x1x2 = p1. x( ) * p2. x( ) ;
113115 let y1y2 = p1. y( ) * p2. y( ) ;
114- let dx1x2y1y2 = Self :: CURVE_D * x1x2 * y1y2;
116+ let dx1x2y1y2 = Self :: CURVE_D * & x1x2 * & y1y2;
115117
116- let x3 = ( x1y2 + y1x2) . div_unsafe( & ( Self :: Coordinate :: ONE + dx1x2y1y2) ) ;
117- let y3 = ( y1y2 - Self :: CURVE_A * x1x2) . div_unsafe( & ( Self :: Coordinate :: ONE - dx1x2y1y2) ) ;
118+ let x3 = ( x1y2 + y1x2) . div_unsafe( & <#intmod_type as openvm_algebra_guest :: IntMod > :: ONE + & dx1x2y1y2) ;
119+ let y3 = ( y1y2 - Self :: CURVE_A * x1x2) . div_unsafe( & <#intmod_type as openvm_algebra_guest :: IntMod > :: ONE - & dx1x2y1y2) ;
118120
119121 #struct_name { x: x3, y: y3 }
120122 }
Original file line number Diff line number Diff line change @@ -268,9 +268,7 @@ fn test_plonk_zkvm() -> eyre::Result<()> {
268268 BN254_MODULUS . clone( ) ,
269269 BN254_ORDER . clone( ) ,
270270 ] ) )
271- . ecc ( EccExtension :: new ( vec ! [
272- PairingCurve :: Bn254 . curve_config( )
273- ] ) )
271+ . ecc ( EccExtension :: new ( vec ! [ PairingCurve :: Bn254 . curve_config( ) ] ) )
274272 . fp2 ( Fp2Extension :: new ( vec ! [ BN254_MODULUS . clone( ) ] ) )
275273 . pairing ( PairingExtension :: new ( vec ! [ PairingCurve :: Bn254 ] ) )
276274 . build ( ) ;
You can’t perform that action at this time.
0 commit comments