@Override
public byte[] getEncoded() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SEQUENCE privateKeyInfo = new SEQUENCE();
privateKeyInfo.addElement(new INTEGER(0));
SEQUENCE algid = new SEQUENCE();
algid.addElement(new OBJECT_IDENTIFIER("1.2.840.10045.2.1"));
algid.addElement(new OBJECT_IDENTIFIER(EcCore.getOID(params)));
privateKeyInfo.addElement(algid);
SEQUENCE ecPrivateKey = new SEQUENCE();
ecPrivateKey.addElement(new INTEGER(1));
ecPrivateKey
.addElement(new OCTET_STRING(EcCore.fieldElemToBytes(S, params)));
try {
ecPrivateKey.encode(baos);