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

#25 in #const-fn

Download history 10/week @ 2024-01-11 24/week @ 2024-01-18 4/week @ 2024-01-25 7/week @ 2024-02-01 10/week @ 2024-02-08 32/week @ 2024-02-15 47/week @ 2024-02-22 32/week @ 2024-02-29 26/week @ 2024-03-07 22/week @ 2024-03-14 2/week @ 2024-03-21 21/week @ 2024-03-28 20/week @ 2024-04-04 8/week @ 2024-04-11 11/week @ 2024-04-18 5/week @ 2024-04-25

51 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