Class: SelfSDK::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/signature_graph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action) ⇒ Key

Returns a new instance of Key.



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/signature_graph.rb', line 60

def initialize(action)
  @kid = action[:kid]
  @did = action[:did]
  @type = action[:type]
  @created = action[:from]
  @revoked = 0

  @raw_public_key = action[:key]
  @public_key = Ed25519::VerifyKey.new(Base64.urlsafe_decode64(@raw_public_key))

  @incoming = Array.new
  @outgoing = Array.new
end

Instance Attribute Details

#createdObject (readonly)

Returns the value of attribute created.



58
59
60
# File 'lib/signature_graph.rb', line 58

def created
  @created
end

#didObject (readonly)

Returns the value of attribute did.



58
59
60
# File 'lib/signature_graph.rb', line 58

def did
  @did
end

#incomingObject (readonly)

Returns the value of attribute incoming.



58
59
60
# File 'lib/signature_graph.rb', line 58

def incoming
  @incoming
end

#kidObject (readonly)

Returns the value of attribute kid.



58
59
60
# File 'lib/signature_graph.rb', line 58

def kid
  @kid
end

#outgoingObject (readonly)

Returns the value of attribute outgoing.



58
59
60
# File 'lib/signature_graph.rb', line 58

def outgoing
  @outgoing
end

#public_keyObject (readonly)

Returns the value of attribute public_key.



58
59
60
# File 'lib/signature_graph.rb', line 58

def public_key
  @public_key
end

#raw_public_keyObject (readonly)

Returns the value of attribute raw_public_key.



58
59
60
# File 'lib/signature_graph.rb', line 58

def raw_public_key
  @raw_public_key
end

#revokedObject (readonly)

Returns the value of attribute revoked.



58
59
60
# File 'lib/signature_graph.rb', line 58

def revoked
  @revoked
end

#typeObject (readonly)

Returns the value of attribute type.



58
59
60
# File 'lib/signature_graph.rb', line 58

def type
  @type
end

Instance Method Details

#child_keysObject



86
87
88
89
90
91
92
93
94
# File 'lib/signature_graph.rb', line 86

def child_keys
  keys = @outgoing.dup

  @outgoing.each do |k|
    keys.concat k.child_keys
  end

  keys
end

#revoke(at) ⇒ Object



78
79
80
# File 'lib/signature_graph.rb', line 78

def revoke(at)
  @revoked = at
end

#revoked?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/signature_graph.rb', line 82

def revoked?
  @revoked > 0
end

#valid_at(at) ⇒ Object



74
75
76
# File 'lib/signature_graph.rb', line 74

def valid_at(at)
  created <= at && revoked == 0 || created <= at && revoked > at
end