Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Proof

import { Proof } from "https://raw.githubusercontent.com/marigold-dev/tzstamp/0.3.4/proof/mod.ts";

Cryptographic timestamp proof

class Proof {
constructor({ hash, operations }: ProofOptions);
readonly derivation: Uint8Array;
readonly hash: Uint8Array;
readonly operations: Operation[];
 
concat(proof: AffixedProof): AffixedProof;
concat(proof: Proof): Proof;
concat(proof: AnyProof);
isAffixed(): this is AffixedProof;
isUnresolved(): this is UnresolvedProof;
toJSON(): ProofTemplate;
 
static create(options: AffixedProofOptions): AffixedProof;
static create(options: UnresolvedProofOptions): UnresolvedProof;
static create(options: ProofOptions): Proof;
static create(options: AnyProofOptions);
static from(template: unknown): Proof;
}

§Constructors

§
new Proof({ hash, operations }: ProofOptions)
[src]

§Properties

§
derivation: Uint8Array
[src]

Output of all operations applied sequentially to the input hash

§
hash: Uint8Array
[src]

Input hash

§
operations: Operation[]
[src]

Proof operations

§Methods

§

Concatenates another proof's operations to the current one. Throws MismatchedHashError if the derivation of the current proof does not match the stored hash of the passed proof.

const proofA = Proof.create({ ... });
const proofB = Proof.create({ ... });
const proofAB = proofA.concat(proofB);
// Hash of proofA
// Operations of proofA + proofB
// Calculates new derivation

The AffixedProof and UnresolvedProof subclasses are viral. Concatenating to instances of these classes will produce a new instance of the same subclass:

const affixedProof = new AffixedProof({ ... });
proof.concat(affixedProof);
// AffixedProof {}
// Retains extra fields of affixedProof

const unresolvedProof = new UnresolvedProof({ ... });
proof.concat(unresolvedProof);
// UnresolvedProof {}
// Retains extra fields of unresolvedProof

The AffixedProof subclass represents the end of a proof and cannot be concatenated to:

affixedProof.concat(proof);
// TypeError: Cannot concatenate to an affixed proof
@param proof

Proof to append

concat(proof: Proof): Proof
[src]
concat(proof: AnyProof)
[src]
§
isAffixed(): this is AffixedProof
[src]

Narrows the proof to the affixed subclass.

§
isUnresolved(): this is UnresolvedProof
[src]

Narrows the proof to the unresolved subclass.

§

Converts the proof to a JSON-serializable template.

JSON.stringify(myProof);
// `myProof.toJSON` is called implicitly

§Static Methods

§

Creates an automatically subclassed proof.

Proof.create({
  hash: ...,
  operations: [...],
  remote: "...",
});
// UnresolvedProof{}
@param options

Proof constructor options

create(options: ProofOptions): Proof
[src]
create(options: AnyProofOptions)
[src]
§
from(template: unknown): Proof
[src]

Creates a proof from a template object.

Throws SyntaxError if the template is invalid.

Throws UnsupportedVersionError if the template version is unsupported.

Proof.from({
  version: 1,
  hash: "...":
  operations: [...]
});
// Proof {}
@param template

Template object