public boolean isOne() { return Nat224.isOne(x); }
public boolean isOne() { return Nat224.isOne(x); }
public boolean isOne() { return Nat224.isOne(x); }
public boolean isOne() { return Nat224.isOne(x); }
private static boolean isSquare(int[] x) { int[] t1 = Nat224.create(); int[] t2 = Nat224.create(); Nat224.copy(x, t1); for (int i = 0; i < 7; ++i) { Nat224.copy(t1, t2); SecP224R1Field.squareN(t1, 1 << i, t1); SecP224R1Field.multiply(t1, t2, t1); } SecP224R1Field.squareN(t1, 95, t1); return Nat224.isOne(t1); }
private static boolean isSquare(int[] x) { int[] t1 = Nat224.create(); int[] t2 = Nat224.create(); Nat224.copy(x, t1); for (int i = 0; i < 7; ++i) { Nat224.copy(t1, t2); SecP224R1Field.squareN(t1, 1 << i, t1); SecP224R1Field.multiply(t1, t2, t1); } SecP224R1Field.squareN(t1, 95, t1); return Nat224.isOne(t1); }
/** * return a sqrt root - the routine verifies that the calculation returns the right value - if * none exists it returns null. */ public ECFieldElement sqrt() { int[] c = this.x; if (Nat224.isZero(c) || Nat224.isOne(c)) { return this; } int[] nc = Nat224.create(); SecP224R1Field.negate(c, nc); int[] r = Mod.random(SecP224R1Field.P); int[] t = Nat224.create(); if (!isSquare(c)) { return null; } while (!trySqrt(nc, r, t)) { SecP224R1Field.addOne(r, r); } SecP224R1Field.square(t, r); return Nat224.eq(c, r) ? new SecP224R1FieldElement(t) : null; }
/** * return a sqrt root - the routine verifies that the calculation returns the right value - if * none exists it returns null. */ public ECFieldElement sqrt() { int[] c = this.x; if (Nat224.isZero(c) || Nat224.isOne(c)) { return this; } int[] nc = Nat224.create(); SecP224R1Field.negate(c, nc); int[] r = Mod.random(SecP224R1Field.P); int[] t = Nat224.create(); if (!isSquare(c)) { return null; } while (!trySqrt(nc, r, t)) { SecP224R1Field.addOne(r, r); } SecP224R1Field.square(t, r); return Nat224.eq(c, r) ? new SecP224R1FieldElement(t) : null; }
if (Nat224.isZero(x1) || Nat224.isOne(x1))
if (Nat224.isZero(x1) || Nat224.isOne(x1))