public byte[] sign(byte[] hash){
  ECDSASigner signer=new ECDSASigner(new HMacDSAKCalculator(new SHA256Digest()));
  signer.init(true,new ECPrivateKeyParameters(priv,domain));
  BigInteger[] signature=signer.generateSignature(hash);
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try {
    DERSequenceGenerator seq=new DERSequenceGenerator(baos);
    seq.addObject(new ASN1Integer(signature[0]));
    seq.addObject(new ASN1Integer(toCanonicalS(signature[1])));
    seq.close();
    return baos.toByteArray();
  }
 catch (  IOException e) {
  }
  return null;
}

public byte [ ] sign ( byte [ ] hash ) { ECDSASigner signer = new ECDSASigner ( new HMacDSAKCalculator ( new SHA256Digest ( ) ) ) ; signer . init ( true , new ECPrivateKeyParameters ( priv , domain ) ) ; BigInteger [ ] signature = signer . generateSignature ( hash ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; try { DERSequenceGenerator seq = new DERSequenceGenerator ( baos ) ; seq . addObject ( new ASN1Integer ( signature [ 0 ] ) ) ; seq . addObject ( new ASN1Integer ( toCanonicalS ( signature [ 1 ] ) ) ) ; seq . close ( ) ; return baos . toByteArray ( ) ; } catch ( IOException e ) { } return null ; }
sign a digest with this key .
