Class: H2C::Suite

Inherits:
Object
  • Object
show all
Defined in:
lib/h2c/suite.rb

Overview

Hash to curve suites

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, dst) ⇒ Suite

Initialize suite

Parameters:

  • id (String)

    Suite id.

  • dst (String)

    Domain separation tag.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/h2c/suite.rb', line 13

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

Instance Attribute Details

#curveObject (readonly)

Returns the value of attribute curve.



5
6
7
# File 'lib/h2c/suite.rb', line 5

def curve
  @curve
end

#expObject (readonly)

Returns the value of attribute exp.



5
6
7
# File 'lib/h2c/suite.rb', line 5

def exp
  @exp
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/h2c/suite.rb', line 5

def id
  @id
end

#kObject (readonly)

Returns the value of attribute k.



5
6
7
# File 'lib/h2c/suite.rb', line 5

def k
  @k
end

#lObject (readonly)

Returns the value of attribute l.



5
6
7
# File 'lib/h2c/suite.rb', line 5

def l
  @l
end

#mObject (readonly)

Returns the value of attribute m.



5
6
7
# File 'lib/h2c/suite.rb', line 5

def m
  @m
end

#mapObject (readonly)

Returns the value of attribute map.



5
6
7
# File 'lib/h2c/suite.rb', line 5

def map
  @map
end

#roObject (readonly)

Returns the value of attribute ro.



5
6
7
# File 'lib/h2c/suite.rb', line 5

def ro
  @ro
end