8 unstable releases (3 breaking)

0.4.0 Oct 29, 2023
0.3.2 Oct 27, 2023
0.2.1 Nov 20, 2022
0.2.0 Sep 13, 2022
0.1.1 Sep 11, 2022

#18 in #const-fn

Download history 15/week @ 2024-07-15 209/week @ 2024-07-29 10/week @ 2024-08-05 5/week @ 2024-08-12 9/week @ 2024-08-26 13/week @ 2024-09-02 17/week @ 2024-09-09 6/week @ 2024-09-16 62/week @ 2024-09-23 22/week @ 2024-09-30 9/week @ 2024-10-07 34/week @ 2024-10-14

127 downloads per month
Used in 3 crates (via ethprim)

MIT/Apache

35KB
709 lines

Implementation of Ethereum 32-byte digests for Rust.

This crate provides a Digest type for representing Ethereum 32-byte digests.

Additionally it includes macros for digest constants, both from hexidecimal strings, but also by compile-time Keccak-256 hashing inputs. Under the hood, they are implemented with const fn and do not use procedural macros.

Usage

Just add a dependency to your Cargo.toml:

[dependencies]
ethdigest = "*"

For complete documentation checkout docs.rs.


lib.rs:

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.

Dependencies

~0–440KB