Class: Sidetree::Model::Suffix

Inherits:
Object
  • Object
show all
Defined in:
lib/sidetree/model/suffix.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delta_hash, recovery_commitment) ⇒ Suffix

Returns a new instance of Suffix.

Parameters:

  • delta_hash (String)

    Base64 encoded delta hash.

  • recovery_commitment (String)

    Base64 encoded recovery commitment.



8
9
10
11
# File 'lib/sidetree/model/suffix.rb', line 8

def initialize(delta_hash, recovery_commitment)
  @delta_hash = delta_hash
  @recovery_commitment = recovery_commitment
end

Instance Attribute Details

#delta_hashObject (readonly)

Returns the value of attribute delta_hash.



4
5
6
# File 'lib/sidetree/model/suffix.rb', line 4

def delta_hash
  @delta_hash
end

#recovery_commitmentObject (readonly)

Returns the value of attribute recovery_commitment.



4
5
6
# File 'lib/sidetree/model/suffix.rb', line 4

def recovery_commitment
  @recovery_commitment
end

Class Method Details

.from_object(object) ⇒ Sidetree::Model::Suffix

Create Suffix object from hash object.



16
17
18
19
# File 'lib/sidetree/model/suffix.rb', line 16

def self.from_object(object)
  Sidetree::Validator.validate_suffix_data!(object)
  Suffix.new(object[:deltaHash], object[:recoveryCommitment])
end

Instance Method Details

#to_hHash

Convert data to Hash object.

Returns:

  • (Hash)


23
24
25
# File 'lib/sidetree/model/suffix.rb', line 23

def to_h
  { deltaHash: delta_hash, recoveryCommitment: recovery_commitment }
end

#unique_suffixString

Calculate unique suffix

Returns:

  • (String)

    unique suffix



29
30
31
# File 'lib/sidetree/model/suffix.rb', line 29

def unique_suffix
  Sidetree.to_hash(to_h)
end