[]Module cjdns_crypto::sign

Public-key signatures

Security model

The sign() function is designed to meet the standard notion of unforgeability for a public-key signature scheme under chosen-message attacks.

Selected primitive

crypto::sign::sign is ed25519, a signature scheme specified in Ed25519. This function is conjectured to meet the standard notion of unforgeability for a public-key signature scheme under chosen-message attacks.

Alternate primitives


crypto_signPUBLICKEYBYTESSECRETKEYBYTESBYTES
crypto_sign_ed25519326464
crypto_sign_edwards25519sha512batch326464

crypto_sign_edwards25519sha512batch is a prototype. It has been replaced with Ed25519 and is only kept here for compatibility reasons.

Example

use sodiumoxide::crypto::sign;
let (pk, sk) = sign::gen_keypair();
let data_to_sign = b"some data";
let signed_data = sign::sign(data_to_sign, &sk);
let verified_data = sign::verify(&signed_data, &pk).unwrap();
assert!(data_to_sign == &verified_data[..]);

Example (detached signatures)

use sodiumoxide::crypto::sign;
let (pk, sk) = sign::gen_keypair();
let data_to_sign = b"some data";
let signature = sign::sign_detached(data_to_sign, &sk);
assert!(sign::verify_detached(&signature, data_to_sign, &pk));

Modules

ed25519

ed25519, a signature scheme specified in Ed25519. This function is conjectured to meet the standard notion of unforgeability for a public-key signature scheme under chosen-message attacks.

Structs

Error

Signature errors.

PublicKey

PublicKey for signatures

SecretKey

SecretKey for signatures

Seed

Seed that can be used for keypair generation

Signature

Ed25519 signature.

State

State for multi-part (streaming) computation of signature.

Constants

PUBLICKEYBYTES

Number of bytes in a PublicKey.

SECRETKEYBYTES

Number of bytes in a SecretKey.

SEEDBYTES

Number of bytes in a Seed.

SIGNATUREBYTES

Number of bytes in a Signature.

Traits

Signer

Sign the provided message bytestring using Self (e.g. a cryptographic key or connection to an HSM), returning a digital signature.

Verifier

Verify the provided message bytestring using Self (e.g. a public key)

Functions

gen_keypair

gen_keypair() randomly generates a secret key and a corresponding public key.

keypair_from_seed

keypair_from_seed() computes a secret key and a corresponding public key from a Seed.

sign

sign() signs a message m using the signer's secret key sk. sign() returns the resulting signed message sm.

sign_detached

sign_detached() signs a message m using the signer's secret key sk. sign_detached() returns the resulting signature sig.

verify

verify() verifies the signature in sm using the signer's public key pk. verify() returns the message Ok(m). If the signature fails verification, verify() returns Err(()).

verify_detached

verify_detached() verifies the signature in sig against the message m and the signer's public key pk. verify_detached() returns true if the signature is valid, false otherwise.