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