public boolean isZero() { return Nat224.isZero(x); }
public boolean isZero() { return Nat224.isZero(x); }
public boolean isZero() { return Nat224.isZero(x); }
public boolean isZero() { return Nat224.isZero(x); }
public static void negate(int[] x, int[] z) { if (Nat224.isZero(x)) { Nat224.zero(z); } else { Nat224.sub(P, x, z); } }
public static void negate(int[] x, int[] z) { if (Nat224.isZero(x)) { Nat224.zero(z); } else { Nat224.sub(P, x, z); } }
public static void negate(int[] x, int[] z) { if (Nat224.isZero(x)) { Nat224.zero(z); } else { Nat224.sub(P, x, z); } }
public static void negate(int[] x, int[] z) { if (Nat224.isZero(x)) { Nat224.zero(z); } else { Nat224.sub(P, x, z); } }
/** * 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; }
private static boolean trySqrt(int[] nc, int[] r, int[] t) { int[] d1 = Nat224.create(); Nat224.copy(r, d1); int[] e1 = Nat224.create(); e1[0] = 1; int[] f1 = Nat224.create(); RP(nc, d1, e1, f1, t); int[] d0 = Nat224.create(); int[] e0 = Nat224.create(); for (int k = 1; k < 96; ++k) { Nat224.copy(d1, d0); Nat224.copy(e1, e0); RS(d1, e1, f1, t); if (Nat224.isZero(d1)) { Mod.invert(SecP224R1Field.P, e0, t); SecP224R1Field.multiply(t, d0, t); return true; } } return false; } }
private static boolean trySqrt(int[] nc, int[] r, int[] t) { int[] d1 = Nat224.create(); Nat224.copy(r, d1); int[] e1 = Nat224.create(); e1[0] = 1; int[] f1 = Nat224.create(); RP(nc, d1, e1, f1, t); int[] d0 = Nat224.create(); int[] e0 = Nat224.create(); for (int k = 1; k < 96; ++k) { Nat224.copy(d1, d0); Nat224.copy(e1, e0); RS(d1, e1, f1, t); if (Nat224.isZero(d1)) { Mod.invert(SecP224R1Field.P, e0, t); SecP224R1Field.multiply(t, d0, t); return true; } } return false; } }
if (Nat224.isZero(x1) || Nat224.isOne(x1))
if (Nat224.isZero(x1) || Nat224.isOne(x1))