@umbra-privacy/sdk 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -25
- package/dist/{addresses-Brzgurv_.d.ts → addresses-B7HybtbJ.d.ts} +2 -1
- package/dist/{addresses-D_0YAS6B.d.cts → addresses-CTVY1oi7.d.cts} +2 -1
- package/dist/arcium-BXXlryfe.d.cts +20 -0
- package/dist/arcium-BXXlryfe.d.ts +20 -0
- package/dist/chunk-4RHXVBNI.js +203 -0
- package/dist/chunk-4RHXVBNI.js.map +1 -0
- package/dist/chunk-4TZVXB5G.js +324 -0
- package/dist/chunk-4TZVXB5G.js.map +1 -0
- package/dist/chunk-5GUSMQ74.cjs +549 -0
- package/dist/chunk-5GUSMQ74.cjs.map +1 -0
- package/dist/chunk-5KPQXPQM.js +36 -0
- package/dist/chunk-5KPQXPQM.js.map +1 -0
- package/dist/chunk-AXD7LXYY.cjs +405 -0
- package/dist/chunk-AXD7LXYY.cjs.map +1 -0
- package/dist/{chunk-HOEXDXRC.cjs → chunk-BL6WXLPV.cjs} +32 -360
- package/dist/chunk-BL6WXLPV.cjs.map +1 -0
- package/dist/chunk-CFFLOE7D.cjs +598 -0
- package/dist/chunk-CFFLOE7D.cjs.map +1 -0
- package/dist/{chunk-BM7N6N7E.js → chunk-CFTW5WNG.js} +3 -325
- package/dist/chunk-CFTW5WNG.js.map +1 -0
- package/dist/chunk-DD2WCK4C.js +327 -0
- package/dist/chunk-DD2WCK4C.js.map +1 -0
- package/dist/chunk-DMPMQ74B.cjs +246 -0
- package/dist/chunk-DMPMQ74B.cjs.map +1 -0
- package/dist/{chunk-2Q75CQQJ.js → chunk-EEKF4553.js} +2 -2
- package/dist/chunk-EEKF4553.js.map +1 -0
- package/dist/chunk-ENVYYEM4.cjs +113 -0
- package/dist/chunk-ENVYYEM4.cjs.map +1 -0
- package/dist/chunk-FQX6ZYGJ.js +500 -0
- package/dist/chunk-FQX6ZYGJ.js.map +1 -0
- package/dist/chunk-FSK2ICMB.cjs +39 -0
- package/dist/chunk-FSK2ICMB.cjs.map +1 -0
- package/dist/chunk-FZYWLQAF.cjs +355 -0
- package/dist/chunk-FZYWLQAF.cjs.map +1 -0
- package/dist/chunk-GP26R377.js +436 -0
- package/dist/chunk-GP26R377.js.map +1 -0
- package/dist/chunk-HA5FLM63.js +393 -0
- package/dist/chunk-HA5FLM63.js.map +1 -0
- package/dist/chunk-INJ73LXQ.js +1107 -0
- package/dist/chunk-INJ73LXQ.js.map +1 -0
- package/dist/chunk-JPDF7BIT.cjs +10892 -0
- package/dist/chunk-JPDF7BIT.cjs.map +1 -0
- package/dist/{chunk-MDFSBU5W.cjs → chunk-LTCKPTZC.cjs} +2 -351
- package/dist/chunk-LTCKPTZC.cjs.map +1 -0
- package/dist/chunk-MKNCBUFA.js +564 -0
- package/dist/chunk-MKNCBUFA.js.map +1 -0
- package/dist/chunk-NKVMSABR.cjs +207 -0
- package/dist/chunk-NKVMSABR.cjs.map +1 -0
- package/dist/chunk-OFDWNWCL.js +70 -0
- package/dist/chunk-OFDWNWCL.js.map +1 -0
- package/dist/chunk-QJAUUYZU.cjs +331 -0
- package/dist/chunk-QJAUUYZU.cjs.map +1 -0
- package/dist/chunk-RVUYPKKD.js +10750 -0
- package/dist/chunk-RVUYPKKD.js.map +1 -0
- package/dist/chunk-TLR7A64G.js +103 -0
- package/dist/chunk-TLR7A64G.js.map +1 -0
- package/dist/{chunk-MVKTV3FT.cjs → chunk-TQQZGNOI.cjs} +2 -2
- package/dist/chunk-TQQZGNOI.cjs.map +1 -0
- package/dist/chunk-UOFYS6M3.js +219 -0
- package/dist/chunk-UOFYS6M3.js.map +1 -0
- package/dist/chunk-UXMQI6B7.js +2406 -0
- package/dist/chunk-UXMQI6B7.js.map +1 -0
- package/dist/chunk-WN75ORDT.js +571 -0
- package/dist/chunk-WN75ORDT.js.map +1 -0
- package/dist/chunk-Y55PYKXH.cjs +595 -0
- package/dist/chunk-Y55PYKXH.cjs.map +1 -0
- package/dist/chunk-YEZBTYCP.cjs +77 -0
- package/dist/chunk-YEZBTYCP.cjs.map +1 -0
- package/dist/chunk-ZQOIYCGA.cjs +1126 -0
- package/dist/chunk-ZQOIYCGA.cjs.map +1 -0
- package/dist/chunk-ZY3TSHMJ.cjs +2665 -0
- package/dist/chunk-ZY3TSHMJ.cjs.map +1 -0
- package/dist/client-DkVBHMWb.d.cts +2613 -0
- package/dist/client-V4AF6Bz9.d.ts +2613 -0
- package/dist/common/pda/index.cjs +145 -0
- package/dist/common/pda/index.cjs.map +1 -0
- package/dist/common/pda/index.d.cts +1250 -0
- package/dist/common/pda/index.d.ts +1250 -0
- package/dist/common/pda/index.js +8 -0
- package/dist/common/pda/index.js.map +1 -0
- package/dist/constants/index.cjs +38 -164
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +8 -425
- package/dist/constants/index.d.ts +8 -425
- package/dist/constants/index.js +15 -124
- package/dist/constants/index.js.map +1 -1
- package/dist/crypto/index.cjs +583 -0
- package/dist/crypto/index.cjs.map +1 -0
- package/dist/crypto/index.d.cts +6731 -0
- package/dist/crypto/index.d.ts +6731 -0
- package/dist/crypto/index.js +14 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/{cryptography-BTGC72u-.d.ts → cryptography-BFSJcvi6.d.ts} +3 -2465
- package/dist/{cryptography-BTGC72u-.d.cts → cryptography-D6tPDh-Y.d.cts} +3 -2465
- package/dist/errors/index.cjs +64 -54
- package/dist/errors/index.d.cts +7 -797
- package/dist/errors/index.d.ts +7 -797
- package/dist/errors/index.js +3 -1
- package/dist/errors-B9EoPeWV.d.cts +593 -0
- package/dist/errors-B9EoPeWV.d.ts +593 -0
- package/dist/errors-DAIrstEL.d.cts +300 -0
- package/dist/errors-DPNMfyh0.d.ts +300 -0
- package/dist/index-BG0yjL7C.d.cts +6006 -0
- package/dist/index-ByynoyBO.d.ts +6006 -0
- package/dist/index.cjs +5126 -16118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1031 -7685
- package/dist/index.d.ts +1031 -7685
- package/dist/index.js +3219 -14905
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.cts +14 -6
- package/dist/interfaces/index.d.ts +14 -6
- package/dist/interfaces-43cReBcS.d.cts +3346 -0
- package/dist/interfaces-B8xKNl_6.d.ts +997 -0
- package/dist/interfaces-D2NO6kDD.d.cts +997 -0
- package/dist/interfaces-z_xYJlgV.d.ts +3346 -0
- package/dist/math/index.cjs +115 -0
- package/dist/math/index.cjs.map +1 -0
- package/dist/math/index.d.cts +1327 -0
- package/dist/math/index.d.ts +1327 -0
- package/dist/math/index.js +10 -0
- package/dist/math/index.js.map +1 -0
- package/dist/networks-RMd3abPE.d.ts +44 -0
- package/dist/networks-yAoO8peQ.d.cts +44 -0
- package/dist/relayer-NRRMSMNB.js +4 -0
- package/dist/relayer-NRRMSMNB.js.map +1 -0
- package/dist/relayer-RJHEIXJG.cjs +21 -0
- package/dist/relayer-RJHEIXJG.cjs.map +1 -0
- package/dist/solana/index.cjs +56 -0
- package/dist/solana/index.cjs.map +1 -0
- package/dist/solana/index.d.cts +105 -0
- package/dist/solana/index.d.ts +105 -0
- package/dist/solana/index.js +7 -0
- package/dist/solana/index.js.map +1 -0
- package/dist/{index-CLj_zWSD.d.ts → temporal-BbRaEPoO.d.ts} +1 -1
- package/dist/{index-CX6_pIRS.d.cts → temporal-oUj7iCaq.d.cts} +1 -1
- package/dist/transaction-forwarder-5mAMTjw6.d.ts +1155 -0
- package/dist/transaction-forwarder-C6gMUG7a.d.cts +1155 -0
- package/dist/types/index.cjs +232 -231
- package/dist/types/index.d.cts +15 -1485
- package/dist/types/index.d.ts +15 -1485
- package/dist/types/index.js +2 -1
- package/dist/types-BohhvPth.d.cts +87 -0
- package/dist/types-CW0oTT0j.d.ts +87 -0
- package/dist/types-C_V_CaKK.d.cts +2468 -0
- package/dist/types-C_V_CaKK.d.ts +2468 -0
- package/dist/types-Ca7frykr.d.ts +793 -0
- package/dist/types-CuKeoI19.d.cts +1296 -0
- package/dist/types-CxfTIpN9.d.ts +1052 -0
- package/dist/{types-n-sHFcgr.d.ts → types-D1jDUjfN.d.ts} +2 -2
- package/dist/types-DKEDUlH9.d.ts +1296 -0
- package/dist/types-EKuIfxTz.d.cts +1052 -0
- package/dist/{types-BBuELtY8.d.cts → types-IMGYmlv-.d.cts} +2 -2
- package/dist/types-PwNLi_2k.d.cts +793 -0
- package/dist/utils/index.cjs +823 -525
- package/dist/utils/index.d.cts +1711 -4021
- package/dist/utils/index.d.ts +1711 -4021
- package/dist/utils/index.js +9 -3
- package/dist/{versions-D9PqsEvj.d.cts → versions-BRlR36EA.d.cts} +1 -0
- package/dist/{versions-D9PqsEvj.d.ts → versions-BRlR36EA.d.ts} +1 -0
- package/package.json +79 -18
- package/dist/chunk-2Q75CQQJ.js.map +0 -1
- package/dist/chunk-BM7N6N7E.js.map +0 -1
- package/dist/chunk-GXKSUB2U.cjs +0 -4416
- package/dist/chunk-GXKSUB2U.cjs.map +0 -1
- package/dist/chunk-HOEXDXRC.cjs.map +0 -1
- package/dist/chunk-MDFSBU5W.cjs.map +0 -1
- package/dist/chunk-MQY7HDIA.js +0 -600
- package/dist/chunk-MQY7HDIA.js.map +0 -1
- package/dist/chunk-MVKTV3FT.cjs.map +0 -1
- package/dist/chunk-PG2J6V6Y.js +0 -4094
- package/dist/chunk-PG2J6V6Y.js.map +0 -1
- package/dist/chunk-VEGLTTYQ.cjs +0 -621
- package/dist/chunk-VEGLTTYQ.cjs.map +0 -1
- package/dist/chunk-WVHQ46DD.js +0 -758
- package/dist/chunk-WVHQ46DD.js.map +0 -1
- package/dist/index-B9pDY73x.d.ts +0 -12933
- package/dist/index-D33yo0qB.d.cts +0 -12933
- package/dist/networks-C-orpSFW.d.ts +0 -65
- package/dist/networks-FxYERGD1.d.cts +0 -65
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/types.ts","../src/types/cry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A,YAAA,EAAc,QAAA;AAAA,QACd,UAAA,EAAY,GAAG,MAAA,CAAO,UAAU,CAAC,CAAA,aAAA,EAAgB,MAAA,CAAO,UAAU,CAAC,CAAA;AAAA;AACrE,KACF;AAAA,EACF;AACF;AAjBgB,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA;AA6DT,SAAS,aAAa,KAAA,EAAwC;AACnE,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,MAAM,IAAI,sBAAA,CAAuB,CAAA,qBAAA,EAAwB,OAAO,KAAK,CAAA,CAAA,EAAI;AAAA,MACvE,KAAA;AAAA,MACA,YAAA,EAAc;AAAA,KACf,CAAA;AAAA,EACH;AACA,EAAA,IAAI,KAAA,GAAQ,UAAA,IAAc,KAAA,GAAQ,UAAA,EAAY;AAC5C,IAAA,MAAM,IAAI,sBAAA;AAAA,MACR,4BAA4B,MAAA,CAAO,UAAU,CAAC,CAAA,EAAA,EAAK,MAAA,CAAO,UAAU,CAAC,CAAA,CAAA,CAAA;AAAA,MACrE;AAAA,QACE,KAAA;AAAA,QACA,YAAA,EAAc,QAAA;AAAA,QACd,UAAA,EAAY,GAAG,MAAA,CAAO,UAAU,CAAC,CAAA,aAAA,EAAgB,MAAA,CAAO,UAAU,CAAC,CAAA;AAAA;AACrE,KACF;AAAA,EACF;AACF;AAjBgB,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA","file":"chunk-BM7N6N7E.js","sourcesContent":["/**\n * Mathematics Types Module\n *\n * This module provides a comprehensive set of branded types and runtime assertions\n * for mathematical primitives used throughout the SDK. These types ensure compile-time\n * safety by preventing accidental mixing of incompatible numeric representations.\n *\n * ## Overview\n *\n * The module is organized into several categories:\n *\n * ### Byte Array Types\n * - **Base types**: `LeBytes` (little-endian), `BeBytes` (big-endian)\n * - **Sized types**: `U8LeBytes`, `U16LeBytes`, ..., `U1024LeBytes` (and BE equivalents)\n *\n * ### Integer Types\n * - **Unsigned**: `U8`, `U16`, `U32`, `U64`, `U128`, `U256`, `U512`, `U1024`\n * - **Signed**: `I8`, `I16`, `I32`, `I64`, `I128`, `I256`, `I512`, `I1024`\n *\n * ### Constants\n * - Maximum values for unsigned types (`U8_MAX`, `U16_MAX`, etc.)\n * - Min/max values for signed types (`I8_MIN`, `I8_MAX`, etc.)\n * - Byte lengths for sized arrays (`U8_BYTE_LENGTH`, etc.)\n *\n * ### Assertion Functions\n * - Runtime validation functions that throw `MathematicsAssertionError` on failure\n * - Return branded types on success for type-safe usage\n *\n * ## Usage Example\n *\n * ```typescript\n * import { assertU256, assertU256LeBytes, U256, U256LeBytes } from \"./mathematics\";\n *\n * // Validate and brand a bigint as U256\n * const value: U256 = assertU256(12345n);\n *\n * // Validate and brand a byte array\n * const bytes: U256LeBytes = assertU256LeBytes(new Uint8Array(32));\n *\n * // Type errors are caught at compile time\n * function processU256(value: U256): void { ... }\n * processU256(12345n); // Error: bigint is not assignable to U256\n * processU256(assertU256(12345n)); // OK\n * ```\n *\n * @module types/mathematics\n * @see {@link ./branded} for the underlying branded type utilities\n * @packageDocumentation\n */\n\nimport type { BrandedType, SubBrandedType, SubSubBrandedType } from \"./branded\";\n\n/* =============================================================================\n * BYTE ARRAY TYPES\n *\n * These types represent raw byte arrays with explicit endianness.\n * Endianness determines how multi-byte values are stored in memory:\n * - Little-endian: Least significant byte first (x86/x64, ARM)\n * - Big-endian: Most significant byte first (network byte order)\n * ============================================================================= */\n\n/**\n * Generic branded byte array base type.\n *\n * This is the root type for all byte array types in the SDK.\n * All specialized byte array types (LeBytes, BeBytes, X25519Bytes, etc.)\n * derive from this type.\n *\n * Use this type when:\n * - Endianness is not relevant to the operation\n * - Endianness is handled externally\n * - Working with raw binary data without numeric interpretation\n *\n * @example\n * ```typescript\n * function hashBytes(data: Bytes): Bytes {\n * // Endianness doesn't matter for hashing\n * return sha256(data);\n * }\n * ```\n *\n * @public\n */\nexport type Bytes = BrandedType<Uint8Array, \"Bytes\">;\n\n/**\n * Little-endian byte array base type.\n *\n * Little-endian format stores the **least significant byte first**.\n * This is the native byte order for:\n * - x86 and x64 processors (Intel, AMD)\n * - ARM processors (in little-endian mode)\n * - Most modern desktop and mobile CPUs\n *\n * @remarks\n * Little-endian is often more efficient for arithmetic operations\n * as the least significant bytes can be processed first.\n *\n * @example\n * ```typescript\n * // The 32-bit number 0x12345678 in little-endian:\n * // Memory layout: [0x78, 0x56, 0x34, 0x12]\n * // LSB MSB\n * const leBytes = assertLeBytes(new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n *\n * // Converting to number (conceptually):\n * // 0x78 + (0x56 << 8) + (0x34 << 16) + (0x12 << 24) = 0x12345678\n * ```\n *\n * @see {@link BeBytes} for big-endian representation\n * @public\n */\nexport type LeBytes = SubBrandedType<Bytes, \"LeBytes\">;\n\n/**\n * Big-endian byte array base type.\n *\n * Big-endian format stores the **most significant byte first**.\n * This is used in:\n * - Network protocols (TCP/IP) - hence \"network byte order\"\n * - Many file formats (JPEG, PNG headers)\n * - Java's DataInputStream/DataOutputStream\n * - Most cryptographic specifications\n *\n * @remarks\n * Big-endian is often more human-readable as bytes appear in the\n * same order as the hexadecimal representation.\n *\n * @example\n * ```typescript\n * // The 32-bit number 0x12345678 in big-endian:\n * // Memory layout: [0x12, 0x34, 0x56, 0x78]\n * // MSB LSB\n * const beBytes = assertBeBytes(new Uint8Array([0x12, 0x34, 0x56, 0x78]));\n *\n * // The hex string \"12345678\" maps directly to bytes\n * ```\n *\n * @see {@link LeBytes} for little-endian representation\n * @public\n */\nexport type BeBytes = SubBrandedType<Bytes, \"BeBytes\">;\n\n/* =============================================================================\n * LITTLE-ENDIAN SIZED BYTE ARRAYS\n *\n * These types represent fixed-size byte arrays in little-endian format.\n * The size is encoded in the type name (e.g., U32LeBytes = 4 bytes).\n * ============================================================================= */\n\n/**\n * 8-bit (1 byte) little-endian byte array.\n *\n * Represents a single byte, which is endianness-agnostic.\n * Included for API consistency with larger sizes.\n *\n * @remarks\n * - Size: 1 byte\n * - Value range: [0, 255] (0x00 to 0xFF)\n *\n * @example\n * ```typescript\n * const byte = assertU8LeBytes(new Uint8Array([0xFF]));\n * // Represents the value 255\n * ```\n *\n * @see {@link assertU8LeBytes}\n * @public\n */\nexport type U8LeBytes = SubSubBrandedType<LeBytes, \"U8LeBytes\">;\n\n/**\n * 16-bit (2 bytes) little-endian byte array.\n *\n * @remarks\n * - Size: 2 bytes\n * - Value range: [0, 65,535] (0x0000 to 0xFFFF)\n *\n * @example\n * ```typescript\n * // Value 0x1234 in little-endian\n * const bytes = assertU16LeBytes(new Uint8Array([0x34, 0x12]));\n * ```\n *\n * @see {@link assertU16LeBytes}\n * @public\n */\nexport type U16LeBytes = SubSubBrandedType<LeBytes, \"U16LeBytes\">;\n\n/**\n * 32-bit (4 bytes) little-endian byte array.\n *\n * @remarks\n * - Size: 4 bytes\n * - Value range: [0, 4,294,967,295] (0x00000000 to 0xFFFFFFFF)\n * - Common use: IPv4 addresses, 32-bit hashes, timestamps\n *\n * @example\n * ```typescript\n * // Value 0x12345678 in little-endian\n * const bytes = assertU32LeBytes(new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * ```\n *\n * @see {@link assertU32LeBytes}\n * @public\n */\nexport type U32LeBytes = SubSubBrandedType<LeBytes, \"U32LeBytes\">;\n\n/**\n * 64-bit (8 bytes) little-endian byte array.\n *\n * @remarks\n * - Size: 8 bytes\n * - Value range: [0, 2^64 - 1]\n * - Common use: Timestamps with nanosecond precision, large counters\n *\n * @example\n * ```typescript\n * const bytes = assertU64LeBytes(new Uint8Array(8));\n * ```\n *\n * @see {@link assertU64LeBytes}\n * @public\n */\nexport type U64LeBytes = SubSubBrandedType<LeBytes, \"U64LeBytes\">;\n\n/**\n * 128-bit (16 bytes) little-endian byte array.\n *\n * @remarks\n * - Size: 16 bytes\n * - Value range: [0, 2^128 - 1]\n * - Common use: UUIDs, AES block size\n *\n * @example\n * ```typescript\n * const bytes = assertU128LeBytes(new Uint8Array(16));\n * ```\n *\n * @see {@link assertU128LeBytes}\n * @public\n */\nexport type U128LeBytes = SubSubBrandedType<LeBytes, \"U128LeBytes\">;\n\n/**\n * 256-bit (32 bytes) little-endian byte array.\n *\n * @remarks\n * - Size: 32 bytes\n * - Value range: [0, 2^256 - 1]\n * - Common use: SHA-256 hashes, elliptic curve scalars, private keys\n *\n * @example\n * ```typescript\n * // A 256-bit cryptographic scalar\n * const scalar = assertU256LeBytes(new Uint8Array(32));\n * ```\n *\n * @see {@link assertU256LeBytes}\n * @public\n */\nexport type U256LeBytes = SubSubBrandedType<LeBytes, \"U256LeBytes\">;\n\n/**\n * 512-bit (64 bytes) little-endian byte array.\n *\n * @remarks\n * - Size: 64 bytes\n * - Value range: [0, 2^512 - 1]\n * - Common use: SHA-512 hashes, extended keys\n *\n * @example\n * ```typescript\n * const bytes = assertU512LeBytes(new Uint8Array(64));\n * ```\n *\n * @see {@link assertU512LeBytes}\n * @public\n */\nexport type U512LeBytes = SubSubBrandedType<LeBytes, \"U512LeBytes\">;\n\n/**\n * 1024-bit (128 bytes) little-endian byte array.\n *\n * @remarks\n * - Size: 128 bytes\n * - Value range: [0, 2^1024 - 1]\n * - Common use: RSA keys, large cryptographic values\n *\n * @example\n * ```typescript\n * const bytes = assertU1024LeBytes(new Uint8Array(128));\n * ```\n *\n * @see {@link assertU1024LeBytes}\n * @public\n */\nexport type U1024LeBytes = SubSubBrandedType<LeBytes, \"U1024LeBytes\">;\n\n/* =============================================================================\n * BIG-ENDIAN SIZED BYTE ARRAYS\n *\n * These types represent fixed-size byte arrays in big-endian format.\n * Commonly used in network protocols and cryptographic standards.\n * ============================================================================= */\n\n/**\n * 8-bit (1 byte) big-endian byte array.\n *\n * Represents a single byte, which is endianness-agnostic.\n * Included for API consistency with larger sizes.\n *\n * @remarks\n * - Size: 1 byte\n * - Value range: [0, 255] (0x00 to 0xFF)\n *\n * @example\n * ```typescript\n * const byte = assertU8BeBytes(new Uint8Array([0xFF]));\n * ```\n *\n * @see {@link assertU8BeBytes}\n * @public\n */\nexport type U8BeBytes = SubSubBrandedType<BeBytes, \"U8BeBytes\">;\n\n/**\n * 16-bit (2 bytes) big-endian byte array.\n *\n * @remarks\n * - Size: 2 bytes\n * - Value range: [0, 65,535]\n * - Common use: Network port numbers, protocol headers\n *\n * @example\n * ```typescript\n * // Value 0x1234 in big-endian (network byte order)\n * const bytes = assertU16BeBytes(new Uint8Array([0x12, 0x34]));\n * ```\n *\n * @see {@link assertU16BeBytes}\n * @public\n */\nexport type U16BeBytes = SubSubBrandedType<BeBytes, \"U16BeBytes\">;\n\n/**\n * 32-bit (4 bytes) big-endian byte array.\n *\n * @remarks\n * - Size: 4 bytes\n * - Value range: [0, 4,294,967,295]\n * - Common use: Network addresses, protocol fields\n *\n * @example\n * ```typescript\n * // Value 0x12345678 in big-endian\n * const bytes = assertU32BeBytes(new Uint8Array([0x12, 0x34, 0x56, 0x78]));\n * ```\n *\n * @see {@link assertU32BeBytes}\n * @public\n */\nexport type U32BeBytes = SubSubBrandedType<BeBytes, \"U32BeBytes\">;\n\n/**\n * 64-bit (8 bytes) big-endian byte array.\n *\n * @remarks\n * - Size: 8 bytes\n * - Value range: [0, 2^64 - 1]\n *\n * @example\n * ```typescript\n * const bytes = assertU64BeBytes(new Uint8Array(8));\n * ```\n *\n * @see {@link assertU64BeBytes}\n * @public\n */\nexport type U64BeBytes = SubSubBrandedType<BeBytes, \"U64BeBytes\">;\n\n/**\n * 128-bit (16 bytes) big-endian byte array.\n *\n * @remarks\n * - Size: 16 bytes\n * - Value range: [0, 2^128 - 1]\n * - Common use: UUIDs in standard format, IPv6 addresses\n *\n * @example\n * ```typescript\n * const bytes = assertU128BeBytes(new Uint8Array(16));\n * ```\n *\n * @see {@link assertU128BeBytes}\n * @public\n */\nexport type U128BeBytes = SubSubBrandedType<BeBytes, \"U128BeBytes\">;\n\n/**\n * 256-bit (32 bytes) big-endian byte array.\n *\n * @remarks\n * - Size: 32 bytes\n * - Value range: [0, 2^256 - 1]\n * - Common use: Ethereum addresses (20 bytes, but often padded), field elements\n *\n * @example\n * ```typescript\n * const bytes = assertU256BeBytes(new Uint8Array(32));\n * ```\n *\n * @see {@link assertU256BeBytes}\n * @public\n */\nexport type U256BeBytes = SubSubBrandedType<BeBytes, \"U256BeBytes\">;\n\n/**\n * 512-bit (64 bytes) big-endian byte array.\n *\n * @remarks\n * - Size: 64 bytes\n * - Value range: [0, 2^512 - 1]\n *\n * @example\n * ```typescript\n * const bytes = assertU512BeBytes(new Uint8Array(64));\n * ```\n *\n * @see {@link assertU512BeBytes}\n * @public\n */\nexport type U512BeBytes = SubSubBrandedType<BeBytes, \"U512BeBytes\">;\n\n/**\n * 1024-bit (128 bytes) big-endian byte array.\n *\n * @remarks\n * - Size: 128 bytes\n * - Value range: [0, 2^1024 - 1]\n *\n * @example\n * ```typescript\n * const bytes = assertU1024BeBytes(new Uint8Array(128));\n * ```\n *\n * @see {@link assertU1024BeBytes}\n * @public\n */\nexport type U1024BeBytes = SubSubBrandedType<BeBytes, \"U1024BeBytes\">;\n\n/* =============================================================================\n * INTEGER BASE TYPES\n *\n * These are the foundational integer types from which specific bit-width\n * integers derive. They use JavaScript's BigInt for arbitrary precision.\n * ============================================================================= */\n\n/**\n * Base type for all unsigned integers.\n *\n * Unsigned integers represent non-negative whole numbers (0, 1, 2, ...).\n * All specific unsigned integer types (`U8`, `U16`, etc.) are sub-brands of this type.\n *\n * @remarks\n * - Uses JavaScript's `BigInt` for arbitrary precision arithmetic\n * - No upper bound at the base type level (bounds are enforced by sub-types)\n * - Guaranteed to be non-negative (>= 0)\n *\n * ## Type Hierarchy\n * ```\n * bigint\n * └── UnsignedInteger (branded, value >= 0)\n * ├── U8 (0 to 255)\n * ├── U16 (0 to 65,535)\n * ├── U32 (0 to 4,294,967,295)\n * └── ...\n * ```\n *\n * @example\n * ```typescript\n * const value = assertUnsignedInteger(12345n);\n * // value is typed as UnsignedInteger\n *\n * // Can be assigned to functions expecting UnsignedInteger\n * function processUnsigned(n: UnsignedInteger): void { ... }\n * processUnsigned(value); // OK\n * ```\n *\n * @see {@link assertUnsignedInteger}\n * @public\n */\nexport type UnsignedInteger = BrandedType<bigint, \"UnsignedInteger\">;\n\n/**\n * Base type for all signed integers.\n *\n * Signed integers represent whole numbers including negatives (..., -2, -1, 0, 1, 2, ...).\n * All specific signed integer types (`I8`, `I16`, etc.) are sub-brands of this type.\n *\n * @remarks\n * - Uses JavaScript's `BigInt` for arbitrary precision arithmetic\n * - No bounds at the base type level (bounds are enforced by sub-types)\n * - Two's complement representation is assumed for negative values\n *\n * ## Two's Complement\n * Two's complement is the standard way computers represent signed integers:\n * - Positive numbers are represented normally\n * - Negative numbers: invert all bits and add 1\n * - Example (8-bit): -1 = 0xFF, -128 = 0x80\n *\n * ## Type Hierarchy\n * ```\n * bigint\n * └── SignedInteger (branded)\n * ├── I8 (-128 to 127)\n * ├── I16 (-32,768 to 32,767)\n * ├── I32 (-2,147,483,648 to 2,147,483,647)\n * └── ...\n * ```\n *\n * @example\n * ```typescript\n * const value = assertSignedInteger(-12345n);\n * // value is typed as SignedInteger\n * ```\n *\n * @see {@link assertSignedInteger}\n * @public\n */\nexport type SignedInteger = BrandedType<bigint, \"SignedInteger\">;\n\n/* =============================================================================\n * UNSIGNED INTEGER TYPES\n *\n * Fixed-width unsigned integer types. These types guarantee that values\n * fall within the specified bit-width range.\n * ============================================================================= */\n\n/**\n * 8-bit unsigned integer.\n *\n * @remarks\n * - Bit width: 8 bits (1 byte)\n * - Range: [0, 255] or [0x00, 0xFF]\n * - Max value: 2^8 - 1 = 255\n *\n * ## Common Uses\n * - Single byte values\n * - Color channel values (RGB)\n * - Character codes (ASCII)\n * - Small counters and flags\n *\n * @example\n * ```typescript\n * const red: U8 = assertU8(255n); // Maximum red\n * const green: U8 = assertU8(128n); // Medium green\n * const blue: U8 = assertU8(0n); // No blue\n * ```\n *\n * @see {@link assertU8}\n * @see {@link U8_MAX}\n * @public\n */\nexport type U8 = SubBrandedType<UnsignedInteger, \"U8\">;\n\n/**\n * 16-bit unsigned integer.\n *\n * @remarks\n * - Bit width: 16 bits (2 bytes)\n * - Range: [0, 65,535] or [0x0000, 0xFFFF]\n * - Max value: 2^16 - 1 = 65,535\n *\n * ## Common Uses\n * - Port numbers (0-65535)\n * - Unicode code points (BMP)\n * - Audio samples (16-bit PCM)\n * - Small array indices\n *\n * @example\n * ```typescript\n * const port: U16 = assertU16(443n); // HTTPS port\n * const sample: U16 = assertU16(32768n); // Audio sample\n * ```\n *\n * @see {@link assertU16}\n * @see {@link U16_MAX}\n * @public\n */\nexport type U16 = SubBrandedType<UnsignedInteger, \"U16\">;\n\n/**\n * 32-bit unsigned integer.\n *\n * @remarks\n * - Bit width: 32 bits (4 bytes)\n * - Range: [0, 4,294,967,295] or [0x00000000, 0xFFFFFFFF]\n * - Max value: 2^32 - 1 = 4,294,967,295 (~4.3 billion)\n *\n * ## Common Uses\n * - IPv4 addresses\n * - Unix timestamps (until 2038)\n * - Array indices\n * - Color values (RGBA packed)\n * - CRC32 checksums\n *\n * @example\n * ```typescript\n * const timestamp: U32 = assertU32(1704067200n); // 2024-01-01 00:00:00 UTC\n * const ipAddress: U32 = assertU32(0x7F000001n); // 127.0.0.1\n * ```\n *\n * @see {@link assertU32}\n * @see {@link U32_MAX}\n * @public\n */\nexport type U32 = SubBrandedType<UnsignedInteger, \"U32\">;\n\n/**\n * 64-bit unsigned integer.\n *\n * @remarks\n * - Bit width: 64 bits (8 bytes)\n * - Range: [0, 18,446,744,073,709,551,615]\n * - Max value: 2^64 - 1 (~18.4 quintillion)\n *\n * ## Common Uses\n * - High-precision timestamps (nanoseconds)\n * - File sizes\n * - Database primary keys\n * - Memory addresses\n * - Large counters\n *\n * @example\n * ```typescript\n * const nanoTimestamp: U64 = assertU64(1704067200000000000n);\n * const fileSize: U64 = assertU64(1099511627776n); // 1 TiB\n * ```\n *\n * @see {@link assertU64}\n * @see {@link U64_MAX}\n * @public\n */\nexport type U64 = SubBrandedType<UnsignedInteger, \"U64\">;\n\n/**\n * 128-bit unsigned integer.\n *\n * @remarks\n * - Bit width: 128 bits (16 bytes)\n * - Range: [0, 2^128 - 1]\n * - Max value: ~3.4 × 10^38\n *\n * ## Common Uses\n * - UUIDs (128-bit identifiers)\n * - IPv6 addresses\n * - Cryptographic nonces\n * - Very large counters\n *\n * @example\n * ```typescript\n * const uuid: U128 = assertU128(0x550e8400e29b41d4a716446655440000n);\n * ```\n *\n * @see {@link assertU128}\n * @see {@link U128_MAX}\n * @public\n */\nexport type U128 = SubBrandedType<UnsignedInteger, \"U128\">;\n\n/**\n * 256-bit unsigned integer.\n *\n * @remarks\n * - Bit width: 256 bits (32 bytes)\n * - Range: [0, 2^256 - 1]\n * - Max value: ~1.16 × 10^77\n *\n * ## Common Uses\n * - Elliptic curve field elements (BN254, secp256k1)\n * - Cryptographic scalars and private keys\n * - SHA-256 hash outputs\n * - Blockchain addresses and balances\n *\n * ## Cryptographic Significance\n * 256 bits provides approximately 128 bits of security for symmetric\n * operations and is the standard size for modern elliptic curves.\n *\n * @example\n * ```typescript\n * // A private key (256-bit scalar)\n * const privateKey: U256 = assertU256(\n * 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdefn\n * );\n *\n * // A SHA-256 hash interpreted as a number\n * const hashValue: U256 = assertU256(hashAsNumber);\n * ```\n *\n * @see {@link assertU256}\n * @see {@link U256_MAX}\n * @public\n */\nexport type U256 = SubBrandedType<UnsignedInteger, \"U256\">;\n\n/**\n * 512-bit unsigned integer.\n *\n * @remarks\n * - Bit width: 512 bits (64 bytes)\n * - Range: [0, 2^512 - 1]\n *\n * ## Common Uses\n * - SHA-512 hash outputs\n * - Extended cryptographic keys\n * - Large field elements\n *\n * @example\n * ```typescript\n * const hash: U512 = assertU512(sha512HashValue);\n * ```\n *\n * @see {@link assertU512}\n * @see {@link U512_MAX}\n * @public\n */\nexport type U512 = SubBrandedType<UnsignedInteger, \"U512\">;\n\n/**\n * 1024-bit unsigned integer.\n *\n * @remarks\n * - Bit width: 1024 bits (128 bytes)\n * - Range: [0, 2^1024 - 1]\n *\n * ## Common Uses\n * - RSA key components\n * - Very large cryptographic values\n * - Pairing-based cryptography\n *\n * @example\n * ```typescript\n * const rsaModulus: U1024 = assertU1024(modulusValue);\n * ```\n *\n * @see {@link assertU1024}\n * @see {@link U1024_MAX}\n * @public\n */\nexport type U1024 = SubBrandedType<UnsignedInteger, \"U1024\">;\n\n/* =============================================================================\n * SIGNED INTEGER TYPES\n *\n * Fixed-width signed integer types using two's complement representation.\n * These types guarantee that values fall within the specified bit-width range.\n * ============================================================================= */\n\n/**\n * 8-bit signed integer.\n *\n * @remarks\n * - Bit width: 8 bits (1 byte)\n * - Range: [-128, 127] or [-2^7, 2^7 - 1]\n * - Uses two's complement representation\n *\n * ## Two's Complement Values\n * - 0x00 = 0\n * - 0x7F = 127 (maximum positive)\n * - 0x80 = -128 (minimum negative)\n * - 0xFF = -1\n *\n * @example\n * ```typescript\n * const positive: I8 = assertI8(127n);\n * const negative: I8 = assertI8(-128n);\n * const zero: I8 = assertI8(0n);\n * ```\n *\n * @see {@link assertI8}\n * @see {@link I8_MIN}\n * @see {@link I8_MAX}\n * @public\n */\nexport type I8 = SubBrandedType<SignedInteger, \"I8\">;\n\n/**\n * 16-bit signed integer.\n *\n * @remarks\n * - Bit width: 16 bits (2 bytes)\n * - Range: [-32,768, 32,767] or [-2^15, 2^15 - 1]\n * - Uses two's complement representation\n *\n * ## Common Uses\n * - Audio samples (16-bit signed PCM)\n * - Small offsets and deltas\n *\n * @example\n * ```typescript\n * const audioSample: I16 = assertI16(-16384n);\n * ```\n *\n * @see {@link assertI16}\n * @see {@link I16_MIN}\n * @see {@link I16_MAX}\n * @public\n */\nexport type I16 = SubBrandedType<SignedInteger, \"I16\">;\n\n/**\n * 32-bit signed integer.\n *\n * @remarks\n * - Bit width: 32 bits (4 bytes)\n * - Range: [-2,147,483,648, 2,147,483,647] or [-2^31, 2^31 - 1]\n * - Uses two's complement representation\n *\n * ## Common Uses\n * - General-purpose integers\n * - Array indices (with negative sentinel values)\n * - Differences and offsets\n *\n * @example\n * ```typescript\n * const offset: I32 = assertI32(-1000n);\n * const index: I32 = assertI32(42n);\n * ```\n *\n * @see {@link assertI32}\n * @see {@link I32_MIN}\n * @see {@link I32_MAX}\n * @public\n */\nexport type I32 = SubBrandedType<SignedInteger, \"I32\">;\n\n/**\n * 64-bit signed integer.\n *\n * @remarks\n * - Bit width: 64 bits (8 bytes)\n * - Range: [-9,223,372,036,854,775,808, 9,223,372,036,854,775,807]\n * - Range: [-2^63, 2^63 - 1]\n * - Uses two's complement representation\n *\n * ## Common Uses\n * - Large offsets and differences\n * - Signed timestamps\n * - Financial calculations (with appropriate scaling)\n *\n * @example\n * ```typescript\n * const difference: I64 = assertI64(-1000000000000n);\n * ```\n *\n * @see {@link assertI64}\n * @see {@link I64_MIN}\n * @see {@link I64_MAX}\n * @public\n */\nexport type I64 = SubBrandedType<SignedInteger, \"I64\">;\n\n/**\n * 128-bit signed integer.\n *\n * @remarks\n * - Bit width: 128 bits (16 bytes)\n * - Range: [-2^127, 2^127 - 1]\n * - Uses two's complement representation\n *\n * @example\n * ```typescript\n * const value: I128 = assertI128(-170141183460469231731687303715884105728n);\n * ```\n *\n * @see {@link assertI128}\n * @see {@link I128_MIN}\n * @see {@link I128_MAX}\n * @public\n */\nexport type I128 = SubBrandedType<SignedInteger, \"I128\">;\n\n/**\n * 256-bit signed integer.\n *\n * @remarks\n * - Bit width: 256 bits (32 bytes)\n * - Range: [-2^255, 2^255 - 1]\n * - Uses two's complement representation\n *\n * ## Common Uses\n * - Signed cryptographic values\n * - Large signed arithmetic\n *\n * @example\n * ```typescript\n * const signedScalar: I256 = assertI256(-12345678901234567890n);\n * ```\n *\n * @see {@link assertI256}\n * @see {@link I256_MIN}\n * @see {@link I256_MAX}\n * @public\n */\nexport type I256 = SubBrandedType<SignedInteger, \"I256\">;\n\n/**\n * 512-bit signed integer.\n *\n * @remarks\n * - Bit width: 512 bits (64 bytes)\n * - Range: [-2^511, 2^511 - 1]\n * - Uses two's complement representation\n *\n * @example\n * ```typescript\n * const value: I512 = assertI512(-1n);\n * ```\n *\n * @see {@link assertI512}\n * @see {@link I512_MIN}\n * @see {@link I512_MAX}\n * @public\n */\nexport type I512 = SubBrandedType<SignedInteger, \"I512\">;\n\n/**\n * 1024-bit signed integer.\n *\n * @remarks\n * - Bit width: 1024 bits (128 bytes)\n * - Range: [-2^1023, 2^1023 - 1]\n * - Uses two's complement representation\n *\n * @example\n * ```typescript\n * const value: I1024 = assertI1024(0n);\n * ```\n *\n * @see {@link assertI1024}\n * @see {@link I1024_MIN}\n * @see {@link I1024_MAX}\n * @public\n */\nexport type I1024 = SubBrandedType<SignedInteger, \"I1024\">;\n\n/* =============================================================================\n * CONSTANTS - UNSIGNED INTEGER BOUNDS\n *\n * Maximum values for each unsigned integer type.\n * These constants are used by assertion functions to validate ranges.\n * ============================================================================= */\n\n/**\n * Maximum value for an 8-bit unsigned integer.\n *\n * @remarks\n * - Value: 255 (0xFF)\n * - Formula: 2^8 - 1\n *\n * @example\n * ```typescript\n * if (value > U8_MAX) {\n * throw new Error(\"Value exceeds U8 range\");\n * }\n * ```\n *\n * @see {@link U8}\n * @public\n */\nexport const U8_MAX = 0xffn;\n\n/**\n * Maximum value for a 16-bit unsigned integer.\n *\n * @remarks\n * - Value: 65,535 (0xFFFF)\n * - Formula: 2^16 - 1\n *\n * @example\n * ```typescript\n * if (portNumber > U16_MAX) {\n * throw new Error(\"Port number exceeds U16 range\");\n * }\n * ```\n *\n * @see {@link U16}\n * @public\n */\nexport const U16_MAX = 0xff_ffn;\n\n/**\n * Maximum value for a 32-bit unsigned integer.\n *\n * @remarks\n * - Value: 4,294,967,295 (0xFFFFFFFF)\n * - Formula: 2^32 - 1\n *\n * @example\n * ```typescript\n * if (timestamp > U32_MAX) {\n * throw new Error(\"Timestamp exceeds U32 range (Year 2038 problem)\");\n * }\n * ```\n *\n * @see {@link U32}\n * @public\n */\nexport const U32_MAX = 0xff_ff_ff_ffn;\n\n/**\n * Maximum value for a 64-bit unsigned integer.\n *\n * @remarks\n * - Value: 18,446,744,073,709,551,615 (0xFFFFFFFFFFFFFFFF)\n * - Formula: 2^64 - 1\n *\n * @example\n * ```typescript\n * if (counter > U64_MAX) {\n * throw new Error(\"Counter exceeds U64 range\");\n * }\n * ```\n *\n * @see {@link U64}\n * @public\n */\nexport const U64_MAX = 0xff_ff_ff_ff_ff_ff_ff_ffn;\n\n/**\n * Maximum value for a 128-bit unsigned integer.\n *\n * @remarks\n * - Value: 2^128 - 1\n * - Approximately: 3.4 × 10^38\n *\n * @example\n * ```typescript\n * if (value > U128_MAX) {\n * throw new Error(\"Value exceeds U128 range\");\n * }\n * ```\n *\n * @see {@link U128}\n * @public\n */\nexport const U128_MAX = (1n << 128n) - 1n;\n\n/**\n * Maximum value for a 256-bit unsigned integer.\n *\n * @remarks\n * - Value: 2^256 - 1\n * - Approximately: 1.16 × 10^77\n * - This exceeds the estimated number of atoms in the observable universe\n *\n * @example\n * ```typescript\n * // Validate a field element is within BN254 range (BN254 prime < U256_MAX)\n * if (fieldElement > U256_MAX) {\n * throw new Error(\"Field element exceeds U256 range\");\n * }\n * ```\n *\n * @see {@link U256}\n * @public\n */\nexport const U256_MAX = (1n << 256n) - 1n;\n\n/**\n * Maximum value for a 512-bit unsigned integer.\n *\n * @remarks\n * - Value: 2^512 - 1\n *\n * @example\n * ```typescript\n * if (value > U512_MAX) {\n * throw new Error(\"Value exceeds U512 range\");\n * }\n * ```\n *\n * @see {@link U512}\n * @public\n */\nexport const U512_MAX = (1n << 512n) - 1n;\n\n/**\n * Maximum value for a 1024-bit unsigned integer.\n *\n * @remarks\n * - Value: 2^1024 - 1\n *\n * @example\n * ```typescript\n * if (rsaModulus > U1024_MAX) {\n * throw new Error(\"RSA modulus exceeds U1024 range\");\n * }\n * ```\n *\n * @see {@link U1024}\n * @public\n */\nexport const U1024_MAX = (1n << 1024n) - 1n;\n\n/* =============================================================================\n * CONSTANTS - SIGNED INTEGER BOUNDS\n *\n * Minimum and maximum values for each signed integer type.\n * Signed integers use two's complement representation.\n * ============================================================================= */\n\n/**\n * Minimum value for an 8-bit signed integer.\n *\n * @remarks\n * - Value: -128 (0x80 in two's complement)\n * - Formula: -2^7\n *\n * @see {@link I8}\n * @public\n */\nexport const I8_MIN = -(1n << 7n);\n\n/**\n * Maximum value for an 8-bit signed integer.\n *\n * @remarks\n * - Value: 127 (0x7F)\n * - Formula: 2^7 - 1\n *\n * @see {@link I8}\n * @public\n */\nexport const I8_MAX = (1n << 7n) - 1n;\n\n/**\n * Minimum value for a 16-bit signed integer.\n *\n * @remarks\n * - Value: -32,768\n * - Formula: -2^15\n *\n * @see {@link I16}\n * @public\n */\nexport const I16_MIN = -(1n << 15n);\n\n/**\n * Maximum value for a 16-bit signed integer.\n *\n * @remarks\n * - Value: 32,767\n * - Formula: 2^15 - 1\n *\n * @see {@link I16}\n * @public\n */\nexport const I16_MAX = (1n << 15n) - 1n;\n\n/**\n * Minimum value for a 32-bit signed integer.\n *\n * @remarks\n * - Value: -2,147,483,648\n * - Formula: -2^31\n *\n * @see {@link I32}\n * @public\n */\nexport const I32_MIN = -(1n << 31n);\n\n/**\n * Maximum value for a 32-bit signed integer.\n *\n * @remarks\n * - Value: 2,147,483,647\n * - Formula: 2^31 - 1\n *\n * @see {@link I32}\n * @public\n */\nexport const I32_MAX = (1n << 31n) - 1n;\n\n/**\n * Minimum value for a 64-bit signed integer.\n *\n * @remarks\n * - Value: -9,223,372,036,854,775,808\n * - Formula: -2^63\n *\n * @see {@link I64}\n * @public\n */\nexport const I64_MIN = -(1n << 63n);\n\n/**\n * Maximum value for a 64-bit signed integer.\n *\n * @remarks\n * - Value: 9,223,372,036,854,775,807\n * - Formula: 2^63 - 1\n *\n * @see {@link I64}\n * @public\n */\nexport const I64_MAX = (1n << 63n) - 1n;\n\n/**\n * Minimum value for a 128-bit signed integer.\n *\n * @remarks\n * - Formula: -2^127\n *\n * @see {@link I128}\n * @public\n */\nexport const I128_MIN = -(1n << 127n);\n\n/**\n * Maximum value for a 128-bit signed integer.\n *\n * @remarks\n * - Formula: 2^127 - 1\n *\n * @see {@link I128}\n * @public\n */\nexport const I128_MAX = (1n << 127n) - 1n;\n\n/**\n * Minimum value for a 256-bit signed integer.\n *\n * @remarks\n * - Formula: -2^255\n *\n * @see {@link I256}\n * @public\n */\nexport const I256_MIN = -(1n << 255n);\n\n/**\n * Maximum value for a 256-bit signed integer.\n *\n * @remarks\n * - Formula: 2^255 - 1\n *\n * @see {@link I256}\n * @public\n */\nexport const I256_MAX = (1n << 255n) - 1n;\n\n/**\n * Minimum value for a 512-bit signed integer.\n *\n * @remarks\n * - Formula: -2^511\n *\n * @see {@link I512}\n * @public\n */\nexport const I512_MIN = -(1n << 511n);\n\n/**\n * Maximum value for a 512-bit signed integer.\n *\n * @remarks\n * - Formula: 2^511 - 1\n *\n * @see {@link I512}\n * @public\n */\nexport const I512_MAX = (1n << 511n) - 1n;\n\n/**\n * Minimum value for a 1024-bit signed integer.\n *\n * @remarks\n * - Formula: -2^1023\n *\n * @see {@link I1024}\n * @public\n */\nexport const I1024_MIN = -(1n << 1023n);\n\n/**\n * Maximum value for a 1024-bit signed integer.\n *\n * @remarks\n * - Formula: 2^1023 - 1\n *\n * @see {@link I1024}\n * @public\n */\nexport const I1024_MAX = (1n << 1023n) - 1n;\n\n/* =============================================================================\n * CONSTANTS - BYTE LENGTHS\n *\n * Expected byte lengths for sized byte array types.\n * Used by assertion functions to validate array lengths.\n * ============================================================================= */\n\n/**\n * Expected byte length for 8-bit values.\n *\n * @remarks Value: 1 byte\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(U8_BYTE_LENGTH); // 1 byte\n * ```\n *\n * @see {@link U8LeBytes}\n * @see {@link U8BeBytes}\n * @public\n */\nexport const U8_BYTE_LENGTH = 1;\n\n/**\n * Expected byte length for 16-bit values.\n *\n * @remarks Value: 2 bytes\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(U16_BYTE_LENGTH); // 2 bytes\n * ```\n *\n * @see {@link U16LeBytes}\n * @see {@link U16BeBytes}\n * @public\n */\nexport const U16_BYTE_LENGTH = 2;\n\n/**\n * Expected byte length for 32-bit values.\n *\n * @remarks Value: 4 bytes\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(U32_BYTE_LENGTH); // 4 bytes\n * ```\n *\n * @see {@link U32LeBytes}\n * @see {@link U32BeBytes}\n * @public\n */\nexport const U32_BYTE_LENGTH = 4;\n\n/**\n * Expected byte length for 64-bit values.\n *\n * @remarks Value: 8 bytes\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(U64_BYTE_LENGTH); // 8 bytes\n * ```\n *\n * @see {@link U64LeBytes}\n * @see {@link U64BeBytes}\n * @public\n */\nexport const U64_BYTE_LENGTH = 8;\n\n/**\n * Expected byte length for 128-bit values.\n *\n * @remarks Value: 16 bytes\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(U128_BYTE_LENGTH); // 16 bytes\n * ```\n *\n * @see {@link U128LeBytes}\n * @see {@link U128BeBytes}\n * @public\n */\nexport const U128_BYTE_LENGTH = 16;\n\n/**\n * Expected byte length for 256-bit values.\n *\n * @remarks Value: 32 bytes\n *\n * @example\n * ```typescript\n * // Allocate a buffer for a 256-bit cryptographic scalar\n * const scalarBytes = new Uint8Array(U256_BYTE_LENGTH); // 32 bytes\n * ```\n *\n * @see {@link U256LeBytes}\n * @see {@link U256BeBytes}\n * @public\n */\nexport const U256_BYTE_LENGTH = 32;\n\n/**\n * Expected byte length for 512-bit values.\n *\n * @remarks Value: 64 bytes\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(U512_BYTE_LENGTH); // 64 bytes\n * ```\n *\n * @see {@link U512LeBytes}\n * @see {@link U512BeBytes}\n * @public\n */\nexport const U512_BYTE_LENGTH = 64;\n\n/**\n * Expected byte length for 1024-bit values.\n *\n * @remarks Value: 128 bytes\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(U1024_BYTE_LENGTH); // 128 bytes\n * ```\n *\n * @see {@link U1024LeBytes}\n * @see {@link U1024BeBytes}\n * @public\n */\nexport const U1024_BYTE_LENGTH = 128;\n\n/* =============================================================================\n * ASSERTION ERROR\n *\n * Custom error class thrown when type assertions fail.\n * ============================================================================= */\n\n/**\n * Error thrown when a value fails a mathematical type assertion.\n *\n * This error provides detailed information about why an assertion failed,\n * including the actual value, the expected type, and the constraint that\n * was violated.\n *\n * @remarks\n * All assertion functions in this module throw this error type on failure.\n * You can catch this specific error type to handle assertion failures\n * differently from other errors.\n *\n * ## Error Properties\n * - `value`: The actual value that failed assertion\n * - `expectedType`: The type that was expected (e.g., \"U8\", \"U256LeBytes\")\n * - `constraint`: Optional description of the constraint that was violated\n *\n * @example\n * ```typescript\n * import { assertU8, MathematicsAssertionError } from \"./mathematics\";\n *\n * try {\n * const value = assertU8(256n); // Will throw\n * } catch (error) {\n * if (error instanceof MathematicsAssertionError) {\n * console.error(`Assertion failed for ${error.expectedType}`);\n * console.error(`Value: ${error.value}`);\n * console.error(`Constraint: ${error.constraint}`);\n * // Output:\n * // Assertion failed for U8\n * // Value: 256\n * // Constraint: 0 <= value <= 255\n * }\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Custom error handling\n * function safeParseU8(value: bigint): U8 | null {\n * try {\n * return assertU8(value);\n * } catch (error) {\n * if (error instanceof MathematicsAssertionError) {\n * console.warn(`Invalid U8 value: ${value}`);\n * return null;\n * }\n * throw error; // Re-throw unexpected errors\n * }\n * }\n * ```\n *\n * @sealed\n * @public\n */\nexport class MathematicsAssertionError extends Error {\n /**\n * The actual value that failed the assertion.\n *\n * @remarks\n * This can be any type depending on what was being asserted.\n * For integer assertions, this will be a `bigint`.\n * For byte array assertions, this will be a `Uint8Array`.\n *\n * @readonly\n */\n public readonly value: unknown;\n\n /**\n * The type that was expected.\n *\n * @remarks\n * This is the branded type name (e.g., \"U8\", \"U256\", \"U32LeBytes\").\n *\n * @readonly\n */\n public readonly expectedType: string;\n\n /**\n * Description of the constraint that was violated.\n *\n * @remarks\n * This is `undefined` if only a type check failed (e.g., expected bigint, got string).\n * It contains a human-readable constraint description when a value is out of range.\n *\n * @example\n * - \"0 <= value <= 255\" for U8 range violations\n * - \"length === 32\" for U256LeBytes length violations\n * - \"value >= 0\" for negative unsigned integer attempts\n *\n * @readonly\n */\n public readonly constraint: string | undefined;\n\n /**\n * Creates a new MathematicsAssertionError.\n *\n * @param message - Human-readable error message\n * @param options - Error details\n * @param options.value - The value that failed assertion\n * @param options.expectedType - The expected type name\n * @param options.constraint - Optional constraint description\n */\n constructor(\n message: string,\n options: {\n value: unknown;\n expectedType: string;\n constraint?: string;\n },\n ) {\n super(message);\n this.name = \"MathematicsAssertionError\";\n this.value = options.value;\n this.expectedType = options.expectedType;\n this.constraint = options.constraint;\n\n // Maintains proper stack trace for where our error was thrown (V8 only)\n Error.captureStackTrace(this, MathematicsAssertionError);\n\n // Set the prototype explicitly for proper instanceof checks\n Object.setPrototypeOf(this, MathematicsAssertionError.prototype);\n }\n}\n\n/* =============================================================================\n * BYTE ARRAY ASSERTIONS - BASE TYPES\n *\n * Assertion functions for base byte array types.\n * These validate that a value is a Uint8Array and brand it accordingly.\n * ============================================================================= */\n\n/**\n * Asserts that a value is a valid Uint8Array and narrows it to `Bytes`.\n *\n * This is the base assertion for all byte array types. It validates that\n * the input is a `Uint8Array` instance.\n *\n * @param value - The Uint8Array to assert\n * @throws {MathematicsAssertionError} If the value is not a Uint8Array\n *\n * @example\n * ```typescript\n * const rawBytes = new Uint8Array([0x01, 0x02, 0x03]);\n * assertBytes(rawBytes);\n * // rawBytes is now typed as Bytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link Bytes}\n * @public\n */\nexport function assertBytes(value: Uint8Array): asserts value is Bytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"Bytes\",\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Uint8Array and narrows it to `LeBytes`.\n *\n * This function validates that the input is a `Uint8Array` instance and\n * uses TypeScript's type narrowing to treat it as a little-endian byte array.\n * No length validation is performed.\n *\n * @param value - The Uint8Array to assert\n * @throws {MathematicsAssertionError} If the value is not a Uint8Array\n *\n * @remarks\n * This is the base assertion for little-endian byte arrays.\n * For sized byte arrays, use the specific assertions like `assertU32LeBytes`.\n *\n * @example\n * ```typescript\n * // Brand a byte array as little-endian\n * const rawBytes = new Uint8Array([0x78, 0x56, 0x34, 0x12]);\n * assertLeBytes(rawBytes);\n * // rawBytes is now typed as LeBytes\n *\n * // The branded type prevents mixing with big-endian\n * function processLittleEndian(bytes: LeBytes): void { ... }\n * processLittleEndian(rawBytes); // OK after assertion\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link LeBytes}\n * @public\n */\nexport function assertLeBytes(value: Uint8Array): asserts value is LeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"LeBytes\",\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Uint8Array and narrows it to `BeBytes`.\n *\n * This function validates that the input is a `Uint8Array` instance and\n * uses TypeScript's type narrowing to treat it as a big-endian byte array.\n * No length validation is performed.\n *\n * @param value - The Uint8Array to assert\n * @throws {MathematicsAssertionError} If the value is not a Uint8Array\n *\n * @remarks\n * This is the base assertion for big-endian byte arrays.\n * For sized byte arrays, use the specific assertions like `assertU32BeBytes`.\n *\n * @example\n * ```typescript\n * // Brand a byte array as big-endian (network byte order)\n * const rawBytes = new Uint8Array([0x12, 0x34, 0x56, 0x78]);\n * assertBeBytes(rawBytes);\n * // rawBytes is now typed as BeBytes\n *\n * // Use for network protocol data\n * function sendNetworkData(bytes: BeBytes): void { ... }\n * sendNetworkData(rawBytes); // OK after assertion\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link BeBytes}\n * @public\n */\nexport function assertBeBytes(value: Uint8Array): asserts value is BeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"BeBytes\",\n });\n }\n}\n\n/* =============================================================================\n * LITTLE-ENDIAN SIZED BYTE ARRAY ASSERTIONS\n *\n * Assertion functions that validate both type and length.\n * ============================================================================= */\n\n/**\n * Asserts that a value is a 1-byte little-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 1 byte)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * const byte = new Uint8Array([0xFF]);\n * assertU8LeBytes(byte);\n * // byte is now typed as U8LeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U8LeBytes}\n * @public\n */\nexport function assertU8LeBytes(value: Uint8Array): asserts value is U8LeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U8LeBytes\",\n });\n }\n if (value.length !== U8_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U8_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U8LeBytes\",\n constraint: `length === ${String(U8_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 2-byte little-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 2 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * // 0x1234 in little-endian\n * const bytes = new Uint8Array([0x34, 0x12]);\n * assertU16LeBytes(bytes);\n * // bytes is now typed as U16LeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U16LeBytes}\n * @public\n */\nexport function assertU16LeBytes(value: Uint8Array): asserts value is U16LeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U16LeBytes\",\n });\n }\n if (value.length !== U16_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U16_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U16LeBytes\",\n constraint: `length === ${String(U16_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 4-byte little-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 4 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * // 0x12345678 in little-endian\n * const bytes = new Uint8Array([0x78, 0x56, 0x34, 0x12]);\n * assertU32LeBytes(bytes);\n * // bytes is now typed as U32LeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U32LeBytes}\n * @public\n */\nexport function assertU32LeBytes(value: Uint8Array): asserts value is U32LeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U32LeBytes\",\n });\n }\n if (value.length !== U32_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U32_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U32LeBytes\",\n constraint: `length === ${String(U32_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is an 8-byte little-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 8 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(8);\n * assertU64LeBytes(bytes);\n * // bytes is now typed as U64LeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U64LeBytes}\n * @public\n */\nexport function assertU64LeBytes(value: Uint8Array): asserts value is U64LeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U64LeBytes\",\n });\n }\n if (value.length !== U64_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U64_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U64LeBytes\",\n constraint: `length === ${String(U64_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 16-byte little-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 16 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(16);\n * assertU128LeBytes(bytes);\n * // bytes is now typed as U128LeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U128LeBytes}\n * @public\n */\nexport function assertU128LeBytes(value: Uint8Array): asserts value is U128LeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U128LeBytes\",\n });\n }\n if (value.length !== U128_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U128_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U128LeBytes\",\n constraint: `length === ${String(U128_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 32-byte little-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 32 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @remarks\n * 32-byte arrays are commonly used for:\n * - SHA-256 hash outputs\n * - Elliptic curve scalars\n * - Private keys\n *\n * @example\n * ```typescript\n * // Create a 256-bit scalar representation\n * const scalar = new Uint8Array(32);\n * assertU256LeBytes(scalar);\n * // scalar is now typed as U256LeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U256LeBytes}\n * @public\n */\nexport function assertU256LeBytes(value: Uint8Array): asserts value is U256LeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U256LeBytes\",\n });\n }\n if (value.length !== U256_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U256_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U256LeBytes\",\n constraint: `length === ${String(U256_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 64-byte little-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 64 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(64);\n * assertU512LeBytes(bytes);\n * // bytes is now typed as U512LeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U512LeBytes}\n * @public\n */\nexport function assertU512LeBytes(value: Uint8Array): asserts value is U512LeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U512LeBytes\",\n });\n }\n if (value.length !== U512_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U512_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U512LeBytes\",\n constraint: `length === ${String(U512_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 128-byte little-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 128 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(128);\n * assertU1024LeBytes(bytes);\n * // bytes is now typed as U1024LeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U1024LeBytes}\n * @public\n */\nexport function assertU1024LeBytes(value: Uint8Array): asserts value is U1024LeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U1024LeBytes\",\n });\n }\n if (value.length !== U1024_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U1024_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U1024LeBytes\",\n constraint: `length === ${String(U1024_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * BIG-ENDIAN SIZED BYTE ARRAY ASSERTIONS\n *\n * Assertion functions that validate both type and length for big-endian arrays.\n * ============================================================================= */\n\n/**\n * Asserts that a value is a 1-byte big-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 1 byte)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * const byte = new Uint8Array([0xFF]);\n * assertU8BeBytes(byte);\n * // byte is now typed as U8BeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U8BeBytes}\n * @public\n */\nexport function assertU8BeBytes(value: Uint8Array): asserts value is U8BeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U8BeBytes\",\n });\n }\n if (value.length !== U8_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U8_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U8BeBytes\",\n constraint: `length === ${String(U8_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 2-byte big-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 2 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * // Network port 443 in big-endian\n * const portBytes = new Uint8Array([0x01, 0xBB]);\n * assertU16BeBytes(portBytes);\n * // portBytes is now typed as U16BeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U16BeBytes}\n * @public\n */\nexport function assertU16BeBytes(value: Uint8Array): asserts value is U16BeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U16BeBytes\",\n });\n }\n if (value.length !== U16_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U16_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U16BeBytes\",\n constraint: `length === ${String(U16_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 4-byte big-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 4 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * // IP address 127.0.0.1 in big-endian\n * const ipBytes = new Uint8Array([127, 0, 0, 1]);\n * assertU32BeBytes(ipBytes);\n * // ipBytes is now typed as U32BeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U32BeBytes}\n * @public\n */\nexport function assertU32BeBytes(value: Uint8Array): asserts value is U32BeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U32BeBytes\",\n });\n }\n if (value.length !== U32_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U32_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U32BeBytes\",\n constraint: `length === ${String(U32_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is an 8-byte big-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 8 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(8);\n * assertU64BeBytes(bytes);\n * // bytes is now typed as U64BeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U64BeBytes}\n * @public\n */\nexport function assertU64BeBytes(value: Uint8Array): asserts value is U64BeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U64BeBytes\",\n });\n }\n if (value.length !== U64_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U64_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U64BeBytes\",\n constraint: `length === ${String(U64_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 16-byte big-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 16 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * // UUID bytes in big-endian format\n * const uuidBytes = new Uint8Array(16);\n * assertU128BeBytes(uuidBytes);\n * // uuidBytes is now typed as U128BeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U128BeBytes}\n * @public\n */\nexport function assertU128BeBytes(value: Uint8Array): asserts value is U128BeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U128BeBytes\",\n });\n }\n if (value.length !== U128_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U128_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U128BeBytes\",\n constraint: `length === ${String(U128_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 32-byte big-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 32 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @remarks\n * Big-endian 256-bit arrays are common in cryptographic specifications\n * and blockchain protocols.\n *\n * @example\n * ```typescript\n * // Hash output in standard big-endian format\n * assertU256BeBytes(sha256Result);\n * // sha256Result is now typed as U256BeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U256BeBytes}\n * @public\n */\nexport function assertU256BeBytes(value: Uint8Array): asserts value is U256BeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U256BeBytes\",\n });\n }\n if (value.length !== U256_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U256_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U256BeBytes\",\n constraint: `length === ${String(U256_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 64-byte big-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 64 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(64);\n * assertU512BeBytes(bytes);\n * // bytes is now typed as U512BeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U512BeBytes}\n * @public\n */\nexport function assertU512BeBytes(value: Uint8Array): asserts value is U512BeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U512BeBytes\",\n });\n }\n if (value.length !== U512_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U512_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U512BeBytes\",\n constraint: `length === ${String(U512_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a 128-byte big-endian byte array.\n *\n * @param value - The Uint8Array to assert (must be exactly 128 bytes)\n * @throws {MathematicsAssertionError} If not a Uint8Array or wrong length\n *\n * @example\n * ```typescript\n * const bytes = new Uint8Array(128);\n * assertU1024BeBytes(bytes);\n * // bytes is now typed as U1024BeBytes\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U1024BeBytes}\n * @public\n */\nexport function assertU1024BeBytes(value: Uint8Array): asserts value is U1024BeBytes {\n if (!(value instanceof Uint8Array)) {\n throw new MathematicsAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"U1024BeBytes\",\n });\n }\n if (value.length !== U1024_BYTE_LENGTH) {\n throw new MathematicsAssertionError(\n `Expected ${String(U1024_BYTE_LENGTH)} byte(s), got ${String(value.length)}`,\n {\n value,\n expectedType: \"U1024BeBytes\",\n constraint: `length === ${String(U1024_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * INTEGER BASE TYPE ASSERTIONS\n *\n * Assertion functions for base integer types (UnsignedInteger, SignedInteger).\n * ============================================================================= */\n\n/**\n * Asserts that a value is a non-negative bigint and narrows it to `UnsignedInteger`.\n *\n * This is the base assertion for all unsigned integer types.\n * It validates that the value is a `bigint` and is non-negative (>= 0).\n *\n * @param value - The bigint to assert (must be >= 0)\n * @throws {MathematicsAssertionError} If not a bigint or if negative\n *\n * @remarks\n * Use this when you need to ensure a value is unsigned but don't need\n * a specific bit-width constraint.\n *\n * @example\n * ```typescript\n * const value = 12345n;\n * assertUnsignedInteger(value);\n * // value is now typed as UnsignedInteger\n *\n * assertUnsignedInteger(-1n); // Throws: negative value\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link UnsignedInteger}\n * @public\n */\nexport function assertUnsignedInteger(value: bigint): asserts value is UnsignedInteger {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"UnsignedInteger\",\n });\n }\n if (value < 0n) {\n throw new MathematicsAssertionError(`Expected non-negative value, got ${String(value)}`, {\n value,\n expectedType: \"UnsignedInteger\",\n constraint: \"value >= 0\",\n });\n }\n}\n\n/**\n * Asserts that a value is a bigint and narrows it to `SignedInteger`.\n *\n * This is the base assertion for all signed integer types.\n * It only validates that the value is a `bigint` (no range constraints).\n *\n * @param value - The bigint to assert\n * @throws {MathematicsAssertionError} If not a bigint\n *\n * @remarks\n * Use this when you need to ensure a value is a bigint but don't need\n * a specific bit-width constraint.\n *\n * @example\n * ```typescript\n * const value = -12345n;\n * assertSignedInteger(value);\n * // value is now typed as SignedInteger\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link SignedInteger}\n * @public\n */\nexport function assertSignedInteger(value: bigint): asserts value is SignedInteger {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"SignedInteger\",\n });\n }\n}\n\n/* =============================================================================\n * UNSIGNED INTEGER ASSERTIONS\n *\n * Assertion functions for specific unsigned integer bit-widths.\n * Each function validates both type and range.\n * ============================================================================= */\n\n/**\n * Asserts that a value is a valid 8-bit unsigned integer (0 to 255).\n *\n * @param value - The bigint to assert (must be in range [0, 255])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * const value = 255n;\n * assertU8(value);\n * // value is now typed as U8\n *\n * assertU8(256n); // Throws: exceeds maximum\n * assertU8(-1n); // Throws: below minimum\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U8}\n * @public\n */\nexport function assertU8(value: bigint): asserts value is U8 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"U8\",\n });\n }\n if (value < 0n || value > U8_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for U8 [0, ${String(U8_MAX)}]`,\n {\n value,\n expectedType: \"U8\",\n constraint: `0 <= value <= ${String(U8_MAX)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 16-bit unsigned integer (0 to 65,535).\n *\n * @param value - The bigint to assert (must be in range [0, 65535])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * const port = 443n;\n * assertU16(port);\n * // port is now typed as U16\n *\n * assertU16(65536n); // Throws: exceeds maximum\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U16}\n * @public\n */\nexport function assertU16(value: bigint): asserts value is U16 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"U16\",\n });\n }\n if (value < 0n || value > U16_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for U16 [0, ${String(U16_MAX)}]`,\n {\n value,\n expectedType: \"U16\",\n constraint: `0 <= value <= ${String(U16_MAX)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 32-bit unsigned integer (0 to 4,294,967,295).\n *\n * @param value - The bigint to assert (must be in range [0, 4294967295])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * const timestamp = 1704067200n;\n * assertU32(timestamp);\n * // timestamp is now typed as U32\n *\n * assertU32(4294967296n); // Throws: exceeds maximum (2^32)\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U32}\n * @public\n */\nexport function assertU32(value: bigint): asserts value is U32 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"U32\",\n });\n }\n if (value < 0n || value > U32_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for U32 [0, ${String(U32_MAX)}]`,\n {\n value,\n expectedType: \"U32\",\n constraint: `0 <= value <= ${String(U32_MAX)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 64-bit unsigned integer.\n *\n * @param value - The bigint to assert (must be in range [0, 2^64 - 1])\n * @param name - The name of the variable being asserted, used in error messages for context.\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @defaultValue `name` defaults to `\"value\"`\n *\n * @example\n * ```typescript\n * const large = 18446744073709551615n;\n * assertU64(large, \"large\");\n * // large is now typed as U64\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U64}\n * @public\n */\nexport function assertU64(value: bigint, name = \"value\"): asserts value is U64 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`${name}: Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"U64\",\n });\n }\n if (value < 0n || value > U64_MAX) {\n throw new MathematicsAssertionError(\n `${name}: Value ${String(value)} is out of range for U64 [0, ${String(U64_MAX)}]`,\n {\n value,\n expectedType: \"U64\",\n constraint: `0 <= value <= ${String(U64_MAX)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 128-bit unsigned integer.\n *\n * @param value - The bigint to assert (must be in range [0, 2^128 - 1])\n * @param name - The name of the variable being asserted, used in error messages for context.\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @defaultValue `name` defaults to `\"value\"`\n *\n * @example\n * ```typescript\n * const uuid = 0x550e8400e29b41d4a716446655440000n;\n * assertU128(uuid, \"uuid\");\n * // uuid is now typed as U128\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U128}\n * @public\n */\nexport function assertU128(value: bigint, name = \"value\"): asserts value is U128 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`${name}: Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"U128\",\n });\n }\n if (value < 0n || value > U128_MAX) {\n throw new MathematicsAssertionError(\n `${name}: Value ${String(value)} is out of range for U128 [0, 2^128 - 1]`,\n {\n value,\n expectedType: \"U128\",\n constraint: \"0 <= value <= 2^128 - 1\",\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 256-bit unsigned integer.\n *\n * @param value - The bigint to assert (must be in range [0, 2^256 - 1])\n * @param name - The name of the variable being asserted, used in error messages for context.\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @defaultValue `name` defaults to `\"value\"`\n *\n * @remarks\n * This is commonly used for elliptic curve operations where scalars\n * and field elements must be within the 256-bit range.\n *\n * @example\n * ```typescript\n * // Validate a private key is in valid range\n * assertU256(secretKeyBigInt, \"secretKeyBigInt\");\n * // secretKeyBigInt is now typed as U256\n *\n * // Validate a hash value\n * assertU256(sha256AsBigInt, \"sha256AsBigInt\");\n * // sha256AsBigInt is now typed as U256\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U256}\n * @public\n */\nexport function assertU256(value: bigint, name = \"value\"): asserts value is U256 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`${name}: Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"U256\",\n });\n }\n if (value < 0n || value > U256_MAX) {\n throw new MathematicsAssertionError(\n `${name}: Value ${String(value)} is out of range for U256 [0, 2^256 - 1]`,\n {\n value,\n expectedType: \"U256\",\n constraint: \"0 <= value <= 2^256 - 1\",\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 512-bit unsigned integer.\n *\n * @param value - The bigint to assert (must be in range [0, 2^512 - 1])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * assertU512(sha512AsBigInt);\n * // sha512AsBigInt is now typed as U512\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U512}\n * @public\n */\nexport function assertU512(value: bigint): asserts value is U512 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"U512\",\n });\n }\n if (value < 0n || value > U512_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for U512 [0, 2^512 - 1]`,\n {\n value,\n expectedType: \"U512\",\n constraint: \"0 <= value <= 2^512 - 1\",\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 1024-bit unsigned integer.\n *\n * @param value - The bigint to assert (must be in range [0, 2^1024 - 1])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * assertU1024(modulusBigInt);\n * // modulusBigInt is now typed as U1024\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link U1024}\n * @public\n */\nexport function assertU1024(value: bigint): asserts value is U1024 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"U1024\",\n });\n }\n if (value < 0n || value > U1024_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for U1024 [0, 2^1024 - 1]`,\n {\n value,\n expectedType: \"U1024\",\n constraint: \"0 <= value <= 2^1024 - 1\",\n },\n );\n }\n}\n\n/* =============================================================================\n * SIGNED INTEGER ASSERTIONS\n *\n * Assertion functions for specific signed integer bit-widths.\n * Each function validates both type and range using two's complement bounds.\n * ============================================================================= */\n\n/**\n * Asserts that a value is a valid 8-bit signed integer (-128 to 127).\n *\n * @param value - The bigint to assert (must be in range [-128, 127])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * const value = 127n;\n * assertI8(value);\n * // value is now typed as I8\n *\n * assertI8(128n); // Throws: exceeds maximum\n * assertI8(-129n); // Throws: below minimum\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link I8}\n * @public\n */\nexport function assertI8(value: bigint): asserts value is I8 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"I8\",\n });\n }\n if (value < I8_MIN || value > I8_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for I8 [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n {\n value,\n expectedType: \"I8\",\n constraint: `${String(I8_MIN)} <= value <= ${String(I8_MAX)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 16-bit signed integer (-32,768 to 32,767).\n *\n * @param value - The bigint to assert (must be in range [-32768, 32767])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * const audioSample = -16384n;\n * assertI16(audioSample);\n * // audioSample is now typed as I16\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link I16}\n * @public\n */\nexport function assertI16(value: bigint): asserts value is I16 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"I16\",\n });\n }\n if (value < I16_MIN || value > I16_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for I16 [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n {\n value,\n expectedType: \"I16\",\n constraint: `${String(I16_MIN)} <= value <= ${String(I16_MAX)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 32-bit signed integer.\n *\n * @param value - The bigint to assert (must be in range [-2147483648, 2147483647])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * const offset = -1000n;\n * assertI32(offset);\n * // offset is now typed as I32\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link I32}\n * @public\n */\nexport function assertI32(value: bigint): asserts value is I32 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"I32\",\n });\n }\n if (value < I32_MIN || value > I32_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for I32 [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n {\n value,\n expectedType: \"I32\",\n constraint: `${String(I32_MIN)} <= value <= ${String(I32_MAX)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 64-bit signed integer.\n *\n * @param value - The bigint to assert (must be in range [-2^63, 2^63 - 1])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * const difference = -1000000000000n;\n * assertI64(difference);\n * // difference is now typed as I64\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link I64}\n * @public\n */\nexport function assertI64(value: bigint): asserts value is I64 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"I64\",\n });\n }\n if (value < I64_MIN || value > I64_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for I64 [-2^63, 2^63 - 1]`,\n {\n value,\n expectedType: \"I64\",\n constraint: \"-2^63 <= value <= 2^63 - 1\",\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 128-bit signed integer.\n *\n * @param value - The bigint to assert (must be in range [-2^127, 2^127 - 1])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * const value = -170141183460469231731687303715884105728n;\n * assertI128(value);\n * // value is now typed as I128\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link I128}\n * @public\n */\nexport function assertI128(value: bigint): asserts value is I128 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"I128\",\n });\n }\n if (value < I128_MIN || value > I128_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for I128 [-2^127, 2^127 - 1]`,\n {\n value,\n expectedType: \"I128\",\n constraint: \"-2^127 <= value <= 2^127 - 1\",\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 256-bit signed integer.\n *\n * @param value - The bigint to assert (must be in range [-2^255, 2^255 - 1])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * const signedScalar = -12345678901234567890n;\n * assertI256(signedScalar);\n * // signedScalar is now typed as I256\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link I256}\n * @public\n */\nexport function assertI256(value: bigint): asserts value is I256 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"I256\",\n });\n }\n if (value < I256_MIN || value > I256_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for I256 [-2^255, 2^255 - 1]`,\n {\n value,\n expectedType: \"I256\",\n constraint: \"-2^255 <= value <= 2^255 - 1\",\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 512-bit signed integer.\n *\n * @param value - The bigint to assert (must be in range [-2^511, 2^511 - 1])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * const value = -1n;\n * assertI512(value);\n * // value is now typed as I512\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link I512}\n * @public\n */\nexport function assertI512(value: bigint): asserts value is I512 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"I512\",\n });\n }\n if (value < I512_MIN || value > I512_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for I512 [-2^511, 2^511 - 1]`,\n {\n value,\n expectedType: \"I512\",\n constraint: \"-2^511 <= value <= 2^511 - 1\",\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid 1024-bit signed integer.\n *\n * @param value - The bigint to assert (must be in range [-2^1023, 2^1023 - 1])\n * @throws {MathematicsAssertionError} If not a bigint or out of range\n *\n * @example\n * ```typescript\n * const value = 0n;\n * assertI1024(value);\n * // value is now typed as I1024\n * ```\n *\n * @returns `void` — type narrowing is applied to the argument in-place.\n * @see {@link I1024}\n * @public\n */\nexport function assertI1024(value: bigint): asserts value is I1024 {\n if (typeof value !== \"bigint\") {\n throw new MathematicsAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"I1024\",\n });\n }\n if (value < I1024_MIN || value > I1024_MAX) {\n throw new MathematicsAssertionError(\n `Value ${String(value)} is out of range for I1024 [-2^1023, 2^1023 - 1]`,\n {\n value,\n expectedType: \"I1024\",\n constraint: \"-2^1023 <= value <= 2^1023 - 1\",\n },\n );\n }\n}\n","/**\n * Cryptography Types\n *\n * This module defines branded types for cryptographic primitives used throughout the SDK.\n * These types provide compile-time safety for elliptic curve field elements and cipher operations.\n *\n * ## Overview\n *\n * The module includes:\n * - **Field Elements**: Types for elliptic curve operations (BN254, Curve25519)\n * - **Cipher Types**: Poseidon and Rescue cipher primitives\n * - **Constants**: Field primes for validation\n * - **Assertions**: Runtime validation functions\n *\n * @remarks\n * All numeric cryptographic types use TypeScript branded types (phantom type tags) to prevent\n * accidental mixing of values from different domains. For example, a `PoseidonKey` cannot be\n * passed where a `RcKey` is expected, even though both are ultimately bigints. This catches\n * a large class of cryptographic misuse bugs at compile time rather than runtime.\n *\n * Byte-array types (X25519, AES, Groth16 proof components) use Uint8Array sub-brands so that\n * the TypeScript compiler enforces correct sizes and semantics at every call site.\n *\n * @packageDocumentation\n * @module types/cryptography\n */\n\nimport type {\n SubBrandedType,\n SubSubBrandedType,\n SubSubSubBrandedType,\n SubSubSubSubBrandedType,\n} from \"../common/branded\";\nimport {\n type Bytes,\n type U128,\n type U256,\n type U256LeBytes,\n type U512LeBytes,\n U128_MAX,\n U256_BYTE_LENGTH,\n U512_BYTE_LENGTH,\n} from \"../common/types\";\n\n/* =============================================================================\n * CONSTANTS - FIELD PRIMES\n * ============================================================================= */\n\n/**\n * The prime field modulus for BN254 (alt_bn128) curve.\n *\n * @remarks\n * This is the order of the scalar field Fr for the BN254 pairing-friendly elliptic curve.\n * Value: 21888242871839275222246405745257275088548364400416034343698204186575808495617\n *\n * All `Bn254FieldElement` values and derived types (Poseidon keys, hashes, viewing keys)\n * must be strictly less than this constant.\n *\n * @see {@link Bn254FieldElement}\n * @see {@link assertBn254FieldElement}\n * @public\n */\nexport const BN254_FIELD_PRIME =\n 21_888_242_871_839_275_222_246_405_745_257_275_088_548_364_400_416_034_343_698_204_186_575_808_495_617n;\n\n/**\n * The prime field modulus for Curve25519.\n *\n * @remarks\n * Value: 2^255 - 19 = 57896044618658097711785492504343953926634992332820282019728792003956564819949\n *\n * All `Curve25519FieldElement` values and derived types (Rescue cipher types, RcEncryptionNonce)\n * must be strictly less than this constant.\n *\n * @see {@link Curve25519FieldElement}\n * @see {@link assertCurve25519FieldElement}\n * @public\n */\nexport const CURVE25519_FIELD_PRIME = (1n << 255n) - 19n;\n\n/* =============================================================================\n * ASSERTION ERROR\n * ============================================================================= */\n\n/**\n * Error thrown when a cryptographic type assertion fails.\n *\n * This error provides detailed information about why an assertion failed,\n * including the actual value, the expected type, and the constraint that\n * was violated.\n *\n * @remarks\n * Every `assertXxx` function in this module throws `CryptographyAssertionError` on failure.\n * Catch this specific type when you need to handle assertion failures differently from\n * other runtime errors (e.g., to provide user-friendly validation messages or to fall back\n * to a safe default).\n *\n * @example\n * ```typescript\n * import { assertBn254FieldElement, CryptographyAssertionError } from \"./cryptography\";\n *\n * try {\n * const value = assertBn254FieldElement(-1n); // Will throw\n * } catch (error) {\n * if (error instanceof CryptographyAssertionError) {\n * console.error(`Assertion failed for ${error.expectedType}`);\n * console.error(`Value: ${error.value}`);\n * console.error(`Constraint: ${error.constraint}`);\n * }\n * }\n * ```\n *\n * @sealed\n * @public\n */\nexport class CryptographyAssertionError extends Error {\n /**\n * The actual value that failed the assertion.\n * @readonly\n */\n public readonly value: unknown;\n\n /**\n * The type that was expected (e.g., \"Bn254FieldElement\", \"PoseidonKey\").\n * @readonly\n */\n public readonly expectedType: string;\n\n /**\n * Description of the constraint that was violated.\n *\n * @remarks\n * Will be `undefined` when the failure is purely a type mismatch (e.g., received a string\n * instead of a bigint). Contains a human-readable range or length constraint when the value\n * was the correct type but out of the valid range.\n *\n * @example `\"value >= 0\"`, `\"value < BN254_FIELD_PRIME\"`, `\"length === 32\"`\n * @readonly\n */\n public readonly constraint: string | undefined;\n\n /**\n * Creates a new CryptographyAssertionError.\n *\n * @param message - Human-readable error message describing what went wrong\n * @param options - Structured error details for programmatic inspection\n * @param options.value - The value that failed the assertion\n * @param options.expectedType - Name of the branded type that was expected\n * @param options.constraint - Optional human-readable constraint that was violated\n */\n constructor(\n message: string,\n options: {\n value: unknown;\n expectedType: string;\n constraint?: string;\n },\n ) {\n super(message);\n this.name = \"CryptographyAssertionError\";\n this.value = options.value;\n this.expectedType = options.expectedType;\n this.constraint = options.constraint;\n\n Error.captureStackTrace(this, CryptographyAssertionError);\n\n Object.setPrototypeOf(this, CryptographyAssertionError.prototype);\n }\n}\n\n/* =============================================================================\n * ELLIPTIC CURVE FIELD ELEMENTS\n * ============================================================================= */\n\n/**\n * Field element for the BN254 (alt_bn128) elliptic curve.\n *\n * BN254 is a pairing-friendly elliptic curve widely used in zero-knowledge proofs.\n * The field prime is: 21888242871839275222246405745257275088548364400416034343698204186575808495617\n *\n * @remarks\n * - Used in Ethereum precompiles (EIP-196, EIP-197)\n * - Provides ~100 bits of security\n * - Supports efficient pairing operations\n * - Valid range: [0, BN254_FIELD_PRIME - 1]\n * - Encoded as a TypeScript `bigint`; the sub-brand prevents mixing with Curve25519 or raw U256 values\n *\n * This is the base type for all Poseidon cipher types and all viewing key types used in the\n * Umbra protocol.\n *\n * @see {@link BN254_FIELD_PRIME}\n * @see {@link assertBn254FieldElement}\n * @see https://eips.ethereum.org/EIPS/eip-196\n * @public\n */\nexport type Bn254FieldElement = SubSubBrandedType<U256, \"Bn254FieldElement\">;\n\n/**\n * Field element for the Curve25519 elliptic curve.\n *\n * Curve25519 is a Montgomery curve designed for high-speed Diffie-Hellman key exchange.\n * The field prime is: 2^255 - 19\n *\n * @remarks\n * - Provides ~128 bits of security\n * - Designed to be resistant to timing attacks\n * - Used in Ed25519 signatures and X25519 key exchange\n * - Valid range: [0, CURVE25519_FIELD_PRIME - 1]\n * - Encoded as a TypeScript `bigint`; the sub-brand prevents mixing with BN254 field values\n *\n * This is the base type for all Rescue cipher types (RcCiphertext, RcPlaintext, RcKey, RcCounter).\n *\n * @see {@link CURVE25519_FIELD_PRIME}\n * @see {@link assertCurve25519FieldElement}\n * @see https://cr.yp.to/ecdh/curve25519-20060209.pdf\n * @public\n */\nexport type Curve25519FieldElement = SubSubBrandedType<U256, \"Curve25519FieldElement\">;\n\n/* =============================================================================\n * X25519 KEY EXCHANGE TYPES\n *\n * These types are used for X25519 Diffie-Hellman key exchange operations.\n * X25519 uses Curve25519 for elliptic curve Diffie-Hellman (ECDH).\n * ============================================================================= */\n\n/**\n * Byte length for all X25519 key exchange values (keys and shared secrets).\n *\n * @remarks\n * X25519 public keys, private keys, and shared secrets are all exactly 32 bytes (256 bits)\n * as specified in RFC 7748. This constant is used by all X25519 assertion functions.\n *\n * @see {@link assertX25519Bytes}\n * @see {@link assertX25519PrivateKey}\n * @see {@link assertX25519PublicKey}\n * @see {@link assertSharedSecret}\n * @public\n */\nexport const X25519_BYTE_LENGTH = 32;\n\n/**\n * Byte array type for X25519 key exchange operations.\n *\n * X25519 is an elliptic curve Diffie-Hellman (ECDH) protocol using Curve25519.\n * All X25519 values (public keys, private keys, shared secrets) are exactly 32 bytes.\n *\n * @remarks\n * - Size: 32 bytes (256 bits)\n * - Used for X25519 key exchange operations\n * - Parallel to LeBytes/BeBytes as a sub-brand of Bytes\n * - Endianness-agnostic (X25519 spec defines byte order)\n * - This is the base type from which `X25519PrivateKey`, `X25519PublicKey`, and `SharedSecret` are derived\n *\n * @see {@link X25519_BYTE_LENGTH}\n * @see {@link X25519PrivateKey}\n * @see {@link X25519PublicKey}\n * @see {@link SharedSecret}\n * @see https://cr.yp.to/ecdh/curve25519-20060209.pdf\n * @see https://tools.ietf.org/html/rfc7748\n * @public\n */\nexport type X25519Bytes = SubBrandedType<Bytes, \"X25519Bytes\">;\n\n/**\n * X25519 private key for elliptic curve Diffie-Hellman key exchange.\n *\n * A private key is a 32-byte value that should be generated using a\n * cryptographically secure random number generator. It is used together\n * with a public key to compute a shared secret.\n *\n * @remarks\n * - Size: 32 bytes (256 bits)\n * - Must be kept secret and never shared\n * - Should be generated using crypto.getRandomValues() or similar CSPRNG\n * - The X25519 algorithm applies clamping to the private key during use\n *\n * ## Type Hierarchy\n * ```\n * Bytes (base)\n * └── X25519Bytes (sub-brand, 32 bytes)\n * └── X25519PrivateKey (sub-sub-brand)\n * ```\n *\n * @example\n * ```typescript\n * // Generate a new private key\n * const rawPrivateKey = crypto.getRandomValues(new Uint8Array(32));\n * assertX25519PrivateKey(rawPrivateKey);\n * // rawPrivateKey is now typed as X25519PrivateKey\n *\n * // Derive the public key\n * const publicKey = x25519GetPublicKey(rawPrivateKey);\n * ```\n *\n * @see https://tools.ietf.org/html/rfc7748#section-5\n * @public\n */\nexport type X25519PrivateKey = SubSubBrandedType<X25519Bytes, \"X25519PrivateKey\">;\n\n/**\n * X25519 public key for elliptic curve Diffie-Hellman key exchange.\n *\n * A public key is a 32-byte value derived from a private key. It can be\n * freely shared and is used by other parties to compute a shared secret.\n *\n * @remarks\n * - Size: 32 bytes (256 bits)\n * - Can be shared publicly\n * - Derived from a corresponding X25519PrivateKey\n * - Used as input to X25519 key exchange\n *\n * ## Type Hierarchy\n * ```\n * Bytes (base)\n * └── X25519Bytes (sub-brand, 32 bytes)\n * └── X25519PublicKey (sub-sub-brand)\n * ```\n *\n * @example\n * ```typescript\n * // Receive a public key from another party\n * const theirPublicKey = receivePublicKey();\n * assertX25519PublicKey(theirPublicKey);\n * // theirPublicKey is now typed as X25519PublicKey\n *\n * // Compute shared secret\n * const sharedSecret = x25519(myPrivateKey, theirPublicKey);\n * ```\n *\n * @see https://tools.ietf.org/html/rfc7748#section-5\n * @public\n */\nexport type X25519PublicKey = SubSubBrandedType<X25519Bytes, \"X25519PublicKey\">;\n\n/**\n * Shared secret produced by X25519 key exchange.\n *\n * This type represents the output of an X25519 ECDH operation, which combines\n * a private key with a public key to produce a shared secret that both parties\n * can compute independently.\n *\n * @remarks\n * - Size: 32 bytes (256 bits)\n * - Should be used as input to a Key Derivation Function (KDF)\n * - Never use raw shared secrets directly as encryption keys\n *\n * ## Type Hierarchy\n * ```\n * Bytes (base)\n * └── X25519Bytes (sub-brand, 32 bytes)\n * └── SharedSecret (sub-sub-brand)\n * ```\n *\n * @example\n * ```typescript\n * // After performing X25519 key exchange\n * const rawSharedSecret = x25519(myPrivateKey, theirPublicKey);\n * assertSharedSecret(rawSharedSecret);\n * // rawSharedSecret is now typed as SharedSecret\n *\n * // Derive an encryption key from the shared secret\n * const encryptionKey = kdf(rawSharedSecret);\n * ```\n *\n * @see https://tools.ietf.org/html/rfc7748#section-6\n * @public\n */\nexport type SharedSecret = SubSubBrandedType<X25519Bytes, \"SharedSecret\">;\n\n/* =============================================================================\n * POSEIDON CIPHER TYPES\n * ============================================================================= */\n\n/**\n * Plaintext input for Poseidon cipher encryption.\n *\n * Poseidon is a cryptographic hash function and cipher optimized for\n * zero-knowledge proof systems. It operates natively on field elements.\n *\n * @remarks\n * Must be a valid BN254 field element (less than the field prime). Plaintext values that\n * represent token amounts or account balances are encoded as field elements before being\n * passed to the Poseidon cipher.\n *\n * @see {@link assertPoseidonPlaintext}\n * @see {@link BN254_FIELD_PRIME}\n * @public\n */\nexport type PoseidonPlaintext = SubSubSubBrandedType<Bn254FieldElement, \"PoseidonPlaintext\">;\n\n/**\n * Hash output from the Poseidon hash function.\n *\n * The Poseidon hash function produces a single field element as output.\n * It is collision-resistant and designed for efficient verification in SNARKs.\n *\n * @remarks\n * Output is always a valid BN254 field element. Used extensively in the Umbra protocol for\n * UTXO commitment construction, nullifier derivation, and Merkle tree nodes.\n *\n * @see {@link assertPoseidonHash}\n * @public\n */\nexport type PoseidonHash = SubSubSubBrandedType<Bn254FieldElement, \"PoseidonHash\">;\n\n/**\n * Encryption key for the Poseidon cipher.\n *\n * Keys should be generated using a cryptographically secure random number generator\n * and must be valid BN254 field elements.\n *\n * @remarks\n * Key security depends on uniform random sampling from the field. In the Umbra protocol,\n * Poseidon keys are derived deterministically from viewing keys and are scoped per-transaction.\n *\n * @see {@link assertPoseidonKey}\n * @public\n */\nexport type PoseidonKey = SubSubSubBrandedType<Bn254FieldElement, \"PoseidonKey\">;\n\n/**\n * Ciphertext output from Poseidon cipher encryption.\n *\n * The ciphertext is a field element that can only be decrypted\n * with the corresponding PoseidonKey.\n *\n * @remarks\n * Ciphertext is indistinguishable from random field elements under the security assumptions of\n * Poseidon. In the Umbra protocol, Poseidon ciphertexts are stored on-chain to represent\n * encrypted token balances in confidential token accounts.\n *\n * @see {@link assertPoseidonCiphertext}\n * @see {@link PoseidonKey}\n * @public\n */\nexport type PoseidonCiphertext = SubSubSubBrandedType<Bn254FieldElement, \"PoseidonCiphertext\">;\n\n/**\n * Counter value for the Poseidon cipher.\n *\n * Used as a nonce or counter in counter-mode encryption operations\n * with the Poseidon cipher. Similar to RcCounter but operates on\n * the BN254 field for compatibility with Poseidon's field arithmetic.\n *\n * @remarks\n * - Must be a valid BN254 field element (less than the field prime)\n * - Should be unique for each encryption operation with the same key\n * - Commonly used in counter-mode constructions for deterministic encryption\n * - Reusing a counter with the same key may compromise security\n *\n * @example\n * ```typescript\n * // Create a counter for Poseidon encryption\n * const counter = 0n;\n * assertPoseidonCounter(counter);\n * // counter is now typed as PoseidonCounter\n *\n * // Increment for next encryption\n * const nextCounter = counter + 1n;\n * assertPoseidonCounter(nextCounter);\n * ```\n *\n * @see {@link assertPoseidonCounter}\n * @public\n */\nexport type PoseidonCounter = SubSubSubBrandedType<Bn254FieldElement, \"PoseidonCounter\">;\n\n/**\n * Keystream value generated by the Poseidon keystream generator.\n *\n * A keystream is a pseudo-random value derived from a master key and counter\n * using the Poseidon PRF. It is used in stream cipher operations to encrypt\n * plaintext data (e.g., `ciphertext = plaintext + keystream`).\n *\n * @remarks\n * - Must be a valid BN254 field element (less than the field prime)\n * - Derived deterministically from (key, counter, evaluation_point)\n * - Different counters produce different keystreams for the same key\n * - Should be used only once per encryption operation\n *\n * ## Generation Formula\n *\n * ```\n * keystream = Poseidon([transactionViewingKey, counter, evaluationPoint])\n * ```\n *\n * Where `evaluationPoint` is a domain separation constant (typically 2).\n *\n * @example\n * ```typescript\n * const keystreamGenerator = getPoseidonKeystreamGenerator();\n * const keystreamMap = await keystreamGenerator([0n, 1n, 2n], masterKey);\n *\n * const keystream0 = keystreamMap.get(0n); // PoseidonKeystream for counter 0\n * const ciphertext = (plaintext + keystream0) % BN254_FIELD_PRIME;\n * ```\n *\n * @see {@link assertPoseidonKeystream}\n * @see {@link PoseidonKey}\n * @see {@link PoseidonCounter}\n * @public\n */\nexport type PoseidonKeystream = SubSubSubBrandedType<Bn254FieldElement, \"PoseidonKeystream\">;\n\n/* =============================================================================\n * RESCUE CIPHER TYPES\n * ============================================================================= */\n\n/**\n * Ciphertext output from Rescue cipher encryption.\n *\n * Rescue is an algebraic hash function and cipher designed for\n * zero-knowledge applications with a focus on STARK-friendliness.\n *\n * @remarks\n * Operates on Curve25519 field elements for compatibility with X25519 key exchange and\n * Ed25519 signatures. Used in the Umbra protocol for encrypting user account data that\n * is decryptable by the MXE (multi-party execution environment) network.\n *\n * @see {@link assertRcCiphertext}\n * @see {@link RcKey}\n * @public\n */\nexport type RcCiphertext = SubSubSubBrandedType<Curve25519FieldElement, \"RcCiphertext\">;\n\n/**\n * Plaintext input for Rescue cipher encryption.\n *\n * @remarks\n * Must be a valid Curve25519 field element (less than 2^255 - 19). Represents the raw\n * data to be encrypted with the Rescue cipher before being stored as `RcCiphertext`.\n *\n * @see {@link assertRcPlaintext}\n * @public\n */\nexport type RcPlaintext = SubSubSubBrandedType<Curve25519FieldElement, \"RcPlaintext\">;\n\n/**\n * Encryption key for the Rescue cipher.\n *\n * @remarks\n * Keys should be generated using a cryptographically secure random number generator.\n * Must be a valid Curve25519 field element (less than 2^255 - 19). In the Umbra protocol,\n * Rescue keys are typically derived from X25519 shared secrets via a KDF.\n *\n * @see {@link assertRcKey}\n * @public\n */\nexport type RcKey = SubSubSubBrandedType<Curve25519FieldElement, \"RcKey\">;\n\n/**\n * Counter value for the Rescue cipher.\n *\n * Used as a nonce or counter in counter-mode encryption operations.\n *\n * @remarks\n * Must be a valid Curve25519 field element (less than 2^255 - 19).\n * Should be unique for each encryption operation with the same key.\n * Reusing a counter with the same key may compromise confidentiality.\n *\n * @see {@link assertRcCounter}\n * @public\n */\nexport type RcCounter = SubSubSubBrandedType<Curve25519FieldElement, \"RcCounter\">;\n\n/**\n * Encryption nonce for the Rescue cipher.\n *\n * A nonce (number used once) is a unique value used to ensure that the same\n * plaintext encrypted with the same key produces different ciphertexts.\n *\n * @remarks\n * - Must be a valid U128 (128-bit unsigned integer, range [0, 2^128 - 1])\n * - Must be unique for each encryption operation with the same key\n * - Reusing a nonce with the same key compromises security\n * - Can be generated randomly or as a counter\n * - 128-bit nonces provide sufficient uniqueness for most applications\n *\n * ## Type Hierarchy\n * ```\n * bigint\n * └── UnsignedInteger (branded, value >= 0)\n * └── U128 (sub-brand, value < 2^128)\n * └── RcEncryptionNonce (sub-sub-brand)\n * ```\n *\n * @example\n * ```typescript\n * // Generate a random nonce\n * const randomNonce = generateRandomNonce();\n *\n * // Or use a counter-based nonce\n * const counterNonce = createRcEncryptionNonce(encryptionCounter++);\n * ```\n *\n * @see {@link assertRcEncryptionNonce}\n * @see {@link Nonce}\n * @public\n */\nexport type RcEncryptionNonce = SubSubBrandedType<U128, \"RcEncryptionNonce\">;\n\n/* =============================================================================\n * ELLIPTIC CURVE FIELD ELEMENT ASSERTIONS\n * ============================================================================= */\n\n/**\n * Asserts that a value is a valid BN254 field element.\n *\n * Validates that the value is a `bigint` and is within the BN254 field prime.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @param name - The name of the variable being asserted (used in error messages)\n * @defaultValue `name` — `\"value\"`\n * @throws {CryptographyAssertionError} If `value` is not a bigint, is negative, or is\n * greater than or equal to `BN254_FIELD_PRIME`\n * @returns `void` — narrows the type of `value` to `Bn254FieldElement` on success\n *\n * @example\n * ```typescript\n * const value = 12345n;\n * assertBn254FieldElement(value, \"value\");\n * // value is now typed as Bn254FieldElement\n *\n * assertBn254FieldElement(-1n, \"myValue\"); // Throws: myValue is negative\n * assertBn254FieldElement(BN254_FIELD_PRIME, \"myValue\"); // Throws: myValue exceeds field prime\n * ```\n *\n * @public\n */\nexport function assertBn254FieldElement(\n value: bigint,\n name = \"value\",\n): asserts value is Bn254FieldElement {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`${name}: Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"Bn254FieldElement\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`${name}: Value ${String(value)} is negative`, {\n value,\n expectedType: \"Bn254FieldElement\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`${name}: Value exceeds BN254 field prime`, {\n value,\n expectedType: \"Bn254FieldElement\",\n constraint: `value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Curve25519 field element.\n *\n * Validates that the value is a `bigint` and is within the Curve25519 field prime (2^255 - 19).\n *\n * @param value - The bigint to assert (must be in range [0, CURVE25519_FIELD_PRIME - 1])\n * @param name - The name of the variable being asserted (used in error messages)\n * @defaultValue `name` — `\"value\"`\n * @throws {CryptographyAssertionError} If `value` is not a bigint, is negative, or is\n * greater than or equal to `CURVE25519_FIELD_PRIME`\n * @returns `void` — narrows the type of `value` to `Curve25519FieldElement` on success\n *\n * @example\n * ```typescript\n * const value = 12345n;\n * assertCurve25519FieldElement(value, \"value\");\n * // value is now typed as Curve25519FieldElement\n *\n * assertCurve25519FieldElement(-1n, \"myValue\"); // Throws: myValue is negative\n * ```\n *\n * @public\n */\nexport function assertCurve25519FieldElement(\n value: bigint,\n name = \"value\",\n): asserts value is Curve25519FieldElement {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`${name}: Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"Curve25519FieldElement\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`${name}: Value ${String(value)} is negative`, {\n value,\n expectedType: \"Curve25519FieldElement\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= CURVE25519_FIELD_PRIME) {\n throw new CryptographyAssertionError(`${name}: Value exceeds Curve25519 field prime`, {\n value,\n expectedType: \"Curve25519FieldElement\",\n constraint: \"value < 2^255 - 19\",\n });\n }\n}\n\n/* =============================================================================\n * X25519 KEY EXCHANGE ASSERTIONS\n * ============================================================================= */\n\n/**\n * Asserts that a value is a valid X25519 byte array (32 bytes).\n *\n * X25519 operations (public keys, private keys, shared secrets) all use\n * 32-byte values. This assertion validates that the input is a `Uint8Array`\n * with exactly 32 bytes.\n *\n * @param value - The Uint8Array to assert (must be exactly `X25519_BYTE_LENGTH` bytes)\n * @throws {CryptographyAssertionError} If the value is not a Uint8Array or not exactly 32 bytes\n * @returns `void` — narrows the type of `value` to `X25519Bytes` on success\n *\n * @example\n * ```typescript\n * const rawBytes = new Uint8Array(32);\n * assertX25519Bytes(rawBytes);\n * // rawBytes is now typed as X25519Bytes\n *\n * assertX25519Bytes(new Uint8Array(31)); // Throws: wrong length\n * ```\n *\n * @public\n */\nexport function assertX25519Bytes(value: Uint8Array): asserts value is X25519Bytes {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"X25519Bytes\",\n });\n }\n if (value.length !== X25519_BYTE_LENGTH) {\n throw new CryptographyAssertionError(\n `Expected ${String(X25519_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"X25519Bytes\",\n constraint: `length === ${String(X25519_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid X25519 private key.\n *\n * A private key must be exactly 32 bytes. This assertion validates both\n * the type and the length of the input.\n *\n * @param value - The Uint8Array to assert (must be exactly `X25519_BYTE_LENGTH` bytes)\n * @throws {CryptographyAssertionError} If the value is not a Uint8Array or not exactly 32 bytes\n * @returns `void` — narrows the type of `value` to `X25519PrivateKey` on success\n *\n * @remarks\n * **Security Warning**: Private keys must be kept secret. Never log, transmit, or expose private\n * keys. Use secure storage mechanisms such as encrypted local storage or a hardware wallet.\n *\n * @example\n * ```typescript\n * // Generate a new private key\n * const rawKey = crypto.getRandomValues(new Uint8Array(32));\n * assertX25519PrivateKey(rawKey);\n * // rawKey is now typed as X25519PrivateKey\n * ```\n *\n * @public\n */\nexport function assertX25519PrivateKey(value: Uint8Array): asserts value is X25519PrivateKey {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"X25519PrivateKey\",\n });\n }\n if (value.length !== X25519_BYTE_LENGTH) {\n throw new CryptographyAssertionError(\n `Expected ${String(X25519_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"X25519PrivateKey\",\n constraint: `length === ${String(X25519_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid X25519 public key.\n *\n * A public key must be exactly 32 bytes. This assertion validates both\n * the type and the length of the input.\n *\n * @param value - The Uint8Array to assert (must be exactly `X25519_BYTE_LENGTH` bytes)\n * @throws {CryptographyAssertionError} If the value is not a Uint8Array or not exactly 32 bytes\n * @returns `void` — narrows the type of `value` to `X25519PublicKey` on success\n *\n * @example\n * ```typescript\n * // Receive and validate a public key\n * const theirKey = receivePublicKey();\n * assertX25519PublicKey(theirKey);\n * // theirKey is now typed as X25519PublicKey\n *\n * // Use in key exchange\n * const sharedSecret = x25519(myPrivateKey, theirKey);\n * ```\n *\n * @public\n */\nexport function assertX25519PublicKey(value: Uint8Array): asserts value is X25519PublicKey {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"X25519PublicKey\",\n });\n }\n if (value.length !== X25519_BYTE_LENGTH) {\n throw new CryptographyAssertionError(\n `Expected ${String(X25519_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"X25519PublicKey\",\n constraint: `length === ${String(X25519_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid X25519 shared secret.\n *\n * A shared secret is the result of an X25519 Diffie-Hellman key exchange.\n * It must be exactly 32 bytes. This assertion validates both the type\n * and the length of the input.\n *\n * @param value - The Uint8Array to assert (must be exactly `X25519_BYTE_LENGTH` bytes)\n * @throws {CryptographyAssertionError} If the value is not a Uint8Array or not exactly 32 bytes\n * @returns `void` — narrows the type of `value` to `SharedSecret` on success\n *\n * @remarks\n * Shared secrets should never be used directly as encryption keys.\n * Always use a Key Derivation Function (KDF) like HKDF to derive\n * encryption keys from shared secrets.\n *\n * @example\n * ```typescript\n * // After performing X25519 key exchange\n * const rawSecret = x25519(privateKey, publicKey);\n * assertSharedSecret(rawSecret);\n * // rawSecret is now typed as SharedSecret\n *\n * // Use with a KDF (recommended)\n * const encryptionKey = hkdf(rawSecret, salt, info);\n * ```\n *\n * @public\n */\nexport function assertSharedSecret(value: Uint8Array): asserts value is SharedSecret {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"SharedSecret\",\n });\n }\n if (value.length !== X25519_BYTE_LENGTH) {\n throw new CryptographyAssertionError(\n `Expected ${String(X25519_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"SharedSecret\",\n constraint: `length === ${String(X25519_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * POSEIDON CIPHER ASSERTIONS\n * ============================================================================= */\n\n/**\n * Asserts that a value is a valid Poseidon plaintext.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint, is negative, or exceeds BN254 field prime\n * @returns `void` — narrows the type of `value` to `PoseidonPlaintext` on success\n *\n * @example\n * ```typescript\n * assertPoseidonPlaintext(messageAsBigInt);\n * // messageAsBigInt is now typed as PoseidonPlaintext\n * ```\n *\n * @public\n */\nexport function assertPoseidonPlaintext(value: bigint): asserts value is PoseidonPlaintext {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"PoseidonPlaintext\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`Value ${String(value)} is negative`, {\n value,\n expectedType: \"PoseidonPlaintext\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value exceeds BN254 field prime`, {\n value,\n expectedType: \"PoseidonPlaintext\",\n constraint: `value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Poseidon hash.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint, is negative, or exceeds BN254 field prime\n * @returns `void` — narrows the type of `value` to `PoseidonHash` on success\n *\n * @example\n * ```typescript\n * assertPoseidonHash(hashOutputBigInt);\n * // hashOutputBigInt is now typed as PoseidonHash\n * ```\n *\n * @public\n */\nexport function assertPoseidonHash(value: bigint): asserts value is PoseidonHash {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"PoseidonHash\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`Value ${String(value)} is negative`, {\n value,\n expectedType: \"PoseidonHash\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value exceeds BN254 field prime`, {\n value,\n expectedType: \"PoseidonHash\",\n constraint: `value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Poseidon key.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint, is negative, or exceeds BN254 field prime\n * @returns `void` — narrows the type of `value` to `PoseidonKey` on success\n *\n * @example\n * ```typescript\n * assertPoseidonKey(secretKeyBigInt);\n * // secretKeyBigInt is now typed as PoseidonKey\n * ```\n *\n * @public\n */\nexport function assertPoseidonKey(value: bigint): asserts value is PoseidonKey {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"PoseidonKey\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`Value ${String(value)} is negative`, {\n value,\n expectedType: \"PoseidonKey\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value exceeds BN254 field prime`, {\n value,\n expectedType: \"PoseidonKey\",\n constraint: `value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Poseidon ciphertext.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint, is negative, or exceeds BN254 field prime\n * @returns `void` — narrows the type of `value` to `PoseidonCiphertext` on success\n *\n * @example\n * ```typescript\n * assertPoseidonCiphertext(encryptedBigInt);\n * // encryptedBigInt is now typed as PoseidonCiphertext\n * ```\n *\n * @public\n */\nexport function assertPoseidonCiphertext(value: bigint): asserts value is PoseidonCiphertext {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"PoseidonCiphertext\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`Value ${String(value)} is negative`, {\n value,\n expectedType: \"PoseidonCiphertext\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value exceeds BN254 field prime`, {\n value,\n expectedType: \"PoseidonCiphertext\",\n constraint: `value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Poseidon counter.\n *\n * Validates that the value is a `bigint` and is within the BN254 field prime.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint or out of range\n *\n * @remarks\n * - Input must be a non-negative bigint\n * - Value must be less than the BN254 field prime\n * - Counters should be unique for each encryption operation with the same key\n * - Commonly incremented sequentially starting from 0\n *\n * @example\n * ```typescript\n * assertPoseidonCounter(counterBigInt);\n * // counterBigInt is now typed as PoseidonCounter\n *\n * assertPoseidonCounter(-1n); // Throws: negative value\n * assertPoseidonCounter(BN254_FIELD_PRIME); // Throws: exceeds field prime\n * ```\n *\n * @public\n */\nexport function assertPoseidonCounter(value: bigint): asserts value is PoseidonCounter {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"PoseidonCounter\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`Value ${String(value)} is negative`, {\n value,\n expectedType: \"PoseidonCounter\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value exceeds BN254 field prime`, {\n value,\n expectedType: \"PoseidonCounter\",\n constraint: `value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Poseidon keystream.\n *\n * Validates that the value is a `bigint` and is within the BN254 field prime.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint or out of range\n *\n * @remarks\n * - Input must be a non-negative bigint\n * - Value must be less than the BN254 field prime\n * - Keystreams are derived from (key, counter) pairs using Poseidon PRF\n *\n * @example\n * ```typescript\n * assertPoseidonKeystream(keystreamBigInt);\n * // keystreamBigInt is now typed as PoseidonKeystream\n *\n * assertPoseidonKeystream(-1n); // Throws: negative value\n * assertPoseidonKeystream(BN254_FIELD_PRIME); // Throws: exceeds field prime\n * ```\n *\n * @public\n */\nexport function assertPoseidonKeystream(value: bigint): asserts value is PoseidonKeystream {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"PoseidonKeystream\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`Value ${String(value)} is negative`, {\n value,\n expectedType: \"PoseidonKeystream\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value exceeds BN254 field prime`, {\n value,\n expectedType: \"PoseidonKeystream\",\n constraint: `value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/* =============================================================================\n * RESCUE CIPHER ASSERTIONS\n * ============================================================================= */\n\n/**\n * Asserts that a value is a valid Rescue cipher ciphertext.\n *\n * Validates that the value is a `bigint` and is within the Curve25519 field prime.\n *\n * @param value - The bigint to assert (must be in range [0, 2^255 - 19 - 1])\n * @param name - The name of the variable being asserted (for error messages)\n * @throws {CryptographyAssertionError} If not a bigint or out of range\n *\n * @remarks\n * - Input must be a non-negative bigint\n * - Value must be less than the Curve25519 field prime (2^255 - 19)\n *\n * @example\n * ```typescript\n * assertRcCiphertext(encryptedBigInt, \"encryptedBigInt\");\n * // encryptedBigInt is now typed as RcCiphertext\n *\n * assertRcCiphertext(-1n, \"myValue\"); // Throws: myValue is negative\n * assertRcCiphertext(CURVE25519_FIELD_PRIME, \"myValue\"); // Throws: myValue exceeds field prime\n * ```\n *\n * @public\n */\nexport function assertRcCiphertext(value: bigint, name = \"value\"): asserts value is RcCiphertext {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`${name}: Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"RcCiphertext\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`${name}: Value ${String(value)} is negative`, {\n value,\n expectedType: \"RcCiphertext\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= CURVE25519_FIELD_PRIME) {\n throw new CryptographyAssertionError(`${name}: Value exceeds Curve25519 field prime`, {\n value,\n expectedType: \"RcCiphertext\",\n constraint: \"value < 2^255 - 19\",\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Rescue cipher plaintext.\n *\n * Validates that the value is a `bigint` and is within the Curve25519 field prime.\n *\n * @param value - The bigint to assert (must be in range [0, 2^255 - 19 - 1])\n * @param name - The name of the variable being asserted (for error messages)\n * @throws {CryptographyAssertionError} If not a bigint or out of range\n *\n * @remarks\n * - Input must be a non-negative bigint\n * - Value must be less than the Curve25519 field prime (2^255 - 19)\n *\n * @example\n * ```typescript\n * assertRcPlaintext(messageBigInt, \"messageBigInt\");\n * // messageBigInt is now typed as RcPlaintext\n *\n * assertRcPlaintext(-1n, \"myValue\"); // Throws: myValue is negative\n * ```\n *\n * @public\n */\nexport function assertRcPlaintext(value: bigint, name = \"value\"): asserts value is RcPlaintext {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`${name}: Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"RcPlaintext\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`${name}: Value ${String(value)} is negative`, {\n value,\n expectedType: \"RcPlaintext\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= CURVE25519_FIELD_PRIME) {\n throw new CryptographyAssertionError(`${name}: Value exceeds Curve25519 field prime`, {\n value,\n expectedType: \"RcPlaintext\",\n constraint: \"value < 2^255 - 19\",\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Rescue cipher key.\n *\n * Validates that the value is a `bigint` and is within the Curve25519 field prime.\n *\n * @param value - The bigint to assert (must be in range [0, 2^255 - 19 - 1])\n * @param name - The name of the variable being asserted (for error messages)\n * @throws {CryptographyAssertionError} If not a bigint or out of range\n *\n * @remarks\n * - Input must be a non-negative bigint\n * - Value must be less than the Curve25519 field prime (2^255 - 19)\n * - Keys should be generated using a cryptographically secure random number generator\n *\n * @example\n * ```typescript\n * assertRcKey(secretKeyBigInt, \"secretKeyBigInt\");\n * // secretKeyBigInt is now typed as RcKey\n *\n * assertRcKey(-1n, \"myKey\"); // Throws: myKey is negative\n * ```\n *\n * @public\n */\nexport function assertRcKey(value: bigint, name = \"value\"): asserts value is RcKey {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`${name}: Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"RcKey\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`${name}: Value ${String(value)} is negative`, {\n value,\n expectedType: \"RcKey\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= CURVE25519_FIELD_PRIME) {\n throw new CryptographyAssertionError(`${name}: Value exceeds Curve25519 field prime`, {\n value,\n expectedType: \"RcKey\",\n constraint: \"value < 2^255 - 19\",\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Rescue cipher counter.\n *\n * Validates that the value is a `bigint` and is within the Curve25519 field prime.\n *\n * @param value - The bigint to assert (must be in range [0, 2^255 - 19 - 1])\n * @throws {CryptographyAssertionError} If not a bigint or out of range\n *\n * @remarks\n * - Input must be a non-negative bigint\n * - Value must be less than the Curve25519 field prime (2^255 - 19)\n * - Counters should be unique for each encryption operation with the same key\n *\n * @example\n * ```typescript\n * assertRcCounter(counterBigInt);\n * // counterBigInt is now typed as RcCounter\n *\n * assertRcCounter(-1n); // Throws: negative value\n * ```\n *\n * @public\n */\nexport function assertRcCounter(value: bigint): asserts value is RcCounter {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"RcCounter\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`Value ${String(value)} is negative`, {\n value,\n expectedType: \"RcCounter\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= CURVE25519_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value exceeds Curve25519 field prime`, {\n value,\n expectedType: \"RcCounter\",\n constraint: \"value < 2^255 - 19\",\n });\n }\n}\n\n/**\n * Asserts that a value is a valid Rescue cipher encryption nonce.\n *\n * Validates that the value is a `bigint` and is within the U128 range.\n *\n * @param value - The bigint to assert (must be in range [0, 2^128 - 1])\n * @param name - The name of the variable being asserted (for error messages)\n * @throws {CryptographyAssertionError} If not a bigint or out of range\n *\n * @remarks\n * - Input must be a non-negative bigint\n * - Value must be less than or equal to 2^128 - 1\n * - Nonces must be unique for each encryption operation with the same key\n * - Reusing a nonce with the same key compromises security\n *\n * @example\n * ```typescript\n * assertRcEncryptionNonce(nonceBigInt, \"nonceBigInt\");\n * // nonceBigInt is now typed as RcEncryptionNonce\n *\n * assertRcEncryptionNonce(-1n, \"myNonce\"); // Throws: myNonce is negative\n * assertRcEncryptionNonce(2n ** 128n, \"myNonce\"); // Throws: myNonce exceeds U128 max\n * ```\n *\n * @public\n */\nexport function assertRcEncryptionNonce(\n value: bigint,\n name = \"value\",\n): asserts value is RcEncryptionNonce {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`${name}: Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"RcEncryptionNonce\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`${name}: Value ${String(value)} is negative`, {\n value,\n expectedType: \"RcEncryptionNonce\",\n constraint: \"value >= 0\",\n });\n }\n if (value > U128_MAX) {\n throw new CryptographyAssertionError(`${name}: Value exceeds U128 maximum`, {\n value,\n expectedType: \"RcEncryptionNonce\",\n constraint: \"value <= 2^128 - 1\",\n });\n }\n}\n\n/* =============================================================================\n * KECCAK HASH TYPES\n *\n * Branded types for Keccak (SHA-3) hash outputs. These types ensure\n * type-safe handling of cryptographic hash values.\n * ============================================================================= */\n\n/**\n * Output of the Keccak-256 (SHA3-256) hash function.\n *\n * Keccak-256 is a cryptographic hash function from the SHA-3 family that produces\n * a 256-bit (32-byte) digest. It is widely used in blockchain applications,\n * notably as the primary hash function in Ethereum.\n *\n * @remarks\n * - Always exactly 32 bytes (256 bits)\n * - Stored in little-endian byte order\n * - Collision-resistant and preimage-resistant\n * - NOT the same as NIST SHA3-256 (uses different padding)\n *\n * ## Type Hierarchy\n * ```\n * Bytes (base branded type)\n * └── LeBytes (little-endian sub-brand)\n * └── U256LeBytes (256-bit sized sub-sub-brand)\n * └── Keccak256Hash (hash-specific sub-sub-sub-brand)\n * ```\n *\n * ## Use Cases\n * - Address derivation in Ethereum-compatible systems\n * - Commitment schemes\n * - Merkle tree construction\n * - General-purpose cryptographic hashing\n *\n * @example\n * ```typescript\n * import { assertKeccak256Hash, Keccak256Hash } from \"./cryptography\";\n *\n * const hashBytes = keccak256(data);\n * assertKeccak256Hash(hashBytes);\n * // hashBytes is now typed as Keccak256Hash\n * ```\n *\n * @see {@link assertKeccak256Hash}\n * @public\n */\nexport type Keccak256Hash = SubSubSubBrandedType<U256LeBytes, \"Keccak256Hash\">;\n\n/**\n * Output of the Keccak-512 (SHA3-512) hash function.\n *\n * Keccak-512 is a cryptographic hash function from the SHA-3 family that produces\n * a 512-bit (64-byte) digest. It provides a higher security margin than Keccak-256\n * and is used when stronger collision resistance is required.\n *\n * @remarks\n * - Always exactly 64 bytes (512 bits)\n * - Stored in little-endian byte order\n * - Provides 256-bit security against collision attacks\n * - Used as the basis for master seed derivation\n *\n * ## Type Hierarchy\n * ```\n * Bytes (base branded type)\n * └── LeBytes (little-endian sub-brand)\n * └── U512LeBytes (512-bit sized sub-sub-brand)\n * └── Keccak512Hash (hash-specific sub-sub-sub-brand)\n * ```\n *\n * ## Use Cases\n * - Master seed generation (see {@link MasterSeed})\n * - High-security key derivation\n * - Extended hash outputs for cryptographic protocols\n *\n * @example\n * ```typescript\n * import { assertKeccak512Hash, Keccak512Hash } from \"./cryptography\";\n *\n * const hashBytes = keccak512(entropy);\n * assertKeccak512Hash(hashBytes);\n * // hashBytes is now typed as Keccak512Hash\n * ```\n *\n * @see {@link assertKeccak512Hash}\n * @see {@link MasterSeed}\n * @public\n */\nexport type Keccak512Hash = SubSubSubBrandedType<U512LeBytes, \"Keccak512Hash\">;\n\n/* =============================================================================\n * KEY DERIVATION TYPES\n *\n * Types for hierarchical key derivation used in privacy-preserving protocols.\n * These types represent the master seed and viewing keys at various time granularities.\n * ============================================================================= */\n\n/**\n * Master seed for hierarchical key derivation.\n *\n * The master seed is the root of a hierarchical deterministic (HD) key derivation\n * tree. It is generated from high-entropy input (typically via Keccak-512 hashing)\n * and is used to derive all other keys in the system.\n *\n * @remarks\n * - Always exactly 64 bytes (512 bits)\n * - Generated from Keccak-512 hash of entropy source\n * - MUST be kept secret - compromise reveals all derived keys\n * - Should be generated from at least 256 bits of entropy\n * - Used to derive the master viewing key\n *\n * ## Type Hierarchy\n * ```\n * Bytes (base)\n * └── LeBytes\n * └── U512LeBytes\n * └── Keccak512Hash\n * └── MasterSeed\n * ```\n *\n * ## Security Considerations\n * - Store securely (encrypted at rest)\n * - Never transmit over insecure channels\n * - Consider using hardware security modules (HSM) for production\n * - Backup procedures should use secure, offline storage\n *\n * @example\n * ```typescript\n * import { assertMasterSeed, MasterSeed } from \"./cryptography\";\n *\n * // Generate master seed from entropy\n * const entropy = crypto.getRandomValues(new Uint8Array(32));\n * const seedBytes = keccak512(entropy);\n * assertMasterSeed(seedBytes);\n * // seedBytes is now typed as MasterSeed\n *\n * // Derive master viewing key\n * const masterViewingKey = deriveMasterViewingKey(seedBytes);\n * ```\n *\n * @see {@link assertMasterSeed}\n * @see {@link MasterViewingKey}\n * @public\n */\nexport type MasterSeed = SubSubSubSubBrandedType<Keccak512Hash, \"MasterSeed\">;\n\n/**\n * Generation seed for ephemeral key derivation.\n *\n * A generation seed is used as input to derive ephemeral master seeds for\n * single-use key derivation scenarios. This enables forward secrecy by\n * allowing unique seeds to be generated for each operation.\n *\n * @remarks\n * - Always exactly 64 bytes (512 bits)\n * - Typically derived from external entropy or protocol-specific data\n * - Used as input to ephemeral master seed generation\n * - Different from MasterSeed in that it's meant as an input, not a derived root\n *\n * ## Type Hierarchy\n * ```\n * Bytes (base)\n * └── LeBytes\n * └── U512LeBytes\n * └── Keccak512Hash\n * └── GenerationSeed\n * ```\n *\n * ## Use Cases\n * - Ephemeral key generation with deterministic input\n * - Protocol-specific seed derivation\n * - Forward secrecy implementations\n *\n * @example\n * ```typescript\n * import { assertGenerationSeed, GenerationSeed } from \"./cryptography\";\n *\n * // Create generation seed from protocol data\n * const seedBytes = keccak512(protocolData);\n * assertGenerationSeed(seedBytes);\n * // seedBytes is now typed as GenerationSeed\n *\n * // Use to generate ephemeral master seed\n * const ephemeralSeed = generateEphemeralMasterSeed(seedBytes);\n * ```\n *\n * @see {@link assertGenerationSeed}\n * @public\n */\nexport type GenerationSeed = SubSubSubSubBrandedType<Keccak512Hash, \"GenerationSeed\">;\n\n/**\n * Master viewing key for privacy-preserving protocols.\n *\n * The master viewing key is derived from the master seed and serves as the root\n * of the viewing key derivation tree. It can be used to derive time-scoped viewing keys\n * (yearly, monthly, daily, etc.) for selective disclosure of transaction history.\n *\n * @remarks\n * - Element of the BN254 scalar field (< field prime)\n * - Derived deterministically from the master seed\n * - Allows viewing ALL transactions without spending capability\n * - Can be shared to grant full viewing access\n *\n * ## Type Hierarchy\n * All viewing keys are siblings under Bn254FieldElement (NOT subbrands of each other):\n * ```\n * bigint (base)\n * └── U256 (SubBrandedType)\n * └── Bn254FieldElement (SubSubBrandedType)\n * ├── MasterViewingKey (SubSubSubBrandedType)\n * ├── YearlyViewingKey (SubSubSubBrandedType)\n * ├── MonthlyViewingKey (SubSubSubBrandedType)\n * ├── DailyViewingKey (SubSubSubBrandedType)\n * ├── HourlyViewingKey (SubSubSubBrandedType)\n * ├── MinuteViewingKey (SubSubSubBrandedType)\n * └── SecondViewingKey (SubSubSubBrandedType)\n * ```\n *\n * ## Derivation Hierarchy (NOT type hierarchy)\n * The following shows how keys are DERIVED, not their type relationships:\n * ```\n * MasterSeed\n * └── MasterViewingKey (views all time)\n * ├── YearlyViewingKey (views specific year)\n * ├── MonthlyViewingKey (views specific month)\n * ├── DailyViewingKey (views specific day)\n * ├── HourlyViewingKey (views specific hour)\n * ├── MinuteViewingKey (views specific minute)\n * └── SecondViewingKey (views specific second)\n * ```\n *\n * @example\n * ```typescript\n * import { MasterViewingKey, assertMasterViewingKey } from \"./cryptography\";\n *\n * const mvk = deriveMasterViewingKey(masterSeed);\n * assertMasterViewingKey(mvk);\n *\n * // Grant viewing access to auditor\n * shareViewingKey(auditor, mvk); // Full access\n * ```\n *\n * @see {@link assertMasterViewingKey}\n * @see {@link YearlyViewingKey}\n * @see {@link MintViewingKey}\n * @public\n */\nexport type MasterViewingKey = SubSubSubBrandedType<Bn254FieldElement, \"MasterViewingKey\">;\n\n/**\n * Yearly viewing key for time-scoped transaction viewing.\n *\n * A yearly viewing key is derived from the master viewing key and grants\n * viewing access to all transactions within a specific calendar year.\n * This enables selective disclosure for annual audits or tax reporting.\n *\n * @remarks\n * - Element of the BN254 scalar field\n * - Derived from master viewing key + year identifier\n * - Can view all transactions in the specified year\n * - Cannot view transactions from other years\n * - Can derive monthly, daily, and finer-grained keys\n *\n * ## Use Cases\n * - Annual financial audits\n * - Tax reporting requirements\n * - Yearly compliance reviews\n * - Historical transaction analysis for a specific year\n *\n * @example\n * ```typescript\n * import { YearlyViewingKey, assertYearlyViewingKey } from \"./cryptography\";\n *\n * const yearKey = deriveYearlyViewingKey(masterViewingKey, 2024);\n * assertYearlyViewingKey(yearKey);\n *\n * // Share with tax authority for 2024 audit\n * shareViewingKey(taxAuthority, yearKey);\n * ```\n *\n * @see {@link assertYearlyViewingKey}\n * @see {@link MonthlyViewingKey}\n * @public\n */\nexport type YearlyViewingKey = SubSubSubBrandedType<Bn254FieldElement, \"YearlyViewingKey\">;\n\n/**\n * Monthly viewing key for time-scoped transaction viewing.\n *\n * A monthly viewing key grants viewing access to all transactions within\n * a specific calendar month. It is derived from the yearly viewing key\n * and provides more granular access control than yearly keys.\n *\n * @remarks\n * - Element of the BN254 scalar field\n * - Derived from yearly viewing key + month identifier\n * - Can view all transactions in the specified month\n * - Cannot view transactions from other months\n * - Can derive daily and finer-grained keys\n *\n * ## Use Cases\n * - Monthly financial reconciliation\n * - Periodic audit sampling\n * - Subscription billing verification\n * - Monthly expense reporting\n *\n * @example\n * ```typescript\n * import { MonthlyViewingKey, assertMonthlyViewingKey } from \"./cryptography\";\n *\n * const monthKey = deriveMonthlyViewingKey(yearlyKey, 6); // June\n * assertMonthlyViewingKey(monthKey);\n *\n * // Share with accountant for monthly review\n * shareViewingKey(accountant, monthKey);\n * ```\n *\n * @see {@link assertMonthlyViewingKey}\n * @see {@link DailyViewingKey}\n * @public\n */\nexport type MonthlyViewingKey = SubSubSubBrandedType<Bn254FieldElement, \"MonthlyViewingKey\">;\n\n/**\n * Daily viewing key for time-scoped transaction viewing.\n *\n * A daily viewing key grants viewing access to all transactions within\n * a specific calendar day. It provides fine-grained access control for\n * scenarios requiring day-level precision.\n *\n * @remarks\n * - Element of the BN254 scalar field\n * - Derived from monthly viewing key + day identifier\n * - Can view all transactions on the specified day\n * - Cannot view transactions from other days\n * - Can derive hourly and finer-grained keys\n *\n * ## Use Cases\n * - Daily settlement verification\n * - Incident investigation for specific dates\n * - Daily trading activity review\n * - Point-in-time compliance checks\n *\n * @example\n * ```typescript\n * import { DailyViewingKey, assertDailyViewingKey } from \"./cryptography\";\n *\n * const dayKey = deriveDailyViewingKey(monthlyKey, 15); // 15th of month\n * assertDailyViewingKey(dayKey);\n *\n * // Share for investigating a specific date\n * shareViewingKey(investigator, dayKey);\n * ```\n *\n * @see {@link assertDailyViewingKey}\n * @see {@link HourlyViewingKey}\n * @public\n */\nexport type DailyViewingKey = SubSubSubBrandedType<Bn254FieldElement, \"DailyViewingKey\">;\n\n/**\n * Hourly viewing key for time-scoped transaction viewing.\n *\n * An hourly viewing key grants viewing access to all transactions within\n * a specific hour. This provides very fine-grained access control for\n * high-frequency trading scenarios or detailed forensic analysis.\n *\n * @remarks\n * - Element of the BN254 scalar field\n * - Derived from daily viewing key + hour identifier (0-23)\n * - Can view all transactions in the specified hour\n * - Cannot view transactions from other hours\n * - Can derive minute and second-level keys\n *\n * ## Use Cases\n * - High-frequency trading audits\n * - Incident response for specific time windows\n * - Market manipulation investigation\n * - Detailed activity timeline construction\n *\n * @example\n * ```typescript\n * import { HourlyViewingKey, assertHourlyViewingKey } from \"./cryptography\";\n *\n * const hourKey = deriveHourlyViewingKey(dailyKey, 14); // 2 PM\n * assertHourlyViewingKey(hourKey);\n * ```\n *\n * @see {@link assertHourlyViewingKey}\n * @see {@link MinuteViewingKey}\n * @public\n */\nexport type HourlyViewingKey = SubSubSubBrandedType<Bn254FieldElement, \"HourlyViewingKey\">;\n\n/**\n * Minute viewing key for time-scoped transaction viewing.\n *\n * A minute viewing key grants viewing access to all transactions within\n * a specific minute. This provides extremely fine-grained access control\n * for forensic analysis or real-time monitoring scenarios.\n *\n * @remarks\n * - Element of the BN254 scalar field\n * - Derived from hourly viewing key + minute identifier (0-59)\n * - Can view all transactions in the specified minute\n * - Cannot view transactions from other minutes\n * - Can derive second-level keys for ultimate precision\n *\n * ## Use Cases\n * - Real-time fraud detection analysis\n * - Precise transaction timing verification\n * - Forensic timeline reconstruction\n * - Flash loan attack investigation\n *\n * @example\n * ```typescript\n * import { MinuteViewingKey, assertMinuteViewingKey } from \"./cryptography\";\n *\n * const minuteKey = deriveMinuteViewingKey(hourlyKey, 30); // :30 minute\n * assertMinuteViewingKey(minuteKey);\n * ```\n *\n * @see {@link assertMinuteViewingKey}\n * @see {@link SecondViewingKey}\n * @public\n */\nexport type MinuteViewingKey = SubSubSubBrandedType<Bn254FieldElement, \"MinuteViewingKey\">;\n\n/**\n * Second viewing key for time-scoped transaction viewing.\n *\n * A second viewing key grants viewing access to all transactions within\n * a specific second. This is the finest granularity of viewing keys and\n * is primarily used for forensic analysis of specific transactions.\n *\n * @remarks\n * - Element of the BN254 scalar field\n * - Derived from minute viewing key + second identifier (0-59)\n * - Can view all transactions in the specified second\n * - Cannot view transactions from other seconds\n * - Finest granularity in the viewing key hierarchy\n *\n * ## Use Cases\n * - Precise transaction attribution\n * - MEV (Maximal Extractable Value) analysis\n * - Front-running detection\n * - Block-level transaction ordering analysis\n *\n * @example\n * ```typescript\n * import { SecondViewingKey, assertSecondViewingKey } from \"./cryptography\";\n *\n * const secondKey = deriveSecondViewingKey(minuteKey, 45); // :45 second\n * assertSecondViewingKey(secondKey);\n * ```\n *\n * @see {@link assertSecondViewingKey}\n * @public\n */\nexport type SecondViewingKey = SubSubSubBrandedType<Bn254FieldElement, \"SecondViewingKey\">;\n\n/**\n * Mint viewing key for token-specific transaction viewing.\n *\n * A mint viewing key grants viewing access to all transactions involving\n * a specific token (mint address). This allows selective disclosure of\n * activity for a particular asset without revealing transactions of other tokens.\n *\n * @remarks\n * - Element of the BN254 scalar field\n * - Derived from master viewing key + mint address\n * - Can view all transactions involving the specified mint\n * - Cannot view transactions involving other mints\n * - Used as base for time-scoped viewing keys for a specific mint\n *\n * ## Derivation\n *\n * The mint viewing key is derived using Poseidon hash:\n * ```\n * h0 = Poseidon(MVK, mintAddressLow, mintAddressHigh)\n * ```\n *\n * Where:\n * - MVK is the master viewing key\n * - mintAddressLow is bytes 0-15 of the mint address (little-endian U128)\n * - mintAddressHigh is bytes 16-31 of the mint address (little-endian U128)\n *\n * ## Use Cases\n * - Token-specific compliance reporting\n * - Asset-specific audit trails\n * - Selective disclosure for specific tokens\n * - Token holder activity analysis\n *\n * @example\n * ```typescript\n * import { MintViewingKey, assertMintViewingKey } from \"./cryptography\";\n *\n * const mintKey = deriveMintViewingKey(masterViewingKey, usdcMint);\n * assertMintViewingKey(mintKey);\n *\n * // Share with auditor for USDC-specific review\n * shareViewingKey(auditor, mintKey);\n * ```\n *\n * @see {@link assertMintViewingKey}\n * @public\n */\nexport type MintViewingKey = SubSubSubBrandedType<Bn254FieldElement, \"MintViewingKey\">;\n\n/* =============================================================================\n * X25519 KEYPAIR TYPE\n *\n * A composite type representing an X25519 key pair for Diffie-Hellman\n * key exchange operations.\n * ============================================================================= */\n\n/**\n * An X25519 key pair consisting of a private key and its corresponding public key.\n *\n * X25519 is an elliptic curve Diffie-Hellman (ECDH) protocol using Curve25519.\n * A keypair consists of:\n * - A 32-byte private key (random or derived)\n * - A 32-byte public key (computed from the private key)\n *\n * @remarks\n * ## Key Generation\n * - Private key: 32 random bytes (optionally clamped per X25519 spec)\n * - Public key: Scalar multiplication of private key with base point\n *\n * ## Security Properties\n * - Private key MUST be kept secret\n * - Public key can be freely shared\n * - Shared secret is computed as: `X25519(myPrivate, theirPublic)`\n * - Key exchange is symmetric: both parties compute the same shared secret\n *\n * ## Use Cases\n * - End-to-end encryption key establishment\n * - Ephemeral key exchange for forward secrecy\n * - Diffie-Hellman key agreement in protocols like Noise, Signal\n * - Deriving symmetric encryption keys from asymmetric exchange\n *\n * @example\n * ```typescript\n * import { X25519Keypair, generateX25519Keypair } from \"./cryptography\";\n *\n * // Generate a new keypair\n * const keypair: X25519Keypair = await generateX25519Keypair();\n *\n * // Share public key with peer\n * sendPublicKey(peer, keypair.publicKey);\n *\n * // Compute shared secret with peer's public key\n * const sharedSecret = x25519(keypair.privateKey, peerPublicKey);\n * ```\n *\n * @example\n * ```typescript\n * // Ephemeral key exchange for forward secrecy\n * const ephemeralKeypair: X25519Keypair = await generateX25519Keypair();\n *\n * // Use ephemeral keypair for this session only\n * const sessionKey = deriveSessionKey(\n * x25519(ephemeralKeypair.privateKey, recipientPublicKey)\n * );\n *\n * // Discard private key after use for forward secrecy\n * ```\n *\n * @public\n */\nexport interface X25519Keypair {\n /**\n * The X25519 private key (32 bytes).\n *\n * This key MUST be kept secret. It is used to:\n * - Compute shared secrets with other parties' public keys\n * - Derive the corresponding public key\n *\n * @remarks\n * The private key should be generated from a cryptographically secure\n * random source. The X25519 algorithm applies clamping during use.\n */\n readonly privateKey: X25519PrivateKey;\n\n /**\n * The X25519 public key (32 bytes).\n *\n * This key can be freely shared. It is:\n * - Computed from the private key via scalar multiplication\n * - Used by other parties to compute shared secrets\n * - Safe to transmit over insecure channels\n */\n readonly publicKey: X25519PublicKey;\n}\n\n/* =============================================================================\n * KECCAK HASH ASSERTIONS\n * ============================================================================= */\n\n/**\n * Asserts that a value is a valid Keccak-256 hash output.\n *\n * Validates that the value is a 32-byte Uint8Array.\n *\n * @param value - The Uint8Array to assert (must be exactly `U256_BYTE_LENGTH` = 32 bytes)\n * @throws {CryptographyAssertionError} If not a Uint8Array or not exactly 32 bytes\n * @returns `void` — narrows the type of `value` to `Keccak256Hash` on success\n *\n * @example\n * ```typescript\n * const hashBytes = keccak256(data);\n * assertKeccak256Hash(hashBytes);\n * // hashBytes is now typed as Keccak256Hash\n * ```\n *\n * @public\n */\nexport function assertKeccak256Hash(value: Uint8Array): asserts value is Keccak256Hash {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"Keccak256Hash\",\n });\n }\n if (value.length !== U256_BYTE_LENGTH) {\n throw new CryptographyAssertionError(\n `Expected ${String(U256_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"Keccak256Hash\",\n constraint: `length === ${String(U256_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid Keccak-512 hash output.\n *\n * Validates that the value is a 64-byte Uint8Array.\n *\n * @param value - The Uint8Array to assert (must be exactly `U512_BYTE_LENGTH` = 64 bytes)\n * @throws {CryptographyAssertionError} If not a Uint8Array or not exactly 64 bytes\n * @returns `void` — narrows the type of `value` to `Keccak512Hash` on success\n *\n * @example\n * ```typescript\n * const hashBytes = keccak512(data);\n * assertKeccak512Hash(hashBytes);\n * // hashBytes is now typed as Keccak512Hash\n * ```\n *\n * @public\n */\nexport function assertKeccak512Hash(value: Uint8Array): asserts value is Keccak512Hash {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"Keccak512Hash\",\n });\n }\n if (value.length !== U512_BYTE_LENGTH) {\n throw new CryptographyAssertionError(\n `Expected ${String(U512_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"Keccak512Hash\",\n constraint: `length === ${String(U512_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * KEY DERIVATION ASSERTIONS\n * ============================================================================= */\n\n/**\n * Asserts that a value is a valid master seed.\n *\n * Validates that the value is a 64-byte Uint8Array (Keccak-512 hash output).\n *\n * @param value - The Uint8Array to assert (must be exactly `U512_BYTE_LENGTH` = 64 bytes)\n * @throws {CryptographyAssertionError} If not a Uint8Array or not exactly 64 bytes\n * @returns `void` — narrows the type of `value` to `MasterSeed` on success\n *\n * @example\n * ```typescript\n * const seedBytes = keccak512(entropy);\n * assertMasterSeed(seedBytes);\n * // seedBytes is now typed as MasterSeed\n * ```\n *\n * @public\n */\nexport function assertMasterSeed(value: Uint8Array): asserts value is MasterSeed {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"MasterSeed\",\n });\n }\n if (value.length !== U512_BYTE_LENGTH) {\n throw new CryptographyAssertionError(\n `Expected ${String(U512_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"MasterSeed\",\n constraint: `length === ${String(U512_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid generation seed.\n *\n * Validates that the value is a 64-byte Uint8Array (Keccak-512 hash output).\n *\n * @param value - The Uint8Array to assert (must be exactly `U512_BYTE_LENGTH` = 64 bytes)\n * @throws {CryptographyAssertionError} If not a Uint8Array or not exactly 64 bytes\n * @returns `void` — narrows the type of `value` to `GenerationSeed` on success\n *\n * @example\n * ```typescript\n * const seedBytes = keccak512(protocolData);\n * assertGenerationSeed(seedBytes);\n * // seedBytes is now typed as GenerationSeed\n * ```\n *\n * @public\n */\nexport function assertGenerationSeed(value: Uint8Array): asserts value is GenerationSeed {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"GenerationSeed\",\n });\n }\n if (value.length !== U512_BYTE_LENGTH) {\n throw new CryptographyAssertionError(\n `Expected ${String(U512_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"GenerationSeed\",\n constraint: `length === ${String(U512_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid master viewing key.\n *\n * Validates that the value is a bigint within the BN254 field.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint, is negative, or exceeds BN254 field prime\n * @returns `void` — narrows the type of `value` to `MasterViewingKey` on success\n *\n * @example\n * ```typescript\n * const mvk = deriveMasterViewingKey(masterSeed);\n * assertMasterViewingKey(mvk);\n * // mvk is now typed as MasterViewingKey\n * ```\n *\n * @public\n */\nexport function assertMasterViewingKey(value: bigint): asserts value is MasterViewingKey {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"MasterViewingKey\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`Value ${String(value)} is negative`, {\n value,\n expectedType: \"MasterViewingKey\",\n constraint: \"value >= 0\",\n });\n }\n if (value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value exceeds BN254 field prime`, {\n value,\n expectedType: \"MasterViewingKey\",\n constraint: `value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid yearly viewing key.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint or out of the BN254 field range\n * @returns `void` — narrows the type of `value` to `YearlyViewingKey` on success\n *\n * @example\n * ```typescript\n * const key = deriveYearlyViewingKey(masterViewingKey, 2024n);\n * assertYearlyViewingKey(key);\n * // key is now typed as YearlyViewingKey\n * ```\n *\n * @public\n */\nexport function assertYearlyViewingKey(value: bigint): asserts value is YearlyViewingKey {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"YearlyViewingKey\",\n });\n }\n if (value < 0n || value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value out of BN254 field range`, {\n value,\n expectedType: \"YearlyViewingKey\",\n constraint: `0 <= value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid monthly viewing key.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint or out of the BN254 field range\n * @returns `void` — narrows the type of `value` to `MonthlyViewingKey` on success\n *\n * @example\n * ```typescript\n * const key = deriveMonthlyViewingKey(yearlyViewingKey, 6n);\n * assertMonthlyViewingKey(key);\n * // key is now typed as MonthlyViewingKey\n * ```\n *\n * @public\n */\nexport function assertMonthlyViewingKey(value: bigint): asserts value is MonthlyViewingKey {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"MonthlyViewingKey\",\n });\n }\n if (value < 0n || value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value out of BN254 field range`, {\n value,\n expectedType: \"MonthlyViewingKey\",\n constraint: `0 <= value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid daily viewing key.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint or out of the BN254 field range\n * @returns `void` — narrows the type of `value` to `DailyViewingKey` on success\n *\n * @example\n * ```typescript\n * const key = deriveDailyViewingKey(monthlyViewingKey, 15n);\n * assertDailyViewingKey(key);\n * // key is now typed as DailyViewingKey\n * ```\n *\n * @public\n */\nexport function assertDailyViewingKey(value: bigint): asserts value is DailyViewingKey {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"DailyViewingKey\",\n });\n }\n if (value < 0n || value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value out of BN254 field range`, {\n value,\n expectedType: \"DailyViewingKey\",\n constraint: `0 <= value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid hourly viewing key.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint or out of the BN254 field range\n * @returns `void` — narrows the type of `value` to `HourlyViewingKey` on success\n *\n * @example\n * ```typescript\n * const key = deriveHourlyViewingKey(dailyViewingKey, 14n);\n * assertHourlyViewingKey(key);\n * // key is now typed as HourlyViewingKey\n * ```\n *\n * @public\n */\nexport function assertHourlyViewingKey(value: bigint): asserts value is HourlyViewingKey {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"HourlyViewingKey\",\n });\n }\n if (value < 0n || value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value out of BN254 field range`, {\n value,\n expectedType: \"HourlyViewingKey\",\n constraint: `0 <= value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid minute viewing key.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint or out of the BN254 field range\n * @returns `void` — narrows the type of `value` to `MinuteViewingKey` on success\n *\n * @example\n * ```typescript\n * const key = deriveMinuteViewingKey(hourlyViewingKey, 30n);\n * assertMinuteViewingKey(key);\n * // key is now typed as MinuteViewingKey\n * ```\n *\n * @public\n */\nexport function assertMinuteViewingKey(value: bigint): asserts value is MinuteViewingKey {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"MinuteViewingKey\",\n });\n }\n if (value < 0n || value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value out of BN254 field range`, {\n value,\n expectedType: \"MinuteViewingKey\",\n constraint: `0 <= value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid second viewing key.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint or out of the BN254 field range\n * @returns `void` — narrows the type of `value` to `SecondViewingKey` on success\n *\n * @example\n * ```typescript\n * const key = deriveSecondViewingKey(minuteViewingKey, 45n);\n * assertSecondViewingKey(key);\n * // key is now typed as SecondViewingKey\n * ```\n *\n * @public\n */\nexport function assertSecondViewingKey(value: bigint): asserts value is SecondViewingKey {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"SecondViewingKey\",\n });\n }\n if (value < 0n || value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value out of BN254 field range`, {\n value,\n expectedType: \"SecondViewingKey\",\n constraint: `0 <= value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid mint viewing key.\n *\n * @param value - The bigint to assert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @throws {CryptographyAssertionError} If not a bigint or out of the BN254 field range\n * @returns `void` — narrows the type of `value` to `MintViewingKey` on success\n *\n * @example\n * ```typescript\n * const key = deriveMintViewingKey(masterViewingKey, usdcMintAddress);\n * assertMintViewingKey(key);\n * // key is now typed as MintViewingKey\n * ```\n *\n * @public\n */\nexport function assertMintViewingKey(value: bigint): asserts value is MintViewingKey {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"MintViewingKey\",\n });\n }\n if (value < 0n || value >= BN254_FIELD_PRIME) {\n throw new CryptographyAssertionError(`Value out of BN254 field range`, {\n value,\n expectedType: \"MintViewingKey\",\n constraint: `0 <= value < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n}\n\n/**\n * Asserts that a value is a valid X25519 keypair.\n *\n * Validates that the value is an object with valid `privateKey` and `publicKey` fields,\n * each being a 32-byte Uint8Array.\n *\n * @param value - The object to assert (must have `privateKey` and `publicKey` Uint8Array fields)\n * @throws {CryptographyAssertionError} If the object is missing required fields or either\n * field is not a valid 32-byte Uint8Array\n * @returns `void` — narrows the type of `value` to `X25519Keypair` on success\n *\n * @example\n * ```typescript\n * const keypair = { privateKey: privKey, publicKey: pubKey };\n * assertX25519Keypair(keypair);\n * // keypair is now typed as X25519Keypair\n * ```\n *\n * @public\n */\nexport function assertX25519Keypair(value: {\n privateKey: Uint8Array;\n publicKey: Uint8Array;\n}): asserts value is X25519Keypair {\n if (!(\"privateKey\" in value) || !(\"publicKey\" in value)) {\n throw new CryptographyAssertionError(\n `Expected object with privateKey and publicKey properties`,\n {\n value,\n expectedType: \"X25519Keypair\",\n constraint: \"must have privateKey and publicKey\",\n },\n );\n }\n\n // Validate private key\n assertX25519PrivateKey(value.privateKey);\n\n // Validate public key\n assertX25519PublicKey(value.publicKey);\n}\n\n/* =============================================================================\n * BASE85 LIMB TYPES\n *\n * Types for representing large field elements as limbs for ZK circuit\n * compatibility. Base85 refers to each limb fitting in 85 bits.\n * ============================================================================= */\n\n/**\n * A single Base85 limb value.\n *\n * Base85 limbs are used to represent 256-bit values as 3 limbs, where each\n * limb fits within 85 bits (though stored as U128 for convenience).\n * This representation is commonly used in ZK circuits to handle large\n * field elements efficiently.\n *\n * @remarks\n * - Each limb must be less than 2^85\n * - Used in Poseidon hash inputs for ZK proof generation\n * - Three Base85 limbs can represent a full 256-bit value\n *\n * ## Type Hierarchy\n * ```\n * bigint\n * └── UnsignedInteger\n * └── U128\n * └── Base85Limb\n * ```\n *\n * @example\n * ```typescript\n * const limb = assertBase85Limb(12345n);\n * // limb is now typed as Base85Limb\n * ```\n *\n * @see {@link assertBase85Limb}\n * @see {@link Base85LimbTuple}\n * @see {@link BASE85_LIMB_MAX}\n * @public\n */\nexport type Base85Limb = SubSubBrandedType<U128, \"Base85Limb\">;\n\n/**\n * Maximum value for a Base85 limb.\n *\n * @remarks\n * Value: 2^85 - 1 = 38685626227668133590597631999999999999999999999999999999n (approximately 3.87e25)\n *\n * All `Base85Limb` values must be less than or equal to this constant.\n *\n * @see {@link Base85Limb}\n * @see {@link assertBase85Limb}\n * @public\n */\nexport const BASE85_LIMB_MAX = (1n << 85n) - 1n;\n\n/**\n * A tuple of three Base85 limbs representing a 256-bit value.\n *\n * This interface represents a 256-bit value split into three limbs:\n * - `low`: bits 0-84 (least significant)\n * - `middle`: bits 85-169\n * - `high`: bits 170-255 (most significant)\n *\n * @remarks\n * The total bit capacity is 3 * 85 = 255 bits, which is sufficient\n * for most 256-bit field elements used in cryptography.\n *\n * ## Use Cases\n * - Poseidon hash inputs in ZK circuits\n * - Field element representations for proof generation\n * - Efficient arithmetic in constrained environments\n *\n * @example\n * ```typescript\n * const limbs: Base85LimbTuple = {\n * low: assertBase85Limb(lowBits),\n * middle: assertBase85Limb(middleBits),\n * high: assertBase85Limb(highBits),\n * };\n * ```\n *\n * @see {@link Base85Limb}\n * @public\n */\nexport interface Base85LimbTuple {\n /**\n * The low 85 bits (bits 0-84).\n */\n readonly low: Base85Limb;\n\n /**\n * The middle 85 bits (bits 85-169).\n */\n readonly middle: Base85Limb;\n\n /**\n * The high bits (bits 170-255).\n */\n readonly high: Base85Limb;\n}\n\n/**\n * Asserts that a value is a valid Base85 limb.\n *\n * Validates that the value is a `bigint` and is within the Base85 range [0, 2^85 - 1].\n *\n * @param value - The bigint to assert (must be in range [0, BASE85_LIMB_MAX])\n * @param name - The name of the variable being asserted (used in error messages)\n * @defaultValue `name` — `\"value\"`\n * @throws {CryptographyAssertionError} If not a bigint, is negative, or exceeds `BASE85_LIMB_MAX`\n * @returns `void` — narrows the type of `value` to `Base85Limb` on success\n *\n * @example\n * ```typescript\n * const value = 12345n;\n * assertBase85Limb(value, \"value\");\n * // value is now typed as Base85Limb\n * ```\n *\n * @public\n */\nexport function assertBase85Limb(value: bigint, name = \"value\"): asserts value is Base85Limb {\n if (typeof value !== \"bigint\") {\n throw new CryptographyAssertionError(`${name}: Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"Base85Limb\",\n });\n }\n if (value < 0n) {\n throw new CryptographyAssertionError(`${name}: Value ${String(value)} is negative`, {\n value,\n expectedType: \"Base85Limb\",\n constraint: \"value >= 0\",\n });\n }\n if (value > BASE85_LIMB_MAX) {\n throw new CryptographyAssertionError(`${name}: Value exceeds Base85 limb maximum`, {\n value,\n expectedType: \"Base85Limb\",\n constraint: `value <= 2^85 - 1`,\n });\n }\n}\n\n/* =============================================================================\n * GROTH16 PROOF TYPES\n *\n * Types for Groth16 zero-knowledge proof components used in the Umbra protocol.\n * ============================================================================= */\n\n/**\n * Byte length for G1 points in a Groth16 proof (64 bytes = 2 x 32-byte field elements).\n *\n * @remarks\n * Each G1 point on BN254 is represented as (x, y) where both coordinates are 32-byte\n * big-endian integers. Used for the `a` and `c` components of a Groth16 proof.\n *\n * @see {@link Groth16ProofA}\n * @see {@link Groth16ProofC}\n * @public\n */\nexport const GROTH16_G1_BYTE_LENGTH = 64;\n\n/**\n * Byte length for G2 points in a Groth16 proof (128 bytes = 4 x 32-byte field elements).\n *\n * @remarks\n * G2 points on BN254 are in the extension field Fq2, so each coordinate is a pair of\n * 32-byte field elements: (x0, x1) and (y0, y1). Used for the `b` component of a Groth16 proof.\n *\n * @see {@link Groth16ProofB}\n * @public\n */\nexport const GROTH16_G2_BYTE_LENGTH = 128;\n\n/**\n * The A component of a Groth16 proof (G1 point), serialized as 64 bytes.\n *\n * This is an elliptic curve point on the G1 group of the BN254 curve,\n * serialized as 64 bytes: [x (32 bytes), y (32 bytes)].\n *\n * @remarks\n * - Size: 64 bytes (2 field elements x 32 bytes each)\n * - Format: [x, y] where each coordinate is 32 bytes big-endian\n * - Represents a point on the G1 curve\n * - Part of the zkSNARK proof tuple (A, B, C)\n *\n * @see {@link assertGroth16ProofA}\n * @see {@link Groth16Proof}\n * @public\n */\nexport type Groth16ProofA = SubBrandedType<Bytes, \"Groth16ProofA\">;\n\n/**\n * The B component of a Groth16 proof (G2 point), serialized as 128 bytes.\n *\n * This is an elliptic curve point on the G2 group of the BN254 curve,\n * serialized as 128 bytes: [x0 (32), x1 (32), y0 (32), y1 (32)].\n *\n * @remarks\n * - Size: 128 bytes (4 field elements x 32 bytes each)\n * - Format: [x0, x1, y0, y1] where each component is 32 bytes big-endian\n * - Represents a point on the G2 curve (extension field Fq2)\n * - The x-coordinate is (x0, x1) and y-coordinate is (y0, y1)\n *\n * @see {@link assertGroth16ProofB}\n * @see {@link Groth16Proof}\n * @public\n */\nexport type Groth16ProofB = SubBrandedType<Bytes, \"Groth16ProofB\">;\n\n/**\n * The C component of a Groth16 proof (G1 point), serialized as 64 bytes.\n *\n * This is an elliptic curve point on the G1 group of the BN254 curve,\n * serialized as 64 bytes: [x (32 bytes), y (32 bytes)].\n *\n * @remarks\n * - Size: 64 bytes (2 field elements x 32 bytes each)\n * - Format: [x, y] where each coordinate is 32 bytes big-endian\n * - Represents a point on the G1 curve\n * - Part of the zkSNARK proof tuple (A, B, C)\n *\n * @see {@link assertGroth16ProofC}\n * @see {@link Groth16Proof}\n * @public\n */\nexport type Groth16ProofC = SubBrandedType<Bytes, \"Groth16ProofC\">;\n\n/**\n * Asserts that a value is a valid Groth16ProofA (64 bytes).\n *\n * @param value - The Uint8Array to assert (must be exactly `GROTH16_G1_BYTE_LENGTH` = 64 bytes)\n * @param name - Optional name used in error messages for better diagnostics\n * @throws {TypeError} If the value is not a Uint8Array or not exactly 64 bytes\n * @returns `void` — narrows the type of `value` to `Groth16ProofA` on success\n *\n * @example\n * ```typescript\n * const proofA = new Uint8Array(64);\n * assertGroth16ProofA(proofA);\n * // proofA is now typed as Groth16ProofA\n * ```\n *\n * @public\n */\nexport function assertGroth16ProofA(\n value: Uint8Array,\n name?: string,\n): asserts value is Groth16ProofA {\n if (!(value instanceof Uint8Array)) {\n throw new TypeError(`${name ?? \"value\"} must be a Uint8Array, got ${typeof value}`);\n }\n if (value.length !== GROTH16_G1_BYTE_LENGTH) {\n throw new TypeError(\n `${name ?? \"Groth16ProofA\"} must be exactly ${String(GROTH16_G1_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n );\n }\n}\n\n/**\n * Asserts that a value is a valid Groth16ProofB (128 bytes).\n *\n * @param value - The Uint8Array to assert (must be exactly `GROTH16_G2_BYTE_LENGTH` = 128 bytes)\n * @param name - Optional name used in error messages for better diagnostics\n * @throws {TypeError} If the value is not a Uint8Array or not exactly 128 bytes\n * @returns `void` — narrows the type of `value` to `Groth16ProofB` on success\n *\n * @example\n * ```typescript\n * const proofB = new Uint8Array(128);\n * assertGroth16ProofB(proofB);\n * // proofB is now typed as Groth16ProofB\n * ```\n *\n * @public\n */\nexport function assertGroth16ProofB(\n value: Uint8Array,\n name?: string,\n): asserts value is Groth16ProofB {\n if (!(value instanceof Uint8Array)) {\n throw new TypeError(`${name ?? \"value\"} must be a Uint8Array, got ${typeof value}`);\n }\n if (value.length !== GROTH16_G2_BYTE_LENGTH) {\n throw new TypeError(\n `${name ?? \"Groth16ProofB\"} must be exactly ${String(GROTH16_G2_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n );\n }\n}\n\n/**\n * Asserts that a value is a valid Groth16ProofC (64 bytes).\n *\n * @param value - The Uint8Array to assert (must be exactly `GROTH16_G1_BYTE_LENGTH` = 64 bytes)\n * @param name - Optional name used in error messages for better diagnostics\n * @throws {TypeError} If the value is not a Uint8Array or not exactly 64 bytes\n * @returns `void` — narrows the type of `value` to `Groth16ProofC` on success\n *\n * @example\n * ```typescript\n * const proofC = new Uint8Array(64);\n * assertGroth16ProofC(proofC);\n * // proofC is now typed as Groth16ProofC\n * ```\n *\n * @public\n */\nexport function assertGroth16ProofC(\n value: Uint8Array,\n name?: string,\n): asserts value is Groth16ProofC {\n if (!(value instanceof Uint8Array)) {\n throw new TypeError(`${name ?? \"value\"} must be a Uint8Array, got ${typeof value}`);\n }\n if (value.length !== GROTH16_G1_BYTE_LENGTH) {\n throw new TypeError(\n `${name ?? \"Groth16ProofC\"} must be exactly ${String(GROTH16_G1_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n );\n }\n}\n\n/**\n * A complete Groth16 zero-knowledge proof.\n *\n * Groth16 is a pairing-based zkSNARK proof system that produces compact proofs\n * consisting of three elliptic curve points: A (G1), B (G2), and C (G1).\n *\n * @remarks\n * ## Proof Structure (256 bytes total)\n * - `a`: G1 point (64 bytes)\n * - `b`: G2 point (128 bytes)\n * - `c`: G1 point (64 bytes)\n *\n * ## Security Properties\n * - Proof size is constant regardless of circuit size\n * - Verification is efficient (constant time)\n * - Requires trusted setup (circuit-specific)\n *\n * ## Use Cases\n * - User registration proofs\n * - Transfer validity proofs\n * - Balance update proofs\n *\n * @example\n * ```typescript\n * const proofA = new Uint8Array(64);\n * const proofB = new Uint8Array(128);\n * const proofC = new Uint8Array(64);\n * assertGroth16ProofA(proofA);\n * assertGroth16ProofB(proofB);\n * assertGroth16ProofC(proofC);\n *\n * const proof: Groth16Proof = {\n * a: proofA,\n * b: proofB,\n * c: proofC,\n * };\n * ```\n *\n * @see {@link Groth16ProofA}\n * @see {@link Groth16ProofB}\n * @see {@link Groth16ProofC}\n * @see {@link ZkProofBytes}\n * @public\n */\nexport interface Groth16Proof {\n /**\n * The A component of the proof (G1 point, 64 bytes).\n */\n readonly a: Groth16ProofA;\n\n /**\n * The B component of the proof (G2 point, 128 bytes).\n */\n readonly b: Groth16ProofB;\n\n /**\n * The C component of the proof (G1 point, 64 bytes).\n */\n readonly c: Groth16ProofC;\n}\n\n/* =============================================================================\n * NONCE TYPE\n *\n * Alias for encryption nonces used throughout the protocol.\n * ============================================================================= */\n\n/**\n * A cryptographic nonce for encryption operations.\n *\n * This is an alias for `RcEncryptionNonce` and represents a 128-bit value\n * used to ensure unique encryption outputs.\n *\n * @remarks\n * - Must be unique for each encryption with the same key\n * - Reusing a nonce compromises security\n * - Can be generated randomly or as a counter\n *\n * @example\n * ```typescript\n * const nonce: Nonce = generateRandomNonce();\n * ```\n *\n * @see {@link RcEncryptionNonce}\n * @public\n */\nexport type Nonce = RcEncryptionNonce;\n\n/* =============================================================================\n * ZK PROOF BYTES TYPE\n *\n * Serialized zero-knowledge proof representation.\n * ============================================================================= */\n\n/**\n * Expected byte length for serialized Groth16 proofs.\n *\n * @remarks\n * A Groth16 proof consists of:\n * - A (G1): 2 * 32 = 64 bytes\n * - B (G2): 4 * 32 = 128 bytes\n * - C (G1): 2 * 32 = 64 bytes\n * Total: 256 bytes\n *\n * @see {@link ZkProofBytes}\n * @see {@link assertZkProofBytes}\n * @public\n */\nexport const ZK_PROOF_BYTE_LENGTH = 256;\n\n/**\n * Serialized zero-knowledge proof bytes.\n *\n * This type represents a Groth16 proof serialized to a byte array,\n * suitable for transmission over the network or storage on-chain.\n *\n * @remarks\n * - Size: 256 bytes (8 field elements * 32 bytes each)\n * - Format: [A.x, A.y, B.x0, B.x1, B.y0, B.y1, C.x, C.y]\n * - Each field element is encoded as 32 bytes (big-endian)\n *\n * @example\n * ```typescript\n * const proofBytes = serializeGroth16Proof(proof);\n * assertZkProofBytes(proofBytes);\n * // proofBytes is now typed as ZkProofBytes\n * ```\n *\n * @see {@link assertZkProofBytes}\n * @see {@link ZK_PROOF_BYTE_LENGTH}\n * @public\n */\nexport type ZkProofBytes = SubBrandedType<Bytes, \"ZkProofBytes\">;\n\n/**\n * Asserts that a value is a valid serialized ZK proof.\n *\n * Validates that the value is a 256-byte Uint8Array.\n *\n * @param value - The Uint8Array to assert (must be exactly `ZK_PROOF_BYTE_LENGTH` = 256 bytes)\n * @throws {CryptographyAssertionError} If not a Uint8Array or not exactly 256 bytes\n * @returns `void` — narrows the type of `value` to `ZkProofBytes` on success\n *\n * @example\n * ```typescript\n * const proofBytes = new Uint8Array(256);\n * assertZkProofBytes(proofBytes);\n * // proofBytes is now typed as ZkProofBytes\n * ```\n *\n * @public\n */\nexport function assertZkProofBytes(value: Uint8Array): asserts value is ZkProofBytes {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"ZkProofBytes\",\n });\n }\n if (value.length !== ZK_PROOF_BYTE_LENGTH) {\n throw new CryptographyAssertionError(\n `Expected ${String(ZK_PROOF_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"ZkProofBytes\",\n constraint: `length === ${String(ZK_PROOF_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * AES ENCRYPTION TYPES\n *\n * Types for AES-256-GCM encryption used for UTXO recovery data encryption.\n * ============================================================================= */\n\n/**\n * Byte length for AES-256 keys.\n *\n * @remarks\n * AES-256 requires exactly 32 bytes (256 bits) for the encryption key.\n *\n * @see {@link AesKey}\n * @see {@link assertAesKey}\n * @public\n */\nexport const AES_KEY_LENGTH = 32;\n\n/**\n * Byte length for AES-GCM initialization vectors.\n *\n * @remarks\n * AES-GCM uses a 12-byte (96-bit) IV as recommended by NIST SP 800-38D.\n * Each encryption operation must use a unique IV to maintain security.\n *\n * @see {@link AES_METADATA_OVERHEAD}\n * @public\n */\nexport const AES_IV_LENGTH = 12;\n\n/**\n * Byte length for AES-GCM authentication tags.\n *\n * @remarks\n * AES-GCM produces a 16-byte (128-bit) authentication tag for integrity and\n * authenticity verification. The tag is stored alongside the ciphertext.\n *\n * @see {@link AES_METADATA_OVERHEAD}\n * @public\n */\nexport const AES_AUTH_TAG_LENGTH = 16;\n\n/**\n * Total overhead for AES ciphertext metadata (IV + AuthTag).\n *\n * @remarks\n * The combined ciphertext format is: [IV (12 bytes) | AuthTag (16 bytes) | Ciphertext (N bytes)]\n * Total overhead: 12 + 16 = 28 bytes. Any `AesCiphertextWithMetadata` must be at least this many bytes.\n *\n * @see {@link AesCiphertextWithMetadata}\n * @see {@link assertAesCiphertextWithMetadata}\n * @public\n */\nexport const AES_METADATA_OVERHEAD = AES_IV_LENGTH + AES_AUTH_TAG_LENGTH;\n\n/**\n * AES-256 encryption key.\n *\n * A 32-byte (256-bit) key used for AES-256-GCM encryption. These keys are\n * derived from master seeds (for ephemeral unlocker) or X25519 shared secrets\n * (for receiver unlocker).\n *\n * @remarks\n * - Size: 32 bytes exactly\n * - Must be kept secret and never transmitted in plaintext\n * - Should be derived using a secure KDF\n *\n * ## Type Hierarchy\n * ```\n * Bytes (base)\n * └── AesKey (sub-sub-brand, 32 bytes)\n * ```\n *\n * @example\n * ```typescript\n * const key = deriveAesKey(masterSeed, generationIndex);\n * assertAesKey(key);\n * // key is now typed as AesKey\n * ```\n *\n * @see {@link AES_KEY_LENGTH}\n * @see {@link assertAesKey}\n * @public\n */\nexport type AesKey = SubBrandedType<Bytes, \"AesKey\">;\n\n/**\n * AES plaintext input for encryption.\n *\n * Variable-length byte array to be encrypted with AES-256-GCM.\n * For UTXO recovery, this contains: amount (8), modified generation index (16),\n * destination address (32), and domain separator hash (12) = 68 bytes total.\n *\n * @remarks\n * - Size: Variable (any length)\n * - Must be a valid Uint8Array\n * - Content structure depends on the encryption context\n *\n * ## Type Hierarchy\n * ```\n * Bytes (base)\n * └── AesPlaintext (sub-brand, variable length)\n * ```\n *\n * @example\n * ```typescript\n * const plaintext = buildRecoveryPlaintext(amount, genIndex, destination);\n * assertAesPlaintext(plaintext);\n * const ciphertext = await aesEncryptor(key, plaintext);\n * ```\n *\n * @see {@link assertAesPlaintext}\n * @see {@link AesCiphertextWithMetadata}\n * @public\n */\nexport type AesPlaintext = SubBrandedType<Bytes, \"AesPlaintext\">;\n\n/**\n * AES-GCM ciphertext with embedded metadata.\n *\n * A combined format that includes the IV, authentication tag, and encrypted data\n * in a single byte array. This format is self-contained for decryption.\n *\n * ## Layout (28 + N bytes)\n * ```\n * [IV (12 bytes) | AuthTag (16 bytes) | Ciphertext (N bytes)]\n * ```\n *\n * @remarks\n * - Minimum size: 28 bytes (IV + AuthTag with empty plaintext)\n * - IV is randomly generated per encryption\n * - AuthTag provides authenticity and integrity verification\n * - Ciphertext length equals plaintext length\n *\n * ## Type Hierarchy\n * ```\n * Bytes (base)\n * └── AesCiphertextWithMetadata (sub-brand, 28+ bytes)\n * ```\n *\n * @example\n * ```typescript\n * const ciphertext = await aesEncryptor(key, plaintext);\n * assertAesCiphertextWithMetadata(ciphertext);\n *\n * // Extract components if needed:\n * const iv = ciphertext.slice(0, 12);\n * const authTag = ciphertext.slice(12, 28);\n * const encrypted = ciphertext.slice(28);\n * ```\n *\n * @see {@link assertAesCiphertextWithMetadata}\n * @see {@link AES_METADATA_OVERHEAD}\n * @public\n */\nexport type AesCiphertextWithMetadata = SubBrandedType<Bytes, \"AesCiphertextWithMetadata\">;\n\n/**\n * Asserts that a value is a valid AES-256 key.\n *\n * Validates that the value is a 32-byte Uint8Array.\n *\n * @param value - The Uint8Array to assert (must be exactly `AES_KEY_LENGTH` = 32 bytes)\n * @throws {CryptographyAssertionError} If not a Uint8Array or not exactly 32 bytes\n * @returns `void` — narrows the type of `value` to `AesKey` on success\n *\n * @example\n * ```typescript\n * const keyBytes = deriveKeyFromSeed(seed);\n * assertAesKey(keyBytes);\n * // keyBytes is now typed as AesKey\n * ```\n *\n * @public\n */\nexport function assertAesKey(value: Uint8Array): asserts value is AesKey {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"AesKey\",\n });\n }\n if (value.length !== AES_KEY_LENGTH) {\n throw new CryptographyAssertionError(\n `Expected ${String(AES_KEY_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"AesKey\",\n constraint: `length === ${String(AES_KEY_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Asserts that a value is a valid AES plaintext.\n *\n * Validates that the value is a Uint8Array. Plaintext can be any length.\n *\n * @param value - The Uint8Array to assert (any non-null Uint8Array is valid)\n * @throws {CryptographyAssertionError} If not a Uint8Array\n * @returns `void` — narrows the type of `value` to `AesPlaintext` on success\n *\n * @example\n * ```typescript\n * const data = new Uint8Array([1, 2, 3, 4]);\n * assertAesPlaintext(data);\n * // data is now typed as AesPlaintext\n * ```\n *\n * @public\n */\nexport function assertAesPlaintext(value: Uint8Array): asserts value is AesPlaintext {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"AesPlaintext\",\n });\n }\n}\n\n/**\n * Asserts that a value is a valid AES ciphertext with metadata.\n *\n * Validates that the value is a Uint8Array with at least 28 bytes\n * (12-byte IV + 16-byte AuthTag + 0 or more bytes of ciphertext).\n *\n * @param value - The Uint8Array to assert (must be at least `AES_METADATA_OVERHEAD` = 28 bytes)\n * @throws {CryptographyAssertionError} If not a Uint8Array or fewer than 28 bytes\n * @returns `void` — narrows the type of `value` to `AesCiphertextWithMetadata` on success\n *\n * @example\n * ```typescript\n * const encrypted = await aesEncrypt(key, plaintext);\n * assertAesCiphertextWithMetadata(encrypted);\n * // encrypted is now typed as AesCiphertextWithMetadata\n * ```\n *\n * @public\n */\nexport function assertAesCiphertextWithMetadata(\n value: Uint8Array,\n): asserts value is AesCiphertextWithMetadata {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"AesCiphertextWithMetadata\",\n });\n }\n if (value.length < AES_METADATA_OVERHEAD) {\n throw new CryptographyAssertionError(\n `Expected at least ${String(AES_METADATA_OVERHEAD)} bytes (IV + AuthTag), got ${String(value.length)}`,\n {\n value,\n expectedType: \"AesCiphertextWithMetadata\",\n constraint: `length >= ${String(AES_METADATA_OVERHEAD)}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * OPTIONAL DATA\n *\n * A 32-byte array used for optional data fields in on-chain instructions.\n * ============================================================================= */\n\n/**\n * Byte length of optional data fields used in on-chain instructions.\n *\n * @remarks\n * Optional data fields in Arcium/Umbra protocol instructions are always 32 bytes.\n *\n * @internal\n */\nexport const OPTIONAL_DATA_BYTE_LENGTH = 32;\n\n/**\n * A 32-byte array for optional data fields in on-chain instructions.\n *\n * @remarks\n * Optional data fields are used in Arcium/Umbra protocol instructions\n * for passing additional metadata or future-proofing the protocol.\n *\n * ## Properties\n * - Size: 32 bytes exactly\n * - Content: Arbitrary bytes (meaning depends on context)\n * - Default: All zeros if not used\n *\n * @example\n * ```typescript\n * const optionalData = new Uint8Array(32);\n * assertOptionalData32(optionalData);\n * // optionalData is now typed as OptionalData32\n * ```\n *\n * @see {@link assertOptionalData32}\n * @see {@link OPTIONAL_DATA_BYTE_LENGTH}\n * @public\n */\nexport type OptionalData32 = SubBrandedType<Bytes, \"OptionalData32\">;\n\n/**\n * Asserts that a value is a valid 32-byte optional data array.\n *\n * Validates that the value is a Uint8Array with exactly 32 bytes.\n *\n * @param value - The Uint8Array to assert (must be exactly 32 bytes)\n * @param name - Optional name for error messages\n * @throws {CryptographyAssertionError} If not a Uint8Array or not 32 bytes\n *\n * @example\n * ```typescript\n * const data = new Uint8Array(32);\n * assertOptionalData32(data);\n * // data is now typed as OptionalData32\n * ```\n *\n * @example\n * ```typescript\n * // With custom name for better error messages\n * assertOptionalData32(data, \"accountInitOptionalData\");\n * ```\n *\n * @public\n */\nexport function assertOptionalData32(\n value: Uint8Array,\n name?: string,\n): asserts value is OptionalData32 {\n if (!(value instanceof Uint8Array)) {\n throw new CryptographyAssertionError(\n `${name ?? \"OptionalData32\"}: Expected Uint8Array, got ${typeof value}`,\n {\n value,\n expectedType: \"OptionalData32\",\n },\n );\n }\n if (value.length !== OPTIONAL_DATA_BYTE_LENGTH) {\n throw new CryptographyAssertionError(\n `${name ?? \"OptionalData32\"} must be exactly ${String(OPTIONAL_DATA_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"OptionalData32\",\n constraint: `length === ${String(OPTIONAL_DATA_BYTE_LENGTH)}`,\n },\n );\n }\n}\n","/**\n * Solana Types Module.\n *\n * This module provides branded types and runtime assertion functions for\n * Solana-specific data structures. By attaching nominal brands to primitive\n * `string` and `Uint8Array` values, and to `@solana/kit` transaction objects,\n * the SDK achieves compile-time safety that prevents common mistakes such as:\n * - Passing a raw string where a `TransactionSignature` is expected.\n * - Submitting an unsigned transaction to a `TransactionForwarder`.\n * - Mixing up different byte-array representations.\n *\n * @remarks\n * **Type hierarchy overview:**\n *\n * String types:\n * - {@link String} — root branded string (base type for all string sub-brands)\n * - {@link TransactionSignature} — base58-encoded Ed25519 signature string\n *\n * Byte array types:\n * - {@link SolanaBytes} — root branded `Uint8Array` for Solana binary data\n * - {@link SignatureBytes} — exactly 64-byte raw Ed25519 signature\n *\n * Transaction types (wrapping `@solana/kit`'s `Transaction`):\n * - {@link UnsignedTransaction} — no signatures present\n * - {@link SignedTransaction} — at least one signature; includes blockhash lifetime\n * - {@link PartiallySignedTransaction} — some but not all required signatures\n * - {@link FullySignedTransaction} — all required signatures present; ready for submission\n *\n * **Runtime assertions:**\n * - {@link assertString} — narrows `string` to `String`\n * - {@link assertTransactionSignature} — narrows `string` to `TransactionSignature` (base58 validated)\n * - {@link assertSolanaBytes} — narrows `Uint8Array` to `SolanaBytes`\n * - {@link assertSignatureBytes} — narrows `Uint8Array` to `SignatureBytes` (64-byte validated)\n *\n * **Error class:**\n * - {@link SolanaAssertionError} — thrown by all assertion functions with structured context\n *\n * @example\n * ```typescript\n * import {\n * assertTransactionSignature,\n * assertSignatureBytes,\n * TransactionSignature,\n * SignatureBytes,\n * } from \"./types\";\n *\n * const sigString = \"5wHu1qwD7q5menT3ydT9VdFPQfkLaWvqPgVbqsM1qwD7\";\n * assertTransactionSignature(sigString);\n * // sigString is now typed as TransactionSignature\n *\n * const sigBytes = new Uint8Array(64);\n * assertSignatureBytes(sigBytes);\n * // sigBytes is now typed as SignatureBytes\n * ```\n *\n * @see {@link BrandedType} for the underlying branding utility\n * @see {@link Bytes} for the generic byte array base type\n *\n * @packageDocumentation\n * @module types/solana\n */\n\nimport type { Transaction, TransactionWithBlockhashLifetime } from \"@solana/kit\";\n\nimport type { BrandedType, SubBrandedType, SubSubBrandedType } from \"../common/branded\";\nimport type { Bytes } from \"../common/types\";\n\n/* =============================================================================\n * CONSTANTS\n * ============================================================================= */\n\n/**\n * Length of an Ed25519 signature in bytes.\n *\n * The Ed25519 signature scheme, used by Solana for all transaction signing,\n * always produces exactly 64-byte signatures:\n * - Bytes 0–31: the R component (a compressed point on the Ed25519 curve)\n * - Bytes 32–63: the S component (a scalar value)\n *\n * @remarks\n * This constant is used by {@link assertSignatureBytes} to validate the length\n * of raw signature byte arrays before branding them as {@link SignatureBytes}.\n *\n * @example\n * ```typescript\n * const raw = new Uint8Array(SIGNATURE_BYTE_LENGTH); // 64-byte zeroed buffer\n * assertSignatureBytes(raw);\n * ```\n *\n * @public\n */\nexport const SIGNATURE_BYTE_LENGTH = 64;\n\n/**\n * Valid characters in the Base58 alphabet used by Solana (and Bitcoin).\n *\n * Base58 deliberately omits four characters that are visually ambiguous in\n * common typefaces:\n * - `0` (zero) — easily confused with `O` (capital O)\n * - `O` (capital O) — easily confused with `0` (zero)\n * - `I` (capital I) — easily confused with `l` (lowercase L)\n * - `l` (lowercase L) — easily confused with `I` (capital I) or `1`\n *\n * The remaining 58 characters form the Base58 alphabet.\n *\n * @internal\n */\nconst BASE58_ALPHABET = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\n\n/**\n * Regular expression pattern for validating base58-encoded strings.\n *\n * The character class `[1-9A-HJ-NP-Za-km-z]` corresponds exactly to the\n * 58-character Base58 alphabet — it excludes `0`, `I`, `O`, and `l`.\n *\n * @internal\n */\nconst BASE58_REGEX = /^[1-9A-HJ-NP-Za-km-z]+$/;\n\n/* =============================================================================\n * ERROR CLASSES\n * ============================================================================= */\n\n/**\n * Error thrown when a Solana type assertion function fails.\n *\n * All assertion functions in this module (`assertString`,\n * `assertTransactionSignature`, `assertSolanaBytes`, `assertSignatureBytes`)\n * throw `SolanaAssertionError` when the supplied value does not satisfy the\n * type constraint. The error carries structured fields that make it easy to\n * log diagnostics or write type-specific error handlers.\n *\n * @remarks\n * `SolanaAssertionError` sets `Error.captureStackTrace` (available in V8\n * environments) to exclude the assertion function's own frame from the stack,\n * making the stack trace point to the caller rather than the assertion body.\n *\n * The prototype is explicitly reset via `Object.setPrototypeOf` to ensure\n * `instanceof` works correctly across CommonJS module boundary re-exports.\n *\n * @example\n * Catching and inspecting a failed assertion:\n * ```typescript\n * import { assertTransactionSignature, SolanaAssertionError } from \"./types\";\n *\n * try {\n * assertTransactionSignature(\"invalid!sig\");\n * } catch (error) {\n * if (error instanceof SolanaAssertionError) {\n * console.error(`Expected: ${error.expectedType}`);\n * console.error(`Constraint: ${error.constraint}`);\n * console.error(`Got: ${String(error.value)}`);\n * }\n * }\n * ```\n *\n * @public\n */\nexport class SolanaAssertionError extends Error {\n /**\n * The actual value that was passed to the assertion function and failed\n * the type check.\n *\n * @remarks\n * Typed as `unknown` because assertion functions accept values of unknown\n * type before narrowing. Inspect carefully — the value may be `undefined`,\n * `null`, or any primitive or object.\n */\n public readonly value: unknown;\n\n /**\n * The name of the expected type (e.g., `\"TransactionSignature\"`,\n * `\"SignatureBytes\"`).\n *\n * @remarks\n * Matches the TypeScript type name for the intended branded type, not a\n * JavaScript `typeof` string.\n */\n public readonly expectedType: string;\n\n /**\n * A human-readable description of the specific constraint that was violated,\n * if applicable.\n *\n * @remarks\n * Examples:\n * - `\"length > 0\"` — empty string passed to `assertTransactionSignature`\n * - `\"length === 64\"` — wrong byte count passed to `assertSignatureBytes`\n * - `\"characters must be in base58 alphabet: 123...xyz\"` — invalid character\n *\n * `undefined` when the only constraint is the TypeScript type itself\n * (e.g., `assertString` only checks `typeof value === \"string\"`).\n */\n public readonly constraint: string | undefined;\n\n /**\n * Creates a new `SolanaAssertionError`.\n *\n * @param message - Human-readable description of the assertion failure.\n * @param options - Structured context for the failed assertion.\n * @param options.value - The value that failed the assertion.\n * @param options.expectedType - The name of the expected branded type.\n * @param options.constraint - The specific constraint that was violated, if any.\n */\n constructor(\n message: string,\n options: {\n value: unknown;\n expectedType: string;\n constraint?: string;\n },\n ) {\n super(message);\n this.name = \"SolanaAssertionError\";\n this.value = options.value;\n this.expectedType = options.expectedType;\n this.constraint = options.constraint;\n\n Error.captureStackTrace(this, SolanaAssertionError);\n\n Object.setPrototypeOf(this, SolanaAssertionError.prototype);\n }\n}\n\n/* =============================================================================\n * STRING TYPES\n *\n * Branded string types for Solana-specific string representations.\n * ============================================================================= */\n\n/**\n * Root branded string type for the Solana types module.\n *\n * This is the base type from which all specialized Solana string types derive.\n * Branding it prevents raw `string` literals from being used where a validated\n * Solana string is required, while still allowing structural compatibility with\n * `string` via the underlying primitive.\n *\n * @remarks\n * Prefer the more specific sub-types (e.g., {@link TransactionSignature}) over\n * `String` when the string has additional semantic meaning. Use `String` only\n * when building generic utilities that operate on any validated Solana string\n * and need to accept multiple sub-brands.\n *\n * @example\n * ```typescript\n * function logSolanaString(s: String): void {\n * console.log(\"Solana string:\", s);\n * }\n *\n * const raw = \"hello\";\n * assertString(raw);\n * logSolanaString(raw); // OK — raw is now branded as String\n * ```\n *\n * @see {@link assertString} for the corresponding runtime assertion\n * @public\n */\nexport type String = BrandedType<string, \"String\">;\n\n/**\n * Base58-encoded Solana transaction signature.\n *\n * A transaction signature is the result of an Ed25519 sign operation on the\n * serialized transaction message. Solana encodes it as a base58 string\n * (approximately 87–88 characters) for human-readable display and API usage.\n *\n * @remarks\n * **Encoding details:**\n * - Underlying binary: 64 bytes (see {@link SignatureBytes})\n * - Base58 alphabet: 58 characters (`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)\n * - Excluded characters: `0`, `O`, `I`, `l` (visually ambiguous)\n * - Typical string length: 87–88 characters\n *\n * **Type safety:** The {@link assertTransactionSignature} function validates\n * that a `string` value is non-empty and contains only Base58 characters before\n * branding it as `TransactionSignature`. This catches obvious data errors at\n * the ingestion boundary.\n *\n * **Note:** Validation is character-level only. The assertion does NOT verify\n * cryptographic correctness (i.e., it does not verify that the signature was\n * produced by a specific keypair).\n *\n * @example\n * Narrowing a raw string to `TransactionSignature`:\n * ```typescript\n * const raw = \"5wHu1qwD7q5menT3ydT9VdFPQfkLaWvqPgVbqsM1qwD7\";\n * assertTransactionSignature(raw);\n * // raw is now typed as TransactionSignature\n * ```\n *\n * @example\n * Using in a function signature:\n * ```typescript\n * async function getTransactionDetails(sig: TransactionSignature) {\n * return await rpc.getTransaction(sig).send();\n * }\n * ```\n *\n * @see {@link assertTransactionSignature} for the runtime assertion\n * @see {@link SignatureBytes} for the raw binary equivalent\n * @public\n */\nexport type TransactionSignature = SubBrandedType<String, \"TransactionSignature\">;\n\n/* =============================================================================\n * BYTE ARRAY TYPES\n *\n * Branded byte array types for Solana-specific binary data.\n * ============================================================================= */\n\n/**\n * Root branded `Uint8Array` type for Solana binary data.\n *\n * This is the base type for all Solana-specific byte array types. It derives\n * from the generic `Bytes` type and adds the `\"SolanaBytes\"` nominal brand,\n * distinguishing Solana binary data from other `Uint8Array` values in the SDK.\n *\n * @remarks\n * No specific length constraint — the length depends on the particular data\n * being represented. Sub-types like {@link SignatureBytes} impose their own\n * length requirements.\n *\n * Use `SolanaBytes` when the binary data is Solana-specific but does not fall\n * into a more precise category (e.g., serialized account data, raw message\n * bytes).\n *\n * @example\n * ```typescript\n * const accountData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n * assertSolanaBytes(accountData);\n * // accountData is now typed as SolanaBytes\n * ```\n *\n * @see {@link assertSolanaBytes} for the runtime assertion\n * @see {@link SignatureBytes} for the 64-byte Ed25519 signature sub-type\n * @public\n */\nexport type SolanaBytes = SubBrandedType<Bytes, \"SolanaBytes\">;\n\n/**\n * 64-byte raw Ed25519 signature in binary form.\n *\n * This type represents the binary encoding of an Ed25519 signature as used\n * internally by the Solana runtime and the `@solana/kit` library. It is the\n * binary equivalent of a {@link TransactionSignature} string — the same 64\n * bytes, without the Base58 encoding.\n *\n * @remarks\n * **Structure:**\n * - Bytes 0–31: R component — a compressed Ed25519 curve point\n * - Bytes 32–63: S component — a scalar in the range `[0, l)` where `l` is\n * the order of the Ed25519 base point\n *\n * **Conversion:**\n * - `SignatureBytes` → `TransactionSignature`: Base58-encode the bytes\n * - `TransactionSignature` → `SignatureBytes`: Base58-decode the string\n *\n * The {@link assertSignatureBytes} function validates both that the value is a\n * `Uint8Array` and that it is exactly {@link SIGNATURE_BYTE_LENGTH} (64) bytes.\n *\n * @example\n * Creating and validating a signature byte array:\n * ```typescript\n * const sigBytes = new Uint8Array(64);\n * // ... fill sigBytes with actual Ed25519 signature material ...\n * assertSignatureBytes(sigBytes);\n * // sigBytes is now typed as SignatureBytes\n * ```\n *\n * @example\n * Using with a Solana transaction builder:\n * ```typescript\n * declare function attachSignature(\n * tx: UnsignedTransaction,\n * publicKey: Address,\n * signature: SignatureBytes,\n * ): PartiallySignedTransaction;\n * ```\n *\n * @see {@link assertSignatureBytes} for the runtime assertion\n * @see {@link TransactionSignature} for the base58-encoded equivalent\n * @see {@link SIGNATURE_BYTE_LENGTH} for the required byte length constant\n * @public\n */\nexport type SignatureBytes = SubSubBrandedType<SolanaBytes, \"SignatureBytes\">;\n\n/* =============================================================================\n * TRANSACTION TYPES\n *\n * Branded transaction types for compile-time transaction state safety.\n * These types wrap the @solana/kit Transaction type with state information.\n * ============================================================================= */\n\n/**\n * An unsigned Solana transaction — a transaction that has been constructed\n * but has not yet received any signatures.\n *\n * @remarks\n * This type wraps `Transaction` from `@solana/kit` with the `\"UnsignedTransaction\"`\n * brand. The brand prevents an unsigned transaction from being passed to a\n * `TransactionForwarder` or any function that requires a {@link SignedTransaction},\n * catching the mistake at compile time.\n *\n * **Lifecycle:** Build the transaction message → compile to `Transaction` →\n * brand as `UnsignedTransaction` → sign to produce {@link SignedTransaction}.\n *\n * @example\n * Type-safe transaction building:\n * ```typescript\n * import { UnsignedTransaction } from \"./types\";\n *\n * function buildTransfer(from: Address, to: Address, amount: bigint): UnsignedTransaction {\n * // ... build and compile message ...\n * return compiledTx as UnsignedTransaction;\n * }\n *\n * const tx = buildTransfer(sender, recipient, 1_000_000n);\n * // tx cannot be passed to forwarder.forwardSequentially — compile error\n * ```\n *\n * @see {@link SignedTransaction} for the signed counterpart\n * @public\n */\nexport type UnsignedTransaction = BrandedType<Transaction, \"UnsignedTransaction\">;\n\n/**\n * A Solana transaction that has at least one signature and a blockhash\n * lifetime constraint.\n *\n * This is the base type for all signed transaction variants. It intersects\n * `Transaction` with `TransactionWithBlockhashLifetime` from `@solana/kit`,\n * ensuring the blockhash expiry window (`blockhash` + `lastValidBlockHeight`)\n * is present alongside the signature data.\n *\n * @remarks\n * **Blockhash lifetime** — The `TransactionWithBlockhashLifetime` intersection\n * ensures that every `SignedTransaction` carries `lifetimeConstraint.blockhash`\n * and `lifetimeConstraint.lastValidBlockHeight`. The forwarder uses these to\n * detect expiry before submission.\n *\n * **Sub-types** — `SignedTransaction` is the common type used in forwarder\n * method signatures because it accepts both {@link PartiallySignedTransaction}\n * and {@link FullySignedTransaction}. Use the more specific sub-types when the\n * exact signing completeness matters to the API contract.\n *\n * @example\n * Accepting any signed transaction (partial or full):\n * ```typescript\n * function logSignedTx(tx: SignedTransaction): void {\n * console.log(`Valid until block: ${tx.lifetimeConstraint.lastValidBlockHeight}`);\n * }\n * ```\n *\n * @see {@link PartiallySignedTransaction} for partial signing state\n * @see {@link FullySignedTransaction} for full signing state\n * @see {@link UnsignedTransaction} for the unsigned state\n * @public\n */\nexport type SignedTransaction = BrandedType<\n Transaction & TransactionWithBlockhashLifetime,\n \"SignedTransaction\"\n>;\n\n/**\n * A Solana transaction with some but potentially not all required signatures.\n *\n * A sub-brand of {@link SignedTransaction}. The transaction has been signed by\n * at least one party but may still be missing signatures from other required\n * signers. This state is common in multi-signature workflows where different\n * parties sign at different times or different locations.\n *\n * @remarks\n * In the Umbra SDK, partial signing arises when:\n * - The user's wallet signs the transaction locally.\n * - The relayer counter-signs before submission.\n * - A hardware wallet adds its signature after an initial software signature.\n *\n * A `PartiallySignedTransaction` cannot be submitted to the network until all\n * required signatures are collected, at which point it can be cast (or built\n * up) to {@link FullySignedTransaction}.\n *\n * @example\n * Multi-sig workflow:\n * ```typescript\n * const partial: PartiallySignedTransaction = await userWallet.sign(unsigned);\n * const full: FullySignedTransaction = await relayer.countersign(partial);\n * await forwarder.forwardSequentially([full]);\n * ```\n *\n * @see {@link FullySignedTransaction} for the fully-signed state\n * @see {@link SignedTransaction} for the base signed state\n * @public\n */\nexport type PartiallySignedTransaction = SubBrandedType<\n SignedTransaction,\n \"PartiallySignedTransaction\"\n>;\n\n/**\n * A Solana transaction with all required signatures present and ready for\n * network submission.\n *\n * This is the terminal transaction state in the signing lifecycle. A\n * `FullySignedTransaction` has been signed by every required signer and can be\n * submitted to the Solana network via a {@link TransactionForwarder}.\n *\n * @remarks\n * **Compile-time guarantee** — The {@link TransactionForwarder} interface's\n * `forwardSequentially` and `forwardInParallel` methods accept\n * `readonly SignedTransaction[]` (the common base type). Callers that track\n * signing state explicitly can use `FullySignedTransaction` in their own\n * function signatures to signal that all signatures are present.\n *\n * **Branding vs. validation** — The brand is a compile-time assertion — the\n * runtime does NOT verify that all required pubkeys have corresponding\n * signatures. It is the responsibility of the signing workflow to ensure\n * completeness before casting to `FullySignedTransaction`.\n *\n * @example\n * Enforcing full signing at a function boundary:\n * ```typescript\n * import { FullySignedTransaction } from \"./types\";\n * import type { TransactionForwarder } from \"./interfaces\";\n *\n * async function submitAll(\n * forwarder: TransactionForwarder,\n * txs: readonly FullySignedTransaction[],\n * ) {\n * return forwarder.forwardSequentially(txs);\n * }\n * ```\n *\n * @see {@link PartiallySignedTransaction} for partial signing state\n * @see {@link SignedTransaction} for the base signed state\n * @see {@link TransactionForwarder} for the submission interface\n * @public\n */\nexport type FullySignedTransaction = SubSubBrandedType<\n PartiallySignedTransaction,\n \"FullySignedTransaction\"\n>;\n\n/* =============================================================================\n * STRING ASSERTIONS\n *\n * Assertion functions for Solana string types.\n * ============================================================================= */\n\n/**\n * Asserts that a value is a primitive `string` and narrows it to {@link String}.\n *\n * This is the base assertion for all Solana branded string types. It only\n * checks that the input is a primitive `string` — no format or content\n * validation is performed.\n *\n * @param value - The value to assert. Must be a primitive string.\n * @throws {SolanaAssertionError} If `typeof value !== \"string\"`.\n *\n * @remarks\n * For more specific string types, use the dedicated assertion functions:\n * - {@link assertTransactionSignature} — for base58-encoded signatures\n *\n * @example\n * ```typescript\n * const raw: unknown = \"hello world\";\n * assertString(raw as string);\n * // raw is now typed as String\n *\n * assertString(123 as unknown as string); // Throws: not a string\n * assertString(null as unknown as string); // Throws: not a string\n * ```\n *\n * @see {@link String} for the branded type\n * @see {@link assertTransactionSignature} for the signature-specific assertion\n * @public\n */\nexport function assertString(value: string): asserts value is String {\n if (typeof value !== \"string\") {\n throw new SolanaAssertionError(`Expected string, got ${typeof value}`, {\n value,\n expectedType: \"String\",\n });\n }\n}\n\n/**\n * Asserts that a value is a valid base58-encoded Solana transaction signature\n * and narrows it to {@link TransactionSignature}.\n *\n * Validation rules:\n * 1. `typeof value === \"string\"`\n * 2. `value.length > 0` (non-empty)\n * 3. Every character is in the Base58 alphabet (`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)\n *\n * @param value - The string to assert as a base58 transaction signature.\n * @throws {SolanaAssertionError} If the value is not a string, is empty, or\n * contains characters outside the Base58 alphabet. The error's `constraint`\n * field identifies which rule was violated, and for alphabet violations,\n * includes the position and character that failed.\n *\n * @remarks\n * **Validation scope** — This function performs character-level validation only.\n * It does NOT verify cryptographic correctness (i.e., it does not check that\n * the 64 decoded bytes constitute a valid Ed25519 signature, nor that the\n * signature was produced by any particular keypair).\n *\n * **Excluded characters** — The Base58 alphabet deliberately omits `0` (zero),\n * `O` (capital O), `I` (capital I), and `l` (lowercase L) to avoid\n * transcription errors. Any of these characters in `value` will cause a throw.\n *\n * **Typical usage** — Call this function at SDK ingestion boundaries (e.g.,\n * when accepting a signature string from user input or an external API) to\n * ensure downstream code only ever sees branded, validated values.\n *\n * @example\n * Validating a signature from an external source:\n * ```typescript\n * const rawSig: string = apiResponse.signature;\n * assertTransactionSignature(rawSig);\n * // rawSig is now typed as TransactionSignature\n * ```\n *\n * @example\n * Invalid inputs:\n * ```typescript\n * assertTransactionSignature(\"\"); // Throws: empty string\n * assertTransactionSignature(\"hello!world\"); // Throws: invalid char '!'\n * assertTransactionSignature(\"0abc\"); // Throws: '0' not in Base58\n * assertTransactionSignature(\"IIII\"); // Throws: 'I' not in Base58\n * ```\n *\n * @see {@link TransactionSignature} for the branded type\n * @see {@link SignatureBytes} for the binary equivalent\n * @public\n */\nexport function assertTransactionSignature(value: string): asserts value is TransactionSignature {\n if (typeof value !== \"string\") {\n throw new SolanaAssertionError(`Expected string, got ${typeof value}`, {\n value,\n expectedType: \"TransactionSignature\",\n });\n }\n\n if (value.length === 0) {\n throw new SolanaAssertionError(\"Transaction signature cannot be empty\", {\n value,\n expectedType: \"TransactionSignature\",\n constraint: \"length > 0\",\n });\n }\n\n if (!BASE58_REGEX.test(value)) {\n // Find the first invalid character for a helpful error message\n let invalidChar = \"\";\n let invalidIndex = -1;\n\n // eslint-disable-next-line unicorn/prefer-spread -- Array.from avoids mishandling special characters in string spread\n for (const [index, element] of Array.from(value).entries()) {\n if (!BASE58_ALPHABET.includes(element)) {\n invalidChar = element;\n invalidIndex = index;\n break;\n }\n }\n\n throw new SolanaAssertionError(\n `Invalid base58 character '${invalidChar}' at position ${String(invalidIndex)}`,\n {\n value,\n expectedType: \"TransactionSignature\",\n constraint: `characters must be in base58 alphabet: ${BASE58_ALPHABET}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * BYTE ARRAY ASSERTIONS\n *\n * Assertion functions for Solana byte array types.\n * ============================================================================= */\n\n/**\n * Asserts that a value is a `Uint8Array` and narrows it to {@link SolanaBytes}.\n *\n * This is the base assertion for all Solana byte array types. It only checks\n * that the input is a `Uint8Array` instance — no length validation is performed.\n *\n * @param value - The `Uint8Array` to assert. Must be an instance of `Uint8Array`.\n * @throws {SolanaAssertionError} If `!(value instanceof Uint8Array)`.\n *\n * @remarks\n * For byte arrays with specific length requirements, use the more specific\n * assertion function:\n * - {@link assertSignatureBytes} — for 64-byte Ed25519 signature arrays\n *\n * @example\n * ```typescript\n * const data = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n * assertSolanaBytes(data);\n * // data is now typed as SolanaBytes\n *\n * assertSolanaBytes([] as unknown as Uint8Array); // Throws: not a Uint8Array\n * assertSolanaBytes(\"bytes\" as unknown as Uint8Array); // Throws: not a Uint8Array\n * ```\n *\n * @see {@link SolanaBytes} for the branded type\n * @see {@link assertSignatureBytes} for the length-constrained variant\n * @public\n */\nexport function assertSolanaBytes(value: Uint8Array): asserts value is SolanaBytes {\n if (!(value instanceof Uint8Array)) {\n throw new SolanaAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"SolanaBytes\",\n });\n }\n}\n\n/**\n * Asserts that a value is a `Uint8Array` of exactly {@link SIGNATURE_BYTE_LENGTH}\n * (64) bytes and narrows it to {@link SignatureBytes}.\n *\n * Validation rules:\n * 1. `value instanceof Uint8Array`\n * 2. `value.length === 64`\n *\n * @param value - The `Uint8Array` to assert as a 64-byte Ed25519 signature.\n * @throws {SolanaAssertionError} If the value is not a `Uint8Array` or is not\n * exactly 64 bytes. The error's `constraint` field specifies\n * `\"length === 64\"` for length violations.\n *\n * @remarks\n * The 64-byte requirement is defined by the Ed25519 specification and is\n * invariant across all Solana Ed25519 signatures. Passing a 63- or 65-byte\n * array will always throw, regardless of the content.\n *\n * **Structure:**\n * - Bytes 0–31: R component (compressed curve point)\n * - Bytes 32–63: S component (scalar)\n *\n * @example\n * Validating a signature byte array:\n * ```typescript\n * const sigBytes = new Uint8Array(64);\n * // ... populate with actual Ed25519 signature bytes ...\n * assertSignatureBytes(sigBytes);\n * // sigBytes is now typed as SignatureBytes\n * ```\n *\n * @example\n * Invalid inputs:\n * ```typescript\n * assertSignatureBytes(new Uint8Array(63)); // Throws: expected 64 bytes, got 63\n * assertSignatureBytes(new Uint8Array(65)); // Throws: expected 64 bytes, got 65\n * assertSignatureBytes([] as unknown as Uint8Array); // Throws: not a Uint8Array\n * ```\n *\n * @see {@link SignatureBytes} for the branded type\n * @see {@link SIGNATURE_BYTE_LENGTH} for the required length constant\n * @see {@link TransactionSignature} for the base58-encoded equivalent\n * @public\n */\nexport function assertSignatureBytes(value: Uint8Array): asserts value is SignatureBytes {\n if (!(value instanceof Uint8Array)) {\n throw new SolanaAssertionError(`Expected Uint8Array, got ${typeof value}`, {\n value,\n expectedType: \"SignatureBytes\",\n });\n }\n\n if (value.length !== SIGNATURE_BYTE_LENGTH) {\n throw new SolanaAssertionError(\n `Expected ${String(SIGNATURE_BYTE_LENGTH)} bytes, got ${String(value.length)}`,\n {\n value,\n expectedType: \"SignatureBytes\",\n constraint: `length === ${String(SIGNATURE_BYTE_LENGTH)}`,\n },\n );\n }\n}\n\n/**\n * Brands a compiled `Transaction` as a {@link SignedTransaction} for relay\n * submission.\n *\n * @remarks\n * This function is used for transactions that will be signed by the **relayer**,\n * not by the client. In the Umbra relay flow, the client builds and serializes\n * a transaction message, which is then passed to the relayer service. The\n * relayer signs and submits the transaction. Because the blockhash lifetime is\n * already embedded in the compiled message bytes (`messageBytes`), the\n * transaction is treated as carrying a blockhash constraint even though\n * `lifetimeConstraint` is not set as a TypeScript property.\n *\n * **This is an escape hatch** — it performs an unchecked cast. Use only when\n * you are certain the compiled message bytes include a valid blockhash and the\n * relayer will supply the required signature before submission.\n *\n * @param tx - A `Transaction` object whose compiled message bytes already\n * embed the blockhash lifetime constraint.\n * @returns The same `Transaction` value cast to {@link SignedTransaction}.\n *\n * @example\n * ```typescript\n * import { asRelayableSignedTransaction } from \"./types\";\n *\n * const compiledTx: Transaction = compileTransactionMessage(txMessage);\n * const relayable = asRelayableSignedTransaction(compiledTx);\n * // relayable can now be passed to relayer submission APIs\n * ```\n *\n * @public\n */\nexport function asRelayableSignedTransaction(tx: Transaction): SignedTransaction {\n return tx as SignedTransaction;\n}\n","/**\n * Temporal Types\n *\n * This module defines branded types for timestamp components used in\n * time-scoped viewing key derivation. These types provide compile-time\n * safety for temporal values with runtime validation.\n *\n * ## Overview\n *\n * The module provides a hierarchical type system:\n * - `TimestampComponent` - Base branded type for all timestamp values\n * - `Year`, `Month`, `Day`, `Hour`, `Minute`, `Second` - Subbranded types\n *\n * ## Validation Ranges\n *\n * - Year: 0 to 9999 (reasonable range for most applications)\n * - Month: 1 to 12\n * - Day: 1 to 31\n * - Hour: 0 to 23\n * - Minute: 0 to 59\n * - Second: 0 to 59\n *\n * @remarks\n * All temporal component types are encoded as `bigint` to integrate directly with the BN254\n * field arithmetic used in viewing key derivation. The branded type system prevents accidentally\n * passing a `Month` where a `Year` is expected, catching a class of derivation-key bugs at\n * compile time.\n *\n * @packageDocumentation\n * @module common/temporal/types\n */\n\nimport type { BrandedType, SubBrandedType } from \"../branded\";\n\n/* =============================================================================\n * CONSTANTS\n * ============================================================================= */\n\n/**\n * Minimum valid year value (inclusive).\n *\n * @remarks Year 0 corresponds to 1 BCE in the proleptic Gregorian calendar.\n * @see {@link YEAR_MAX}\n * @see {@link assertYear}\n * @public\n */\nexport const YEAR_MIN = 0n;\n\n/**\n * Maximum valid year value (inclusive).\n *\n * @remarks Upper bound chosen to comfortably cover all practical use cases.\n * @see {@link YEAR_MIN}\n * @see {@link assertYear}\n * @public\n */\nexport const YEAR_MAX = 9999n;\n\n/**\n * Minimum valid month value (inclusive).\n *\n * @remarks January is represented as 1, following the ISO 8601 convention.\n * @see {@link MONTH_MAX}\n * @see {@link assertMonth}\n * @public\n */\nexport const MONTH_MIN = 1n;\n\n/**\n * Maximum valid month value (inclusive).\n *\n * @remarks December is represented as 12.\n * @see {@link MONTH_MIN}\n * @see {@link assertMonth}\n * @public\n */\nexport const MONTH_MAX = 12n;\n\n/**\n * Minimum valid day value (inclusive).\n *\n * @remarks The first day of any month.\n * @see {@link DAY_MAX}\n * @see {@link assertDay}\n * @public\n */\nexport const DAY_MIN = 1n;\n\n/**\n * Maximum valid day value (inclusive).\n *\n * @remarks\n * Set to 31 to accommodate all months. Month-specific validation (e.g., February having at most\n * 28 or 29 days) is not enforced here and must be handled at the application level if needed.\n *\n * @see {@link DAY_MIN}\n * @see {@link assertDay}\n * @public\n */\nexport const DAY_MAX = 31n;\n\n/**\n * Minimum valid hour value (inclusive), in 24-hour format.\n *\n * @see {@link HOUR_MAX}\n * @see {@link assertHour}\n * @public\n */\nexport const HOUR_MIN = 0n;\n\n/**\n * Maximum valid hour value (inclusive), in 24-hour format.\n *\n * @see {@link HOUR_MIN}\n * @see {@link assertHour}\n * @public\n */\nexport const HOUR_MAX = 23n;\n\n/**\n * Minimum valid minute value (inclusive).\n *\n * @see {@link MINUTE_MAX}\n * @see {@link assertMinute}\n * @public\n */\nexport const MINUTE_MIN = 0n;\n\n/**\n * Maximum valid minute value (inclusive).\n *\n * @see {@link MINUTE_MIN}\n * @see {@link assertMinute}\n * @public\n */\nexport const MINUTE_MAX = 59n;\n\n/**\n * Minimum valid second value (inclusive).\n *\n * @see {@link SECOND_MAX}\n * @see {@link assertSecond}\n * @public\n */\nexport const SECOND_MIN = 0n;\n\n/**\n * Maximum valid second value (inclusive).\n *\n * @remarks Leap seconds (value 60) are not supported.\n * @see {@link SECOND_MIN}\n * @see {@link assertSecond}\n * @public\n */\nexport const SECOND_MAX = 59n;\n\n/* =============================================================================\n * ASSERTION ERROR\n * ============================================================================= */\n\n/**\n * Error thrown when a temporal type assertion fails.\n *\n * This error provides detailed information about why an assertion failed,\n * including the actual value, the expected type, and the constraint that\n * was violated.\n *\n * @remarks\n * Every `assertXxx` function in this module throws `TemporalAssertionError` on failure.\n * Catch this specific type to distinguish temporal validation failures from other errors.\n *\n * @example\n * ```typescript\n * import { assertMonth, TemporalAssertionError } from \"./temporal\";\n *\n * try {\n * assertMonth(13n); // Will throw - month must be 1-12\n * } catch (error) {\n * if (error instanceof TemporalAssertionError) {\n * console.error(`Assertion failed for ${error.expectedType}`);\n * console.error(`Value: ${error.value}`);\n * console.error(`Constraint: ${error.constraint}`);\n * }\n * }\n * ```\n *\n * @sealed\n * @public\n */\nexport class TemporalAssertionError extends Error {\n /**\n * The actual value that failed the assertion.\n * @readonly\n */\n public readonly value: unknown;\n\n /**\n * The type that was expected (e.g., `\"Month\"`, `\"Hour\"`).\n * @readonly\n */\n public readonly expectedType: string;\n\n /**\n * Description of the constraint that was violated.\n *\n * @remarks\n * `undefined` when the failure was a type mismatch (e.g., received a number instead of a\n * bigint). Contains a human-readable range string (e.g., `\"1 <= value <= 12\"`) when the\n * value was the correct type but out of the valid range.\n * @readonly\n */\n public readonly constraint: string | undefined;\n\n /**\n * Creates a new TemporalAssertionError.\n *\n * @param message - Human-readable description of what went wrong\n * @param details - Structured error details for programmatic inspection\n * @param details.value - The value that failed the assertion\n * @param details.expectedType - Name of the branded type that was expected\n * @param details.constraint - Optional human-readable constraint that was violated\n */\n constructor(\n message: string,\n details: {\n value: unknown;\n expectedType: string;\n constraint?: string;\n },\n ) {\n super(message);\n this.name = \"TemporalAssertionError\";\n this.value = details.value;\n this.expectedType = details.expectedType;\n this.constraint = details.constraint;\n }\n}\n\n/* =============================================================================\n * BASE TIMESTAMP COMPONENT TYPE\n * ============================================================================= */\n\n/**\n * Base branded type for all timestamp components.\n *\n * `TimestampComponent` is a branded bigint that serves as the parent type for all\n * calendar-component types: `Year`, `Month`, `Day`, `Hour`, `Minute`, and `Second`.\n *\n * @remarks\n * All timestamp component types are subbrands of `TimestampComponent`. Code that accepts\n * any calendar component without caring which one (e.g., a generic key-derivation utility)\n * can accept `TimestampComponent` as its parameter type.\n *\n * @example\n * ```typescript\n * import { TimestampComponent, assertTimestampComponent } from \"./temporal\";\n *\n * const value: bigint = 2024n;\n * assertTimestampComponent(value);\n * // Now value is typed as TimestampComponent\n * ```\n *\n * @see {@link Year}\n * @see {@link Month}\n * @see {@link Day}\n * @see {@link Hour}\n * @see {@link Minute}\n * @see {@link Second}\n * @public\n */\nexport type TimestampComponent = BrandedType<bigint, \"TimestampComponent\">;\n\n/**\n * Asserts that a value is a valid TimestampComponent (non-negative bigint).\n *\n * @param value - The bigint to validate (must be `>= 0`)\n * @throws {TemporalAssertionError} If value is not a bigint or is negative\n * @returns `void` — narrows the type of `value` to `TimestampComponent` on success\n *\n * @example\n * ```typescript\n * const value = 100n;\n * assertTimestampComponent(value);\n * // value is now typed as TimestampComponent\n * ```\n *\n * @public\n */\nexport function assertTimestampComponent(value: bigint): asserts value is TimestampComponent {\n if (typeof value !== \"bigint\") {\n throw new TemporalAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"TimestampComponent\",\n });\n }\n if (value < 0n) {\n throw new TemporalAssertionError(`TimestampComponent must be non-negative`, {\n value,\n expectedType: \"TimestampComponent\",\n constraint: \"value >= 0\",\n });\n }\n}\n\n/* =============================================================================\n * YEAR TYPE\n * ============================================================================= */\n\n/**\n * Branded type for year values in the Gregorian calendar.\n *\n * `Year` is a subbrand of `TimestampComponent` used to represent the year component of a\n * UTC timestamp in time-scoped viewing key derivation. Valid range: `YEAR_MIN` (0) to\n * `YEAR_MAX` (9999).\n *\n * @remarks\n * The type distinction between `Year`, `Month`, `Day`, etc. is intentional: passing\n * a `Month` value where a `Year` is expected is a compile-time error, preventing\n * subtle key-derivation bugs.\n *\n * @example\n * ```typescript\n * import { Year, assertYear } from \"./temporal\";\n *\n * const year: bigint = 2024n;\n * assertYear(year);\n * // year is now typed as Year\n *\n * const generator = getYearlyViewingKeyGenerator({ masterViewingKey });\n * const key = await generator(mint, year);\n * ```\n *\n * @see {@link assertYear}\n * @see {@link YEAR_MIN}\n * @see {@link YEAR_MAX}\n * @public\n */\nexport type Year = SubBrandedType<TimestampComponent, \"Year\">;\n\n/**\n * Asserts that a value is a valid `Year` in the range `[YEAR_MIN, YEAR_MAX]` (0–9999).\n *\n * @param value - The bigint to validate\n * @throws {TemporalAssertionError} If `value` is not a bigint or is outside `[YEAR_MIN, YEAR_MAX]`\n * @returns `void` — narrows the type of `value` to `Year` on success\n *\n * @example\n * ```typescript\n * const year = 2024n;\n * assertYear(year);\n * // year is now typed as Year\n * ```\n *\n * @public\n */\nexport function assertYear(value: bigint): asserts value is Year {\n if (typeof value !== \"bigint\") {\n throw new TemporalAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"Year\",\n });\n }\n if (value < YEAR_MIN || value > YEAR_MAX) {\n throw new TemporalAssertionError(\n `Year must be in range [${String(YEAR_MIN)}, ${String(YEAR_MAX)}]`,\n {\n value,\n expectedType: \"Year\",\n constraint: `${String(YEAR_MIN)} <= value <= ${String(YEAR_MAX)}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * MONTH TYPE\n * ============================================================================= */\n\n/**\n * Branded type for month values in the Gregorian calendar (1 = January, 12 = December).\n *\n * `Month` is a subbrand of `TimestampComponent`. Valid range: `MONTH_MIN` (1) to\n * `MONTH_MAX` (12).\n *\n * @example\n * ```typescript\n * import { Month, assertMonth } from \"./temporal\";\n *\n * const month: bigint = 6n; // June\n * assertMonth(month);\n * // month is now typed as Month\n * ```\n *\n * @see {@link assertMonth}\n * @see {@link MONTH_MIN}\n * @see {@link MONTH_MAX}\n * @public\n */\nexport type Month = SubBrandedType<TimestampComponent, \"Month\">;\n\n/**\n * Asserts that a value is a valid `Month` in the range `[MONTH_MIN, MONTH_MAX]` (1–12).\n *\n * @param value - The bigint to validate\n * @throws {TemporalAssertionError} If `value` is not a bigint or is outside `[MONTH_MIN, MONTH_MAX]`\n * @returns `void` — narrows the type of `value` to `Month` on success\n *\n * @example\n * ```typescript\n * const month = 6n;\n * assertMonth(month);\n * // month is now typed as Month\n * ```\n *\n * @public\n */\nexport function assertMonth(value: bigint): asserts value is Month {\n if (typeof value !== \"bigint\") {\n throw new TemporalAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"Month\",\n });\n }\n if (value < MONTH_MIN || value > MONTH_MAX) {\n throw new TemporalAssertionError(\n `Month must be in range [${String(MONTH_MIN)}, ${String(MONTH_MAX)}]`,\n {\n value,\n expectedType: \"Month\",\n constraint: `${String(MONTH_MIN)} <= value <= ${String(MONTH_MAX)}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * DAY TYPE\n * ============================================================================= */\n\n/**\n * Branded type for day-of-month values in the Gregorian calendar.\n *\n * `Day` is a subbrand of `TimestampComponent`. Valid range: `DAY_MIN` (1) to `DAY_MAX` (31).\n *\n * @remarks\n * This type does not enforce month-specific day limits (e.g., February has 28 or 29 days).\n * Additional calendar validation must be performed by the application if required.\n *\n * @example\n * ```typescript\n * import { Day, assertDay } from \"./temporal\";\n *\n * const day: bigint = 15n;\n * assertDay(day);\n * // day is now typed as Day\n * ```\n *\n * @see {@link assertDay}\n * @see {@link DAY_MIN}\n * @see {@link DAY_MAX}\n * @public\n */\nexport type Day = SubBrandedType<TimestampComponent, \"Day\">;\n\n/**\n * Asserts that a value is a valid `Day` in the range `[DAY_MIN, DAY_MAX]` (1–31).\n *\n * @param value - The bigint to validate\n * @throws {TemporalAssertionError} If `value` is not a bigint or is outside `[DAY_MIN, DAY_MAX]`\n * @returns `void` — narrows the type of `value` to `Day` on success\n *\n * @example\n * ```typescript\n * const day = 15n;\n * assertDay(day);\n * // day is now typed as Day\n * ```\n *\n * @public\n */\nexport function assertDay(value: bigint): asserts value is Day {\n if (typeof value !== \"bigint\") {\n throw new TemporalAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"Day\",\n });\n }\n if (value < DAY_MIN || value > DAY_MAX) {\n throw new TemporalAssertionError(\n `Day must be in range [${String(DAY_MIN)}, ${String(DAY_MAX)}]`,\n {\n value,\n expectedType: \"Day\",\n constraint: `${String(DAY_MIN)} <= value <= ${String(DAY_MAX)}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * HOUR TYPE\n * ============================================================================= */\n\n/**\n * Branded type for hour-of-day values in 24-hour format.\n *\n * `Hour` is a subbrand of `TimestampComponent`. Valid range: `HOUR_MIN` (0) to `HOUR_MAX` (23).\n *\n * @remarks\n * Uses 24-hour clock convention: midnight is 0, noon is 12, and 11 PM is 23.\n *\n * @example\n * ```typescript\n * import { Hour, assertHour } from \"./temporal\";\n *\n * const hour: bigint = 14n; // 2 PM\n * assertHour(hour);\n * // hour is now typed as Hour\n * ```\n *\n * @see {@link assertHour}\n * @see {@link HOUR_MIN}\n * @see {@link HOUR_MAX}\n * @public\n */\nexport type Hour = SubBrandedType<TimestampComponent, \"Hour\">;\n\n/**\n * Asserts that a value is a valid `Hour` in the range `[HOUR_MIN, HOUR_MAX]` (0–23).\n *\n * @param value - The bigint to validate\n * @throws {TemporalAssertionError} If `value` is not a bigint or is outside `[HOUR_MIN, HOUR_MAX]`\n * @returns `void` — narrows the type of `value` to `Hour` on success\n *\n * @example\n * ```typescript\n * const hour = 14n;\n * assertHour(hour);\n * // hour is now typed as Hour\n * ```\n *\n * @public\n */\nexport function assertHour(value: bigint): asserts value is Hour {\n if (typeof value !== \"bigint\") {\n throw new TemporalAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"Hour\",\n });\n }\n if (value < HOUR_MIN || value > HOUR_MAX) {\n throw new TemporalAssertionError(\n `Hour must be in range [${String(HOUR_MIN)}, ${String(HOUR_MAX)}]`,\n {\n value,\n expectedType: \"Hour\",\n constraint: `${String(HOUR_MIN)} <= value <= ${String(HOUR_MAX)}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * MINUTE TYPE\n * ============================================================================= */\n\n/**\n * Branded type for minute-of-hour values.\n *\n * `Minute` is a subbrand of `TimestampComponent`. Valid range: `MINUTE_MIN` (0) to\n * `MINUTE_MAX` (59).\n *\n * @example\n * ```typescript\n * import { Minute, assertMinute } from \"./temporal\";\n *\n * const minute: bigint = 30n;\n * assertMinute(minute);\n * // minute is now typed as Minute\n * ```\n *\n * @see {@link assertMinute}\n * @see {@link MINUTE_MIN}\n * @see {@link MINUTE_MAX}\n * @public\n */\nexport type Minute = SubBrandedType<TimestampComponent, \"Minute\">;\n\n/**\n * Asserts that a value is a valid `Minute` in the range `[MINUTE_MIN, MINUTE_MAX]` (0–59).\n *\n * @param value - The bigint to validate\n * @throws {TemporalAssertionError} If `value` is not a bigint or is outside `[MINUTE_MIN, MINUTE_MAX]`\n * @returns `void` — narrows the type of `value` to `Minute` on success\n *\n * @example\n * ```typescript\n * const minute = 30n;\n * assertMinute(minute);\n * // minute is now typed as Minute\n * ```\n *\n * @public\n */\nexport function assertMinute(value: bigint): asserts value is Minute {\n if (typeof value !== \"bigint\") {\n throw new TemporalAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"Minute\",\n });\n }\n if (value < MINUTE_MIN || value > MINUTE_MAX) {\n throw new TemporalAssertionError(\n `Minute must be in range [${String(MINUTE_MIN)}, ${String(MINUTE_MAX)}]`,\n {\n value,\n expectedType: \"Minute\",\n constraint: `${String(MINUTE_MIN)} <= value <= ${String(MINUTE_MAX)}`,\n },\n );\n }\n}\n\n/* =============================================================================\n * SECOND TYPE\n * ============================================================================= */\n\n/**\n * Branded type for second-of-minute values.\n *\n * `Second` is a subbrand of `TimestampComponent`. Valid range: `SECOND_MIN` (0) to\n * `SECOND_MAX` (59). Leap seconds (value 60) are not supported.\n *\n * @example\n * ```typescript\n * import { Second, assertSecond } from \"./temporal\";\n *\n * const second: bigint = 45n;\n * assertSecond(second);\n * // second is now typed as Second\n * ```\n *\n * @see {@link assertSecond}\n * @see {@link SECOND_MIN}\n * @see {@link SECOND_MAX}\n * @public\n */\nexport type Second = SubBrandedType<TimestampComponent, \"Second\">;\n\n/**\n * Asserts that a value is a valid `Second` in the range `[SECOND_MIN, SECOND_MAX]` (0–59).\n *\n * @param value - The bigint to validate\n * @throws {TemporalAssertionError} If `value` is not a bigint or is outside `[SECOND_MIN, SECOND_MAX]`\n * @returns `void` — narrows the type of `value` to `Second` on success\n *\n * @example\n * ```typescript\n * const second = 45n;\n * assertSecond(second);\n * // second is now typed as Second\n * ```\n *\n * @public\n */\nexport function assertSecond(value: bigint): asserts value is Second {\n if (typeof value !== \"bigint\") {\n throw new TemporalAssertionError(`Expected bigint, got ${typeof value}`, {\n value,\n expectedType: \"Second\",\n });\n }\n if (value < SECOND_MIN || value > SECOND_MAX) {\n throw new TemporalAssertionError(\n `Second must be in range [${String(SECOND_MIN)}, ${String(SECOND_MAX)}]`,\n {\n value,\n expectedType: \"Second\",\n constraint: `${String(SECOND_MIN)} <= value <= ${String(SECOND_MAX)}`,\n },\n );\n }\n}\n"]}
|