Code example for BigInteger

Methods: toByteArray

0
    } 
 
    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);