@blockchaincommons/provenance-mark - v1.0.0-beta.3
    Preparing search index...

    Class ProvenanceMarkGenerator

    Produces a chain of marks from a seed: the chain id and the RNG state derive from the seed, each next draws the next key and advances the state. Persist it between marks with toJSON or toEnvelope.

    const generator = ProvenanceMarkGenerator.fromPassphrase("low", "Wolf");
    const genesis = generator.next(new Date("2023-06-20T12:00:00Z"));
    const second = generator.next(new Date("2023-06-21T12:00:00Z"), "second work");
    genesis.precedes(second); // true

    Implements

    • ToEnvelope
    Index
    • get chainId(): Uint8Array

      A copy of the chain id.

      Returns Uint8Array

    • get nextSeq(): number

      The sequence number the next mark gets.

      Returns number

    • The next mark: the genesis mark's key is the chain id, every later key is drawn from the RNG (which advances); the next key is drawn from a copy so the hash commits to it. The date is a Date or a CborDate; one the resolution cannot encode (YearOutOfRange, DateOutOfRange, InvalidDate) throws before any state changes. info is any CBOR the mark carries: a Cbor, a ToCbor, or a value dcbor encodes.

      Parameters

      Returns ProvenanceMark

    • ProvenanceMarkGenerator(chainID: <hex>, res: <name>, seed: <hex>, nextSeq: <n>, rngState: <hex>).

      Returns string

    • res (wire number), seed, chainID, nextSeq, rngState, bytes in base64.

      Returns Record<string, unknown>

    • The JSON shape, read strictly: every field required, res a wire number, nextSeq a u32, seed and rngState 32 bytes of base64, chainID base64 of the link length. Any fault is Json, worded as serde words it.

      Parameters

      • json: unknown

      Returns ProvenanceMarkGenerator

    • The chain id as the subject, typed provenance-generator, with res, seed, next-seq and rng-state assertions.

      Returns Envelope

    • A generator from its envelope. An envelope not typed provenance-generator, or missing a field, is Envelope; more or fewer than five assertions is ExtraKeys; a field of the wrong shape is Cbor.

      Parameters

      • envelope: Envelope

      Returns ProvenanceMarkGenerator