bn254_hash2curve

Crates.iobn254_hash2curve
lib.rsbn254_hash2curve
version0.1.2
sourcesrc
created_at2024-07-25 08:45:02.571785
updated_at2024-09-05 14:16:21.238032
descriptionhash-to-curve for the BN254 elliptic curve
homepage
repositoryhttps://github.com/hashcloak/bn254-hash-to-curve
max_upload_size
id1314803
size57,251
Manish Kumar (man2706kum)

documentation

README

BN254 Hash-to-Curve

This repository provides implementation of the hash-to-curve for the BN254 elliptic curve, compatible with the gnark-crypto as well as constantine library.

Building and Testing

  • To build with gnark-crypto compatibility: cargo build --features "gnark_crypto_compatible"

  • To build withconstantine compatibility: cargo build --features "constantine_compatible"

  • To run tests of gnark-crypto compatibile hash-to-curve: cargo test --features "gnark_crypto_compatible"

  • To run tests of constantine compatibile hash-to-curve: cargo test --features "constantine_compatible"

Usage

Add this library under dependencies in the Cargo.toml of your project:

bn254_hash2curve = { git = "https://github.com/hashcloak/bn254-hash-to-curve.git", features = ["constantine_compatible"]}

OR

bn254_hash2curve ={ git = "https://github.com/hashcloak/bn254-hash-to-curve.git", features = ["gnark_crypto_compatible"]}

and then use it as shown below:

use bn254_hash2curve::hash2g1::HashToG1;
use bn254_hash2curve::hash2g2::HashToG2;

fn main() {

    let msg = b"abc";
    let dst_g1 = b"QUUX-V01-CS02-with-BN254G1_XMD:SHA-256_SVDW_RO_";
    let dst_g2 = b"QUUX-V01-CS02-with-BN254G2_XMD:SHA-256_SVDW_RO_";

    let hash_to_g1_result = HashToG1(msg, dst_g1);
    let hash_to_g2_result = HashToG2(msg, dst_g2);

    println!("hash_to_g1_result: {:?}", hash_to_g1_result);
    println!("hash_to_g2_result: {:?}", hash_to_g2_result);
}

Overview

Hashing to a curve is a crucial operation in cryptographic protocols, enabling the secure mapping of arbitrary data to elliptic curve points. It leverages efficient cryptographic hashing techniques to map arbitrary messages onto points on the elliptic curve

Features

  • Implements the hash-to-curve method for BN254 elliptic curve.
  • Compatible with the gnark-crypto and constantine library.
  • Ensures points are mapped to the r-torsion subgroup.
  • See tests for usage examples.
Commit count: 0

cargo fmt