Class: FROST::Dealer
- Inherits:
-
Object
- Object
- FROST::Dealer
- Defined in:
- lib/frost/dealer.rb
Overview
Dealer
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#max_signers ⇒ Object
readonly
Returns the value of attribute max_signers.
-
#min_signers ⇒ Object
readonly
Returns the value of attribute min_signers.
-
#polynomial ⇒ Object
readonly
Returns the value of attribute polynomial.
Instance Method Summary collapse
-
#gen_shares(identifiers = nil) ⇒ Array
Generate shares.
-
#group_public_key ⇒ ECDSA::Point
Get a group public key.
-
#initialize(ctx, max_signers, min_signers) ⇒ FROST::Dealer
constructor
Create a new dealer.
Constructor Details
#initialize(ctx, max_signers, min_signers) ⇒ FROST::Dealer
Create a new dealer.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/frost/dealer.rb', line 14 def initialize(ctx, max_signers, min_signers) raise ArgumentError, "context must be FROST::Context." unless ctx.is_a?(FROST::Context) raise ArgumentError, "min_signers must be Integer." unless min_signers.is_a?(Integer) raise ArgumentError, "min_signers must be greater than 1." if min_signers < 2 raise ArgumentError, "max_signers must be Integer." unless max_signers.is_a?(Integer) raise ArgumentError, "max_signers must be greater than or equal to min_signers." if max_signers < min_signers @ctx = ctx @min_signers = min_signers @max_signers = max_signers key = SigningKey.generate(ctx) @polynomial = key.gen_poly(min_signers - 1) end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
4 5 6 |
# File 'lib/frost/dealer.rb', line 4 def ctx @ctx end |
#max_signers ⇒ Object (readonly)
Returns the value of attribute max_signers.
5 6 7 |
# File 'lib/frost/dealer.rb', line 5 def max_signers @max_signers end |
#min_signers ⇒ Object (readonly)
Returns the value of attribute min_signers.
6 7 8 |
# File 'lib/frost/dealer.rb', line 6 def min_signers @min_signers end |
#polynomial ⇒ Object (readonly)
Returns the value of attribute polynomial.
7 8 9 |
# File 'lib/frost/dealer.rb', line 7 def polynomial @polynomial end |
Instance Method Details
#gen_shares(identifiers = nil) ⇒ Array
Generate shares.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/frost/dealer.rb', line 30 def gen_shares(identifiers = nil) raise ArgumentError, "identifiers must be Array." if identifiers && !identifiers.is_a?(Array) identifiers = if identifiers identifiers.each do |id| raise ArgumentError, "identifier must be Integer." unless id.is_a?(Integer) raise ArgumentError, "identifier must be greater than 0." if id < 1 end identifiers else (1..max_signers).to_a end identifiers.map{ |i| polynomial.gen_share(i) } end |
#group_public_key ⇒ ECDSA::Point
Get a group public key.
46 47 48 |
# File 'lib/frost/dealer.rb', line 46 def group_public_key polynomial.verification_point end |