class CryptoToolchain::DiffieHellman::PeerInfo
Attributes
channel[R]
g[RW]
p[RW]
peer[R]
pubkey[RW]
Public Class Methods
new(peer: , channel: , pubkey: nil, p: nil, g: nil)
click to toggle source
# File lib/crypto_toolchain/diffie_hellman/peer_info.rb, line 4 def initialize(peer: , channel: , pubkey: nil, p: nil, g: nil) @peer = peer @channel = channel @pubkey = pubkey @p = p @g = g end
Public Instance Methods
session_key()
click to toggle source
# File lib/crypto_toolchain/diffie_hellman/peer_info.rb, line 28 def session_key if shared_secret.nil? raise ArgumentError.new("Session key requires a shared secret") end @session_key ||= CryptoToolchain::Utilities::SHA1.bindigest(shared_secret.to_s)[0..15] end
to_h()
click to toggle source
# File lib/crypto_toolchain/diffie_hellman/peer_info.rb, line 14 def to_h { name: peer.name, p: p, g: g, pubkey: pubkey, secret: shared_secret } end
update(hsh)
click to toggle source
# File lib/crypto_toolchain/diffie_hellman/peer_info.rb, line 35 def update(hsh) hsh.each do |k, v| self.send("#{k}=", v) unless v.nil? end end