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

#22 in #const-fn

Download history 1/week @ 2024-07-21 208/week @ 2024-07-28 10/week @ 2024-08-04 5/week @ 2024-08-11 1/week @ 2024-08-18 6/week @ 2024-08-25 13/week @ 2024-09-01 18/week @ 2024-09-08 8/week @ 2024-09-15 59/week @ 2024-09-22 23/week @ 2024-09-29 11/week @ 2024-10-06 31/week @ 2024-10-13 23/week @ 2024-10-20 16/week @ 2024-10-27 30/week @ 2024-11-03

101 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–435KB