diff options
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecP256K1Field.cs')
-rw-r--r-- | crypto/src/math/ec/custom/sec/SecP256K1Field.cs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP256K1Field.cs b/crypto/src/math/ec/custom/sec/SecP256K1Field.cs index 6fe575b38..e7a73359f 100644 --- a/crypto/src/math/ec/custom/sec/SecP256K1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP256K1Field.cs @@ -14,7 +14,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec 0xFFFFFFFF, 0xFFFFFFFF }; private const uint PExt15 = 0xFFFFFFFF; private const ulong PInv = 0x00000001000003D1UL; - private const uint PInvLow = 0x3D1; + private const uint PInv33 = 0x3D1; public static void Add(uint[] x, uint[] y, uint[] z) { @@ -88,13 +88,8 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec public static void Reduce(uint[] tt, uint[] z) { - long extra = -(long)tt[8]; - extra += (long)Nat256.MulWordAddExt(PInvLow, tt, 8, tt, 0); - extra += (long)Nat256.AddToExt(tt, 8, tt, 1) << 32; - extra += (long)tt[8]; - - ulong c = Nat256.MulWordDwordAdd(PInvLow, (ulong)extra, tt, 0); - c += Nat256.AddDWord((ulong)extra, tt, 1); + ulong c = Nat256.Mul33AddExt(PInv33, tt, 8, tt, 0); + c = Nat256.Mul33DWordAdd(PInv33, c, tt, 0); Debug.Assert(c == 0 || c == 1); |