arkworks-rs / curves

Implementations of popular elliptic curves
https://www.arkworks.rs
Apache License 2.0
303 stars 103 forks source link

The scalar to be multiplied by should be at most `num_limbs` long #171

Closed mmagician closed 1 year ago

mmagician commented 1 year ago

Description

Fixes(?) the failing tests in https://github.com/arkworks-rs/curves/pull/158.

There's a small problem: The current default method for mul_bigint operates on limbs, and so works for any scalar, also those larger than MODULUS. On the other hand, the GLV interface assumes that the scalar is already an element of the ScalarField:

fn glv_mul_projective(p: Projective<Self>, k: Self::ScalarField) -> Projective<Self>;

And so to call the GLV implementation, when we convert from limbs to ScalarField, we assume that the scalar has already been mod reduced: https://github.com/arkworks-rs/curves/blob/a39aa8480e216fb3193139747e149b252ebfc1fd/ed_on_bls12_381_bandersnatch/src/curves/mod.rs#L144 -> which panics when #limbs > N, thus causing the tests to fail.


Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why.

Pratyush commented 1 year ago

Maybe we should remove the mul_bigint entirely...