Module rust_crypto

Module rust_crypto 

Source
Expand description

Rust Crypto wrappers for the RISC0 Sha256 trait.

§Usage

use risc0_zkp::core::hash::{
    sha::{cpu, rust_crypto::{Sha256, Digest as _}},
};

// create a Sha256 object
let mut hasher = Sha256::<cpu::Impl>::new();

// write input message
hasher.update(b"hello world");

// read hash digest and consume hasher
let result = hasher.finalize();

assert_eq!(hex::encode(result), "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9");

// more concise version of the code above.
assert_eq!(hex::encode(Sha256::<cpu::Impl>::digest(b"hello world")),
    "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
);

Structs§

Sha256VarCore
Core block-level SHA-256 hasher with variable output size.

Traits§

Digest
Convenience wrapper trait covering functionality of cryptographic hash functions with fixed output size.

Type Aliases§

Output
Output array of OutputSizeUser implementors.
Sha256
SHA-256 implementation cross-compatible with sha2::Sha256.