Module: FROST::Repairable
- Defined in:
- lib/frost/repairable.rb
Overview
Implements the Repairable Threshold Scheme (RTS) from <eprint.iacr.org/2017/1155>
Class Method Summary collapse
-
.step1(helpers, participant, share) ⇒ Hash
Step 1 for RTS.
-
.step2(step1_values, group) ⇒ Integer
Step 2 for RTS.
-
.step3(identifier, step2_results, group) ⇒ Object
Participant compute own share with received sum of delta value.
Class Method Details
.step1(helpers, participant, share) ⇒ Hash
Step 1 for RTS. Each helper computes delta_i,j for other helpers.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/frost/repairable.rb', line 12 def step1(helpers, participant, share) raise ArgumentError, "helpers must be greater than 1." if helpers.length < 2 raise ArgumentError, "participant must be greater than 1." if participant < 1 raise ArgumentError, "helpers has duplicate identifier." unless helpers.uniq.length == helpers.length raise ArgumentError, "helpers contains same identifier with participant." if helpers.include?(participant) field = ECDSA::PrimeField.new(share.group.order) random_values = (helpers.length - 1).times.map { SecureRandom.random_number(share.group.order - 1) } # compute last random value ## Calculate Lagrange Coefficient for helper_i zeta_i = Polynomial.derive_interpolating_value(helpers, share.identifier, share.group, x: participant) lhs = field.mod(zeta_i * share.share) # last random value last = field.mod(lhs - random_values.sum) random_values << last helpers.zip(random_values).to_h end |
.step2(step1_values, group) ⇒ Integer
Step 2 for RTS. Each helper sum received delta values from other helpers.
37 38 39 40 41 42 |
# File 'lib/frost/repairable.rb', line 37 def step2(step1_values, group) raise ArgumentError, "group must be ECDSA::Group" unless group.is_a?(ECDSA::Group) field = ECDSA::PrimeField.new(group.order) field.mod(step1_values.sum) end |
.step3(identifier, step2_results, group) ⇒ Object
Participant compute own share with received sum of delta value.
49 50 51 52 53 54 |
# File 'lib/frost/repairable.rb', line 49 def step3(identifier, step2_results, group) raise ArgumentError, "group must be ECDSA::Group" unless group.is_a?(ECDSA::Group) field = ECDSA::PrimeField.new(group.order) FROST::SecretShare.new(identifier, field.mod(step2_results.sum), group) end |