Crate ethdigest

source ·
Expand description

Implementation of Ethereum digest and hashing for Rust.

This crate provides a Digest type for representing an Ethereum 32-byte digest as well as various Keccak-256 hashing utilities for computing them.

Macros

There are a couple of exported macros for creating compile-time digest constants:

  • digest!: hexadecimal constant
  • keccak!: compute constant from a pre-image

Under the hood, they are implemented with const fn and do not use procedural macros.

Features

  • default std: Additional integration with Rust standard library types. Notably, this includes std::error::Error implementation on the ParseDigestError and conversions from Vec<u8>.
  • serde: Serialization traits for the serde crate. Note that the implementation is very much geared towards JSON serialization with serde_json.
  • sha3: Use the Rust Crypto Keccak-256 implementation (provided by the sha3 crate) instead of the built-in one. Note that the keccak! macro will always use the built-in Keccak-256 implementation for computing digests, as sha3 does not expose a const fn API.

Modules

  • A const fn Keccak-256 implementation.

Macros

  • Macro to create Ethereum digest values from string literals that get parsed at compile time. A compiler error will be generated if an invalid digest is specified.
  • Macro to create Ethereum digest values for compile-time hashed input.

Structs

Enums