Class: Duse::Client::Secret

Inherits:
Entity
  • Object
show all
Defined in:
lib/duse/client/secret.rb

Constant Summary

Constants inherited from Entity

Entity::MAP

Instance Attribute Summary

Attributes inherited from Entity

#attributes, #curry

Instance Method Summary collapse

Methods inherited from Entity

add_attribute, attributes, base_path, #delete, id_field, ignore_in_json, #initialize, #load_attribute, many, #missing?, one, #reload, #save, #set_attribute, subclasses, #to_h

Constructor Details

This class inherits a constructor from Duse::Client::Entity

Instance Method Details

#decrypt(private_key) ⇒ Object



96
97
98
99
100
101
102
103
# File 'lib/duse/client/secret.rb', line 96

def decrypt(private_key)
  # require private_key to be private rsa key
  # require shares to be set (real shares object in the future)
  # require cipher_text to be set

  shares = self.shares.map(&:content)
  Encryption.decrypt(self.cipher_text, shares, private_key)
end

#signatures_valid?Boolean

Returns:

  • (Boolean)


105
106
107
108
109
110
# File 'lib/duse/client/secret.rb', line 105

def signatures_valid?
  self.shares.each do |s|
    return false if !s.valid_signature?
  end
  true
end

#to_sObject



112
113
114
# File 'lib/duse/client/secret.rb', line 112

def to_s
  "🔐  #{self.id}: #{self.title}"
end