Crates.io | hashcom-rs |
lib.rs | hashcom-rs |
version | 0.2.0 |
source | src |
created_at | 2022-12-17 01:05:35.525588 |
updated_at | 2022-12-17 01:47:56.462621 |
description | A fast, minimal but yet extensible framework for building and using hash commitment schemes |
homepage | |
repository | https://github.com/quartz-technology/hashcom-rs |
max_upload_size | |
id | 739569 |
size | 1,480,326 |
⚡️ A fast, minimal but yet extensible framework for building and using hash commitment schemes in Rust ⚡️
Cover by DALL-E.
Commitment schemes are very powerful cryptographic primitives used in many existing solutions.
I was inspired by the go-ibft to create a framework to easily integrate and customize a hash commitment scheme in a rust application.
This package exposes both a trait for you to build your scheme given a specific hash function, or use an existing one.
The hashcom-rs
library exposes a HashCommitmentScheme
trait that can be
implemented with you own hash function.
You'll just have to implement the commit
and verify
methods.
A SHA256
implementation is already provided. Below is an example of how it can be used
(here, there's only one party who acts as both the prover and the verifier):
/// Here, one party acts as both the prover and the verifier,
/// assuming that the verifier is not malicious.
fn it_verifies_valid_commitment() {
let s: [u8; 4] = [52, 50, 52, 50]; // 4242 in string format.
let r: [u8; 4] = [50, 52, 50, 52]; // 2424 in string format.
// Commit phase.
let party = SHA256Commitment::new(&s, &r);
let commit = party.commit();
// Verification phase.
let verification = party.verify(&commit.unwrap(), &s, &r);
assert_eq!(verification.is_ok(), true);
assert_eq!(verification.unwrap(), true)
}
Made with ❤️ by 🤖 0xpanoramix 🤖