Expand description
§Introduction
bc-crypto
is a exposes a uniform API for the cryptographic primitives used in higher-level Blockchain Commons projects such as Gordian Envelope. The various providers listed below may change, but the API this package provides should be stable.
Category | Algorithm | Provider |
---|---|---|
Cryptographic digest | SHA-256 | sha2 |
Cryptographic digest | SHA-512 | sha2 |
Hashed Message Authentication Codes | HMAC-SHA-256 | hmac |
Hashed Message Authentication Codes | HMAC-SHA-512 | hmac |
Password Expansion | PBKDF2-HMAC-SHA-256 | pbkdf2 |
Key Derivation | HKDF-HMAC-SHA-256 | hkdf |
Symmetric Encryption | IETF-ChaCha20-Poly1305 | chacha20poly1305 |
Key Agreement | X25519 | x25519-dalek |
Signing/Verification | ECDSA | secp256k1 |
Signing/Verification | Schnorr | secp256k1 |
Secure Random Number Generation | NA | getrandom, rand |
Pseudorandom Number Generation | Xoshiro256** | rand_xoshiro |
§Getting Started
[dependencies]
bc-crypto = "0.4.0"
Modules§
- The
hash
module contains functions for hashing data.
Enums§
Constants§
Functions§
- Symmetrically decrypts the given ciphertext using ChaCha20-Poly1305.
- Symmetrically decrypts the given ciphertext using ChaCha20-Poly1305 and the given additional authenticated data (AAD).
- Symmetrically encrypts the given plaintext using ChaCha20-Poly1305.
- Symmetrically encrypts the given plaintext using ChaCha20-Poly1305 and the given additional authenticated data (AAD).
- Compresses the given ECDSA public key.
- Decompresses the given ECDSA public key.
- Derives the ECDSA private key from the given key material.
- Generate a new ECDSA private key using the given random number generator.
- Derives the ECDSA public key from the given private key.
- ECDSA signs the given message using the given private key.
- Verifies the given ECDSA signature using the given public key.
- Zero out a slice of bytes
- Zero out a vector of vector of bytes
- Derives the Schnorr public key from the given private key.
- Schnorr signs the given message using the given private key and user-defined tag.
- Schnorr signs the given message using the given private key, user-defined tag, and random number generator.
- Verifies the given Schnorr signature against the given message, public key, and user-defined tag, which must match the tag used to create the signature.
- Derive a X25519 public key from a private key.
- Derive an X25519 agreement private key from the given key material.
- Derive an X25519 signing private key from the given key material.
- Create a new X25519 private key using the given random number generator.
- Compute the shared symmetric key from the given agreement private key and agreement public key.