public class NativeSecp256k1 extends Object
This class holds native methods to handle ECDSA verification.
You can find an example library that can be used for this at https://github.com/bitcoin/secp256k1
To build secp256k1 for use with bitcoinj, run `./configure --enable-jni --enable-experimental --enable-module-schnorr --enable-module-ecdh` and `make` then copy `.libs/libsecp256k1.so` to your system library path or point the JVM to the folder containing it with -Djava.library.path
Constructor and Description |
---|
NativeSecp256k1() |
Modifier and Type | Method and Description |
---|---|
static void |
cleanup()
libsecp256k1 Cleanup - This destroys the secp256k1 context object This should be called at the end of the program
for proper cleanup of the context.
|
static long |
cloneContext() |
static byte[] |
computePubkey(byte[] seckey)
libsecp256k1 Compute Pubkey - computes public key from secret key
|
static byte[] |
createECDHSecret(byte[] seckey,
byte[] pubkey)
libsecp256k1 create ECDH secret - constant time ECDH calculation
|
static byte[] |
privKeyTweakAdd(byte[] privkey,
byte[] tweak)
libsecp256k1 PrivKey Tweak-Add - Tweak privkey by adding to it
|
static byte[] |
privKeyTweakMul(byte[] privkey,
byte[] tweak)
libsecp256k1 PrivKey Tweak-Mul - Tweak privkey by multiplying to it
|
static byte[] |
pubKeyTweakAdd(byte[] pubkey,
byte[] tweak)
libsecp256k1 PubKey Tweak-Add - Tweak pubkey by adding to it
|
static byte[] |
pubKeyTweakMul(byte[] pubkey,
byte[] tweak)
libsecp256k1 PubKey Tweak-Mul - Tweak pubkey by multiplying to it
|
static boolean |
randomize(byte[] seed)
libsecp256k1 randomize - updates the context randomization
|
static byte[] |
schnorrSign(byte[] data,
byte[] sec) |
static boolean |
secKeyVerify(byte[] seckey)
libsecp256k1 Seckey Verify - returns 1 if valid, 0 if invalid
|
static byte[] |
sign(byte[] data,
byte[] sec)
libsecp256k1 Create an ECDSA signature.
|
static boolean |
verify(byte[] data,
byte[] signature,
byte[] pub)
Verifies the given secp256k1 signature in native code.
|
public static boolean verify(byte[] data, byte[] signature, byte[] pub) throws NativeSecp256k1Util.AssertFailException
data
- The data which was signed, must be exactly 32 bytessignature
- The signaturepub
- The public key which did the signingNativeSecp256k1Util.AssertFailException
public static byte[] sign(byte[] data, byte[] sec) throws NativeSecp256k1Util.AssertFailException
data
- Message hash, 32 byteskey
- Secret key, 32 bytesNativeSecp256k1Util.AssertFailException
public static boolean secKeyVerify(byte[] seckey)
seckey
- ECDSA Secret key, 32 bytespublic static byte[] computePubkey(byte[] seckey) throws NativeSecp256k1Util.AssertFailException
seckey
- ECDSA Secret key, 32 bytesNativeSecp256k1Util.AssertFailException
public static void cleanup()
public static long cloneContext()
public static byte[] privKeyTweakMul(byte[] privkey, byte[] tweak) throws NativeSecp256k1Util.AssertFailException
tweak
- some bytes to tweak withseckey
- 32-byte seckeyNativeSecp256k1Util.AssertFailException
public static byte[] privKeyTweakAdd(byte[] privkey, byte[] tweak) throws NativeSecp256k1Util.AssertFailException
tweak
- some bytes to tweak withseckey
- 32-byte seckeyNativeSecp256k1Util.AssertFailException
public static byte[] pubKeyTweakAdd(byte[] pubkey, byte[] tweak) throws NativeSecp256k1Util.AssertFailException
tweak
- some bytes to tweak withpubkey
- 32-byte seckeyNativeSecp256k1Util.AssertFailException
public static byte[] pubKeyTweakMul(byte[] pubkey, byte[] tweak) throws NativeSecp256k1Util.AssertFailException
tweak
- some bytes to tweak withpubkey
- 32-byte seckeyNativeSecp256k1Util.AssertFailException
public static byte[] createECDHSecret(byte[] seckey, byte[] pubkey) throws NativeSecp256k1Util.AssertFailException
seckey
- byte array of secret key used in exponentiaionpubkey
- byte array of public key used in exponentiaionNativeSecp256k1Util.AssertFailException
public static boolean randomize(byte[] seed) throws NativeSecp256k1Util.AssertFailException
seed
- 32-byte random seedNativeSecp256k1Util.AssertFailException
public static byte[] schnorrSign(byte[] data, byte[] sec) throws NativeSecp256k1Util.AssertFailException
Copyright © 2016. All rights reserved.