Class: I2P::KeyPair
- Defined in:
- lib/i2p/data/key_pair.rb,
lib/i2p/sdk.rb
Overview
**I2P key pair data structure.**
Constant Summary collapse
- BYTESIZE =
minimum
663
Instance Attribute Summary collapse
Class Method Summary collapse
-
.read(input) ⇒ KeyPair
Reads a key pair from the given ‘input` stream.
Instance Method Summary collapse
-
#initialize(destination, private_key, signing_key) ⇒ KeyPair
constructor
Initializes a new key pair instance.
-
#size ⇒ Integer
(also: #bytesize)
Returns the byte size of this key pair.
-
#to_java ⇒ Object
Returns an instance of the Java class ‘net.i2p.data.PrivateKeyFile`.
-
#to_s ⇒ String
Returns the binary string representation of this key pair.
Methods inherited from Structure
#==, #eql?, parse, #to_base64
Constructor Details
#initialize(destination, private_key, signing_key) ⇒ KeyPair
Initializes a new key pair instance.
25 26 27 28 29 |
# File 'lib/i2p/data/key_pair.rb', line 25 def initialize(destination, private_key, signing_key) @destination = destination @private_key = private_key @signing_key = signing_key end |
Instance Attribute Details
#destination ⇒ Destination
33 34 35 |
# File 'lib/i2p/data/key_pair.rb', line 33 def destination @destination end |
#private_key ⇒ PrivateKey
37 38 39 |
# File 'lib/i2p/data/key_pair.rb', line 37 def private_key @private_key end |
#signing_key ⇒ SigningPrivateKey
41 42 43 |
# File 'lib/i2p/data/key_pair.rb', line 41 def signing_key @signing_key end |
Class Method Details
.read(input) ⇒ KeyPair
Reads a key pair from the given ‘input` stream.
15 16 17 |
# File 'lib/i2p/data/key_pair.rb', line 15 def self.read(input) self.new(Destination.read(input), PrivateKey.read(input), SigningPrivateKey.read(input)) end |
Instance Method Details
#size ⇒ Integer Also known as: bytesize
Returns the byte size of this key pair.
47 48 49 |
# File 'lib/i2p/data/key_pair.rb', line 47 def size destination.size + private_key.size + signing_key.size end |
#to_java ⇒ Object
Returns an instance of the Java class ‘net.i2p.data.PrivateKeyFile`.
**This method only works with JRuby, not with MRI or YARV.**
108 109 110 |
# File 'lib/i2p/sdk.rb', line 108 def to_java raise NotImplementedError.new("#{self.class}#to_java") # TODO end |
#to_s ⇒ String
Returns the binary string representation of this key pair.
56 57 58 59 60 61 62 63 |
# File 'lib/i2p/data/key_pair.rb', line 56 def to_s StringIO.open do |buffer| buffer.write(destination.to_s) buffer.write(private_key.to_s) buffer.write(signing_key.to_s) buffer.string end end |