Class: CryptoToolchain::DiffieHellman::Messages::KeyExchange
- Defined in:
- lib/crypto_toolchain/diffie_hellman/messages.rb
Instance Attribute Summary collapse
-
#g ⇒ Object
readonly
Returns the value of attribute g.
-
#initial ⇒ Object
(also: #initial?)
readonly
Returns the value of attribute initial.
-
#p ⇒ Object
readonly
Returns the value of attribute p.
-
#peer ⇒ Object
readonly
Returns the value of attribute peer.
-
#pubkey ⇒ Object
readonly
Returns the value of attribute pubkey.
Instance Method Summary collapse
-
#initialize(peer:, pubkey:, p: nil, g: nil, initial: false) ⇒ KeyExchange
constructor
A new instance of KeyExchange.
- #to_s ⇒ Object
Constructor Details
#initialize(peer:, pubkey:, p: nil, g: nil, initial: false) ⇒ KeyExchange
Returns a new instance of KeyExchange.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 18 def initialize(peer: , pubkey: , p: nil, g: nil, initial: false) if initial && (p.nil? || g.nil?) raise ArgumentError.new("Initial message must provide p and g") end @p = p @g = g @pubkey = pubkey @peer = peer @initial = initial end |
Instance Attribute Details
#g ⇒ Object (readonly)
Returns the value of attribute g.
28 29 30 |
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 28 def g @g end |
#initial ⇒ Object (readonly) Also known as: initial?
Returns the value of attribute initial.
28 29 30 |
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 28 def initial @initial end |
#p ⇒ Object (readonly)
Returns the value of attribute p.
28 29 30 |
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 28 def p @p end |
#peer ⇒ Object (readonly)
Returns the value of attribute peer.
28 29 30 |
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 28 def peer @peer end |
#pubkey ⇒ Object (readonly)
Returns the value of attribute pubkey.
28 29 30 |
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 28 def pubkey @pubkey end |
Instance Method Details
#to_s ⇒ Object
31 32 33 |
# File 'lib/crypto_toolchain/diffie_hellman/messages.rb', line 31 def to_s "PEER: #{peer.name} P: #{p} G: #{g} PUBKEY: #{pubkey % 1000}" end |