Expand description
§Unambiguously digest structured data
udigest
provides utilities for unambiguous hashing the structured data. Structured
data can be anything that implements Digestable
trait:
str
,String
,CStr
,CString
- Integers:
i8
,i16
,i32
,i64
,i128
,u8
,u16
,u32
,u64
,u128
,char
,isize
,usize
- Containers:
Box
,Arc
,Rc
,Cow
,Option
,Result
- Collections: arrays, slices,
Vec
,LinkedList
,VecDeque
,BTreeSet
,BTreeMap
The trait is intentionally not implemented for certain types:
HashMap
,HashSet
as they can not be traversed in deterministic order
The Digestable
trait can be implemented for the struct using a macro:
#[derive(udigest::Digestable)]
struct Person {
name: String,
job_title: String,
}
let alice = Person {
name: "Alice".into(),
job_title: "cryptographer".into(),
};
let hash = udigest::hash::<sha2::Sha256>(&alice);
The crate intentionally does not try to follow any existing standards for unambiguous
encoding. The format for encoding was designed specifically for udigest
to provide
a better usage experience in Rust. The details of encoding format can be found in
encoding
module.
§Features
digest
enables support of hash functions that implementdigest
traits
If feature is not enabled, the crate is still usable viaDigestable
trait that generically implements unambiguous encodinginline-struct
is required to useinline_struct!
macrostd
implementsDigestable
trait for types in standard libraryalloc
implementsDigestable
trait for type inalloc
cratederive
enablesDigestable
proc macro
§Join us in Discord!
Feel free to reach out to us in Discord!
Re-exports§
Modules§
- Provides utilities for custom digesting rules
- Unambiguous encoding
- inline_
struct inline-struct
Digestable inline structs
Macros§
- inline_
struct inline-struct
Creates digestable inline struct
Structs§
- Wrapper for a bytestring
Traits§
- A value that can be unambiguously digested
Functions§
- hash
digest
Digests a structuredvalue
using fixed-output hash function (like sha2-256) - hash_
iter digest
Digests a list of structured data using fixed-output hash function (like sha2-256) - hash_
vof digest
Digests a structuredvalue
using variable-output hash function (like blake2b) - hash_
vof_ iter digest
Digests a list of structured data using variable-output hash function (like blake2b) - hash_
xof digest
Digests a structuredvalue
using extendable-output hash function (like shake-256) - hash_
xof_ iter digest
Digests a list of structured data using extendable-output hash function (like shake-256)
Derive Macros§
- Digestable
derive
Derives aDigestable
trait