1414import org .bouncycastle .math .ec .ECPoint ;
1515import org .bouncycastle .math .field .FiniteField ;
1616import org .bouncycastle .math .field .PolynomialExtensionField ;
17- import org .bouncycastle .util .Arrays ;
1817
1918/**
2019 * ASN.1 def for Elliptic-Curve ECParameters structure. See
@@ -27,11 +26,10 @@ public class X9ECParameters
2726 private static final BigInteger ONE = BigInteger .valueOf (1 );
2827
2928 private X9FieldID fieldID ;
30- private ECCurve curve ;
29+ private X9Curve curve ;
3130 private X9ECPoint g ;
3231 private BigInteger n ;
3332 private BigInteger h ;
34- private byte [] seed ;
3533
3634 private X9ECParameters (
3735 ASN1Sequence seq )
@@ -49,11 +47,10 @@ private X9ECParameters(
4947 this .h = ((ASN1Integer )seq .getObjectAt (5 )).getValue ();
5048 }
5149
52- X9Curve x9c = new X9Curve (
53- X9FieldID . getInstance ( seq . getObjectAt ( 1 )), n , h ,
54- ASN1Sequence .getInstance (seq .getObjectAt (2 )));
50+ this . fieldID = X9FieldID . getInstance ( seq . getObjectAt ( 1 ));
51+
52+ this . curve = new X9Curve ( fieldID , n , h , ASN1Sequence .getInstance (seq .getObjectAt (2 )));
5553
56- this .curve = x9c .getCurve ();
5754 Object p = seq .getObjectAt (3 );
5855
5956 if (p instanceof X9ECPoint )
@@ -62,10 +59,8 @@ private X9ECParameters(
6259 }
6360 else
6461 {
65- this .g = new X9ECPoint (curve , (ASN1OctetString )p );
62+ this .g = new X9ECPoint (curve . getCurve () , (ASN1OctetString )p );
6663 }
67-
68- this .seed = x9c .getSeed ();
6964 }
7065
7166 public static X9ECParameters getInstance (Object obj )
@@ -107,11 +102,10 @@ public X9ECParameters(
107102 BigInteger h ,
108103 byte [] seed )
109104 {
110- this .curve = curve ;
105+ this .curve = new X9Curve ( curve , seed ) ;
111106 this .g = g ;
112107 this .n = n ;
113108 this .h = h ;
114- this .seed = Arrays .clone (seed );
115109
116110 FiniteField field = curve .getField ();
117111 if (ECAlgorithms .isFpField (field ))
@@ -143,7 +137,7 @@ else if (exponents.length == 5)
143137
144138 public ECCurve getCurve ()
145139 {
146- return curve ;
140+ return curve . getCurve () ;
147141 }
148142
149143 public ECPoint getG ()
@@ -163,12 +157,12 @@ public BigInteger getH()
163157
164158 public byte [] getSeed ()
165159 {
166- return Arrays . clone ( seed );
160+ return curve . getSeed ( );
167161 }
168162
169163 public boolean hasSeed ()
170164 {
171- return null != seed ;
165+ return curve . hasSeed () ;
172166 }
173167
174168 /**
@@ -178,7 +172,7 @@ public boolean hasSeed()
178172 */
179173 public X9Curve getCurveEntry ()
180174 {
181- return new X9Curve ( curve , seed ) ;
175+ return curve ;
182176 }
183177
184178 /**
@@ -220,7 +214,7 @@ public ASN1Primitive toASN1Primitive()
220214
221215 v .add (new ASN1Integer (ONE ));
222216 v .add (fieldID );
223- v .add (new X9Curve ( curve , seed ) );
217+ v .add (curve );
224218 v .add (g );
225219 v .add (new ASN1Integer (n ));
226220
0 commit comments