Class: FROST::Nonce
- Inherits:
-
Object
- Object
- FROST::Nonce
- Defined in:
- lib/frost/nonce.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Group of elliptic curve.
-
#value ⇒ Object
readonly
nonce value.
Class Method Summary collapse
-
.gen_from_secret(secret) ⇒ Object
Generate nonce from secret share.
Instance Method Summary collapse
-
#group ⇒ ECDSA::Group
Get group.
-
#initialize(context, nonce) ⇒ FROST::Nonce
constructor
Generate nonce.
-
#to_hex ⇒ String
Convert nonce as hex string.
-
#to_negate ⇒ FROST::Nonce
Generate negated nonce.
-
#to_point ⇒ ECDSA::Point
Compute public key.
Constructor Details
#initialize(context, nonce) ⇒ FROST::Nonce
Generate nonce.
11 12 13 14 15 16 |
# File 'lib/frost/nonce.rb', line 11 def initialize(context, nonce) raise ArgumentError, "context must be FROST::Context." unless context.is_a?(FROST::Context) raise ArgumentError, "nonce must be Integer." unless nonce.is_a?(Integer) @value = nonce @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Group of elliptic curve
5 6 7 |
# File 'lib/frost/nonce.rb', line 5 def context @context end |
#value ⇒ Object (readonly)
nonce value
4 5 6 |
# File 'lib/frost/nonce.rb', line 4 def value @value end |
Class Method Details
.gen_from_secret(secret) ⇒ Object
Generate nonce from secret share.
26 27 28 |
# File 'lib/frost/nonce.rb', line 26 def self.gen_from_secret(secret) gen_from_random_bytes(secret) end |
Instance Method Details
#group ⇒ ECDSA::Group
Get group
20 21 22 |
# File 'lib/frost/nonce.rb', line 20 def group context.group end |
#to_hex ⇒ String
Convert nonce as hex string.
51 52 53 |
# File 'lib/frost/nonce.rb', line 51 def to_hex ECDSA::Format::IntegerOctetString.encode(value, 32).unpack1('H*') end |
#to_negate ⇒ FROST::Nonce
Generate negated nonce.
63 64 65 |
# File 'lib/frost/nonce.rb', line 63 def to_negate Nonce.new(context, group.order - value) end |
#to_point ⇒ ECDSA::Point
Compute public key.
57 58 59 |
# File 'lib/frost/nonce.rb', line 57 def to_point group.generator * value end |