Module: Confium::Transparency::OTS

Defined in:
lib/confium/transparency/ots.rb

Constant Summary collapse

DEFAULT_CALENDARS =

Default OTS calendar servers (from opentimestamps.org).

%w[
  https://a.pool.opentimestamps.org
  https://b.pool.opentimestamps.org
  https://a.pool.eternitywall.com
].freeze

Class Method Summary collapse

Class Method Details

.stamp(hash) ⇒ Confium::Transparency::OTS::Proof

Stamp a 32-byte digest via the default calendar pool. Returns a Proof (pending attestation — Bitcoin confirmation arrives later; poll with #upgrade).

Parameters:

  • hash (String)

    32-byte SHA-256 digest to anchor

Returns:

  • (Confium::Transparency::OTS::Proof)

Raises:

  • (IOError, ArgumentError)


30
31
32
# File 'lib/confium/transparency/ots.rb', line 30

def stamp(hash)
  default_client.stamp(hash)
end

.upgrade(proof) ⇒ Proof

Upgrade a pending proof (fetch a more complete one).

Returns:

  • (Proof)


50
51
52
# File 'lib/confium/transparency/ots.rb', line 50

def upgrade(proof)
  default_client.upgrade(proof)
end

.verify(proof, digest = nil) ⇒ Hash

Verify a proof: replay its op tree from the digest and classify the attestations.

Parameters:

  • proof (Proof, String)

    the proof (or raw .ots bytes — pass the digest alongside for the String form)

  • digest (String, nil) (defaults to: nil)

    required when proof is bytes

Returns:

  • (Hash)

    { pending: [uri], bitcoin: [height], litecoin: [height], anchored: bool }



42
43
44
45
# File 'lib/confium/transparency/ots.rb', line 42

def verify(proof, digest = nil)
  proof = Proof.new(digest, proof) if digest && proof.is_a?(String)
  proof.verify
end