GLV Decomposition is an efficient way to calculate point scaling
A textbook introduction of enomorphisms of elliptic curves can be found in [4].
Given scalar
Consider the elliptic curve over field
If we can find a scalar
NOTE: On a particular elliptic curve,
We first write
where the integers
Then we have,
Since
The strategy is effective provided that
An efficient algorithm for calculating
Algorithm: decomposition
Algorithm: Extended Euclidean
A full explaination of Barret Reduction can be found here.
Reference code can be found in Yrrid's and Gregor's implementations.
Some demo python code for BLS12-381
>>>p=0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab
>>>q=0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001
>>>z=0xd201000000010000
>>>R=(2**390) % p
0x15de9967f3e804b29f1457663c4a5eec26c26d0b683dcf80dd9a7e0e882431c84b803379b4800ac4676000000d1ff2e
>>>R2=(R*R) % p
0xf696ee04acd918c979001772d32f70a41442921eed21b145efee07b1df507af6ea66ec3a0132243aec641c34510070f
>>> R_inv = pow(R, -1, p)
0xd5484112463df80cd434d6bbe9713b9de9a046ecb252b97586963f65faad0c9315584492c0c63ebccd2ce0964e00276
>>>lambda1=q-z**2
0xac45a4010001a4020000000100000000
>>>lambda1**3 % q
1
>>>beta1=0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe
>>>beta1**3 % p
1
>>>lambda2=z**2-1
0xac45a4010001a40200000000ffffffff
>>>lambda2**3 % q
1
>>>beta2=0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac
>>>beta2**3 % p
1
>>>beta2_mont = (beta2 * R) % p
0x9c6d4856567dd7d18c86532eb0c0550bd16b0d267fd6ffa856e7b9a191c3ebc1bcc91d7b26574c3ef2f79219c907181
>>> inv_approx = hex(2**256 // lambda2)
'0x17c6becf1e01faadd63f6e522f6cfee30'
Beta in montegomery form in Niall's code and Gregor's code
[1] Robert P. Gallant, Robert J. Lambert, and Scott A. Vanstone, Faster Point Multiplication on Elliptic Curves with Efficient Endomorphisms, 2001
[2] https://www.btctimes.com/news/bitcoin-upgrade-glv-enomorphism-tests-show-faster-verification
[3] https://patents.google.com/patent/US7110538B2/en
[4] Darrel Hankerson, Alfred J. Menezes, Scott Vanstone, Guide to Elliptic Curve Cryptography, 2004
[5] bls12-381/glv.go
[6] Barret Reduction
msm
zkp
public