Crate bc_crypto

Crate bc_crypto 

Source
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.

CategoryAlgorithmProvider
Cryptographic digestSHA-256sha2
Cryptographic digestSHA-512sha2
Hashed Message Authentication CodesHMAC-SHA-256hmac
Hashed Message Authentication CodesHMAC-SHA-512hmac
Password ExpansionPBKDF2-HMAC-SHA-256pbkdf2
Key DerivationHKDF-HMAC-SHA-256hkdf
Symmetric EncryptionIETF-ChaCha20-Poly1305chacha20poly1305
Key AgreementX25519x25519-dalek
Signing/VerificationECDSAsecp256k1
Signing/VerificationSchnorrsecp256k1
Secure Random Number GenerationNAgetrandom, rand
Pseudorandom Number GenerationXoshiro256**rand_xoshiro

§Getting Started

[dependencies]
bc-crypto = "0.14.0"

Re-exports§

pub use error::Error;
pub use error::Result;
pub use hash::CRC32_SIZE;
pub use hash::SHA256_SIZE;
pub use hash::SHA512_SIZE;
pub use hash::double_sha256;
pub use hash::hkdf_hmac_sha256;
pub use hash::hmac_sha256;
pub use hash::hmac_sha512;
pub use hash::pbkdf2_hmac_sha256;
pub use hash::sha256;
pub use hash::sha512;

Modules§

error
hash
The hash module contains functions for hashing data.

Constants§

ECDSA_MESSAGE_HASH_SIZE
ECDSA_PRIVATE_KEY_SIZE
ECDSA_PUBLIC_KEY_SIZE
ECDSA_SIGNATURE_SIZE
ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE
ED25519_PRIVATE_KEY_SIZE
ED25519_PUBLIC_KEY_SIZE
ED25519_SIGNATURE_SIZE
SCHNORR_PUBLIC_KEY_SIZE
SCHNORR_SIGNATURE_SIZE
SYMMETRIC_AUTH_SIZE
SYMMETRIC_KEY_SIZE
SYMMETRIC_NONCE_SIZE
X25519_PRIVATE_KEY_SIZE
X25519_PUBLIC_KEY_SIZE

Functions§

aead_chacha20_poly1305_decrypt
Symmetrically decrypts the given ciphertext using ChaCha20-Poly1305.
aead_chacha20_poly1305_decrypt_with_aad
Symmetrically decrypts the given ciphertext using ChaCha20-Poly1305 and the given additional authenticated data (AAD).
aead_chacha20_poly1305_encrypt
Symmetrically encrypts the given plaintext using ChaCha20-Poly1305.
aead_chacha20_poly1305_encrypt_with_aad
Symmetrically encrypts the given plaintext using ChaCha20-Poly1305 and the given additional authenticated data (AAD).
argon2id
derive_agreement_private_key
Derive a 32-byte agreement private key from the given key material.
derive_signing_private_key
Derive a 32-byte signing private key from the given key material.
ecdsa_compress_public_key
Compresses the given ECDSA public key.
ecdsa_decompress_public_key
Decompresses the given ECDSA public key.
ecdsa_derive_private_key
Derives the ECDSA private key from the given key material.
ecdsa_new_private_key_using
Generate a new ECDSA private key using the given random number generator.
ecdsa_public_key_from_private_key
Derives the ECDSA public key from the given private key.
ecdsa_sign
ECDSA signs the given message using the given private key.
ecdsa_verify
Verifies the given ECDSA signature using the given public key.
ed25519_new_private_key_using
ed25519_public_key_from_private_key
ed25519_sign
ed25519_verify
memzero
Zero out a slice of bytes
memzero_vec_vec_u8
Zero out a vector of vector of bytes
schnorr_public_key_from_private_key
Derives the Schnorr public key from the given private key.
schnorr_sign
schnorr_sign_using
schnorr_sign_with_aux_rand
schnorr_verify
scrypt
Computes the scrypt key derivation function using recommended parameters.
scrypt_opt
x25519_new_private_key_using
Create a new X25519 private key using the given random number generator.
x25519_public_key_from_private_key
Derive a X25519 public key from a private key.
x25519_shared_key
Compute the shared symmetric key from the given X25519 private and public keys.