Options
All
  • Public
  • Public/Protected
  • All
Menu

@truestamp/tree - v0.2.1

Index

Type Aliases

MerkleRoot: z.infer<typeof MerkleRoot>
ProofBinary: z.infer<typeof ProofBinary>
ProofHex: z.infer<typeof ProofHex>
ProofObject: z.infer<typeof ProofObject>
ProofObjectLayer: z.infer<typeof ProofObjectLayer>
TreeData: z.infer<typeof TreeData>
TreeHashFunctionName: z.infer<typeof TreeHashFunctionName>
TreeOptions: z.infer<typeof TreeOptions>
TreeTree: z.infer<typeof TreeTree>
UnionProofHashTypes: z.infer<typeof UnionProofHashTypes>

Variables

MerkleRoot: ZodEffects<ZodType<Uint8Array, ZodTypeDef, Uint8Array>, Uint8Array, Uint8Array> = ...

Defines the shape of a Uint8Array Merkle root hash.

ProofBinary: ZodEffects<ZodType<Uint8Array, ZodTypeDef, Uint8Array>, Uint8Array, Uint8Array> = ...

Defines the shape of a Uint8Array inclusion proof.

ProofHex: ZodString = ...

Defines the shape of a Hex encoded inclusion proof.

ProofObject: ZodObject<{ h: ZodUnion<[ZodLiteral<"sha224">, ZodLiteral<"sha256">, ZodLiteral<"sha384">, ZodLiteral<"sha512">, ZodLiteral<"sha512_256">, ZodLiteral<"sha3_224">, ZodLiteral<"sha3_256">, ZodLiteral<"sha3_384">, ZodLiteral<"sha3_512">]>; p: ZodArray<ZodTuple<[ZodNumber, ZodString], null>, "many">; v: ZodNumber }, "strip", ZodTypeAny, { h: "sha224" | "sha256" | "sha384" | "sha512" | "sha512_256" | "sha3_224" | "sha3_256" | "sha3_384" | "sha3_512"; p: [number, string][]; v: number }, { h: "sha224" | "sha256" | "sha384" | "sha512" | "sha512_256" | "sha3_224" | "sha3_256" | "sha3_384" | "sha3_512"; p: [number, string][]; v: number }> = ...

Defines the shape of an Object encoded inclusion proof. v : version number h : hash function p : proof

ProofObjectLayer: ZodTuple<[ZodNumber, ZodString], null> = ...

Defines the shape of one layer of an Object encoded inclusion proof.

TreeData: ZodArray<ZodType<Uint8Array, ZodTypeDef, Uint8Array>, "many"> = ...

Defines the shape of user provided tree data.

TreeHashFunctionName: ZodEffects<ZodString, string, string> = ...

The type that defines the expected shape of user provided hash function names.

TreeOptions: ZodObject<{ debug: ZodOptional<ZodBoolean>; requireBalanced: ZodOptional<ZodBoolean> }, "strip", ZodTypeAny, { debug: undefined | boolean; requireBalanced: undefined | boolean }, { debug: undefined | boolean; requireBalanced: undefined | boolean }> = ...

Defines the shape of user provided tree configuration.

TreeTree: ZodArray<ZodArray<ZodType<Uint8Array, ZodTypeDef, Uint8Array>, "many">, "many"> = ...

Defines the internal structure of a tree.

UnionProofHashTypes: ZodUnion<[ZodLiteral<"sha224">, ZodLiteral<"sha256">, ZodLiteral<"sha384">, ZodLiteral<"sha512">, ZodLiteral<"sha512_256">, ZodLiteral<"sha3_224">, ZodLiteral<"sha3_256">, ZodLiteral<"sha3_384">, ZodLiteral<"sha3_512">]> = ...

Functions

  • compare(a: Uint8Array, b: Uint8Array): boolean
  • Constant time comparison of two Uint8Arrays. Returns true if a and b are of equal non-zero length, and their contents are equal, or false otherwise. Note that zero-length inputs are considered not equal, so this function will return false.

    Parameters

    • a: Uint8Array

      First Uint8Array string to compare.

    • b: Uint8Array

      Second Uint8Array string to compare.

    Returns boolean

    Boolean indicating if both args are identical.

  • concat(...arrays: Uint8Array[]): Uint8Array
  • Concatenates byte arrays.

    Parameters

    • Rest ...arrays: Uint8Array[]

      Uint8Arrays to concatenate.

    Returns Uint8Array

    Concatenated Uint8Array.

  • decodeHex(s: string): Uint8Array
  • Decodes a Hex encoded string to a Uint8Array.

    Parameters

    • s: string

      Hex encoded Uint8Array string to decode.

    Returns Uint8Array

    Decoded Uint8Array.

  • encodeHex(u: Uint8Array): string
  • Encodes a Uint8Array to Hex encoded string.

    Parameters

    • u: Uint8Array

      Uint8Array to encode.

    Returns string

    HEX encoded Uint8Array string.

  • powerOfTwo(x: number): boolean
  • Test whether a number is a power of two (1,2,4,8,16,32,...). This is useful for determining if the data preparing to be added to the tree is a power of two in length, and thus a balanced tree.

    Parameters

    • x: number

      Number to test.

    Returns boolean

    Boolean indicating if the number is a power of two.

  • sha224(data: Uint8Array): Uint8Array
  • Pure JavaScript SHA224 hash function that accepts and returns Uint8Array values.

    Parameters

    • data: Uint8Array

      The data to hash.

    Returns Uint8Array

    The hash digest.

  • sha256(data: Uint8Array): Uint8Array
  • Pure JavaScript SHA256 hash function that accepts and returns Uint8Array values.

    Parameters

    • data: Uint8Array

      The data to hash.

    Returns Uint8Array

    The hash digest.

  • sha384(data: Uint8Array): Uint8Array
  • Pure JavaScript SHA384 hash function that accepts and returns Uint8Array values.

    Parameters

    • data: Uint8Array

      The data to hash.

    Returns Uint8Array

    The hash digest.

  • sha3_224(data: Uint8Array): Uint8Array
  • Pure JavaScript SHA3-224 hash function that accepts and returns Uint8Array values.

    Parameters

    • data: Uint8Array

      The data to hash.

    Returns Uint8Array

    The hash digest.

  • sha3_256(data: Uint8Array): Uint8Array
  • Pure JavaScript SHA3-256 hash function that accepts and returns Uint8Array values.

    Parameters

    • data: Uint8Array

      The data to hash.

    Returns Uint8Array

    The hash digest.

  • sha3_384(data: Uint8Array): Uint8Array
  • Pure JavaScript SHA3-384 hash function that accepts and returns Uint8Array values.

    Parameters

    • data: Uint8Array

      The data to hash.

    Returns Uint8Array

    The hash digest.

  • sha3_512(data: Uint8Array): Uint8Array
  • Pure JavaScript SHA3-512 hash function that accepts and returns Uint8Array values.

    Parameters

    • data: Uint8Array

      The data to hash.

    Returns Uint8Array

    The hash digest.

  • sha512(data: Uint8Array): Uint8Array
  • Pure JavaScript SHA512 hash function that accepts and returns Uint8Array values.

    Parameters

    • data: Uint8Array

      The data to hash.

    Returns Uint8Array

    The hash digest.

  • sha512_256(data: Uint8Array): Uint8Array
  • Pure JavaScript SHA512/256 hash function that accepts and returns Uint8Array values.

    Parameters

    • data: Uint8Array

      The data to hash.

    Returns Uint8Array

    The hash digest.