Module pchain_types::cryptography
source · Expand description
Cryptographic primitives like keypairs and SHA256 hashes.
Generating a Keypair
// OsRng and ChaCha are good defaults for pseudorandom number generation.
use rand::rngs::OsRng;
use rand_chacha::{ChaCha20Rng, rand_core::SeedableRng};
let mut osrng = OsRng{};
let mut chacha20_rng = ChaCha20Rng::from_rng(&mut osrng).unwrap();
let keypair = Keypair::generate(&mut chacha20_rng);
Traits
- Implemented by Keypair and SecretKey to Signer::sign arbitrary bytesequences. Sign the provided message bytestring using
Self
(e.g. a cryptographic key or connection to an HSM), returning a digital signature. - Implemented by Keypair and PublicKey to cryptographically Verifier::verify arbitrary bytesequences. Verify the provided message bytestring using
Self
(e.g. a public key)
Functions
- Compute the SHA256 hash over some data.
Type Definitions
- A 256-bit Bloom Filter.
- An Ed25519 keypair.
- Either:
- An Ed25519 public key.
- An Ed25519 secret key.
- A SHA256 hash over some message.
- An Ed25519 signature.
- 64 bytes that should be an Ed25519 signature.