diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-28 15:25:02 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-28 15:25:02 +0700 |
commit | a959f6a9c1ebb46d9cd044008d92532d1b5fd364 (patch) | |
tree | f7b759f9882c68544925a38a0040ce576901fa3c /crypto/src/math/ec/ECFieldElement.cs | |
parent | Fix and re-enable twicePlus for lambda-projective coordinates (diff) | |
download | BouncyCastle.NET-ed25519-a959f6a9c1ebb46d9cd044008d92532d1b5fd364.tar.xz |
Implement multi-squaring in-place and use for F2m sqrt()
Diffstat (limited to 'crypto/src/math/ec/ECFieldElement.cs')
-rw-r--r-- | crypto/src/math/ec/ECFieldElement.cs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/crypto/src/math/ec/ECFieldElement.cs b/crypto/src/math/ec/ECFieldElement.cs index 838053827..66fadddec 100644 --- a/crypto/src/math/ec/ECFieldElement.cs +++ b/crypto/src/math/ec/ECFieldElement.cs @@ -1160,15 +1160,14 @@ namespace Org.BouncyCastle.Math.EC public override ECFieldElement Sqrt() { - LongArray root = this.x; - if (root.IsOne() || root.IsZero()) - return this; - - for (int i = 1; i < m; ++i) + LongArray x1 = this.x; + if (x1.IsOne() || x1.IsZero()) { - root = root.ModSquare(m, ks); + return this; } - return new F2mFieldElement(m, ks, root); + + LongArray x2 = x1.ModSquareN(m - 1, m, ks); + return new F2mFieldElement(m, ks, x2); } /** |