hashcom-rs

Crates.iohashcom-rs
lib.rshashcom-rs
version0.2.0
sourcesrc
created_at2022-12-17 01:05:35.525588
updated_at2022-12-17 01:47:56.462621
descriptionA fast, minimal but yet extensible framework for building and using hash commitment schemes
homepage
repositoryhttps://github.com/quartz-technology/hashcom-rs
max_upload_size
id739569
size1,480,326
Luca G.F. (0xpanoramix)

documentation

README

hashcom-rs

A DALL-E representation of a 
photo of a computer circuit in cyberpunk style with a dark theme

⚡️ A fast, minimal but yet extensible framework for building and using hash commitment schemes in Rust ⚡️

Cover by DALL-E.

Introduction

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.

Architecture

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)
}

Authors

Made with ❤️ by 🤖 0xpanoramix 🤖

Commit count: 4

cargo fmt