1 package org.bouncycastle.math.ec.custom.sec; 2 3 import java.math.BigInteger; 4 5 import org.bouncycastle.math.ec.ECConstants; 6 import org.bouncycastle.math.ec.ECCurve; 7 import org.bouncycastle.math.ec.ECFieldElement; 8 import org.bouncycastle.math.ec.ECPoint; 9 import org.bouncycastle.util.encoders.Hex; 10 11 public class SecP224K1Curve extends ECCurve.AbstractFp 12 { 13 public static final BigInteger q = new BigInteger(1, 14 Hex.decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFE56D")); 15 16 private static final int SECP224K1_DEFAULT_COORDS = COORD_JACOBIAN; 17 18 protected SecP224K1Point infinity; 19 SecP224K1Curve()20 public SecP224K1Curve() 21 { 22 super(q); 23 24 this.infinity = new SecP224K1Point(this, null, null); 25 26 this.a = fromBigInteger(ECConstants.ZERO); 27 this.b = fromBigInteger(BigInteger.valueOf(5)); 28 this.order = new BigInteger(1, Hex.decode("010000000000000000000000000001DCE8D2EC6184CAF0A971769FB1F7")); 29 this.cofactor = BigInteger.valueOf(1); 30 this.coord = SECP224K1_DEFAULT_COORDS; 31 } 32 cloneCurve()33 protected ECCurve cloneCurve() 34 { 35 return new SecP224K1Curve(); 36 } 37 supportsCoordinateSystem(int coord)38 public boolean supportsCoordinateSystem(int coord) 39 { 40 switch (coord) 41 { 42 case COORD_JACOBIAN: 43 return true; 44 default: 45 return false; 46 } 47 } 48 getQ()49 public BigInteger getQ() 50 { 51 return q; 52 } 53 getFieldSize()54 public int getFieldSize() 55 { 56 return q.bitLength(); 57 } 58 fromBigInteger(BigInteger x)59 public ECFieldElement fromBigInteger(BigInteger x) 60 { 61 return new SecP224K1FieldElement(x); 62 } 63 createRawPoint(ECFieldElement x, ECFieldElement y, boolean withCompression)64 protected ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, boolean withCompression) 65 { 66 return new SecP224K1Point(this, x, y, withCompression); 67 } 68 createRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs, boolean withCompression)69 protected ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs, boolean withCompression) 70 { 71 return new SecP224K1Point(this, x, y, zs, withCompression); 72 } 73 getInfinity()74 public ECPoint getInfinity() 75 { 76 return infinity; 77 } 78 } 79