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.



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

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.



60
61
62
# File 'lib/signature_graph.rb', line 60

def created
  @created
end

#didObject (readonly)

Returns the value of attribute did.



60
61
62
# File 'lib/signature_graph.rb', line 60

def did
  @did
end

#incomingObject (readonly)

Returns the value of attribute incoming.



60
61
62
# File 'lib/signature_graph.rb', line 60

def incoming
  @incoming
end

#kidObject (readonly)

Returns the value of attribute kid.



60
61
62
# File 'lib/signature_graph.rb', line 60

def kid
  @kid
end

#outgoingObject (readonly)

Returns the value of attribute outgoing.



60
61
62
# File 'lib/signature_graph.rb', line 60

def outgoing
  @outgoing
end

#public_keyObject (readonly)

Returns the value of attribute public_key.



60
61
62
# File 'lib/signature_graph.rb', line 60

def public_key
  @public_key
end

#raw_public_keyObject (readonly)

Returns the value of attribute raw_public_key.



60
61
62
# File 'lib/signature_graph.rb', line 60

def raw_public_key
  @raw_public_key
end

#revokedObject (readonly)

Returns the value of attribute revoked.



60
61
62
# File 'lib/signature_graph.rb', line 60

def revoked
  @revoked
end

#typeObject (readonly)

Returns the value of attribute type.



60
61
62
# File 'lib/signature_graph.rb', line 60

def type
  @type
end

Instance Method Details

#child_keysObject



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

def child_keys
  keys = @outgoing.dup

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

  keys
end

#revoke(at) ⇒ Object



80
81
82
# File 'lib/signature_graph.rb', line 80

def revoke(at)
  @revoked = at
end

#revoked?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/signature_graph.rb', line 84

def revoked?
  @revoked > 0
end

#valid_at(at) ⇒ Object



76
77
78
# File 'lib/signature_graph.rb', line 76

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