diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-25 20:45:34 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-25 20:45:34 +0700 |
commit | f65d8b967df6eb86ec5f67e9bd94f6993c9e07bb (patch) | |
tree | 6fdf21e41fcca96753d6652a264e054d15ead83a /crypto/src/math | |
parent | Add 0 guard in ModInverse (diff) | |
download | BouncyCastle.NET-ed25519-f65d8b967df6eb86ec5f67e9bd94f6993c9e07bb.tar.xz |
Implement Sqrt in F2m
Diffstat (limited to 'crypto/src/math')
-rw-r--r-- | crypto/src/math/ec/ECFieldElement.cs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crypto/src/math/ec/ECFieldElement.cs b/crypto/src/math/ec/ECFieldElement.cs index 22cd1e0e8..ac9c62807 100644 --- a/crypto/src/math/ec/ECFieldElement.cs +++ b/crypto/src/math/ec/ECFieldElement.cs @@ -1166,7 +1166,15 @@ namespace Org.BouncyCastle.Math.EC public override ECFieldElement Sqrt() { - throw new ArithmeticException("Not implemented"); + LongArray root = this.x; + if (root.IsOne() || root.IsZero()) + return this; + + for (int i = 1; i < m; ++i) + { + root = root.ModSquare(m, ks); + } + return new F2mFieldElement(m, ks, root); } /** |