Class: FROST::SigningKey

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

Overview

A signing key for a Schnorr signature on a FROST.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scalar, group = ECDSA::Group::Secp256k1) ⇒ SigningKey

Constructor

Parameters:

  • scalar (Integer)

    secret key value.

  • group (ECDSA::Group) (defaults to: ECDSA::Group::Secp256k1)

    Group of elliptic curve.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
# File 'lib/frost/signing_key.rb', line 10

def initialize(scalar, group = ECDSA::Group::Secp256k1)
  raise ArgumentError, "scalar must be integer." unless scalar.is_a?(Integer)
  raise ArgumentError, "group must be ECDSA::Group." unless group.is_a?(ECDSA::Group)
  raise ArgumentError, "Invalid scalar range." if scalar < 1 || group.order - 1 < scalar

  @scalar = scalar
  @group = group
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



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

def group
  @group
end

#scalarObject (readonly)

Returns the value of attribute scalar.



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

def scalar
  @scalar
end

Class Method Details

.generate(group) ⇒ Object

Generate signing key.

Parameters:

  • group (ECDSA::Group)

    Group of elliptic curve.



21
22
23
24
# File 'lib/frost/signing_key.rb', line 21

def self.generate(group)
  scalar = 1 + SecureRandom.random_number(group.order - 1)
  SigningKey.new(scalar, group)
end

Instance Method Details

#gen_poly(degree) ⇒ FROST::Polynomial

Generate random polynomial using this secret.

Parameters:

  • degree (Integer)

    Degree of polynomial.

Returns:



29
30
31
# File 'lib/frost/signing_key.rb', line 29

def gen_poly(degree)
  Polynomial.from_secret(scalar, degree, group)
end

#to_pointECDSA::Point

Compute public key.

Returns:

  • (ECDSA::Point)


35
36
37
# File 'lib/frost/signing_key.rb', line 35

def to_point
  group.generator * scalar
end