Project

h2c

0.0
The project is in a healthy, maintained state
Ruby implementation of hash to curve.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.2.0
 Project Readme

Hashing to Elliptic Curves for Ruby

This is a Ruby implementation of the Hash to Curves proposed by the IETF.

It has been tested using the Test Vector provided, but the code has not been audited to ensure functional specification and safety. Also It is under development and is subject to change without backward compatibility.

The following cipher suites are currently supported:

  • secp256k1_XMD:SHA-256_SSWU_NU_
  • secp256k1_XMD:SHA-256_SSWU_RO_
  • BLS12381G1_XMD:SHA-256_SSWU_NU_
  • BLS12381G1_XMD:SHA-256_SSWU_RO_
  • P256_XMD:SHA-256_SSWU_NU_
  • P256_XMD:SHA-256_SSWU_RO_
  • P384_XMD:SHA-384_SSWU_NU_
  • P384_XMD:SHA-384_SSWU_RO_
  • P521_XMD:SHA-512_SSWU_NU_
  • P521_XMD:SHA-512_SSWU_RO_

Installation

Add this line to your application's Gemfile:

gem 'h2c'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install h2c

Usage

require 'h2c'

dst = "QUUX-V01-CS02-with-secp256k1_XMD:SHA-256_SSWU_RO_"

h2c = H2C.get(H2C::Suite::SECP256K1_XMDSHA256_SSWU_RO_, dst)

msg = "abc"

result = h2c.digest(msg)
puts result.inspect
#<ECDSA::Point: secp256k1, 0x3377e01eab42db296b512293120c6cee72b6ecf9f9205760bd9ff11fb3cb2c4b, 0x7f95890f33efebd1044d382a01b1bee0900fb6116f94688d487c6c7b9c8371f6>