   (:require [clojure.data.codec.base64 :as b64]
             [clojure-fabric.utils :as utils]
             [clojure.java.io :as io])
-  (:import [org.bouncycastle.crypto.generators ECKeyPairGenerator]
+  (:import [java.math BigInteger]
+   [org.bouncycastle.crypto.generators ECKeyPairGenerator]
            [org.bouncycastle.jce ECNamedCurveTable]
            [org.bouncycastle.jce.spec ECNamedCurveParameterSpec ECNamedCurveSpec]
            [org.bouncycastle.jce.provider BouncyCastleProvider]

;;;
(extend-type BCECPrivateKey
  IBCECKey
  (algorithm [this] (-> this .getAlgorithm keyword))
  (curve-spec [this] (keyword (.getName ^ECNamedCurveSpec (.getParams this))))
  (curve-params [this] (-> this .getParameters %curve-params))
  (%derive-key [this opts]
    (derive-bcec-key (curve-params this))))

(extend-type BCECPublicKey
  IBCECKey
  (algorithm [this] (-> this .getAlgorithm keyword))
  (curve-spec [this] (keyword (.getName ^ECNamedCurveSpec (.getParams this))))
  (curve-params [this] (-> this .getParameters %curve-params))
  (%derive-key [this opts]
    (derive-bcec-key (curve-params this))))

           [org.bouncycastle.util.encoders Hex]
           [org.bouncycastle.asn1.pkcs PrivateKeyInfo]
           [org.bouncycastle.asn1.x509 SubjectPublicKeyInfo]
           [org.bouncycastle.asn1 ASN1Integer DERSequenceGenerator]
           [org.bouncycastle.cert X509CertificateHolder]
           [org.bouncycastle.openssl.jcajce JcaPEMKeyConverter]
           [org.bouncycastle.openssl PEMParser]
           [org.bouncycastle.cert.jcajce JcaX509CertificateConverter]
           [org.bouncycastle.crypto.signers ECDSASigner]
           [org.bouncycastle.crypto.params ECDomainParameters ECPrivateKeyParameters]
           [java.io FileInputStream StringReader FileReader File ByteArrayOutputStream]
           [java.util Arrays]
           [javax.crypto Cipher SecretKeyFactory]
           [javax.crypto.spec SecretKeySpec]
