01: package org.bouncycastle.jce.spec;
02:
03: import org.bouncycastle.math.ec.ECCurve;
04: import org.bouncycastle.math.ec.ECPoint;
05:
06: import java.math.BigInteger;
07: import java.security.spec.AlgorithmParameterSpec;
08:
09: /**
10: * basic domain parameters for an Elliptic Curve public or private key.
11: */
12: public class ECParameterSpec implements AlgorithmParameterSpec {
13: private ECCurve curve;
14: private byte[] seed;
15: private ECPoint G;
16: private BigInteger n;
17: private BigInteger h;
18:
19: public ECParameterSpec(ECCurve curve, ECPoint G, BigInteger n) {
20: this .curve = curve;
21: this .G = G;
22: this .n = n;
23: this .h = BigInteger.valueOf(1);
24: this .seed = null;
25: }
26:
27: public ECParameterSpec(ECCurve curve, ECPoint G, BigInteger n,
28: BigInteger h) {
29: this .curve = curve;
30: this .G = G;
31: this .n = n;
32: this .h = h;
33: this .seed = null;
34: }
35:
36: public ECParameterSpec(ECCurve curve, ECPoint G, BigInteger n,
37: BigInteger h, byte[] seed) {
38: this .curve = curve;
39: this .G = G;
40: this .n = n;
41: this .h = h;
42: this .seed = seed;
43: }
44:
45: /**
46: * return the curve along which the base point lies.
47: * @return the curve
48: */
49: public ECCurve getCurve() {
50: return curve;
51: }
52:
53: /**
54: * return the base point we are using for these domain parameters.
55: * @return the base point.
56: */
57: public ECPoint getG() {
58: return G;
59: }
60:
61: /**
62: * return the order N of G
63: * @return the order
64: */
65: public BigInteger getN() {
66: return n;
67: }
68:
69: /**
70: * return the cofactor H to the order of G.
71: * @return the cofactor
72: */
73: public BigInteger getH() {
74: return h;
75: }
76:
77: /**
78: * return the seed used to generate this curve (if available).
79: * @return the random seed
80: */
81: public byte[] getSeed() {
82: return seed;
83: }
84:
85: public boolean equals(Object o) {
86: if (!(o instanceof ECParameterSpec)) {
87: return false;
88: }
89:
90: ECParameterSpec other = (ECParameterSpec) o;
91:
92: return this .getCurve().equals(other.getCurve())
93: && this .getG().equals(other.getG());
94: }
95:
96: public int hashCode() {
97: return this.getCurve().hashCode() ^ this.getG().hashCode();
98: }
99: }
|