Sha256: 94989c7dd860e7b02a3dac6eda43cf72d17ef7096c173892dd4c77f5719aa001

Contents?: true

Size: 1015 Bytes

Versions: 1

Compression:

Stored size: 1015 Bytes

Contents

# frozen_string_literal: true

require_relative "h2c/version"
require "ecdsa"
require_relative "ext/curve"

# Hash to Curves library.
# https://www.ietf.org/archive/id/draft-irtf-cfrg-hash-to-curve-16.html
module H2C
  class Error < StandardError
  end

  autoload :Expander, "h2c/expander"
  autoload :Suite, "h2c/suite"
  autoload :HashToPoint, "h2c/hash_to_point"
  autoload :M2C, "h2c/m2c"

  # Hash function name
  module HashFunc
    SHA256 = "SHA256"
    SHA512 = "SHA512"
    SHAKE128 = "SHAKE128"
    SHAKE256 = "SHAKE256"

    XMD_FUNCS = [SHA256, SHA512].freeze
    XOF_FUNCS = [SHAKE128, SHAKE256].freeze
  end

  module_function

  # Get hash to curve corresponding to +suite+.
  #
  # @param [String] suite Suite name for hashing.
  # Currently supported are "secp256k1_XMD:SHA-256_SSWU_NU_" and "secp256k1_XMD:SHA-256_SSWU_RO_".
  # @param [String] dst Domain separation tag.
  # @return [H2C::HashToPoint]
  def get(suite, dst)
    suite = Suite.new(suite, dst)
    HashToPoint.new(suite)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
h2c-0.1.0 lib/h2c.rb