Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,19 @@ private private_key(KeyPair ecKey){

public compact_signature sign_compact(sha256_object digest, boolean require_canonical ) {
compact_signature signature = null;
try {
final HmacPRNG prng = new HmacPRNG(key_data);
RandomSource randomSource = new RandomSource() {
@Override
public void nextBytes(byte[] bytes) {
prng.nextBytes(bytes);
}
};

while (true) {
InMemoryPrivateKey inMemoryPrivateKey = new InMemoryPrivateKey(key_data);
SignedMessage signedMessage = inMemoryPrivateKey.signHash(new Sha256Hash(digest.hash), randomSource);
byte[] byteCompact = signedMessage.bitcoinEncodingOfSignature();
signature = new compact_signature(byteCompact);

boolean bResult = public_key.is_canonical(signature);
if (bResult == true) {
break;
}
while (true) {
InMemoryPrivateKey inMemoryPrivateKey = new InMemoryPrivateKey(key_data);
SignedMessage signedMessage = inMemoryPrivateKey.signHash(new Sha256Hash(digest.hash));
byte[] byteCompact = signedMessage.bitcoinEncodingOfSignature();
signature = new compact_signature(byteCompact);

boolean bResult = public_key.is_canonical(signature);
if (bResult == true) {
break;
}
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}


return signature;
}

Expand Down