@blockchaincommons/components - v1.0.0-beta.4
    Preparing search index...

    Class Seed

    Cryptographic seed with optional metadata (minimum 16 bytes)

    A Seed is a source of entropy used to generate cryptographic keys in a deterministic manner. Unlike randomly generated keys, seed-derived keys can be recreated if you have the original seed, making them useful for backup and recovery scenarios.

    This implementation of Seed includes the random seed data as well as optional metadata:

    • A name (for identifying the seed)
    • A note (for storing additional information)
    • A creation date

    The minimum seed length is 16 bytes to ensure sufficient security and entropy.

    CBOR Serialization

    Seed implements the CBOR tagged encoding interfaces, which means it can be serialized to and deserialized from CBOR with specific tags. The tags used are TAG_SEED (40300) and the older TAG_SEED_V1 (300) for backward compatibility.

    When serialized to CBOR, a Seed is represented as a map with the following keys:

    • 1: The seed data (required)
    • 2: The creation date (optional)
    • 3: The name (optional, omitted if empty)
    • 4: The note (optional, omitted if empty)

    UR Serialization

    When serialized as a Uniform Resource (UR), a Seed is represented with the type "seed".

    Implements

    Index
    MIN_SEED_LENGTH: 16

    Minimum seed length in bytes.

    • get bytes(): Uint8Array

      A copy of the bytes; mutating it does not touch this value.

      Returns Uint8Array

    • get byteLength(): number

      Number of bytes.

      Returns number

    • get name(): string

      The label, empty when none was given; set it to a string (InvalidData otherwise).

      Returns string

    • set name(name: string): void

      Parameters

      • name: string

      Returns void

    • get note(): string

      Return the note of the seed.

      returns empty string if not set. Setting it requires a string (InvalidData otherwise).

      Returns string

    • set note(note: string): void

      Parameters

      • note: string

      Returns void

    • get creationDate(): Date | undefined

      Return the creation date of the seed.

      Setting it requires a valid Date or undefined (InvalidData otherwise).

      Returns Date | undefined

    • set creationDate(creationDate: Date | undefined): void

      Parameters

      • creationDate: Date | undefined

      Returns void

    • get creationCborDate(): CborDate | undefined

      The creation date as decoded, with the precision the wire carried.

      Returns CborDate | undefined

    • A random seed of length bytes (16 by default), with optional metadata; pass rng to make it deterministic.

      Parameters

      • __namedParameters: { length?: number } & RngOptions & SeedMetadata = {}

      Returns Seed

    • Create a Seed from raw bytes with optional metadata.

      Note: The input data is copied to prevent external mutation of the seed's internal state.

      Parameters

      • data: Uint8Array

        Seed bytes (must be >= 16 bytes)

      • Optionalmetadata: SeedMetadata

        Optional metadata object

      Returns Seed

    • Create a Seed from hex string with optional metadata.

      Parameters

      • hex: string

        Hex string representing seed bytes

      • Optionalmetadata: SeedMetadata

        Optional metadata object

      Returns Seed

    • Get hex string representation.

      Returns string

    • Get base64 representation.

      Returns string

    • Compare with another Seed.

      Parameters

      Returns boolean

    • Get string representation.

      Returns string

    • Returns unique data from which cryptographic keys can be derived.

      This implementation returns a copy of the seed data, which can be used as entropy for deriving private keys in various cryptographic schemes.

      Returns Uint8Array

      A Uint8Array containing the seed data

    • The CBOR tags this type decodes from; the first one is used to encode.

      Returns Tag[]

    • Returns the untagged CBOR encoding (as a map). Map keys:

      • 1: seed data (required)
      • 2: creation date (optional)
      • 3: name (optional, omitted if empty)
      • 4: note (optional, omitted if empty)

      Returns Cbor

    • The tagged CBOR form.

      Returns Cbor

    • As a UR, typed by the first tag's name.

      Returns UR

    • Decode tagged or untagged CBOR.

      Parameters

      • cborValue: Cbor

      Returns Seed