Class: FROST::Nonce
- Inherits:
-
Object
- Object
- FROST::Nonce
- Defined in:
- lib/frost/nonce.rb
Instance Attribute Summary collapse
-
#group ⇒ 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
-
#initialize(nonce, group) ⇒ FROST::Nonce
constructor
Generate nonce.
-
#to_hex ⇒ String
Convert nonce as hex string.
-
#to_point ⇒ ECDSA::Point
Compute public key.
Constructor Details
#initialize(nonce, group) ⇒ FROST::Nonce
Generate nonce.
9 10 11 12 13 14 |
# File 'lib/frost/nonce.rb', line 9 def initialize(nonce, group) raise ArgumentError, "group must by ECDSA::Group." unless group.is_a?(ECDSA::Group) raise ArgumentError, "nonce must by Integer." unless nonce.is_a?(Integer) @value = nonce @group = group end |
Instance Attribute Details
#group ⇒ Object (readonly)
Group of elliptic curve
5 6 7 |
# File 'lib/frost/nonce.rb', line 5 def group @group 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.
18 19 20 |
# File 'lib/frost/nonce.rb', line 18 def self.gen_from_secret(secret) gen_from_random_bytes(secret) end |
Instance Method Details
#to_hex ⇒ String
Convert nonce as hex string.
43 44 45 |
# File 'lib/frost/nonce.rb', line 43 def to_hex ECDSA::Format::IntegerOctetString.encode(value, 32).unpack1('H*') end |
#to_point ⇒ ECDSA::Point
Compute public key.
49 50 51 |
# File 'lib/frost/nonce.rb', line 49 def to_point group.generator * value end |