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

    Class XID

    eXtensible Identifier (XID) - 32-byte identifier bound to a public key

    A XID is a unique 32-byte identifier for a subject entity (person, organization, device, or any other entity). XIDs have the following characteristics:

    • They're cryptographically tied to a public key at inception (the "inception key")
    • They remain stable throughout their lifecycle even as their keys and permissions change
    • They can be extended to XID documents containing keys, endpoints, permissions, and delegation info
    • They support key rotation and multiple verification schemes
    • They allow for delegation of specific permissions to other entities
    • They can include resolution methods to locate and verify the XID document

    A XID is created by taking the SHA-256 hash of the CBOR encoding of a public signing key. This ensures the XID is cryptographically tied to the key.

    As defined in BCR-2024-010.

    CBOR Serialization

    XID is serialized to CBOR with tag 40024 (standard XID tag).

    UR Serialization

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

    Implements

    Index
    XID_SIZE: number = XID_SIZE

    The byte length of a XID.

    • get bytes(): Uint8Array

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

      Returns Uint8Array

    • Create a new XID from data.

      Parameters

      • data: Uint8Array

      Returns XID

    • Create an XID from hex string (64 hex characters).

      Parameters

      • hex: string

      Returns XID

    • Generate a random XID (for testing purposes).

      Note: In practice, XIDs should be created from the SHA-256 hash of a public signing key's CBOR encoding.

      Parameters

      • __namedParameters: RngOptions = {}

      Returns XID

    • Validate the XID against the given public key.

      Returns true if the SHA-256 hash of the key's CBOR encoding matches the XID data. This matches the reference implementation's XID::validate(&self, key: &SigningPublicKey).

      Parameters

      Returns boolean

    • Get hex string representation (lowercase, as the reference implementation does implementation).

      Returns string

    • Get base64 representation.

      Returns string

    • Get short description (first 4 bytes) as hex.

      Returns string

    • Get short reference (first 4 bytes) as hex (alias for shortDescription).

      Returns string

    • Get the first four bytes of the XID as upper-case ByteWords.

      Parameters

      • prefix: boolean = false

        If true, prepends the XID prefix "🅧 "

      Returns string

      Space-separated uppercase bytewords, e.g., "🅧 URGE DICE GURU IRIS"

    • Get the first four bytes of the XID as Bytemoji.

      Parameters

      • prefix: boolean = false

        If true, prepends the XID prefix "🅧 "

      Returns string

      Space-separated emojis, e.g., "🅧 🐻 😻 🍞 💐"

    • ReferenceProvider impl — produces a Reference whose 32 bytes are the raw XID data.

      Reference { Reference::from_data(*self.bytes) } }` — note this is a direct wrap, not a SHA-256 hash of the XID.

      Returns Reference

    • Compare with another XID.

      Parameters

      Returns boolean

    • Get string representation (short format, as the reference implementation does Display). Uses first 4 bytes of the XID as hex, e.g., "XID(71274df1)".

      Returns string

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

      Returns Tag[]

    • Returns the untagged CBOR encoding (as a byte string).

      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

      • cbor: Cbor

      Returns XID