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 SecP521R1Curve extends ECCurve.AbstractFp
11{
12    public static final BigInteger q = new BigInteger(1,
13        Hex.decode("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"));
14
15    private static final int SecP521R1_DEFAULT_COORDS = COORD_JACOBIAN;
16
17    protected SecP521R1Point infinity;
18
19    public SecP521R1Curve()
20    {
21        super(q);
22
23        this.infinity = new SecP521R1Point(this, null, null);
24
25        this.a = fromBigInteger(new BigInteger(1,
26            Hex.decode("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC")));
27        this.b = fromBigInteger(new BigInteger(1,
28            Hex.decode("0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00")));
29        this.order = new BigInteger(1, Hex.decode("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409"));
30        this.cofactor = BigInteger.valueOf(1);
31
32        this.coord = SecP521R1_DEFAULT_COORDS;
33    }
34
35    protected ECCurve cloneCurve()
36    {
37        return new SecP521R1Curve();
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 SecP521R1FieldElement(x);
64    }
65
66    protected ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, boolean withCompression)
67    {
68        return new SecP521R1Point(this, x, y, withCompression);
69    }
70
71    protected ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs, boolean withCompression)
72    {
73        return new SecP521R1Point(this, x, y, zs, withCompression);
74    }
75
76    public ECPoint getInfinity()
77    {
78        return infinity;
79    }
80}
81