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

A SECP256K1 key pair.

class KeyPair

Parameters

class Parameters

PublicKey

A SECP256K1 public key.

class PublicKey

SecretKey

A SECP256K1 private key.

class SecretKey : Destroyable

Signature

A SECP256K1 digital signature.

class Signature

Functions

calculateKeyAgreement

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

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

deriveECDHKeyAgreement

static fun deriveECDHKeyAgreement(srcPrivKey: Bytes!, destPubKey: Bytes!): Bytes!

sign

Generates an ECDSA signature.

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

signHashed

Generates an ECDSA signature.

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

verify

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

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

verifyHashed

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

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