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

    Class ARID

    An "Apparently Random Identifier" (ARID)

    An ARID is a cryptographically strong, universally unique identifier with the following properties:

    • Non-correlatability: The sequence of bits cannot be correlated with its referent or any other ARID
    • Neutral semantics: Contains no inherent type information
    • Open generation: Any method of generation is allowed as long as it produces statistically random bits
    • Minimum strength: Must be 256 bits (32 bytes) in length
    • Cryptographic suitability: Can be used as inputs to cryptographic constructs

    Unlike digests/hashes which identify a fixed, immutable state of data, ARIDs can serve as stable identifiers for mutable data structures.

    ARIDs should not be confused with or cast to/from other identifier types (like UUIDs), used as nonces, keys, or cryptographic seeds.

    As defined in BCR-2022-002.

    CBOR Serialization

    ARID implements the CBOR tagged encoding interfaces, which means it can be serialized to and deserialized from CBOR with a specific tag (TAG_ARID = 40012).

    UR Serialization

    When serialized as a Uniform Resource (UR), an ARID is represented as a binary blob with the type "arid".

    import { ARID } from '@blockchaincommons/components';

    // Create a new random ARID
    const arid = ARID.random();

    // Create an ARID from a hex string
    const arid2 = ARID.fromHex("...");

    // Get the ARID as hex
    console.log(arid.toHex());

    Implements

    • ToCbor
    • ToUR
    Index
    ARID_SIZE: 32

    The byte length of an ARID.

    • get bytes(): Uint8Array

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

      Returns Uint8Array

    • A fresh random ARID; pass rng to make it deterministic.

      Parameters

      • __namedParameters: RngOptions = {}

      Returns ARID

    • Restore an ARID from a fixed-size array of bytes.

      Parameters

      • data: Uint8Array

      Returns ARID

    • Create a new ARID from the given hexadecimal string.

      Parameters

      • hex: string

      Returns ARID

      Error if the string is not exactly 64 hexadecimal digits.

    • The data as a hexadecimal string.

      Returns string

    • Get base64 representation.

      Returns string

    • The first four bytes of the ARID as a hexadecimal string.

      Returns string

    • Compare with another ARID.

      Parameters

      Returns boolean

    • Compare ARIDs lexicographically.

      Parameters

      Returns number

    • Get string representation.

      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 ARID