Class: Cryptos::PrivateKey
- Inherits:
-
Object
- Object
- Cryptos::PrivateKey
- Defined in:
- lib/cryptos/private_key.rb
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.generate(group = EllipticCurve::Secp256k1) ⇒ Object
Generates new private key.
Instance Method Summary collapse
-
#initialize(value, order = nil) ⇒ PrivateKey
constructor
A new instance of PrivateKey.
- #to_s ⇒ Object
Constructor Details
#initialize(value, order = nil) ⇒ PrivateKey
Returns a new instance of PrivateKey.
15 16 17 18 |
# File 'lib/cryptos/private_key.rb', line 15 def initialize(value, order = nil) @value = value @order = order end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
5 6 7 |
# File 'lib/cryptos/private_key.rb', line 5 def order @order end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/cryptos/private_key.rb', line 5 def value @value end |
Class Method Details
.generate(group = EllipticCurve::Secp256k1) ⇒ Object
Generates new private key
10 11 12 13 |
# File 'lib/cryptos/private_key.rb', line 10 def self.generate(group = EllipticCurve::Secp256k1) value = 1 + SecureRandom.random_number(group.order - 1) new value, group.order end |
Instance Method Details
#to_s ⇒ Object
20 21 22 |
# File 'lib/cryptos/private_key.rb', line 20 def to_s value.to_s end |