Skip to content

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

License

Notifications You must be signed in to change notification settings

quartz-technology/hashcom-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 🤖

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published