Crates.io | hashing-serializer |
lib.rs | hashing-serializer |
version | 0.2.0-pre.0 |
source | src |
created_at | 2024-06-12 16:50:04.132513 |
updated_at | 2024-08-01 01:55:33.011628 |
description | Serialize serde-implementing structures directly into a hash |
homepage | |
repository | https://github.com/fjarri/hashing-serializer |
max_upload_size | |
id | 1269764 |
size | 17,041 |
An implementation of [serde::Serializer
] serializing directly into a hash digest (anything implementing [digest::Update
]).
use digest::Digest;
use k256::ecdsa::SigningKey;
use rand_core::OsRng;
use serde::Serialize;
use sha2::Sha256;
use hashing_serializer::HashingSerializer;
let sk = SigningKey::random(&mut OsRng);
let vk = sk.verifying_key();
let mut digest = Sha256::new();
let serializer = HashingSerializer { digest: &mut digest };
vk.serialize(serializer).unwrap();