@Test
public void testBasic() throws Exception {

  ECParameterSpec ecParams = EllipticCurves.getNistP256Params();
  KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
  keyGen.initialize(ecParams);
  KeyPair keyPair = keyGen.generateKeyPair();
  ECPublicKey pub = (ECPublicKey) keyPair.getPublic();
  ECPrivateKey priv = (ECPrivateKey) keyPair.getPrivate();
  // Sign with EcdsaSign.
  String message = "Hello";
  EcdsaSignJce signer = new EcdsaSignJce(priv, HashType.SHA256, EcdsaEncoding.DER);
  byte[] signature = signer.sign(message.getBytes("UTF-8"));
  // Verify with JCE's Signature.
  Signature verifier = Signature.getInstance("SHA256WithECDSA");
  verifier.initVerify(pub);
  verifier.update(message.getBytes("UTF-8"));
  assertTrue(verifier.verify(signature));
}