Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Static Public Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
org.bitcoin.NativeSecp256k1 Class Reference

Static Public Member Functions

static boolean verify (byte[] data, byte[] signature, byte[] pub)
 Verifies the given secp256k1 signature in native code.
 
static byte[] sign (byte[] data, byte[] sec) throws AssertFailException
 libsecp256k1 Create an ECDSA signature.
 
static boolean secKeyVerify (byte[] seckey)
 libsecp256k1 Seckey Verify - returns 1 if valid, 0 if invalid
 
static byte[] computePubkey (byte[] seckey) throws AssertFailException
 libsecp256k1 Compute Pubkey - computes public key from secret key
 
static synchronized 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[] privKeyTweakMul (byte[] privkey, byte[] tweak) throws AssertFailException
 libsecp256k1 PrivKey Tweak-Mul - Tweak privkey by multiplying to it
 
static byte[] privKeyTweakAdd (byte[] privkey, byte[] tweak) throws AssertFailException
 libsecp256k1 PrivKey Tweak-Add - Tweak privkey by adding to it
 
static byte[] pubKeyTweakAdd (byte[] pubkey, byte[] tweak) throws AssertFailException
 libsecp256k1 PubKey Tweak-Add - Tweak pubkey by adding to it
 
static byte[] pubKeyTweakMul (byte[] pubkey, byte[] tweak) throws AssertFailException
 libsecp256k1 PubKey Tweak-Mul - Tweak pubkey by multiplying to it
 
static byte[] createECDHSecret (byte[] seckey, byte[] pubkey) throws AssertFailException
 libsecp256k1 create ECDH secret - constant time ECDH calculation
 
static synchronized boolean randomize (byte[] seed) throws AssertFailException
 libsecp256k1 randomize - updates the context randomization
 
static byte[] schnorrSign (byte[] data, byte[] seckey) throws AssertFailException
 libsecp256k1 Create a Schnorr signature.
 
static boolean schnorrVerify (byte[] data, byte[] signature, byte[] pub)
 Verifies the given Schnorr signature in native code.
 

Static Private Member Functions

static native long secp256k1_ctx_clone (long context)
 
static native int secp256k1_context_randomize (ByteBuffer byteBuff, long context)
 
static native byte[][] secp256k1_privkey_tweak_add (ByteBuffer byteBuff, long context)
 
static native byte[][] secp256k1_privkey_tweak_mul (ByteBuffer byteBuff, long context)
 
static native byte[][] secp256k1_pubkey_tweak_add (ByteBuffer byteBuff, long context, int pubLen)
 
static native byte[][] secp256k1_pubkey_tweak_mul (ByteBuffer byteBuff, long context, int pubLen)
 
static native void secp256k1_destroy_context (long context)
 
static native int secp256k1_ecdsa_verify (ByteBuffer byteBuff, long context, int sigLen, int pubLen)
 
static native byte[][] secp256k1_ecdsa_sign (ByteBuffer byteBuff, long context)
 
static native int secp256k1_ec_seckey_verify (ByteBuffer byteBuff, long context)
 
static native byte[][] secp256k1_ec_pubkey_create (ByteBuffer byteBuff, long context)
 
static native byte[][] secp256k1_ec_pubkey_parse (ByteBuffer byteBuff, long context, int inputLen)
 
static native int secp256k1_schnorr_verify (ByteBuffer byteBuff, long context, int pubLen)
 
static native byte[][] secp256k1_schnorr_sign (ByteBuffer byteBuff, long context)
 
static native byte[][] secp256k1_ecdh (ByteBuffer byteBuff, long context, int inputLen)
 

Static Private Attributes

static final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock()
 
static final Lock r = rwl.readLock()
 
static final Lock w = rwl.writeLock()
 
static ThreadLocal< ByteBuffernativeByteBuffer = new ThreadLocal<ByteBuffer>()
 

Detailed Description

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-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

Definition at line 39 of file NativeSecp256k1.java.

Member Function Documentation

◆ cleanup()

static synchronized void org.bitcoin.NativeSecp256k1.cleanup ( )
inlinestatic

libsecp256k1 Cleanup - This destroys the secp256k1 context object This should be called at the end of the program for proper cleanup of the context.

Definition at line 184 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cloneContext()

static long org.bitcoin.NativeSecp256k1.cloneContext ( )
inlinestatic

Definition at line 193 of file NativeSecp256k1.java.

Here is the call graph for this function:

◆ computePubkey()

static byte[] org.bitcoin.NativeSecp256k1.computePubkey ( byte[]  seckey) throws AssertFailException
inlinestatic

libsecp256k1 Compute Pubkey - computes public key from secret key

Parameters
seckeyECDSA Secret key, 32 bytes

Return values

Parameters
pubkeyECDSA Public key, 33 or 65 bytes

Definition at line 150 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createECDHSecret()

static byte[] org.bitcoin.NativeSecp256k1.createECDHSecret ( byte[]  seckey,
byte[]  pubkey 
) throws AssertFailException
inlinestatic

libsecp256k1 create ECDH secret - constant time ECDH calculation

Parameters
seckeybyte array of secret key used in exponentiaion
pubkeybyte array of public key used in exponentiaion

Definition at line 362 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ privKeyTweakAdd()

static byte[] org.bitcoin.NativeSecp256k1.privKeyTweakAdd ( byte[]  privkey,
byte[]  tweak 
) throws AssertFailException
inlinestatic

libsecp256k1 PrivKey Tweak-Add - Tweak privkey by adding to it

Parameters
tweaksome bytes to tweak with
seckey32-byte seckey

Definition at line 245 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ privKeyTweakMul()

static byte[] org.bitcoin.NativeSecp256k1.privKeyTweakMul ( byte[]  privkey,
byte[]  tweak 
) throws AssertFailException
inlinestatic

libsecp256k1 PrivKey Tweak-Mul - Tweak privkey by multiplying to it

Parameters
tweaksome bytes to tweak with
seckey32-byte seckey

Definition at line 206 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pubKeyTweakAdd()

static byte[] org.bitcoin.NativeSecp256k1.pubKeyTweakAdd ( byte[]  pubkey,
byte[]  tweak 
) throws AssertFailException
inlinestatic

libsecp256k1 PubKey Tweak-Add - Tweak pubkey by adding to it

Parameters
tweaksome bytes to tweak with
pubkey32-byte seckey

Definition at line 284 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pubKeyTweakMul()

static byte[] org.bitcoin.NativeSecp256k1.pubKeyTweakMul ( byte[]  pubkey,
byte[]  tweak 
) throws AssertFailException
inlinestatic

libsecp256k1 PubKey Tweak-Mul - Tweak pubkey by multiplying to it

Parameters
tweaksome bytes to tweak with
pubkey32-byte seckey

Definition at line 323 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ randomize()

static synchronized boolean org.bitcoin.NativeSecp256k1.randomize ( byte[]  seed) throws AssertFailException
inlinestatic

libsecp256k1 randomize - updates the context randomization

Parameters
seed32-byte random seed

Definition at line 397 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ schnorrSign()

static byte[] org.bitcoin.NativeSecp256k1.schnorrSign ( byte[]  data,
byte[]  seckey 
) throws AssertFailException
inlinestatic

libsecp256k1 Create a Schnorr signature.

Parameters
dataMessage hash, 32 bytes
seckeySecret key, 32 bytes
Returns
sig byte array of signature

Definition at line 424 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ schnorrVerify()

static boolean org.bitcoin.NativeSecp256k1.schnorrVerify ( byte[]  data,
byte[]  signature,
byte[]  pub 
)
inlinestatic

Verifies the given Schnorr signature in native code.

Calling when enabled == false is undefined (probably library not loaded)

Parameters
dataThe data which was signed, must be exactly 32 bytes
signatureThe signature is exactly 64 bytes
pubThe public key which did the signing which is the same ECDSA

Definition at line 462 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ secKeyVerify()

static boolean org.bitcoin.NativeSecp256k1.secKeyVerify ( byte[]  seckey)
inlinestatic

libsecp256k1 Seckey Verify - returns 1 if valid, 0 if invalid

Parameters
seckeyECDSA Secret key, 32 bytes

Definition at line 120 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ secp256k1_context_randomize()

static native int org.bitcoin.NativeSecp256k1.secp256k1_context_randomize ( ByteBuffer  byteBuff,
long  context 
)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_ctx_clone()

static native long org.bitcoin.NativeSecp256k1.secp256k1_ctx_clone ( long  context)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_destroy_context()

static native void org.bitcoin.NativeSecp256k1.secp256k1_destroy_context ( long  context)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_ec_pubkey_create()

static native byte[][] org.bitcoin.NativeSecp256k1.secp256k1_ec_pubkey_create ( ByteBuffer  byteBuff,
long  context 
)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_ec_pubkey_parse()

static native byte[][] org.bitcoin.NativeSecp256k1.secp256k1_ec_pubkey_parse ( ByteBuffer  byteBuff,
long  context,
int  inputLen 
)
staticprivate

◆ secp256k1_ec_seckey_verify()

static native int org.bitcoin.NativeSecp256k1.secp256k1_ec_seckey_verify ( ByteBuffer  byteBuff,
long  context 
)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_ecdh()

static native byte[][] org.bitcoin.NativeSecp256k1.secp256k1_ecdh ( ByteBuffer  byteBuff,
long  context,
int  inputLen 
)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_ecdsa_sign()

static native byte[][] org.bitcoin.NativeSecp256k1.secp256k1_ecdsa_sign ( ByteBuffer  byteBuff,
long  context 
)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_ecdsa_verify()

static native int org.bitcoin.NativeSecp256k1.secp256k1_ecdsa_verify ( ByteBuffer  byteBuff,
long  context,
int  sigLen,
int  pubLen 
)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_privkey_tweak_add()

static native byte[][] org.bitcoin.NativeSecp256k1.secp256k1_privkey_tweak_add ( ByteBuffer  byteBuff,
long  context 
)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_privkey_tweak_mul()

static native byte[][] org.bitcoin.NativeSecp256k1.secp256k1_privkey_tweak_mul ( ByteBuffer  byteBuff,
long  context 
)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_pubkey_tweak_add()

static native byte[][] org.bitcoin.NativeSecp256k1.secp256k1_pubkey_tweak_add ( ByteBuffer  byteBuff,
long  context,
int  pubLen 
)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_pubkey_tweak_mul()

static native byte[][] org.bitcoin.NativeSecp256k1.secp256k1_pubkey_tweak_mul ( ByteBuffer  byteBuff,
long  context,
int  pubLen 
)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_schnorr_sign()

static native byte[][] org.bitcoin.NativeSecp256k1.secp256k1_schnorr_sign ( ByteBuffer  byteBuff,
long  context 
)
staticprivate
Here is the caller graph for this function:

◆ secp256k1_schnorr_verify()

static native int org.bitcoin.NativeSecp256k1.secp256k1_schnorr_verify ( ByteBuffer  byteBuff,
long  context,
int  pubLen 
)
staticprivate
Here is the caller graph for this function:

◆ sign()

static byte[] org.bitcoin.NativeSecp256k1.sign ( byte[]  data,
byte[]  sec 
) throws AssertFailException
inlinestatic

libsecp256k1 Create an ECDSA signature.

Parameters
dataMessage hash, 32 bytes
keySecret key, 32 bytes

Return values

Parameters
sigbyte array of signature

Definition at line 84 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify()

static boolean org.bitcoin.NativeSecp256k1.verify ( byte[]  data,
byte[]  signature,
byte[]  pub 
)
inlinestatic

Verifies the given secp256k1 signature in native code.

Calling when enabled == false is undefined (probably library not loaded)

Parameters
dataThe data which was signed, must be exactly 32 bytes
signatureThe signature
pubThe public key which did the signing

Definition at line 53 of file NativeSecp256k1.java.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ nativeByteBuffer

ThreadLocal<ByteBuffer> org.bitcoin.NativeSecp256k1.nativeByteBuffer = new ThreadLocal<ByteBuffer>()
staticprivate

Definition at line 44 of file NativeSecp256k1.java.

◆ r

final Lock org.bitcoin.NativeSecp256k1.r = rwl.readLock()
staticprivate

Definition at line 42 of file NativeSecp256k1.java.

◆ rwl

final ReentrantReadWriteLock org.bitcoin.NativeSecp256k1.rwl = new ReentrantReadWriteLock()
staticprivate

Definition at line 41 of file NativeSecp256k1.java.

◆ w

final Lock org.bitcoin.NativeSecp256k1.w = rwl.writeLock()
staticprivate

Definition at line 43 of file NativeSecp256k1.java.


The documentation for this class was generated from the following file: