Class: FROST::DKG::Package

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier, commitments, proof) ⇒ Package

Constructor

Parameters:

  • identifier (Integer)
  • commitments (Array)

    The list of commitment.

  • proof (FROST::Signature)

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
# File 'lib/frost/dkg/package.rb', line 12

def initialize(identifier, commitments, proof)
  raise ArgumentError, "identifier must be Integer." unless identifier.is_a?(Integer)
  raise ArgumentError, "identifier must be greater than 0." if identifier < 1
  raise ArgumentError, "proof must be FROST::Signature." unless proof.is_a?(FROST::Signature)

  @identifier = identifier
  @commitments = commitments
  @proof = proof
end

Instance Attribute Details

#commitmentsObject (readonly)

Returns the value of attribute commitments.



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

def commitments
  @commitments
end

#identifierObject (readonly)

Returns the value of attribute identifier.



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

def identifier
  @identifier
end

#proofObject (readonly)

Returns the value of attribute proof.



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

def proof
  @proof
end

Instance Method Details

#verification_keyECDSA::Point

Get verification key for this proof.

Returns:

  • (ECDSA::Point)


24
25
26
# File 'lib/frost/dkg/package.rb', line 24

def verification_key
  commitments.first
end

#verify_share(share) ⇒ Boolean

Verify share.

Parameters:

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
39
# File 'lib/frost/dkg/package.rb', line 31

def verify_share(share)
  x = share.identifier
  result = commitments[1..-1].inject(commitments.first) do |sum, com|
    tmp = com * x
    x *= x
    sum + tmp
  end
  result == share.to_point
end