crypto / org.apache.tuweni.crypto.sodium / Signature

Signature

class Signature (source)

Public-key signatures.

In this system, a signer generates a key pair:

Verifiers need to already know and ultimately trust a public key before messages signed using it can be verified.

Warning: this is different from authenticated encryption. Appending a signature does not change the representation of the message itself.

This class depends upon the JNR-FFI library being available on the classpath, along with its dependencies. See https://github.com/jnr/jnr-ffi. JNR-FFI can be included using the gradle dependency 'com.github.jnr:jnr-ffi'.

Types

KeyPair

class KeyPair

A Signature key pair.

PublicKey

class PublicKey

A signing public key.

SecretKey

class SecretKey : Destroyable

A Signature secret key.

Seed

class Seed

A Signature key pair seed.

Functions

sign

static fun sign(message: Bytes, secretKey: SecretKey): Bytes
static fun sign(message: ByteArray, secretKey: SecretKey): ByteArray

Signs a message for a given key.

signDetached

static fun signDetached(message: Bytes, secretKey: SecretKey): Bytes
static fun signDetached(message: Allocated, secretKey: SecretKey): Allocated
static fun signDetached(message: ByteArray, secretKey: SecretKey): ByteArray

Signs a message for a given key.

verify

static fun verify(signed: Bytes, publicKey: PublicKey): Bytes
static fun verify(signed: ByteArray, publicKey: PublicKey): ByteArray

Verifies the signature of the signed message using the public key and returns the message.

verifyDetached

static fun verifyDetached(message: Bytes, signature: Bytes, publicKey: PublicKey): Boolean
static fun verifyDetached(message: Allocated, signature: Allocated, publicKey: PublicKey): Boolean
static fun verifyDetached(message: ByteArray, signature: ByteArray, publicKey: PublicKey): Boolean

Decrypt a message using a given key.