FileDocCategorySizeDatePackage
X9ECParameters.javaAPI DocAzureus 3.0.3.43561Mon Mar 20 04:56:46 GMT 2006org.bouncycastle.asn1.x9

X9ECParameters

public class X9ECParameters extends Object implements X9ObjectIdentifiers, org.bouncycastle.asn1.DEREncodable
ASN.1 def for Elliptic-Curve ECParameters structure. See X9.62, for further details.

Fields Summary
private static BigInteger
ONE
private X9FieldID
fieldID
private org.bouncycastle.math.ec.ECCurve
curve
private org.bouncycastle.math.ec.ECPoint
g
private BigInteger
n
private BigInteger
h
private byte[]
seed
Constructors Summary
public X9ECParameters(org.bouncycastle.asn1.ASN1Sequence seq)


	 
          
    
        if (!(seq.getObjectAt(0) instanceof DERInteger)
           || !((DERInteger)seq.getObjectAt(0)).getValue().equals(ONE))
        {
            throw new IllegalArgumentException("bad version in X9ECParameters");
        }

        X9Curve     x9c = new X9Curve(
                        new X9FieldID((ASN1Sequence)seq.getObjectAt(1)),
                        (ASN1Sequence)seq.getObjectAt(2));

        this.curve = x9c.getCurve();
		this.g = new X9ECPoint(curve, (ASN1OctetString)seq.getObjectAt(3)).getPoint();
		this.n = ((DERInteger)seq.getObjectAt(4)).getValue();
        this.seed = x9c.getSeed();

        if (seq.size() == 6)
        {
		    this.h = ((DERInteger)seq.getObjectAt(5)).getValue();
        }
        else
        {
            this.h = ONE;
        }
    
public X9ECParameters(org.bouncycastle.math.ec.ECCurve curve, org.bouncycastle.math.ec.ECPoint g, BigInteger n)

        this(curve, g, n, ONE, null);
	
public X9ECParameters(org.bouncycastle.math.ec.ECCurve curve, org.bouncycastle.math.ec.ECPoint g, BigInteger n, BigInteger h)

        this(curve, g, n, h, null);
	
public X9ECParameters(org.bouncycastle.math.ec.ECCurve curve, org.bouncycastle.math.ec.ECPoint g, BigInteger n, BigInteger h, byte[] seed)

		this.curve = curve;
		this.g = g;
		this.n = n;
		this.h = h;
        this.seed = seed;

        if (curve instanceof ECCurve.Fp)
        {
            this.fieldID = new X9FieldID(prime_field, ((ECCurve.Fp)curve).getQ());
        }
        else
        {
            this.fieldID = new X9FieldID(characteristic_two_field, null);
        }
	
Methods Summary
public org.bouncycastle.math.ec.ECCurvegetCurve()

		return curve;
	
public org.bouncycastle.asn1.DERObjectgetDERObject()
Produce an object suitable for an ASN1OutputStream.
ECParameters ::= SEQUENCE {
version INTEGER { ecpVer1(1) } (ecpVer1),
fieldID FieldID {{FieldTypes}},
curve X9Curve,
base X9ECPoint,
order INTEGER,
cofactor INTEGER OPTIONAL
}

        ASN1EncodableVector v = new ASN1EncodableVector();

        v.add(new DERInteger(1));
        v.add(fieldID);
        v.add(new X9Curve(curve, seed));
        v.add(new X9ECPoint(g));
        v.add(new DERInteger(n));

        if (!h.equals(BigInteger.valueOf(1)))
        {
            v.add(new DERInteger(h));
        }

        return new DERSequence(v);
    
public org.bouncycastle.math.ec.ECPointgetG()

		return g;
	
public java.math.BigIntegergetH()

		return h;
	
public java.math.BigIntegergetN()

		return n;
	
public byte[]getSeed()

		return seed;