Skip to content

Commit b1c8962

Browse files
authored
ec: small refactor for scalar_decomposition (#898)
1 parent 6272bcb commit b1c8962

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

ec/src/scalar_mul/glv.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ pub trait GLVConfig: Send + Sync + 'static + SWCurveConfig {
3131
) -> ((bool, Self::ScalarField), (bool, Self::ScalarField)) {
3232
let scalar: BigInt = k.into_bigint().into().into();
3333

34-
let coeff_bigints: [BigInt; 4] = Self::SCALAR_DECOMP_COEFFS.map(|x| {
34+
let [n11, n12, n21, n22] = Self::SCALAR_DECOMP_COEFFS.map(|x| {
3535
let sign = if x.0 { Sign::Plus } else { Sign::Minus };
3636
BigInt::from_biguint(sign, x.1.into())
3737
});
3838

39-
let [n11, n12, n21, n22] = coeff_bigints;
40-
4139
let r = BigInt::from(Self::ScalarField::MODULUS.into());
4240

4341
// beta = vector([k,0]) * self.curve.N_inv
@@ -81,8 +79,8 @@ pub trait GLVConfig: Send + Sync + 'static + SWCurveConfig {
8179
let k2_abs = BigUint::try_from(k2.abs()).unwrap();
8280

8381
(
84-
(k1.sign() == Sign::Plus, Self::ScalarField::from(k1_abs)),
85-
(k2.sign() == Sign::Plus, Self::ScalarField::from(k2_abs)),
82+
(k1.sign() == Sign::Plus, k1_abs.into()),
83+
(k2.sign() == Sign::Plus, k2_abs.into()),
8684
)
8785
}
8886

0 commit comments

Comments
 (0)