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