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(context, nonce) ⇒ FROST::Nonce

Generate nonce.

Parameters:

Raises:

  • (ArgumentError)


11
12
13
14
15
16
# File 'lib/frost/nonce.rb', line 11

def initialize(context, nonce)
  raise ArgumentError, "context must be FROST::Context." unless context.is_a?(FROST::Context)
  raise ArgumentError, "nonce must be Integer." unless nonce.is_a?(Integer)
  @value = nonce
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Group of elliptic curve



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

def context
  @context
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:



26
27
28
# File 'lib/frost/nonce.rb', line 26

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

Instance Method Details

#groupECDSA::Group

Get group

Returns:

  • (ECDSA::Group)


20
21
22
# File 'lib/frost/nonce.rb', line 20

def group
  context.group
end

#to_hexString

Convert nonce as hex string.

Returns:

  • (String)


51
52
53
# File 'lib/frost/nonce.rb', line 51

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

#to_negateFROST::Nonce

Generate negated nonce.

Returns:



63
64
65
# File 'lib/frost/nonce.rb', line 63

def to_negate
  Nonce.new(context, group.order - value)
end

#to_pointECDSA::Point

Compute public key.

Returns:

  • (ECDSA::Point)


57
58
59
# File 'lib/frost/nonce.rb', line 57

def to_point
  group.generator * value
end