Exemplo n.º 1
0
 @Override
 public byte[] recoverKey(int recId, byte[] signatureParam, byte[] hashValue) {
   Signature signature = Signatures.decodeSignatureParameters(new ByteReader(signatureParam));
   Sha256Hash hash = new Sha256Hash(hashValue);
   PublicKey key = SignedMessage.recoverFromSignature(recId, signature, hash, false);
   if (key != null) {
     return key.getPublicKeyBytes();
   } else {
     return null;
   }
 }
Exemplo n.º 2
0
 @Override
 public BitcoinSigner findSignerByPublicKey(PublicKey publicKey) {
   Address address = publicKey.toAddress(_network);
   InMemoryPrivateKey privateKey;
   try {
     privateKey = getPrivateKeyForAddress(address, _cipher);
   } catch (InvalidKeyCipher e) {
     throw new RuntimeException(
         "Unable to decrypt private key for address " + address.toString());
   }
   if (privateKey != null) {
     return privateKey;
   }
   throw new RuntimeException("Unable to find private key for address " + address.toString());
 }