[][src]Module solana_libra_crypto::signing

An implementation of the associated functions for handling cryptographic signatures for the Libra project.

This is an API for Pure Ed25519 EdDSA signatures.

Warning: This API will soon be updated in the [nextgen] module.

Example

Note that the signing and verifying functions take an input message of type HashValue.

use crypto::{hash::*, signing::*};

let mut hasher = TestOnlyHasher::default();
hasher.write("Test message".as_bytes());
let hashed_message = hasher.finish();

let (private_key, public_key) = generate_keypair();
let signature = sign_message(hashed_message, &private_key).unwrap();
assert!(verify_signature(hashed_message, &signature, &public_key).is_ok());

Structs

KeyPair

A public and private key pair.

PrivateKey

An ed25519 private key.

PublicKey

An ed25519 public key.

Signature

An ed25519 signature.

Functions

batch_verify_signatures

Batch signature verification as described in the original EdDSA article by Bernstein et al. "High-speed high-security signatures". Current implementation works for signatures on the same message and it checks for malleability.

derive_keypair_from_seed

Derives a keypair (PrivateKey, PublicKey) from a) salt (optional) - denoted as 'salt' in RFC 5869 b) seed - denoted as 'IKM' in RFC 5869 c) application info (optional) - denoted as 'info' in RFC 5869

generate_and_encode_keypair

Generates a random keypair (PrivateKey, PublicKey) and returns a tuple of string representations:

generate_genesis_keypair

Generates a well-known keypair (PrivateKey, PublicKey) for special use in the genesis block.

generate_keypair

Generates a random keypair (PrivateKey, PublicKey).

generate_keypair_for_testing

Generates consistent keypair (PrivateKey, PublicKey) for unit tests.

generate_keypair_from_rng

Generates a keypair (PrivateKey, PublicKey) based on an RNG.

generate_keypair_hybrid

Generates a random keypair (PrivateKey, PublicKey) by combining the output of EntropyRng with a user-provided seed. This concatenated seed is used as the seed to HKDF (RFC 5869).

sign_message

Constructs a signature for message using private_key.

verify_signature

Checks that signature is valid for message using public_key.