params = new X962Parameters(ECUtil.getNamedCurveByOid(ECUtil.getNamedCurveOid(((ECNamedCurveParameterSpec)ecSpec).getName())));
DERObjectIdentifier curveOid = ECUtil.getNamedCurveOid(((ECNamedCurveParameterSpec)ecSpec).getName());  params = new X962Parameters(curveOid);
    public byte[] getEncoded()    {        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();        DEROutputStream         dOut = new DEROutputStream(bOut);        X962Parameters          params = null;        if (ecSpec instanceof ECNamedCurveParameterSpec)        {            params = new X962Parameters(ECUtil.getNamedCurveByOid(ECUtil.getNamedCurveOid(((ECNamedCurveParameterSpec)ecSpec).getName())));        }        else        {            ECParameterSpec         p = (ECParameterSpec)ecSpec;            ECCurve curve = p.getG().getCurve();            ECPoint generator;                        if (curve instanceof ECCurve.Fp)             {                generator = new ECPoint.Fp(curve, p.getG().getX(), p.getG().getY(), withCompression);            }             else if (curve instanceof ECCurve.F2m)             {                generator = new ECPoint.F2m(curve, p.getG().getX(), p.getG().getY(), withCompression);            }            else             {                throw new UnsupportedOperationException("Subclass of ECPoint " + curve.getClass().toString() + "not supported");            }                        X9ECParameters ecP = new X9ECParameters(                  p.getCurve(),                  generator,                  p.getN(),                  p.getH(),                  p.getSeed());            params = new X962Parameters(ecP);        }        PrivateKeyInfo          info;                if (algorithm.equals("ECGOST3410"))        {            info = new PrivateKeyInfo(new AlgorithmIdentifier(CryptoProObjectIdentifiers.gostR3410_2001, params.getDERObject()), new ECPrivateKeyStructure(this.getD()).getDERObject());        }        else        {            info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_ecPublicKey, params.getDERObject()), new ECPrivateKeyStructure(this.getD()).getDERObject());        }                try        {            dOut.writeObject(info);            dOut.close();        }        catch (IOException e)        {            throw new RuntimeException("Error encoding EC private key");        }        return bOut.toByteArray();    }