This commit is contained in:
Nadav Kohen 2025-03-12 10:35:20 -05:00 committed by GitHub
commit ec35af649c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View file

@ -1,6 +1,6 @@
package org.bitcoins.crypto
import org.bitcoin.NativeSecp256k1
import org.bitcoin.{NativeSecp256k1, Secp256k1Context}
import scodec.bits.ByteVector
/** This is an implementation of [[CryptoRuntime]] that defaults to libsecp256k1
@ -295,4 +295,9 @@ trait LibSecp256k1CryptoRuntime extends CryptoRuntime {
}
}
object LibSecp256k1CryptoRuntime extends LibSecp256k1CryptoRuntime
object LibSecp256k1CryptoRuntime extends LibSecp256k1CryptoRuntime {
if (Secp256k1Context.isEnabled) {
NativeSecp256k1.randomize(
BouncycastleCryptoRuntime.freshPrivateKey.bytes.toArray)
}
}

View file

@ -43,6 +43,14 @@ public class Secp256k1Context {
}
enabled = isEnabled;
context = contextRef;
if (isEnabled) {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
NativeSecp256k1.cleanup();
}
});
}
}
/**