Class: Cryptosphere::Identity

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cryptosphere/identity.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(private_key) ⇒ Identity

Returns a new instance of Identity.



12
13
14
15
# File 'lib/cryptosphere/identity.rb', line 12

def initialize(private_key)
  @cipher = AsymmetricCipher.new(private_key)
  @id     = @cipher.public_key_fingerprint
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/cryptosphere/identity.rb', line 3

def id
  @id
end

Class Method Details

.generateObject



8
9
10
# File 'lib/cryptosphere/identity.rb', line 8

def self.generate
  new AsymmetricCipher.generate_key
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/cryptosphere/identity.rb', line 17

def to_s
  "#<Cryptosphere::Identity:#{id}>"
end