Class: FROST::SigningKey
- Inherits:
-
Object
- Object
- FROST::SigningKey
- Defined in:
- lib/frost/signing_key.rb
Overview
A signing key for a Schnorr signature on a FROST.
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#scalar ⇒ Object
readonly
Returns the value of attribute scalar.
Class Method Summary collapse
-
.generate(group) ⇒ Object
Generate signing key.
Instance Method Summary collapse
-
#gen_poly(degree) ⇒ FROST::Polynomial
Generate random polynomial using this secret.
-
#initialize(scalar, group = ECDSA::Group::Secp256k1) ⇒ SigningKey
constructor
Constructor.
-
#to_point ⇒ ECDSA::Point
Compute public key.
Constructor Details
#initialize(scalar, group = ECDSA::Group::Secp256k1) ⇒ SigningKey
Constructor
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
#group ⇒ Object (readonly)
Returns the value of attribute group.
5 6 7 |
# File 'lib/frost/signing_key.rb', line 5 def group @group end |
#scalar ⇒ Object (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.
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.
29 30 31 |
# File 'lib/frost/signing_key.rb', line 29 def gen_poly(degree) Polynomial.from_secret(scalar, degree, group) end |
#to_point ⇒ ECDSA::Point
Compute public key.
35 36 37 |
# File 'lib/frost/signing_key.rb', line 35 def to_point group.generator * scalar end |