Class: FROST::Nonce

Inherits:
Object
  • Object
show all
Defined in:
lib/frost/nonce.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nonce, group) ⇒ FROST::Nonce

Generate nonce.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
# File 'lib/frost/nonce.rb', line 9

def initialize(nonce, group)
  raise ArgumentError, "group must by ECDSA::Group." unless group.is_a?(ECDSA::Group)
  raise ArgumentError, "nonce must by Integer." unless nonce.is_a?(Integer)
  @value = nonce
  @group = group
end

Instance Attribute Details

#groupObject (readonly)

Group of elliptic curve



5
6
7
# File 'lib/frost/nonce.rb', line 5

def group
  @group
end

#valueObject (readonly)

nonce value



4
5
6
# File 'lib/frost/nonce.rb', line 4

def value
  @value
end

Class Method Details

.gen_from_secret(secret) ⇒ Object

Generate nonce from secret share.

Parameters:



18
19
20
# File 'lib/frost/nonce.rb', line 18

def self.gen_from_secret(secret)
  gen_from_random_bytes(secret)
end

Instance Method Details

#to_hexString

Convert nonce as hex string.

Returns:

  • (String)


43
44
45
# File 'lib/frost/nonce.rb', line 43

def to_hex
  ECDSA::Format::IntegerOctetString.encode(value, 32).unpack1('H*')
end

#to_pointECDSA::Point

Compute public key.

Returns:

  • (ECDSA::Point)


49
50
51
# File 'lib/frost/nonce.rb', line 49

def to_point
  group.generator * value
end