public ECFieldElement fromBigInteger(BigInteger x) { return new SM2P256V1FieldElement(x); }
protected ECPoint detach() { return new SM2P256V1Point(null, getAffineXCoord(), getAffineYCoord()); }
protected ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, boolean withCompression) { return new SM2P256V1Point(this, x, y, withCompression); }
public ECFieldElement multiply(ECFieldElement b) { int[] z = Nat256.create(); SM2P256V1Field.multiply(x, ((SM2P256V1FieldElement)b).x, z); return new SM2P256V1FieldElement(z); }
public ECFieldElement addOne() { int[] z = Nat256.create(); SM2P256V1Field.addOne(x, z); return new SM2P256V1FieldElement(z); }
public ECFieldElement square() { int[] z = Nat256.create(); SM2P256V1Field.square(x, z); return new SM2P256V1FieldElement(z); }
public ECFieldElement negate() { int[] z = Nat256.create(); SM2P256V1Field.negate(x, z); return new SM2P256V1FieldElement(z); }
public ECFieldElement add(ECFieldElement b) { int[] z = Nat256.create(); SM2P256V1Field.add(x, ((SM2P256V1FieldElement)b).x, z); return new SM2P256V1FieldElement(z); }
public ECFieldElement subtract(ECFieldElement b) { int[] z = Nat256.create(); SM2P256V1Field.subtract(x, ((SM2P256V1FieldElement)b).x, z); return new SM2P256V1FieldElement(z); }
public ECPoint negate() { if (this.isInfinity()) { return this; } return new SM2P256V1Point(curve, this.x, this.y.negate(), this.zs, this.withCompression); } }
public SM2P256V1Curve() { super(q); this.infinity = new SM2P256V1Point(this, null, null); this.a = fromBigInteger(new BigInteger(1, Hex.decode("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC"))); this.b = fromBigInteger(new BigInteger(1, Hex.decode("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93"))); this.order = new BigInteger(1, Hex.decode("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123")); this.cofactor = BigInteger.valueOf(1); this.coord = SM2P256V1_DEFAULT_COORDS; }
public ECPoint lookup(int index) { int[] x = Nat256.create(), y = Nat256.create(); int pos = 0; for (int i = 0; i < len; ++i) { int MASK = ((i ^ index) - 1) >> 31; for (int j = 0; j < FE_INTS; ++j) { x[j] ^= table[pos + j] & MASK; y[j] ^= table[pos + FE_INTS + j] & MASK; } pos += (FE_INTS * 2); } return createRawPoint(new SM2P256V1FieldElement(x), new SM2P256V1FieldElement(y), false); } };
protected ECCurve cloneCurve() { return new SM2P256V1Curve(); }
public static void subtract(int[] x, int[] y, int[] z) { int c = Nat256.sub(x, y, z); if (c != 0) { subPInvFrom(z); } }
public static void add(int[] x, int[] y, int[] z) { int c = Nat256.add(x, y, z); if (c != 0 || ((z[7] >>> 1) >= P7s1 && Nat256.gte(z, P))) { addPInvTo(z); } }
public ECFieldElement divide(ECFieldElement b) { // return multiply(b.invert()); int[] z = Nat256.create(); Mod.invert(SM2P256V1Field.P, ((SM2P256V1FieldElement)b).x, z); SM2P256V1Field.multiply(z, x, z); return new SM2P256V1FieldElement(z); }
public static void multiply(int[] x, int[] y, int[] z) { int[] tt = Nat256.createExt(); Nat256.mul(x, y, tt); reduce(tt, z); }
protected ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs, boolean withCompression) { return new SM2P256V1Point(this, x, y, zs, withCompression); }
public static void square(int[] x, int[] z) { int[] tt = Nat256.createExt(); Nat256.square(x, tt); reduce(tt, z); }