Class: FROST::Commitments

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

Overview

Participant commitment

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier, hiding, binding) ⇒ Commitments

Constructor

Parameters:

  • identifier (Integer)

    Identifier of participant.

  • hiding (ECDSA::Point)

    Commitment point.

  • binding (ECDSA::Point)

    Commitment point.

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
# File 'lib/frost/commitments.rb', line 13

def initialize(identifier, hiding, binding)
  raise ArgumentError, "id must be Integer." unless identifier.is_a?(Integer)
  raise ArgumentError, "id must be greater than 0." if identifier < 1
  raise ArgumentError, "hiding must be ECDSA::Point." unless hiding.is_a?(ECDSA::Point)
  raise ArgumentError, "binding must be ECDSA::Point." unless binding.is_a?(ECDSA::Point)

  @identifier = identifier
  @hiding = hiding
  @binding = binding
end

Instance Attribute Details

#bindingObject (readonly)

Returns the value of attribute binding.



7
8
9
# File 'lib/frost/commitments.rb', line 7

def binding
  @binding
end

#hidingObject (readonly)

Returns the value of attribute hiding.



6
7
8
# File 'lib/frost/commitments.rb', line 6

def hiding
  @hiding
end

#identifierObject (readonly)

Returns the value of attribute identifier.



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

def identifier
  @identifier
end

Class Method Details

.encode_group_commitment(commitment_list) ⇒ String

Encodes a list of participant commitments into a byte string

Parameters:

  • commitment_list (Array)

    The list of FROST::Commitments

Returns:

  • (String)

    The encoded byte string.



32
33
34
# File 'lib/frost/commitments.rb', line 32

def self.encode_group_commitment(commitment_list)
  commitment_list.map(&:encode).join
end

Instance Method Details

#encodeObject



24
25
26
27
# File 'lib/frost/commitments.rb', line 24

def encode
  id = FROST.encode_identifier(identifier, hiding.group)
  id + [hiding.to_hex + binding.to_hex].pack("H*")
end