tuweni / org.apache.tuweni.crypto / SECP256K1

SECP256K1

class SECP256K1 (source)

An Elliptic Curve Digital Signature using parameters as used by Bitcoin, and defined in Standards for Efficient Cryptography (SEC) (Certicom Research, http://www.secg.org/sec2-v2.pdf).

This class depends upon the BouncyCastle library being available and added as a java.security.Provider. See https://www.bouncycastle.org/wiki/display/JA1/Provider+Installation.

BouncyCastle can be included using the gradle dependency 'org.bouncycastle:bcprov-jdk15on'.

Types

KeyPair

class KeyPair

A SECP256K1 key pair.

Parameters

class Parameters

PublicKey

class PublicKey

A SECP256K1 public key.

SecretKey

class SecretKey : Destroyable

A SECP256K1 private key.

Signature

class Signature

A SECP256K1 digital signature.

Functions

calculateKeyAgreement

static fun calculateKeyAgreement(privKey: SecretKey, theirPubKey: PublicKey): Bytes32

Calculates an ECDH key agreement between the private and the public key of another party, formatted as a 32 bytes array.

sign

static fun sign(data: ByteArray, keyPair: KeyPair): Signature
static fun sign(data: Bytes, keyPair: KeyPair): Signature

Generates an ECDSA signature.

signHashed

static fun signHashed(hash: ByteArray, keyPair: KeyPair): Signature
static fun signHashed(hash: Bytes32, keyPair: KeyPair): Signature

Generates an ECDSA signature.

verify

static fun verify(data: ByteArray, signature: Signature, publicKey: PublicKey): Boolean
static fun verify(data: Bytes, signature: Signature, publicKey: PublicKey): Boolean

Verifies the given ECDSA signature against the message bytes using the public key bytes.

verifyHashed

static fun verifyHashed(hash: Bytes32, signature: Signature, publicKey: PublicKey): Boolean
static fun verifyHashed(hash: ByteArray, signature: Signature, publicKey: PublicKey): Boolean

Verifies the given ECDSA signature against the message bytes using the public key bytes.