Class: FROST::DKG::Package
- Inherits:
-
Object
- Object
- FROST::DKG::Package
- Defined in:
- lib/frost/dkg/package.rb
Instance Attribute Summary collapse
-
#commitments ⇒ Object
readonly
Returns the value of attribute commitments.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#proof ⇒ Object
readonly
Returns the value of attribute proof.
Instance Method Summary collapse
-
#initialize(identifier, commitments, proof) ⇒ Package
constructor
Constructor.
-
#verification_key ⇒ ECDSA::Point
Get verification key for this proof.
-
#verify_share(share) ⇒ Boolean
Verify share.
Constructor Details
#initialize(identifier, commitments, proof) ⇒ Package
Constructor
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
#commitments ⇒ Object (readonly)
Returns the value of attribute commitments.
5 6 7 |
# File 'lib/frost/dkg/package.rb', line 5 def commitments @commitments end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
4 5 6 |
# File 'lib/frost/dkg/package.rb', line 4 def identifier @identifier end |
#proof ⇒ Object (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_key ⇒ ECDSA::Point
Get verification key for this proof.
24 25 26 |
# File 'lib/frost/dkg/package.rb', line 24 def verification_key commitments.first end |
#verify_share(share) ⇒ Boolean
Verify share.
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 |