diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-31 19:05:46 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-31 19:05:46 +0700 |
commit | e7c2c2029676b6dd0f13560b56aa9611c51c99f7 (patch) | |
tree | 168337a6a9ed7fca3da1136a9c5bbeacc9acbf16 /crypto/src/math/ec/custom/sec/SecP256K1Field.cs | |
parent | Improve reduction speed for secp192k1 and secp256k1 custom fields (diff) | |
download | BouncyCastle.NET-ed25519-e7c2c2029676b6dd0f13560b56aa9611c51c99f7.tar.xz |
Avoid modifying the input to the Reduce() methods
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecP256K1Field.cs')
-rw-r--r-- | crypto/src/math/ec/custom/sec/SecP256K1Field.cs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP256K1Field.cs b/crypto/src/math/ec/custom/sec/SecP256K1Field.cs index e7a73359f..3f5437d4d 100644 --- a/crypto/src/math/ec/custom/sec/SecP256K1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP256K1Field.cs @@ -86,19 +86,17 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec } } - public static void Reduce(uint[] tt, uint[] z) + public static void Reduce(uint[] xx, uint[] z) { - ulong c = Nat256.Mul33AddExt(PInv33, tt, 8, tt, 0); - c = Nat256.Mul33DWordAdd(PInv33, c, tt, 0); + ulong c = Nat256.Mul33AddExt(PInv33, xx, 8, xx, 0, z, 0); + c = Nat256.Mul33DWordAdd(PInv33, c, z, 0); Debug.Assert(c == 0 || c == 1); - if (c != 0 || (tt[7] == P7 && Nat256.Gte(tt, P))) + if (c != 0 || (z[7] == P7 && Nat256.Gte(z, P))) { - Nat256.AddDWord(PInv, tt, 0); + Nat256.AddDWord(PInv, z, 0); } - - Array.Copy(tt, 0, z, 0, 8); } public static void Square(uint[] x, uint[] z) |