mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-13 11:35:40 +01:00
Merge ca9d6c2122
into 2dd140ad59
This commit is contained in:
commit
ec35af649c
2 changed files with 15 additions and 2 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,14 @@ public class Secp256k1Context {
|
|||
}
|
||||
enabled = isEnabled;
|
||||
context = contextRef;
|
||||
|
||||
if (isEnabled) {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
public void run() {
|
||||
NativeSecp256k1.cleanup();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue