FileDocCategorySizeDatePackage
ECPrivateKeyStructure.javaAPI DocAzureus 3.0.3.41088Tue Jun 08 05:13:04 BST 2004org.bouncycastle.asn1.sec

ECPrivateKeyStructure

public class ECPrivateKeyStructure extends Object implements DEREncodable
the elliptic curve private key object from SEC 1

Fields Summary
private ASN1Sequence
seq
Constructors Summary
public ECPrivateKeyStructure(ASN1Sequence seq)

        this.seq = seq;
    
public ECPrivateKeyStructure(BigInteger key)

        byte[]  bytes = key.toByteArray();

        if (bytes[0] == 0)
        {
            byte[]  tmp = new byte[bytes.length - 1];

            System.arraycopy(bytes, 1, tmp, 0, tmp.length);
            bytes = tmp;
        }

        ASN1EncodableVector v = new ASN1EncodableVector();

        v.add(new DERInteger(1));
        v.add(new DEROctetString(bytes));

        seq = new DERSequence(v);
    
Methods Summary
public DERObjectgetDERObject()

        return seq;
    
public java.math.BigIntegergetKey()

        ASN1OctetString  octs = (ASN1OctetString)seq.getObjectAt(1);

        BigInteger  k = new BigInteger(1, octs.getOctets());

        return k;