Skip to content

Commit

Permalink
ec: small refactor for scalar_decomposition (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Nov 30, 2024
1 parent 6272bcb commit b1c8962
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ec/src/scalar_mul/glv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ pub trait GLVConfig: Send + Sync + 'static + SWCurveConfig {
) -> ((bool, Self::ScalarField), (bool, Self::ScalarField)) {
let scalar: BigInt = k.into_bigint().into().into();

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

let [n11, n12, n21, n22] = coeff_bigints;

let r = BigInt::from(Self::ScalarField::MODULUS.into());

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

(
(k1.sign() == Sign::Plus, Self::ScalarField::from(k1_abs)),
(k2.sign() == Sign::Plus, Self::ScalarField::from(k2_abs)),
(k1.sign() == Sign::Plus, k1_abs.into()),
(k2.sign() == Sign::Plus, k2_abs.into()),
)
}

Expand Down

0 comments on commit b1c8962

Please sign in to comment.