Sha256: e5ca9619c440702e8793e850286ed7baaadb6628390794395d70c1545eeefce5

Contents?: true

Size: 870 Bytes

Versions: 1

Compression:

Stored size: 870 Bytes

Contents

# frozen_string_literal: true
module H2C
  # Hash to curve suites
  class Suite
    attr_reader :id, :curve, :k, :exp, :m, :l, :ro, :map

    SECP256K1_XMDSHA256_SSWU_NU_ = "secp256k1_XMD:SHA-256_SSWU_NU_"
    SECP256K1_XMDSHA256_SSWU_RO_ = "secp256k1_XMD:SHA-256_SSWU_RO_"

    # Initialize suite
    # @param [String] id Suite id.
    # @param [String] dst Domain separation tag.
    def initialize(id, dst)
      @id = id
      case id
      when SECP256K1_XMDSHA256_SSWU_NU_, SECP256K1_XMDSHA256_SSWU_RO_
        @curve = ECDSA::Group::Secp256k1
        @k = 128
        @exp = Expander.get(HashFunc::SHA256, dst, @k)
        @m = 1
        @l = 48
        @map = M2C::SSWUAB0.new(H2C::M2C::ISOGeny::Secp256k1.new, -11)
        @ro = (id == SECP256K1_XMDSHA256_SSWU_RO_)
      else
        raise H2C::Error, "suite #{curve} unsupported."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
h2c-0.1.0 lib/h2c/suite.rb