diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-26 20:13:52 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-26 20:13:52 +0700 |
commit | 57d401f1c1919e507eb42ac0964a8b5d61ee6049 (patch) | |
tree | 413d79b8d57700b9270ab4533787474910e44822 /crypto/src/math/ec/custom/sec/SecP224R1Field.cs | |
parent | Optimize Sqrt() for custom curve secp224k1 (diff) | |
download | BouncyCastle.NET-ed25519-57d401f1c1919e507eb42ac0964a8b5d61ee6049.tar.xz |
Optimization for custom curve reduction when only a few bits need reducing; used to delay reduction in point doubling.
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecP224R1Field.cs')
-rw-r--r-- | crypto/src/math/ec/custom/sec/SecP224R1Field.cs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP224R1Field.cs b/crypto/src/math/ec/custom/sec/SecP224R1Field.cs index 4eb04325a..1cb3fe352 100644 --- a/crypto/src/math/ec/custom/sec/SecP224R1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP224R1Field.cs @@ -137,6 +137,15 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec } } + public static void Reduce32(uint x, uint[] z) + { + int c = Nat224.SubWord(x, z, 0) + (int)Nat224.AddWord(x, z, 3); + if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P))) + { + Nat224.Sub(z, P, z); + } + } + public static void Square(uint[] x, uint[] z) { uint[] tt = Nat224.CreateExt(); |