From f65d8b967df6eb86ec5f67e9bd94f6993c9e07bb Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sat, 25 Jan 2014 20:45:34 +0700 Subject: Implement Sqrt in F2m --- crypto/src/math/ec/ECFieldElement.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crypto/src/math') 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); } /** -- cgit 1.4.1