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
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#scalar ⇒ Object
readonly
Returns the value of attribute scalar.
Class Method Summary collapse
-
.generate(context) ⇒ Object
Generate signing key.
Instance Method Summary collapse
-
#gen_poly(degree) ⇒ FROST::Polynomial
Generate random polynomial using this secret.
-
#group ⇒ ECDSA::Group
Get group.
-
#initialize(context, scalar) ⇒ SigningKey
constructor
Constructor.
-
#to_point ⇒ ECDSA::Point
Compute public key.
Constructor Details
#initialize(context, scalar) ⇒ SigningKey
Constructor
10 11 12 13 14 15 16 17 |
# File 'lib/frost/signing_key.rb', line 10 def initialize(context, scalar) raise ArgumentError "context must be FROST::Context." unless context.is_a?(FROST::Context) raise ArgumentError, "scalar must be integer." unless scalar.is_a?(Integer) raise ArgumentError, "Invalid scalar range." if scalar < 1 || context.group.order - 1 < scalar @scalar = scalar @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/frost/signing_key.rb', line 5 def context @context 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(context) ⇒ Object
Generate signing key.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/frost/signing_key.rb', line 27 def self.generate(context) raise ArgumentError "context must be FROST::Context." unless context.is_a?(FROST::Context) scalar = 1 + SecureRandom.random_number(context.group.order - 1) key = SigningKey.new(context, scalar) if context.taproot? && !key.to_point.y.even? self.generate(context) else key end end |
Instance Method Details
#gen_poly(degree) ⇒ FROST::Polynomial
Generate random polynomial using this secret.
41 42 43 |
# File 'lib/frost/signing_key.rb', line 41 def gen_poly(degree) Polynomial.from_secret(context, scalar, degree) end |
#group ⇒ ECDSA::Group
Get group
21 22 23 |
# File 'lib/frost/signing_key.rb', line 21 def group context.group end |
#to_point ⇒ ECDSA::Point
Compute public key.
47 48 49 |
# File 'lib/frost/signing_key.rb', line 47 def to_point group.generator * scalar end |