Blockchain Commons Components TypeScript Library - v1.0.0-alpha.13
    Preparing search index...

    Class Seed

    Interface for types that can provide unique data for cryptographic key derivation.

    The provided data should be sufficiently random and have enough entropy to serve as the basis for secure cryptographic key derivation.

    Implements

    Index

    Properties

    MIN_SEED_LENGTH: 16

    Minimum seed length in bytes (matches Rust MIN_SEED_LENGTH).

    Methods

    • Create a new random seed with a specified length.

      Rust equivalent: Seed::new_with_len(count)

      Parameters

      • count: number

        Number of bytes (must be >= 16)

      Returns Seed

      CryptoError if count < 16

    • Create a new random seed with a specified length using provided RNG.

      Rust equivalent: Seed::new_with_len_using(count, rng)

      Parameters

      • count: number

        Number of bytes (must be >= 16)

      • rng: { randomData: (size: number) => Uint8Array }

        Random number generator

      Returns Seed

      CryptoError if count < 16

    • Create a new seed from data and optional metadata.

      Rust equivalent: Seed::new_opt(data, name, note, creation_date)

      Parameters

      • data: Uint8Array

        Seed bytes (must be >= 16 bytes)

      • name: string | undefined

        Optional name for the seed

      • note: string | undefined

        Optional note for the seed

      • creationDate: Date | undefined

        Optional creation date

      Returns Seed

      CryptoError if data < 16 bytes

    • 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

    • Generate a random seed with specified size (default 32 bytes).

      Convenience method that wraps newWithLen().

      Parameters

      • size: number = 32

        Number of bytes (must be >= 16, default 32)

      • Optionalmetadata: SeedMetadata

        Optional metadata object

      Returns Seed

    • Generate a random seed using provided RNG.

      Convenience method that wraps newWithLenUsing().

      Parameters

      • rng: { randomData: (size: number) => Uint8Array }

        Random number generator

      • size: number = 32

        Number of bytes (must be >= 16, default 32)

      • Optionalmetadata: SeedMetadata

        Optional metadata object

      Returns Seed

    • Return the data of the seed as a reference to the internal bytes.

      Rust equivalent: seed.as_bytes()

      Note: Returns a reference to internal data. For a copy, use toData().

      Returns Uint8Array

    • Get the raw seed bytes (copy).

      Note: Returns a copy to prevent external mutation of the seed's internal state.

      Returns Uint8Array

    • Return the name of the seed.

      Rust equivalent: seed.name() - returns empty string if not set.

      Returns string

    • Set the name of the seed.

      Rust equivalent: seed.set_name(name)

      Parameters

      • name: string

      Returns void

    • Return the note of the seed.

      Rust equivalent: seed.note() - returns empty string if not set.

      Returns string

    • Set the note of the seed.

      Rust equivalent: seed.set_note(note)

      Parameters

      • note: string

      Returns void

    • Return the creation date of the seed.

      Rust equivalent: seed.creation_date()

      Returns Date | undefined

    • Set the creation date of the seed.

      Rust equivalent: seed.set_creation_date(date)

      Parameters

      • creationDate: Date | undefined

      Returns void

    • Return the creation date of the seed (alias for creationDate).

      Returns Date | undefined

      Use creationDate() for Rust API parity.

    • Set the creation date of the seed (alias for setCreationDate).

      Parameters

      • date: Date

      Returns void

      Use setCreationDate() for Rust API parity.

    • 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

    • Returns the CBOR tags associated with Seed. Includes TAG_SEED (40300) and TAG_SEED_V1 (300) for backward compatibility.

      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

    • Returns the tagged CBOR encoding.

      Returns Cbor

    • Returns the tagged value in CBOR binary representation.

      Returns Uint8Array

    • Creates a Seed by decoding it from untagged CBOR.

      Parameters

      • cborValue: Cbor

      Returns Seed

    • Creates a Seed by decoding it from tagged CBOR.

      Parameters

      • cbor: Cbor

      Returns Seed

    • Static method to decode from tagged CBOR binary data.

      Parameters

      • data: Uint8Array

      Returns Seed

    • Static method to decode from untagged CBOR binary data.

      Parameters

      • data: Uint8Array

      Returns Seed

    • Returns the UR representation of the Seed. Note: URs use untagged CBOR since the type is conveyed by the UR type itself.

      Returns UR

    • Returns the UR string representation.

      Returns string