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

    Class EncryptedMessage

    Encrypted message with ChaCha20-Poly1305 AEAD

    A secure encrypted message using IETF ChaCha20-Poly1305 authenticated encryption.

    EncryptedMessage represents data that has been encrypted using a symmetric key with the ChaCha20-Poly1305 AEAD (Authenticated Encryption with Associated Data) construction as specified in RFC-8439.

    An EncryptedMessage contains:

    • ciphertext: The encrypted data (same length as the original plaintext)
    • aad: Additional Authenticated Data that is not encrypted but is authenticated (optional)
    • nonce: A 12-byte number used once for this specific encryption operation
    • auth: A 16-byte authentication tag that verifies the integrity of the message

    The aad field is often used to include the Digest of the plaintext, which allows verification of the plaintext after decryption and preserves the unique identity of the data when used with structures like Gordian Envelope.

    CBOR Serialization

    EncryptedMessage is serialized to CBOR with tag 40002.

    CDDL:

    EncryptedMessage =
        #6.40002([ ciphertext: bstr, nonce: bstr, auth: bstr, ? aad: bstr ])
    

    UR Serialization

    When serialized as a Uniform Resource (UR), an EncryptedMessage is represented with the type "encrypted".

    Implements

    • ToCbor
    • ToUR
    Index
    • Assemble a message from its parts (no encryption happens here).

      Parameters

      • __namedParameters: {
            ciphertext: Uint8Array;
            nonce: Nonce;
            authTag: Uint8Array<ArrayBufferLike> | AuthenticationTag;
            aad?: Uint8Array<ArrayBufferLike>;
        }

      Returns EncryptedMessage

    • Returns the untagged CBOR encoding (as an array). Array format: [ciphertext, nonce, auth, ?aad]

      Returns Cbor