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

Class Method Details

.step1(helpers, participant, share) ⇒ Hash

Step 1 for RTS. Each helper computes delta_i,j for other helpers.

Parameters:

  • helpers (Array)

    Array of helper’s identifier.

  • participant (Integer)

    Identifier of the participant whose shares you want to restore.

  • share (FROST::SecretShare)

    Share of participant running this process.

Returns:

  • (Hash)

    Hash with helper ID as key and value as delta value.

Raises:

  • (ArgumentError)


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.

Parameters:

  • step1_values (Array)

    Array of delta values.

  • group (ECDSA::Group)

Returns:

  • (Integer)

    Sum of delta values.

Raises:

  • (ArgumentError)


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.

Parameters:

  • identifier (Integer)

    Identifier of the participant whose shares you want to restore.

  • step2_results (Array)

    Array of Step 2 results received from other helpers.

  • group (ECDSA::Group)

Returns:

Raises:

  • (ArgumentError)


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