reticulum-js
    Preparing search index...

    Class Identity

    Represents a Reticulum Identity.

    Identity creation, signing, and verification

    Hierarchy

    • EventTarget
      • Identity
    Index
    • Low-level constructor. Prefer the static factories (Identity.generate, Identity.fromPublicKey, Identity.fromBytes).

      Parameters

      • x25519Priv: CryptoKey | null
      • ed25519Priv: CryptoKey | null
      • x25519Pub: CryptoKey
      • ed25519Pub: CryptoKey
      • publicKey: Uint8Array<ArrayBufferLike>
      • identityHash: Uint8Array<ArrayBufferLike>

      Returns Identity

    appData: Uint8Array<ArrayBuffer> = ...
    ed25519Priv: CryptoKey | null
    ed25519Pub: CryptoKey
    identityHash: Uint8Array<ArrayBufferLike>
    publicKey: Uint8Array<ArrayBufferLike>
    x25519Priv: CryptoKey | null
    x25519Pub: CryptoKey
    TRUNCATED_HASHLENGTH: number = 128
    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • Decrypt information for the identity.

      Parameters

      • ciphertextToken: Uint8Array<ArrayBufferLike>
      • ratchets: Uint8Array<ArrayBufferLike>[] | null = null

      Returns Promise<Uint8Array<ArrayBufferLike> | null>

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • Encrypt information for the identity.

      Parameters

      • plaintext: Uint8Array<ArrayBufferLike>
      • ratchet: Uint8Array<ArrayBufferLike> | null = null

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Returns the application-specific metadata as a UTF-8 string.

      Returns string

    • Get the context for HKDF.

      Returns Uint8Array<ArrayBufferLike> | null

    • Get the raw private key bytes (64 bytes).

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Get the public key as bytes.

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Get the salt for HKDF.

      Returns Uint8Array<ArrayBufferLike>

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | EventListenerOptions

      Returns void

    • Sets the application-specific metadata attached to announcements.

      Parameters

      • data: string

      Returns void

    • Signs information by the identity.

      Parameters

      • message: Uint8Array<ArrayBufferLike>

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Validates the signature of a signed message.

      Parameters

      • signature: Uint8Array<ArrayBufferLike>
      • messageId: Uint8Array<ArrayBufferLike>

      Returns Promise<boolean>

    • Load an identity from raw bytes.

      Parameters

      • bytes: Uint8Array<ArrayBufferLike>

      Returns Promise<Identity | null>

    • Load an identity from a public key.

      Parameters

      • publicKey: Uint8Array<ArrayBufferLike>

      Returns Promise<Identity>

    • Get a SHA-256 hash of passed data.

      Parameters

      • data: Uint8Array<ArrayBufferLike>

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Returns 16 fresh random bytes (TRUNCATED_HASHLENGTH//8).

      Mirrors RNS.Identity.get_random_hash(). Despite the name this is plain randomness, not a hash of anything. It is the source of the random half of the announce random_hash (SPEC.md §4.1) and the Resource random-hash prefix (§10.2 step 3).

      Returns Uint8Array<ArrayBufferLike>

      16 random bytes.

    • Attempts to load an identity from a storage adapter, or generates and saves a new one.

      Parameters

      • OptionalstorageAdapter: any

        Must implement async loadKey() and async saveKey(bytes)

      Returns Promise<Identity>

    • Get a truncated SHA-256 hash of passed data.

      Parameters

      • data: Uint8Array<ArrayBufferLike>

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Validates an announce exactly like RNS/Identity.py::validate_announce (SPEC.md §4.5 steps 1-3).

      Parses the announce body — branching on contextFlag so a ratchet-bearing announce shifts the signature 32 bytes deeper (§4.5 step 1) — verifies the Ed25519 signature over the §4.2 signed_data (step 2), and recomputes the destination hash from (name_hash, public_key) to confirm it matches the outer packet header (step 3).

      The caller is responsible for the §4.5 step 4 public-key collision check and step 6 caching, since those touch Destination.knownDestinations.

      Parameters

      • destinationHash: Uint8Array<ArrayBufferLike>

        16-byte dest_hash from the outer packet header.

      • contextFlag: boolean

        the packet header's context_flag bit (ratchet present).

      • data: Uint8Array<ArrayBufferLike>

        the announce body (packet payload).

      Returns Promise<AnnounceValidation | null>

      null on any validation failure.