@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.
Files changed (181) hide show
  1. package/README.md +104 -25
  2. package/dist/{addresses-Brzgurv_.d.ts → addresses-B7HybtbJ.d.ts} +2 -1
  3. package/dist/{addresses-D_0YAS6B.d.cts → addresses-CTVY1oi7.d.cts} +2 -1
  4. package/dist/arcium-BXXlryfe.d.cts +20 -0
  5. package/dist/arcium-BXXlryfe.d.ts +20 -0
  6. package/dist/chunk-4RHXVBNI.js +203 -0
  7. package/dist/chunk-4RHXVBNI.js.map +1 -0
  8. package/dist/chunk-4TZVXB5G.js +324 -0
  9. package/dist/chunk-4TZVXB5G.js.map +1 -0
  10. package/dist/chunk-5GUSMQ74.cjs +549 -0
  11. package/dist/chunk-5GUSMQ74.cjs.map +1 -0
  12. package/dist/chunk-5KPQXPQM.js +36 -0
  13. package/dist/chunk-5KPQXPQM.js.map +1 -0
  14. package/dist/chunk-AXD7LXYY.cjs +405 -0
  15. package/dist/chunk-AXD7LXYY.cjs.map +1 -0
  16. package/dist/{chunk-HOEXDXRC.cjs → chunk-BL6WXLPV.cjs} +32 -360
  17. package/dist/chunk-BL6WXLPV.cjs.map +1 -0
  18. package/dist/chunk-CFFLOE7D.cjs +598 -0
  19. package/dist/chunk-CFFLOE7D.cjs.map +1 -0
  20. package/dist/{chunk-BM7N6N7E.js → chunk-CFTW5WNG.js} +3 -325
  21. package/dist/chunk-CFTW5WNG.js.map +1 -0
  22. package/dist/chunk-DD2WCK4C.js +327 -0
  23. package/dist/chunk-DD2WCK4C.js.map +1 -0
  24. package/dist/chunk-DMPMQ74B.cjs +246 -0
  25. package/dist/chunk-DMPMQ74B.cjs.map +1 -0
  26. package/dist/{chunk-2Q75CQQJ.js → chunk-EEKF4553.js} +2 -2
  27. package/dist/chunk-EEKF4553.js.map +1 -0
  28. package/dist/chunk-ENVYYEM4.cjs +113 -0
  29. package/dist/chunk-ENVYYEM4.cjs.map +1 -0
  30. package/dist/chunk-FQX6ZYGJ.js +500 -0
  31. package/dist/chunk-FQX6ZYGJ.js.map +1 -0
  32. package/dist/chunk-FSK2ICMB.cjs +39 -0
  33. package/dist/chunk-FSK2ICMB.cjs.map +1 -0
  34. package/dist/chunk-FZYWLQAF.cjs +355 -0
  35. package/dist/chunk-FZYWLQAF.cjs.map +1 -0
  36. package/dist/chunk-GP26R377.js +436 -0
  37. package/dist/chunk-GP26R377.js.map +1 -0
  38. package/dist/chunk-HA5FLM63.js +393 -0
  39. package/dist/chunk-HA5FLM63.js.map +1 -0
  40. package/dist/chunk-INJ73LXQ.js +1107 -0
  41. package/dist/chunk-INJ73LXQ.js.map +1 -0
  42. package/dist/chunk-JPDF7BIT.cjs +10892 -0
  43. package/dist/chunk-JPDF7BIT.cjs.map +1 -0
  44. package/dist/{chunk-MDFSBU5W.cjs → chunk-LTCKPTZC.cjs} +2 -351
  45. package/dist/chunk-LTCKPTZC.cjs.map +1 -0
  46. package/dist/chunk-MKNCBUFA.js +564 -0
  47. package/dist/chunk-MKNCBUFA.js.map +1 -0
  48. package/dist/chunk-NKVMSABR.cjs +207 -0
  49. package/dist/chunk-NKVMSABR.cjs.map +1 -0
  50. package/dist/chunk-OFDWNWCL.js +70 -0
  51. package/dist/chunk-OFDWNWCL.js.map +1 -0
  52. package/dist/chunk-QJAUUYZU.cjs +331 -0
  53. package/dist/chunk-QJAUUYZU.cjs.map +1 -0
  54. package/dist/chunk-RVUYPKKD.js +10750 -0
  55. package/dist/chunk-RVUYPKKD.js.map +1 -0
  56. package/dist/chunk-TLR7A64G.js +103 -0
  57. package/dist/chunk-TLR7A64G.js.map +1 -0
  58. package/dist/{chunk-MVKTV3FT.cjs → chunk-TQQZGNOI.cjs} +2 -2
  59. package/dist/chunk-TQQZGNOI.cjs.map +1 -0
  60. package/dist/chunk-UOFYS6M3.js +219 -0
  61. package/dist/chunk-UOFYS6M3.js.map +1 -0
  62. package/dist/chunk-UXMQI6B7.js +2406 -0
  63. package/dist/chunk-UXMQI6B7.js.map +1 -0
  64. package/dist/chunk-WN75ORDT.js +571 -0
  65. package/dist/chunk-WN75ORDT.js.map +1 -0
  66. package/dist/chunk-Y55PYKXH.cjs +595 -0
  67. package/dist/chunk-Y55PYKXH.cjs.map +1 -0
  68. package/dist/chunk-YEZBTYCP.cjs +77 -0
  69. package/dist/chunk-YEZBTYCP.cjs.map +1 -0
  70. package/dist/chunk-ZQOIYCGA.cjs +1126 -0
  71. package/dist/chunk-ZQOIYCGA.cjs.map +1 -0
  72. package/dist/chunk-ZY3TSHMJ.cjs +2665 -0
  73. package/dist/chunk-ZY3TSHMJ.cjs.map +1 -0
  74. package/dist/client-DkVBHMWb.d.cts +2613 -0
  75. package/dist/client-V4AF6Bz9.d.ts +2613 -0
  76. package/dist/common/pda/index.cjs +145 -0
  77. package/dist/common/pda/index.cjs.map +1 -0
  78. package/dist/common/pda/index.d.cts +1250 -0
  79. package/dist/common/pda/index.d.ts +1250 -0
  80. package/dist/common/pda/index.js +8 -0
  81. package/dist/common/pda/index.js.map +1 -0
  82. package/dist/constants/index.cjs +38 -164
  83. package/dist/constants/index.cjs.map +1 -1
  84. package/dist/constants/index.d.cts +8 -425
  85. package/dist/constants/index.d.ts +8 -425
  86. package/dist/constants/index.js +15 -124
  87. package/dist/constants/index.js.map +1 -1
  88. package/dist/crypto/index.cjs +583 -0
  89. package/dist/crypto/index.cjs.map +1 -0
  90. package/dist/crypto/index.d.cts +6731 -0
  91. package/dist/crypto/index.d.ts +6731 -0
  92. package/dist/crypto/index.js +14 -0
  93. package/dist/crypto/index.js.map +1 -0
  94. package/dist/{cryptography-BTGC72u-.d.ts → cryptography-BFSJcvi6.d.ts} +3 -2465
  95. package/dist/{cryptography-BTGC72u-.d.cts → cryptography-D6tPDh-Y.d.cts} +3 -2465
  96. package/dist/errors/index.cjs +64 -54
  97. package/dist/errors/index.d.cts +7 -797
  98. package/dist/errors/index.d.ts +7 -797
  99. package/dist/errors/index.js +3 -1
  100. package/dist/errors-B9EoPeWV.d.cts +593 -0
  101. package/dist/errors-B9EoPeWV.d.ts +593 -0
  102. package/dist/errors-DAIrstEL.d.cts +300 -0
  103. package/dist/errors-DPNMfyh0.d.ts +300 -0
  104. package/dist/index-BG0yjL7C.d.cts +6006 -0
  105. package/dist/index-ByynoyBO.d.ts +6006 -0
  106. package/dist/index.cjs +5126 -16118
  107. package/dist/index.cjs.map +1 -1
  108. package/dist/index.d.cts +1031 -7685
  109. package/dist/index.d.ts +1031 -7685
  110. package/dist/index.js +3219 -14905
  111. package/dist/index.js.map +1 -1
  112. package/dist/interfaces/index.d.cts +14 -6
  113. package/dist/interfaces/index.d.ts +14 -6
  114. package/dist/interfaces-43cReBcS.d.cts +3346 -0
  115. package/dist/interfaces-B8xKNl_6.d.ts +997 -0
  116. package/dist/interfaces-D2NO6kDD.d.cts +997 -0
  117. package/dist/interfaces-z_xYJlgV.d.ts +3346 -0
  118. package/dist/math/index.cjs +115 -0
  119. package/dist/math/index.cjs.map +1 -0
  120. package/dist/math/index.d.cts +1327 -0
  121. package/dist/math/index.d.ts +1327 -0
  122. package/dist/math/index.js +10 -0
  123. package/dist/math/index.js.map +1 -0
  124. package/dist/networks-RMd3abPE.d.ts +44 -0
  125. package/dist/networks-yAoO8peQ.d.cts +44 -0
  126. package/dist/relayer-NRRMSMNB.js +4 -0
  127. package/dist/relayer-NRRMSMNB.js.map +1 -0
  128. package/dist/relayer-RJHEIXJG.cjs +21 -0
  129. package/dist/relayer-RJHEIXJG.cjs.map +1 -0
  130. package/dist/solana/index.cjs +56 -0
  131. package/dist/solana/index.cjs.map +1 -0
  132. package/dist/solana/index.d.cts +105 -0
  133. package/dist/solana/index.d.ts +105 -0
  134. package/dist/solana/index.js +7 -0
  135. package/dist/solana/index.js.map +1 -0
  136. package/dist/{index-CLj_zWSD.d.ts → temporal-BbRaEPoO.d.ts} +1 -1
  137. package/dist/{index-CX6_pIRS.d.cts → temporal-oUj7iCaq.d.cts} +1 -1
  138. package/dist/transaction-forwarder-5mAMTjw6.d.ts +1155 -0
  139. package/dist/transaction-forwarder-C6gMUG7a.d.cts +1155 -0
  140. package/dist/types/index.cjs +232 -231
  141. package/dist/types/index.d.cts +15 -1485
  142. package/dist/types/index.d.ts +15 -1485
  143. package/dist/types/index.js +2 -1
  144. package/dist/types-BohhvPth.d.cts +87 -0
  145. package/dist/types-CW0oTT0j.d.ts +87 -0
  146. package/dist/types-C_V_CaKK.d.cts +2468 -0
  147. package/dist/types-C_V_CaKK.d.ts +2468 -0
  148. package/dist/types-Ca7frykr.d.ts +793 -0
  149. package/dist/types-CuKeoI19.d.cts +1296 -0
  150. package/dist/types-CxfTIpN9.d.ts +1052 -0
  151. package/dist/{types-n-sHFcgr.d.ts → types-D1jDUjfN.d.ts} +2 -2
  152. package/dist/types-DKEDUlH9.d.ts +1296 -0
  153. package/dist/types-EKuIfxTz.d.cts +1052 -0
  154. package/dist/{types-BBuELtY8.d.cts → types-IMGYmlv-.d.cts} +2 -2
  155. package/dist/types-PwNLi_2k.d.cts +793 -0
  156. package/dist/utils/index.cjs +823 -525
  157. package/dist/utils/index.d.cts +1711 -4021
  158. package/dist/utils/index.d.ts +1711 -4021
  159. package/dist/utils/index.js +9 -3
  160. package/dist/{versions-D9PqsEvj.d.cts → versions-BRlR36EA.d.cts} +1 -0
  161. package/dist/{versions-D9PqsEvj.d.ts → versions-BRlR36EA.d.ts} +1 -0
  162. package/package.json +79 -18
  163. package/dist/chunk-2Q75CQQJ.js.map +0 -1
  164. package/dist/chunk-BM7N6N7E.js.map +0 -1
  165. package/dist/chunk-GXKSUB2U.cjs +0 -4416
  166. package/dist/chunk-GXKSUB2U.cjs.map +0 -1
  167. package/dist/chunk-HOEXDXRC.cjs.map +0 -1
  168. package/dist/chunk-MDFSBU5W.cjs.map +0 -1
  169. package/dist/chunk-MQY7HDIA.js +0 -600
  170. package/dist/chunk-MQY7HDIA.js.map +0 -1
  171. package/dist/chunk-MVKTV3FT.cjs.map +0 -1
  172. package/dist/chunk-PG2J6V6Y.js +0 -4094
  173. package/dist/chunk-PG2J6V6Y.js.map +0 -1
  174. package/dist/chunk-VEGLTTYQ.cjs +0 -621
  175. package/dist/chunk-VEGLTTYQ.cjs.map +0 -1
  176. package/dist/chunk-WVHQ46DD.js +0 -758
  177. package/dist/chunk-WVHQ46DD.js.map +0 -1
  178. package/dist/index-B9pDY73x.d.ts +0 -12933
  179. package/dist/index-D33yo0qB.d.cts +0 -12933
  180. package/dist/networks-C-orpSFW.d.ts +0 -65
  181. package/dist/networks-FxYERGD1.d.cts +0 -65
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/converters/branded.ts","../src/common/converters/mathematics.ts","../src/common/converters/cryptography.ts","../src/common/math-utils.ts","../src/common/arcium.ts","../src/common/addresses.ts","../src/common/pda/umbra.ts","../src/common/pda/user.ts","../src/common/pda/arcium.ts","../src/common/pda/compliance.ts","../src/common/pda/global.ts","../src/common/pda/pool.ts","../src/common/pda/relayer.ts","../src/common/pda/fees.ts","../src/common/pda/zk.ts","../src/common/temporal/index.ts","../src/common/token/index.ts","../src/common/type-helpers.ts"],"names":["__name","U8_BYTE_LENGTH","U16_BYTE_LENGTH","U32_BYTE_LENGTH","U64_BYTE_LENGTH","U128_BYTE_LENGTH","U256_BYTE_LENGTH","U512_BYTE_LENGTH","U1024_BYTE_LENGTH","U8_MAX","U16_MAX","U32_MAX","U64_MAX","U128_MAX","U256_MAX","U512_MAX","U1024_MAX","I8_MIN","I8_MAX","I16_MIN","I16_MAX","I32_MIN","I32_MAX","I64_MIN","I64_MAX","I128_MIN","I128_MAX","I256_MIN","I256_MAX","I512_MIN","I512_MAX","I1024_MIN","I1024_MAX","BN254_FIELD_PRIME","CURVE25519_FIELD_PRIME","X25519_BYTE_LENGTH","assertU8","assertU16","assertU32","assertU64","assertU128","assertU256","assertU512","assertU1024","assertI8","assertI16","assertI32","assertI64","assertI128","assertI256","assertI512","assertI1024","assertU8LeBytes","assertU8BeBytes","assertU16LeBytes","assertU16BeBytes","assertU32LeBytes","assertU32BeBytes","assertU64LeBytes","assertU64BeBytes","assertU128LeBytes","assertU128BeBytes","assertU256LeBytes","assertU256BeBytes","assertU512LeBytes","assertU512BeBytes","assertU1024LeBytes","assertU1024BeBytes","assertBn254FieldElement","assertCurve25519FieldElement","assertPoseidonPlaintext","assertPoseidonHash","assertPoseidonKey","assertPoseidonCiphertext","assertRcPlaintext","assertRcCiphertext","assertRcKey","assertRcCounter","assertRcEncryptionNonce","assertX25519Bytes","assertX25519PrivateKey","assertX25519PublicKey","assertSharedSecret","assertBase85Limb","getAddressEncoder","address","sha256","getProgramDerivedAddress","getAccountOffsetEncoder","ARCIUM_MXE_ACCOUNT_SEED","ARCIUM_MEMPOOL_SEED","ARCIUM_EXEC_POOL_SEED","ARCIUM_COMPUTATION_SEED","ARCIUM_COMP_DEF_SEED","ARCIUM_CLUSTER_SEED","getArciumX25519PublicKeyEncoder","getArciumX25519NonceEncoder","assertYear","assertMonth","assertDay","assertHour","assertMinute","assertSecond"],"mappings":";;;;;;;;;;AAoKO,IAAM,eAAA,GAAN,MAAM,gBAAA,SAAwB,KAAA,CAAM;AAAA,EApK3C;AAoK2C,IAAAA,wBAAA,CAAA,IAAA,EAAA,iBAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzB,WAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAahB,WAAA,CACE,SACA,OAAA,EAMA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AACZ,IAAA,IAAA,CAAK,cAAc,OAAA,CAAQ,WAAA;AAC3B,IAAA,IAAA,CA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ChG;AAAA,EACF;AACA,EAAA,MAAM,IAAA,GAAO,MAAM,KAAK,CAAA;AAGxB,EAAA,IAAI,SAAS,MAAA,EAAW;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,EAAG,IAAI,CAAA,gBAAA,EAAmB,MAAA,CAAO,KAAK,CAAC,CAAA,6BAAA,EAAgC,MAAA,CAAO,KAAA,CAAM,MAAM,CAAC,CAAA,CAAA;AAAA,KAC7F;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT;AAfgBA,wBAAA,CAAA,SAAA,EAAA,WAAA,CAAA","file":"chunk-GXKSUB2U.cjs","sourcesContent":["/**\n * Branded Type Converters\n *\n * This module provides conversion functions to transform standard JavaScript types\n * into branded mathematical and cryptographic types. All converters validate input\n * and throw `ConversionError` on invalid data.\n *\n * ## Supported Input Types\n *\n * - `number` - JavaScript numbers (validated for integer and range)\n * - `bigint` - JavaScript BigInts\n * - `string` - Hex strings (with/without \"0x\" prefix) or decimal strings\n * - `Uint8Array` - Raw byte arrays (padded if undersized)\n * - `ArrayBuffer` - Raw binary data\n * - `DataView` - Binary data view\n *\n * ## Usage Example\n *\n * ```typescript\n * import { createU256, createU256LeBytes, createBn254FieldElement } from \"./convertors/branded\";\n *\n * // From various types\n * const a = createU256(12345n);\n * const b = createU256(255);\n * const c = createU256(\"0x1234\");\n * const d = createU256(\"4660\"); // decimal string\n *\n * // Byte arrays (auto-padded)\n * const bytes = createU256LeBytes(new Uint8Array([1, 2, 3])); // Padded to 32 bytes\n *\n * // Cryptographic types\n * const fieldElement = createBn254FieldElement(scalarValue);\n * ```\n *\n * @packageDocumentation\n * @module utils/convertors/branded\n * @public\n */\n\nimport {\n // Byte array types\n type Bytes,\n type LeBytes,\n type BeBytes,\n type U8LeBytes,\n type U16LeBytes,\n type U32LeBytes,\n type U64LeBytes,\n type U128LeBytes,\n type U256LeBytes,\n type U512LeBytes,\n type U1024LeBytes,\n type U8BeBytes,\n type U16BeBytes,\n type U32BeBytes,\n type U64BeBytes,\n type U128BeBytes,\n type U256BeBytes,\n type U512BeBytes,\n type U1024BeBytes,\n // Integer types\n type UnsignedInteger,\n type SignedInteger,\n type U8,\n type U16,\n type U32,\n type U64,\n type U128,\n type U256,\n type U512,\n type U1024,\n type I8,\n type I16,\n type I32,\n type I64,\n type I128,\n type I256,\n type I512,\n type I1024,\n // Constants\n U8_MAX,\n U16_MAX,\n U32_MAX,\n U64_MAX,\n U128_MAX,\n U256_MAX,\n U512_MAX,\n U1024_MAX,\n I8_MIN,\n I8_MAX,\n I16_MIN,\n I16_MAX,\n I32_MIN,\n I32_MAX,\n I64_MIN,\n I64_MAX,\n I128_MIN,\n I128_MAX,\n I256_MIN,\n I256_MAX,\n I512_MIN,\n I512_MAX,\n I1024_MIN,\n I1024_MAX,\n U8_BYTE_LENGTH,\n U16_BYTE_LENGTH,\n U32_BYTE_LENGTH,\n U64_BYTE_LENGTH,\n U128_BYTE_LENGTH,\n U256_BYTE_LENGTH,\n U512_BYTE_LENGTH,\n U1024_BYTE_LENGTH,\n} from \"../types\";\n\nimport {\n type Bn254FieldElement,\n type Curve25519FieldElement,\n type PoseidonPlaintext,\n type PoseidonHash,\n type PoseidonKey,\n type PoseidonCiphertext,\n type RcCiphertext,\n type RcPlaintext,\n type RcKey,\n type RcCounter,\n type RcEncryptionNonce,\n type X25519Bytes,\n type X25519PrivateKey,\n type X25519PublicKey,\n type SharedSecret,\n BN254_FIELD_PRIME,\n CURVE25519_FIELD_PRIME,\n X25519_BYTE_LENGTH,\n} from \"../../types/cryptography\";\n\n/* =============================================================================\n * CONVERSION ERROR\n * ============================================================================= */\n\n/**\n * Error thrown when a type conversion fails.\n *\n * @remarks\n * This error provides structured metadata about the failure: which value was\n * being converted, from which type, to which target type, and why it failed.\n * Always catch this when calling narrowing or range-checking converters.\n *\n * All `create*` and `convert*` functions in this module throw `ConversionError`\n * when inputs are out of range, the wrong type, or cannot be parsed.\n *\n * @example\n * ```typescript\n * try {\n * const value = createU8(256); // Will throw - exceeds U8 max (255)\n * } catch (error) {\n * if (error instanceof ConversionError) {\n * console.error(`Cannot convert ${error.sourceType} to ${error.targetType}`);\n * console.error(`Reason: ${error.reason}`);\n * }\n * }\n * ```\n *\n * @public\n */\nexport class ConversionError extends Error {\n /**\n * The original value that failed conversion.\n * @public\n */\n public readonly sourceValue: unknown;\n\n /**\n * The type name of the source value (e.g., \"number\", \"string\", \"Uint8Array\").\n * @public\n */\n public readonly sourceType: string;\n\n /**\n * The target branded type name (e.g., \"U8\", \"U256LeBytes\", \"Bn254FieldElement\").\n * @public\n */\n public readonly targetType: string;\n\n /**\n * Human-readable explanation of why the conversion failed.\n * @public\n */\n public readonly reason: string;\n\n /**\n * Creates a new ConversionError with structured metadata.\n *\n * @param message - A human-readable error message summarising the failure\n * @param options - Structured details about the failed conversion\n * @param options.sourceValue - The original value that could not be converted\n * @param options.sourceType - The type name of the source value\n * @param options.targetType - The branded type name that was the conversion target\n * @param options.reason - A concise description of why the conversion was rejected\n * @public\n */\n constructor(\n message: string,\n options: {\n sourceValue: unknown;\n sourceType: string;\n targetType: string;\n reason: string;\n },\n ) {\n super(message);\n this.name = \"ConversionError\";\n this.sourceValue = options.sourceValue;\n this.sourceType = options.sourceType;\n this.targetType = options.targetType;\n this.reason = options.reason;\n\n Error.captureStackTrace(this, ConversionError);\n\n Object.setPrototypeOf(this, ConversionError.prototype);\n }\n}\n\n/* =============================================================================\n * INPUT TYPE DEFINITIONS\n * ============================================================================= */\n\n/**\n * Union of all input types that can be converted to integer branded types.\n *\n * @remarks\n * - `number` — must be a finite integer; converted via `BigInt(value)`\n * - `bigint` — used directly\n * - `string` — parsed as hex (with or without `0x` prefix), binary (`0b`), octal (`0o`), or decimal\n * - `Uint8Array` — interpreted as a big-endian byte sequence and decoded to bigint\n * - `ArrayBuffer` — wrapped in `Uint8Array` then treated as big-endian\n * - `DataView` — byte-range aware; treated as big-endian\n *\n * @public\n */\nexport type IntegerInput = number | bigint | string | Uint8Array | ArrayBuffer | DataView;\n\n/**\n * Union of all input types that can be converted to byte array branded types.\n *\n * @remarks\n * - `Uint8Array` — used directly (possibly zero-padded on the right to reach target length)\n * - `ArrayBuffer` — wrapped in `Uint8Array`\n * - `DataView` — byte-range aware wrapper\n * - `string` — interpreted as a hex string (with or without `0x` prefix)\n * - `number[]` — each element must be an integer in [0, 255]\n * - `bigint` — encoded as big-endian bytes and right-padded to reach target length\n *\n * @public\n */\nexport type ByteArrayInput = Uint8Array | ArrayBuffer | DataView | string | number[] | bigint;\n\n/* =============================================================================\n * HELPER FUNCTIONS - INTERNAL\n * ============================================================================= */\n\n/**\n * Returns a descriptive type name for a value, used in error messages.\n *\n * @remarks\n * Handles `null`, `undefined`, `Uint8Array`, `ArrayBuffer`, `DataView`, and\n * plain `Array` as special cases before falling back to `typeof`.\n *\n * @param value - Any value whose type name is needed\n * @returns A string describing the runtime type of `value`\n *\n * @internal\n */\nfunction getTypeName(value: unknown): string {\n if (value === null) {\n return \"null\";\n }\n if (value === undefined) {\n return \"undefined\";\n }\n if (value instanceof Uint8Array) {\n return \"Uint8Array\";\n }\n if (value instanceof ArrayBuffer) {\n return \"ArrayBuffer\";\n }\n if (value instanceof DataView) {\n return \"DataView\";\n }\n if (Array.isArray(value)) {\n return \"Array\";\n }\n return typeof value;\n}\n\n/**\n * Parses a string to `bigint`, supporting hex, decimal, binary, and octal notation.\n *\n * @remarks\n * Supported string formats:\n * - `\"0x1a2b\"` or `\"0X1A2B\"` — hexadecimal with prefix\n * - `\"0b1010\"` — binary with prefix\n * - `\"0o17\"` — octal with prefix\n * - `\"1a2b\"` — bare hex (detected by presence of a-f/A-F characters)\n * - `\"12345\"` — decimal (no letters, no prefix)\n *\n * Leading/trailing whitespace is trimmed before parsing. An empty string (after trim)\n * always throws.\n *\n * @param value - The string to parse\n * @param targetType - The target branded type name, used in error messages\n * @returns The parsed `bigint` value\n * @throws {ConversionError} If the string is empty, contains invalid characters,\n * or cannot be parsed by `BigInt()`\n *\n * @example\n * ```typescript\n * parseStringToBigInt(\"0xFF\", \"U8\"); // 255n\n * parseStringToBigInt(\"255\", \"U8\"); // 255n\n * parseStringToBigInt(\"FF\", \"U8\"); // 255n (bare hex)\n * parseStringToBigInt(\"0b11\", \"U8\"); // 3n\n * ```\n *\n * @internal\n */\nfunction parseStringToBigInt(value: string, targetType: string): bigint {\n const trimmed = value.trim();\n\n if (trimmed === \"\") {\n throw new ConversionError(`Cannot convert empty string to ${targetType}`, {\n sourceValue: value,\n sourceType: \"string\",\n targetType,\n reason: \"Empty string is not a valid number\",\n });\n }\n\n try {\n // Check for hex prefix (case-insensitive)\n if (trimmed.toLowerCase().startsWith(\"0x\")) {\n return BigInt(trimmed);\n }\n\n // Check for binary prefix\n if (trimmed.toLowerCase().startsWith(\"0b\")) {\n return BigInt(trimmed);\n }\n\n // Check for octal prefix\n if (trimmed.toLowerCase().startsWith(\"0o\")) {\n return BigInt(trimmed);\n }\n\n // Check if it looks like a hex string without prefix (all hex chars)\n if (/^[0-9a-fA-F]+$/.test(trimmed) && /[a-fA-F]/.test(trimmed)) {\n // Contains letters, treat as hex\n return BigInt(`0x${trimmed}`);\n }\n\n // Treat as decimal\n return BigInt(trimmed);\n } catch {\n throw new ConversionError(`Cannot parse string \"${value}\" to ${targetType}`, {\n sourceValue: value,\n sourceType: \"string\",\n targetType,\n reason: \"Invalid number format\",\n });\n }\n}\n\n/**\n * Converts any `IntegerInput` value to a raw `bigint`.\n *\n * @remarks\n * This is the central dispatch function used by all integer `create*` functions.\n * It handles each branch of `IntegerInput`:\n * - `bigint` — returned as-is\n * - `number` — validated finite integer, then `BigInt(value)`\n * - `string` — delegated to {@link parseStringToBigInt}\n * - `Uint8Array` — delegated to {@link bytesToBigInt} (big-endian decode)\n * - `ArrayBuffer` — wrapped in `Uint8Array`, then big-endian decode\n * - `DataView` — byte-range aware; big-endian decode\n *\n * No range or sign validation is performed here — callers are responsible\n * for checking the result against their target type's bounds.\n *\n * @param value - The value to convert to `bigint`\n * @param targetType - The target branded type name, used in error messages\n * @returns The `bigint` representation of `value`\n * @throws {ConversionError} If `value` is not a finite integer (for `number`),\n * cannot be parsed (for `string`), or is an unsupported type\n *\n * @internal\n */\nfunction toBigIntValue(value: IntegerInput, targetType: string): bigint {\n if (typeof value === \"bigint\") {\n return value;\n }\n\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) {\n throw new ConversionError(`Cannot convert ${String(value)} to ${targetType}`, {\n sourceValue: value,\n sourceType: \"number\",\n targetType,\n reason: \"Value must be a finite number\",\n });\n }\n if (!Number.isInteger(value)) {\n throw new ConversionError(`Cannot convert ${String(value)} to ${targetType}`, {\n sourceValue: value,\n sourceType: \"number\",\n targetType,\n reason: \"Value must be an integer\",\n });\n }\n return BigInt(value);\n }\n\n if (typeof value === \"string\") {\n return parseStringToBigInt(value, targetType);\n }\n\n if (value instanceof Uint8Array) {\n return bytesToBigInt(value);\n }\n\n if (value instanceof ArrayBuffer) {\n return bytesToBigInt(new Uint8Array(value));\n }\n\n if (value instanceof DataView) {\n return bytesToBigInt(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\n }\n\n throw new ConversionError(`Cannot convert ${getTypeName(value)} to ${targetType}`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType,\n reason: \"Unsupported input type\",\n });\n}\n\n/**\n * Decodes a `Uint8Array` to a `bigint` using big-endian byte order.\n *\n * @remarks\n * Byte order: **big-endian** — the first byte is the most significant.\n * An empty array decodes to `0n`.\n *\n * This is the inverse of the big-endian encoding performed by {@link bigIntToBytes}.\n *\n * @param bytes - The byte array to decode\n * @returns The decoded `bigint` value (always non-negative)\n *\n * @example\n * ```typescript\n * bytesToBigInt(new Uint8Array([0x01, 0x00])); // 256n\n * bytesToBigInt(new Uint8Array([0xff])); // 255n\n * bytesToBigInt(new Uint8Array([])); // 0n\n * ```\n *\n * @internal\n */\nfunction bytesToBigInt(bytes: Uint8Array): bigint {\n let result = 0n;\n for (const byte of bytes) {\n result = (result << 8n) | BigInt(byte);\n }\n return result;\n}\n\n/**\n * Converts any `ByteArrayInput` value to a `Uint8Array`, optionally zero-padding\n * on the right to reach a target length.\n *\n * @remarks\n * Handles each branch of `ByteArrayInput`:\n * - `Uint8Array` — used directly\n * - `ArrayBuffer` — wrapped in `Uint8Array`\n * - `DataView` — byte-range slice\n * - `string` — hex-decoded via {@link hexStringToBytes}\n * - `number[]` — each element validated as [0, 255] integer, then converted\n * - `bigint` — big-endian encoded via {@link bigIntToBytes}\n *\n * If `targetLength` is non-null and the resulting byte array is shorter than\n * `targetLength`, zeros are appended on the right (little-endian padding style).\n * If the byte array is longer than `targetLength`, a `ConversionError` is thrown.\n *\n * @param value - The value to convert to `Uint8Array`\n * @param targetLength - Expected byte length, or `null` to skip padding/length checks\n * @param targetType - The target branded type name, used in error messages\n * @returns The `Uint8Array` representation of `value`, padded if necessary\n * @throws {ConversionError} If the resulting bytes exceed `targetLength`,\n * or if any `number[]` element is not a valid byte\n *\n * @internal\n */\nfunction toByteArrayValue(\n value: ByteArrayInput,\n targetLength: number | null,\n targetType: string,\n): Uint8Array {\n let bytes: Uint8Array;\n\n if (value instanceof Uint8Array) {\n bytes = value;\n } else if (value instanceof ArrayBuffer) {\n bytes = new Uint8Array(value);\n } else if (value instanceof DataView) {\n bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n } else if (typeof value === \"string\") {\n bytes = hexStringToBytes(value, targetType);\n } else if (Array.isArray(value)) {\n // Validate array elements are valid bytes\n for (let index = 0; index < value.length; index++) {\n const element = value[index];\n if (\n typeof element !== \"number\" ||\n element < 0 ||\n element > 255 ||\n !Number.isInteger(element)\n ) {\n throw new ConversionError(`Invalid byte value at index ${String(index)}`, {\n sourceValue: value,\n sourceType: \"Array\",\n targetType,\n reason: `Array element at index ${String(index)} must be an integer between 0 and 255`,\n });\n }\n }\n bytes = new Uint8Array(value);\n } else if (typeof value === \"bigint\") {\n bytes = bigIntToBytes(value, targetLength ?? 0, targetType);\n } else {\n throw new ConversionError(`Cannot convert ${getTypeName(value)} to ${targetType}`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType,\n reason: \"Unsupported input type\",\n });\n }\n\n // Apply padding if needed\n if (targetLength !== null) {\n if (bytes.length > targetLength) {\n throw new ConversionError(\n `Byte array too large for ${targetType}: ${String(bytes.length)} > ${String(targetLength)}`,\n {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType,\n reason: `Maximum length is ${String(targetLength)} bytes`,\n },\n );\n }\n\n if (bytes.length < targetLength) {\n // Pad with zeros on the right (for little-endian) or left (for big-endian)\n // Default to right-padding (little-endian style)\n const padded = new Uint8Array(targetLength);\n padded.set(bytes, 0);\n bytes = padded;\n }\n }\n\n return bytes;\n}\n\n/**\n * Decodes a hex string (with or without `0x` prefix) to a `Uint8Array`.\n *\n * @remarks\n * - `0x` (or `0X`) prefix is stripped if present.\n * - An odd-length hex string is left-padded with a leading `\"0\"`.\n * - An empty string (after stripping the prefix) returns an empty `Uint8Array`.\n * - Any non-hexadecimal character causes a `ConversionError`.\n *\n * The resulting bytes are in the same order as the hex string (big-endian):\n * `\"0x0102\"` → `[0x01, 0x02]`.\n *\n * @param value - The hex string to decode\n * @param targetType - The target branded type name, used in error messages\n * @returns The decoded `Uint8Array`\n * @throws {ConversionError} If the string contains non-hex characters\n *\n * @example\n * ```typescript\n * hexStringToBytes(\"0x0102\", \"U16BeBytes\"); // Uint8Array [1, 2]\n * hexStringToBytes(\"FF\", \"U8BeBytes\"); // Uint8Array [255]\n * ```\n *\n * @internal\n */\nfunction hexStringToBytes(value: string, targetType: string): Uint8Array {\n let hex = value.trim();\n\n // Remove 0x prefix if present\n if (hex.toLowerCase().startsWith(\"0x\")) {\n hex = hex.slice(2);\n }\n\n // Validate hex string\n if (!/^[0-9a-fA-F]*$/.test(hex)) {\n throw new ConversionError(`Invalid hex string: \"${value}\"`, {\n sourceValue: value,\n sourceType: \"string\",\n targetType,\n reason: \"String contains non-hexadecimal characters\",\n });\n }\n\n // Handle empty string\n if (hex === \"\") {\n return new Uint8Array(0);\n }\n\n // Pad with leading zero if odd length\n if (hex.length % 2 !== 0) {\n hex = `0${hex}`;\n }\n\n const bytes = new Uint8Array(hex.length / 2);\n for (let index = 0; index < bytes.length; index++) {\n bytes[index] = Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16);\n }\n\n return bytes;\n}\n\n/**\n * Encodes a non-negative `bigint` to a `Uint8Array` in big-endian byte order.\n *\n * @remarks\n * Byte order: **big-endian** — the most significant byte is first.\n * The result is zero-padded on the left to reach `minLength` bytes if needed.\n * If the value is `0n`, a zero-filled array of `minLength` bytes is returned.\n *\n * This is the inverse of the big-endian decode performed by {@link bytesToBigInt}.\n *\n * @param value - The non-negative `bigint` to encode\n * @param minLength - Minimum output length in bytes; result is left-padded with zeros\n * @param targetType - The target branded type name, used in error messages\n * @returns The big-endian `Uint8Array` encoding of `value`\n * @throws {ConversionError} If `value` is negative\n *\n * @example\n * ```typescript\n * bigIntToBytes(256n, 2, \"U16BeBytes\"); // Uint8Array [0x01, 0x00]\n * bigIntToBytes(0n, 4, \"U32BeBytes\"); // Uint8Array [0, 0, 0, 0]\n * ```\n *\n * @internal\n */\nfunction bigIntToBytes(value: bigint, minLength: number, targetType: string): Uint8Array {\n if (value < 0n) {\n throw new ConversionError(`Cannot convert negative bigint to ${targetType}`, {\n sourceValue: value,\n sourceType: \"bigint\",\n targetType,\n reason: \"Byte arrays cannot represent negative values directly\",\n });\n }\n\n if (value === 0n) {\n return new Uint8Array(minLength);\n }\n\n // Calculate required bytes\n const hex = value.toString(16);\n const byteLength = Math.ceil(hex.length / 2);\n const bytes = new Uint8Array(Math.max(byteLength, minLength));\n\n let temporary = value;\n for (let index = bytes.length - 1; index >= 0 && temporary > 0n; index--) {\n bytes[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n\n return bytes;\n}\n\n/* =============================================================================\n * BASE BYTE ARRAY CONVERTERS\n * ============================================================================= */\n\n/**\n * Converts a value to an unsized little-endian byte array (`LeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput` (Uint8Array, ArrayBuffer, DataView, hex string,\n * number[], or bigint).\n * Output type: `LeBytes` — the base branded type for all little-endian byte arrays,\n * with no fixed length constraint.\n *\n * No padding is applied and no length limit is enforced. Use sized variants like\n * {@link createU256LeBytes} when a specific byte length is required.\n *\n * @param value - The value to convert\n * @returns The value as `LeBytes`\n * @throws {ConversionError} If the value cannot be converted to bytes\n *\n * @example\n * ```typescript\n * const bytes1 = createLeBytes(new Uint8Array([1, 2, 3, 4]));\n * const bytes2 = createLeBytes(\"0x12345678\");\n * const bytes3 = createLeBytes([0x78, 0x56, 0x34, 0x12]);\n * ```\n *\n * @see {@link createBeBytes} — for big-endian base byte arrays\n * @see {@link createU256LeBytes} — for a fixed-32-byte LE array\n * @public\n */\nexport function createLeBytes(value: ByteArrayInput): LeBytes {\n const bytes = toByteArrayValue(value, null, \"LeBytes\");\n return bytes as LeBytes;\n}\n\n/**\n * Converts a value to an unsized big-endian byte array (`BeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `BeBytes` — the base branded type for all big-endian byte arrays,\n * with no fixed length constraint.\n *\n * No padding is applied and no length limit is enforced. Use sized variants like\n * {@link createU256BeBytes} when a specific byte length is required.\n *\n * @param value - The value to convert\n * @returns The value as `BeBytes`\n * @throws {ConversionError} If the value cannot be converted to bytes\n *\n * @example\n * ```typescript\n * const bytes1 = createBeBytes(new Uint8Array([1, 2, 3, 4]));\n * const bytes2 = createBeBytes(\"0x12345678\");\n * const bytes3 = createBeBytes([0x12, 0x34, 0x56, 0x78]);\n * ```\n *\n * @see {@link createLeBytes} — for little-endian base byte arrays\n * @public\n */\nexport function createBeBytes(value: ByteArrayInput): BeBytes {\n const bytes = toByteArrayValue(value, null, \"BeBytes\");\n return bytes as BeBytes;\n}\n\n/* =============================================================================\n * LITTLE-ENDIAN SIZED BYTE ARRAY CONVERTERS\n * ============================================================================= */\n\n/**\n * Converts a value to a 1-byte little-endian byte array (`U8LeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U8LeBytes` — exactly 1 byte.\n *\n * The byte order label (little-endian) is meaningful only for multi-byte types;\n * for a single byte there is no difference. Undersized inputs are zero-padded on\n * the right. Inputs exceeding 1 byte throw `ConversionError`.\n *\n * @param value - The value to convert (must fit in 1 byte)\n * @returns The value as `U8LeBytes`\n * @throws {ConversionError} If the value exceeds 1 byte\n *\n * @example\n * ```typescript\n * const bytes = createU8LeBytes(new Uint8Array([0xFF]));\n * const fromHex = createU8LeBytes(\"0xFF\");\n * ```\n *\n * @see {@link createU8BeBytes} — big-endian variant (identical for 1 byte)\n * @public\n */\nexport function createU8LeBytes(value: ByteArrayInput): U8LeBytes {\n const bytes = toByteArrayValue(value, U8_BYTE_LENGTH, \"U8LeBytes\");\n return bytes as U8LeBytes;\n}\n\n/**\n * Converts a value to a 2-byte little-endian byte array (`U16LeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U16LeBytes` — exactly 2 bytes, least significant byte first.\n *\n * Undersized inputs are zero-padded on the right. Inputs exceeding 2 bytes throw.\n * When the input is a hex string like `\"0x1234\"`, the decoded bytes are\n * `[0x12, 0x34]` (big-endian from the string), which is then placed as-is into\n * the array — callers must ensure the byte order of string inputs matches the\n * intended little-endian layout.\n *\n * @param value - The value to convert (must fit in 2 bytes)\n * @returns The value as `U16LeBytes`\n * @throws {ConversionError} If the value exceeds 2 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU16LeBytes(new Uint8Array([0x34, 0x12])); // 0x1234 in LE\n * const fromHex = createU16LeBytes(\"0x1234\");\n * ```\n *\n * @see {@link createU16BeBytes} — big-endian variant\n * @public\n */\nexport function createU16LeBytes(value: ByteArrayInput): U16LeBytes {\n const bytes = toByteArrayValue(value, U16_BYTE_LENGTH, \"U16LeBytes\");\n return bytes as U16LeBytes;\n}\n\n/**\n * Converts a value to a 4-byte little-endian byte array (`U32LeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U32LeBytes` — exactly 4 bytes, least significant byte first.\n *\n * Undersized inputs are zero-padded on the right. Inputs exceeding 4 bytes throw.\n *\n * @param value - The value to convert (must fit in 4 bytes)\n * @returns The value as `U32LeBytes`\n * @throws {ConversionError} If the value exceeds 4 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU32LeBytes(new Uint8Array([0x78, 0x56, 0x34, 0x12])); // 0x12345678 in LE\n * const fromHex = createU32LeBytes(\"0x12345678\");\n * ```\n *\n * @see {@link createU32BeBytes} — big-endian variant\n * @public\n */\nexport function createU32LeBytes(value: ByteArrayInput): U32LeBytes {\n const bytes = toByteArrayValue(value, U32_BYTE_LENGTH, \"U32LeBytes\");\n return bytes as U32LeBytes;\n}\n\n/**\n * Converts a value to an 8-byte little-endian byte array (`U64LeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U64LeBytes` — exactly 8 bytes, least significant byte first.\n *\n * Used to encode `U64` token amounts and slot numbers for on-chain Solana storage,\n * which uses little-endian byte order for all integer fields.\n *\n * @param value - The value to convert (must fit in 8 bytes)\n * @returns The value as `U64LeBytes`\n * @throws {ConversionError} If the value exceeds 8 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU64LeBytes(new Uint8Array(8));\n * const fromBigInt = createU64LeBytes(0x123456789ABCDEFn);\n * ```\n *\n * @see {@link createU64BeBytes} — big-endian variant\n * @public\n */\nexport function createU64LeBytes(value: ByteArrayInput): U64LeBytes {\n const bytes = toByteArrayValue(value, U64_BYTE_LENGTH, \"U64LeBytes\");\n return bytes as U64LeBytes;\n}\n\n/**\n * Converts a value to a 16-byte little-endian byte array (`U128LeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U128LeBytes` — exactly 16 bytes, least significant byte first.\n *\n * Used to encode encrypted balances and nonces for on-chain Solana storage.\n *\n * @param value - The value to convert (must fit in 16 bytes)\n * @returns The value as `U128LeBytes`\n * @throws {ConversionError} If the value exceeds 16 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU128LeBytes(new Uint8Array(16));\n * ```\n *\n * @see {@link createU128BeBytes} — big-endian variant\n * @public\n */\nexport function createU128LeBytes(value: ByteArrayInput): U128LeBytes {\n const bytes = toByteArrayValue(value, U128_BYTE_LENGTH, \"U128LeBytes\");\n return bytes as U128LeBytes;\n}\n\n/**\n * Converts a value to a 32-byte little-endian byte array (`U256LeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U256LeBytes` — exactly 32 bytes, least significant byte first.\n *\n * Undersized inputs are zero-padded on the right to reach 32 bytes. Inputs\n * exceeding 32 bytes throw `ConversionError`.\n *\n * Used extensively to encode field elements, scalars, and keys for on-chain\n * Solana storage and Arcium MPC inputs.\n *\n * @param value - The value to convert (must fit in 32 bytes)\n * @returns The value as `U256LeBytes`\n * @throws {ConversionError} If the value exceeds 32 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU256LeBytes(new Uint8Array(32));\n * const fromHex = createU256LeBytes(\"0x\" + \"ab\".repeat(32));\n * ```\n *\n * @see {@link createU256BeBytes} — big-endian variant\n * @public\n */\nexport function createU256LeBytes(value: ByteArrayInput): U256LeBytes {\n const bytes = toByteArrayValue(value, U256_BYTE_LENGTH, \"U256LeBytes\");\n return bytes as U256LeBytes;\n}\n\n/**\n * Converts a value to a 64-byte little-endian byte array (`U512LeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U512LeBytes` — exactly 64 bytes, least significant byte first.\n *\n * @param value - The value to convert (must fit in 64 bytes)\n * @returns The value as `U512LeBytes`\n * @throws {ConversionError} If the value exceeds 64 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU512LeBytes(new Uint8Array(64));\n * ```\n *\n * @see {@link createU512BeBytes} — big-endian variant\n * @public\n */\nexport function createU512LeBytes(value: ByteArrayInput): U512LeBytes {\n const bytes = toByteArrayValue(value, U512_BYTE_LENGTH, \"U512LeBytes\");\n return bytes as U512LeBytes;\n}\n\n/**\n * Converts a value to a 128-byte little-endian byte array (`U1024LeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U1024LeBytes` — exactly 128 bytes, least significant byte first.\n *\n * @param value - The value to convert (must fit in 128 bytes)\n * @returns The value as `U1024LeBytes`\n * @throws {ConversionError} If the value exceeds 128 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU1024LeBytes(new Uint8Array(128));\n * ```\n *\n * @see {@link createU1024BeBytes} — big-endian variant\n * @public\n */\nexport function createU1024LeBytes(value: ByteArrayInput): U1024LeBytes {\n const bytes = toByteArrayValue(value, U1024_BYTE_LENGTH, \"U1024LeBytes\");\n return bytes as U1024LeBytes;\n}\n\n/* =============================================================================\n * BIG-ENDIAN SIZED BYTE ARRAY CONVERTERS\n * ============================================================================= */\n\n/**\n * Converts a value to a 1-byte big-endian byte array (`U8BeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U8BeBytes` — exactly 1 byte.\n *\n * For a single byte, big-endian and little-endian are identical.\n *\n * @param value - The value to convert (must fit in 1 byte)\n * @returns The value as `U8BeBytes`\n * @throws {ConversionError} If the value exceeds 1 byte\n *\n * @example\n * ```typescript\n * const bytes = createU8BeBytes(new Uint8Array([0xFF]));\n * const fromHex = createU8BeBytes(\"0xFF\");\n * ```\n *\n * @see {@link createU8LeBytes} — little-endian variant (identical for 1 byte)\n * @public\n */\nexport function createU8BeBytes(value: ByteArrayInput): U8BeBytes {\n const bytes = toByteArrayValue(value, U8_BYTE_LENGTH, \"U8BeBytes\");\n return bytes as U8BeBytes;\n}\n\n/**\n * Converts a value to a 2-byte big-endian byte array (`U16BeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U16BeBytes` — exactly 2 bytes, most significant byte first.\n *\n * Used for network-order (big-endian) encoding of 16-bit values, e.g. in\n * cryptographic protocol messages.\n *\n * @param value - The value to convert (must fit in 2 bytes)\n * @returns The value as `U16BeBytes`\n * @throws {ConversionError} If the value exceeds 2 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU16BeBytes(new Uint8Array([0x12, 0x34])); // 0x1234 in BE\n * const fromHex = createU16BeBytes(\"0x1234\");\n * ```\n *\n * @see {@link createU16LeBytes} — little-endian variant\n * @public\n */\nexport function createU16BeBytes(value: ByteArrayInput): U16BeBytes {\n const bytes = toByteArrayValue(value, U16_BYTE_LENGTH, \"U16BeBytes\");\n return bytes as U16BeBytes;\n}\n\n/**\n * Converts a value to a 4-byte big-endian byte array (`U32BeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U32BeBytes` — exactly 4 bytes, most significant byte first.\n *\n * @param value - The value to convert (must fit in 4 bytes)\n * @returns The value as `U32BeBytes`\n * @throws {ConversionError} If the value exceeds 4 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU32BeBytes(new Uint8Array([0x12, 0x34, 0x56, 0x78])); // 0x12345678 in BE\n * const fromHex = createU32BeBytes(\"0x12345678\");\n * ```\n *\n * @see {@link createU32LeBytes} — little-endian variant\n * @public\n */\nexport function createU32BeBytes(value: ByteArrayInput): U32BeBytes {\n const bytes = toByteArrayValue(value, U32_BYTE_LENGTH, \"U32BeBytes\");\n return bytes as U32BeBytes;\n}\n\n/**\n * Converts a value to an 8-byte big-endian byte array (`U64BeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U64BeBytes` — exactly 8 bytes, most significant byte first.\n *\n * @param value - The value to convert (must fit in 8 bytes)\n * @returns The value as `U64BeBytes`\n * @throws {ConversionError} If the value exceeds 8 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU64BeBytes(new Uint8Array(8));\n * ```\n *\n * @see {@link createU64LeBytes} — little-endian variant\n * @public\n */\nexport function createU64BeBytes(value: ByteArrayInput): U64BeBytes {\n const bytes = toByteArrayValue(value, U64_BYTE_LENGTH, \"U64BeBytes\");\n return bytes as U64BeBytes;\n}\n\n/**\n * Converts a value to a 16-byte big-endian byte array (`U128BeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U128BeBytes` — exactly 16 bytes, most significant byte first.\n *\n * @param value - The value to convert (must fit in 16 bytes)\n * @returns The value as `U128BeBytes`\n * @throws {ConversionError} If the value exceeds 16 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU128BeBytes(new Uint8Array(16));\n * ```\n *\n * @see {@link createU128LeBytes} — little-endian variant\n * @public\n */\nexport function createU128BeBytes(value: ByteArrayInput): U128BeBytes {\n const bytes = toByteArrayValue(value, U128_BYTE_LENGTH, \"U128BeBytes\");\n return bytes as U128BeBytes;\n}\n\n/**\n * Converts a value to a 32-byte big-endian byte array (`U256BeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U256BeBytes` — exactly 32 bytes, most significant byte first.\n *\n * Used for encoding field elements and scalars in big-endian form, as required\n * by some ZK proof systems and cryptographic libraries.\n *\n * @param value - The value to convert (must fit in 32 bytes)\n * @returns The value as `U256BeBytes`\n * @throws {ConversionError} If the value exceeds 32 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU256BeBytes(new Uint8Array(32));\n * ```\n *\n * @see {@link createU256LeBytes} — little-endian variant\n * @public\n */\nexport function createU256BeBytes(value: ByteArrayInput): U256BeBytes {\n const bytes = toByteArrayValue(value, U256_BYTE_LENGTH, \"U256BeBytes\");\n return bytes as U256BeBytes;\n}\n\n/**\n * Converts a value to a 64-byte big-endian byte array (`U512BeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U512BeBytes` — exactly 64 bytes, most significant byte first.\n *\n * @param value - The value to convert (must fit in 64 bytes)\n * @returns The value as `U512BeBytes`\n * @throws {ConversionError} If the value exceeds 64 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU512BeBytes(new Uint8Array(64));\n * ```\n *\n * @see {@link createU512LeBytes} — little-endian variant\n * @public\n */\nexport function createU512BeBytes(value: ByteArrayInput): U512BeBytes {\n const bytes = toByteArrayValue(value, U512_BYTE_LENGTH, \"U512BeBytes\");\n return bytes as U512BeBytes;\n}\n\n/**\n * Converts a value to a 128-byte big-endian byte array (`U1024BeBytes`).\n *\n * @remarks\n * Input type: any `ByteArrayInput`.\n * Output type: `U1024BeBytes` — exactly 128 bytes, most significant byte first.\n *\n * @param value - The value to convert (must fit in 128 bytes)\n * @returns The value as `U1024BeBytes`\n * @throws {ConversionError} If the value exceeds 128 bytes\n *\n * @example\n * ```typescript\n * const bytes = createU1024BeBytes(new Uint8Array(128));\n * ```\n *\n * @see {@link createU1024LeBytes} — little-endian variant\n * @public\n */\nexport function createU1024BeBytes(value: ByteArrayInput): U1024BeBytes {\n const bytes = toByteArrayValue(value, U1024_BYTE_LENGTH, \"U1024BeBytes\");\n return bytes as U1024BeBytes;\n}\n\n/* =============================================================================\n * BASE INTEGER CONVERTERS\n * ============================================================================= */\n\n/**\n * Converts a value to the base `UnsignedInteger` branded type.\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `UnsignedInteger` — a non-negative bigint with no upper bound constraint.\n *\n * This is the widest unsigned integer type. Use it when you need to accept any\n * non-negative integer regardless of bit width. For range-constrained types,\n * use the specific `create*` functions (e.g., {@link createU64}).\n *\n * @param value - The value to convert (must be non-negative)\n * @returns The value as `UnsignedInteger`\n * @throws {ConversionError} If the value is negative or cannot be parsed\n *\n * @example\n * ```typescript\n * const uint1 = createUnsignedInteger(12345n);\n * const uint2 = createUnsignedInteger(255);\n * const uint3 = createUnsignedInteger(\"0x1234\");\n * ```\n *\n * @see {@link createSignedInteger} — for signed integers\n * @public\n */\nexport function createUnsignedInteger(value: IntegerInput): UnsignedInteger {\n const bigIntValue = toBigIntValue(value, \"UnsignedInteger\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Cannot convert negative value to UnsignedInteger`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"UnsignedInteger\",\n reason: \"Unsigned integers must be non-negative\",\n });\n }\n\n return bigIntValue as UnsignedInteger;\n}\n\n/**\n * Converts a value to the base `SignedInteger` branded type.\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `SignedInteger` — a bigint with no range constraint (positive or negative).\n *\n * This is the widest signed integer type. All bigint values are valid.\n * For range-constrained types, use the specific `create*` functions (e.g., {@link createI64}).\n *\n * @param value - The value to convert (positive, negative, or zero)\n * @returns The value as `SignedInteger`\n * @throws {ConversionError} If the value cannot be parsed from the given input type\n *\n * @example\n * ```typescript\n * const sint1 = createSignedInteger(-12345n);\n * const sint2 = createSignedInteger(255);\n * const sint3 = createSignedInteger(\"-1234\");\n * ```\n *\n * @see {@link createUnsignedInteger} — for unsigned (non-negative) integers\n * @public\n */\nexport function createSignedInteger(value: IntegerInput): SignedInteger {\n const bigIntValue = toBigIntValue(value, \"SignedInteger\");\n return bigIntValue as SignedInteger;\n}\n\n/* =============================================================================\n * UNSIGNED INTEGER CONVERTERS\n * ============================================================================= */\n\n/**\n * Converts a value to an 8-bit unsigned integer (`U8`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `U8` — a non-negative bigint in [0, 255].\n *\n * This is a **narrowing constructor**: any value outside [0, 255] is rejected.\n * Accepts `number`, `bigint`, decimal/hex/binary strings, and byte arrays\n * (interpreted as big-endian).\n *\n * @param value - The value to convert (must be in range [0, 255])\n * @returns The value as `U8`\n * @throws {ConversionError} If the value is negative, exceeds 255, or cannot be parsed\n *\n * @example\n * ```typescript\n * const byte1 = createU8(255);\n * const byte2 = createU8(0xFFn);\n * const byte3 = createU8(\"255\");\n * const byte4 = createU8(\"0xFF\");\n * ```\n *\n * @see {@link createU16} — for 16-bit unsigned integers\n * @public\n */\nexport function createU8(value: IntegerInput): U8 {\n const bigIntValue = toBigIntValue(value, \"U8\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value ${String(bigIntValue)} is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U8\",\n reason: \"U8 must be non-negative\",\n });\n }\n\n if (bigIntValue > U8_MAX) {\n throw new ConversionError(\n `Value ${String(bigIntValue)} exceeds U8 maximum (${String(U8_MAX)})`,\n {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U8\",\n reason: `Value must be <= ${String(U8_MAX)}`,\n },\n );\n }\n\n return bigIntValue as U8;\n}\n\n/**\n * Converts a value to a 16-bit unsigned integer (`U16`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `U16` — a non-negative bigint in [0, 65535].\n *\n * @param value - The value to convert (must be in range [0, 65535])\n * @returns The value as `U16`\n * @throws {ConversionError} If the value is negative, exceeds 65535, or cannot be parsed\n *\n * @example\n * ```typescript\n * const port = createU16(443);\n * const max = createU16(65535);\n * const fromHex = createU16(\"0xFFFF\");\n * ```\n *\n * @see {@link createU8} — for 8-bit unsigned integers\n * @see {@link createU32} — for 32-bit unsigned integers\n * @public\n */\nexport function createU16(value: IntegerInput): U16 {\n const bigIntValue = toBigIntValue(value, \"U16\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value ${String(bigIntValue)} is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U16\",\n reason: \"U16 must be non-negative\",\n });\n }\n\n if (bigIntValue > U16_MAX) {\n throw new ConversionError(\n `Value ${String(bigIntValue)} exceeds U16 maximum (${String(U16_MAX)})`,\n {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U16\",\n reason: `Value must be <= ${String(U16_MAX)}`,\n },\n );\n }\n\n return bigIntValue as U16;\n}\n\n/**\n * Converts a value to a 32-bit unsigned integer (`U32`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `U32` — a non-negative bigint in [0, 4294967295].\n *\n * @param value - The value to convert (must be in range [0, 4294967295])\n * @returns The value as `U32`\n * @throws {ConversionError} If the value is negative, exceeds 4294967295, or cannot be parsed\n *\n * @example\n * ```typescript\n * const timestamp = createU32(1704067200);\n * const ip = createU32(0x7F000001);\n * const fromHex = createU32(\"0xFFFFFFFF\");\n * ```\n *\n * @see {@link createU16} — for 16-bit unsigned integers\n * @see {@link createU64} — for 64-bit unsigned integers\n * @public\n */\nexport function createU32(value: IntegerInput): U32 {\n const bigIntValue = toBigIntValue(value, \"U32\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value ${String(bigIntValue)} is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U32\",\n reason: \"U32 must be non-negative\",\n });\n }\n\n if (bigIntValue > U32_MAX) {\n throw new ConversionError(\n `Value ${String(bigIntValue)} exceeds U32 maximum (${String(U32_MAX)})`,\n {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U32\",\n reason: `Value must be <= ${String(U32_MAX)}`,\n },\n );\n }\n\n return bigIntValue as U32;\n}\n\n/**\n * Converts a value to a 64-bit unsigned integer (`U64`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `U64` — a non-negative bigint in [0, 2^64 - 1].\n *\n * This is the primary integer type for Solana token amounts, slot numbers,\n * and other 64-bit on-chain values. Note that `number` cannot represent all\n * U64 values exactly (JavaScript `number` has 53-bit precision); use `bigint`\n * or string inputs for values larger than 2^53 - 1.\n *\n * @param value - The value to convert (must be in range [0, 2^64 - 1])\n * @returns The value as `U64`\n * @throws {ConversionError} If the value is negative, exceeds 2^64 - 1, or cannot be parsed\n *\n * @example\n * ```typescript\n * const large = createU64(18446744073709551615n);\n * const fromHex = createU64(\"0xFFFFFFFFFFFFFFFF\");\n * const amount = createU64(1_000_000); // lamports\n * ```\n *\n * @see {@link createU32} — for 32-bit unsigned integers\n * @see {@link createU128} — for 128-bit unsigned integers\n * @public\n */\nexport function createU64(value: IntegerInput): U64 {\n const bigIntValue = toBigIntValue(value, \"U64\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value ${String(bigIntValue)} is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U64\",\n reason: \"U64 must be non-negative\",\n });\n }\n\n if (bigIntValue > U64_MAX) {\n throw new ConversionError(`Value exceeds U64 maximum`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U64\",\n reason: \"Value must be <= 2^64 - 1\",\n });\n }\n\n return bigIntValue as U64;\n}\n\n/**\n * Converts a value to a 128-bit unsigned integer (`U128`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `U128` — a non-negative bigint in [0, 2^128 - 1].\n *\n * Used for encrypted balance representations and nonces that require more\n * than 64 bits of precision.\n *\n * @param value - The value to convert (must be in range [0, 2^128 - 1])\n * @returns The value as `U128`\n * @throws {ConversionError} If the value is negative, exceeds 2^128 - 1, or cannot be parsed\n *\n * @example\n * ```typescript\n * const uuid = createU128(0x550e8400e29b41d4a716446655440000n);\n * ```\n *\n * @see {@link createU64} — for 64-bit unsigned integers\n * @see {@link createU256} — for 256-bit unsigned integers\n * @public\n */\nexport function createU128(value: IntegerInput): U128 {\n const bigIntValue = toBigIntValue(value, \"U128\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U128\",\n reason: \"U128 must be non-negative\",\n });\n }\n\n if (bigIntValue > U128_MAX) {\n throw new ConversionError(`Value exceeds U128 maximum`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U128\",\n reason: \"Value must be <= 2^128 - 1\",\n });\n }\n\n return bigIntValue as U128;\n}\n\n/**\n * Converts a value to a 256-bit unsigned integer (`U256`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `U256` — a non-negative bigint in [0, 2^256 - 1].\n *\n * This is the primary integer width for cryptographic scalars, field elements,\n * and hash outputs. It is the widest integer type that maps directly to a single\n * 32-byte on-chain field.\n *\n * @param value - The value to convert (must be in range [0, 2^256 - 1])\n * @returns The value as `U256`\n * @throws {ConversionError} If the value is negative, exceeds 2^256 - 1, or cannot be parsed\n *\n * @example\n * ```typescript\n * const scalar = createU256(0x1234567890abcdef1234567890abcdefn);\n * const fromHex = createU256(\"0x\" + \"ab\".repeat(32));\n * ```\n *\n * @see {@link createU128} — for 128-bit unsigned integers\n * @see {@link createU512} — for 512-bit unsigned integers\n * @see {@link createBn254FieldElement} — for values constrained to BN254 field\n * @public\n */\nexport function createU256(value: IntegerInput): U256 {\n const bigIntValue = toBigIntValue(value, \"U256\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U256\",\n reason: \"U256 must be non-negative\",\n });\n }\n\n if (bigIntValue > U256_MAX) {\n throw new ConversionError(`Value exceeds U256 maximum`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U256\",\n reason: \"Value must be <= 2^256 - 1\",\n });\n }\n\n return bigIntValue as U256;\n}\n\n/**\n * Converts a value to a 512-bit unsigned integer (`U512`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `U512` — a non-negative bigint in [0, 2^512 - 1].\n *\n * Used for hash outputs (e.g. SHA-512) and concatenated field element pairs\n * that require 512 bits of precision.\n *\n * @param value - The value to convert (must be in range [0, 2^512 - 1])\n * @returns The value as `U512`\n * @throws {ConversionError} If the value is negative, exceeds 2^512 - 1, or cannot be parsed\n *\n * @example\n * ```typescript\n * const hash = createU512(sha512AsBigInt);\n * ```\n *\n * @see {@link createU256} — for 256-bit unsigned integers\n * @see {@link createU1024} — for 1024-bit unsigned integers\n * @public\n */\nexport function createU512(value: IntegerInput): U512 {\n const bigIntValue = toBigIntValue(value, \"U512\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U512\",\n reason: \"U512 must be non-negative\",\n });\n }\n\n if (bigIntValue > U512_MAX) {\n throw new ConversionError(`Value exceeds U512 maximum`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U512\",\n reason: \"Value must be <= 2^512 - 1\",\n });\n }\n\n return bigIntValue as U512;\n}\n\n/**\n * Converts a value to a 1024-bit unsigned integer (`U1024`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `U1024` — a non-negative bigint in [0, 2^1024 - 1].\n *\n * Used for large modular arithmetic results and RSA-1024 moduli.\n *\n * @param value - The value to convert (must be in range [0, 2^1024 - 1])\n * @returns The value as `U1024`\n * @throws {ConversionError} If the value is negative, exceeds 2^1024 - 1, or cannot be parsed\n *\n * @example\n * ```typescript\n * const rsaModulus = createU1024(modulusBigInt);\n * ```\n *\n * @see {@link createU512} — for 512-bit unsigned integers\n * @public\n */\nexport function createU1024(value: IntegerInput): U1024 {\n const bigIntValue = toBigIntValue(value, \"U1024\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U1024\",\n reason: \"U1024 must be non-negative\",\n });\n }\n\n if (bigIntValue > U1024_MAX) {\n throw new ConversionError(`Value exceeds U1024 maximum`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"U1024\",\n reason: \"Value must be <= 2^1024 - 1\",\n });\n }\n\n return bigIntValue as U1024;\n}\n\n/* =============================================================================\n * SIGNED INTEGER CONVERTERS\n * ============================================================================= */\n\n/**\n * Converts a value to an 8-bit signed integer (`I8`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `I8` — a bigint in [-128, 127].\n *\n * Values outside [-128, 127] throw `ConversionError`. Both positive and negative\n * values are accepted.\n *\n * @param value - The value to convert (must be in range [-128, 127])\n * @returns The value as `I8`\n * @throws {ConversionError} If the value is outside [-128, 127] or cannot be parsed\n *\n * @example\n * ```typescript\n * const pos = createI8(127);\n * const neg = createI8(-128);\n * const fromString = createI8(\"-100\");\n * ```\n *\n * @see {@link createI16} — for 16-bit signed integers\n * @public\n */\nexport function createI8(value: IntegerInput): I8 {\n const bigIntValue = toBigIntValue(value, \"I8\");\n\n if (bigIntValue < I8_MIN || bigIntValue > I8_MAX) {\n throw new ConversionError(`Value ${String(bigIntValue)} is out of range for I8`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"I8\",\n reason: `Value must be in range [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n });\n }\n\n return bigIntValue as I8;\n}\n\n/**\n * Converts a value to a 16-bit signed integer (`I16`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `I16` — a bigint in [-32768, 32767].\n *\n * @param value - The value to convert (must be in range [-32768, 32767])\n * @returns The value as `I16`\n * @throws {ConversionError} If the value is outside [-32768, 32767] or cannot be parsed\n *\n * @example\n * ```typescript\n * const audio = createI16(-16384);\n * ```\n *\n * @see {@link createI8} — for 8-bit signed integers\n * @see {@link createI32} — for 32-bit signed integers\n * @public\n */\nexport function createI16(value: IntegerInput): I16 {\n const bigIntValue = toBigIntValue(value, \"I16\");\n\n if (bigIntValue < I16_MIN || bigIntValue > I16_MAX) {\n throw new ConversionError(`Value ${String(bigIntValue)} is out of range for I16`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"I16\",\n reason: `Value must be in range [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n });\n }\n\n return bigIntValue as I16;\n}\n\n/**\n * Converts a value to a 32-bit signed integer (`I32`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `I32` — a bigint in [-2147483648, 2147483647].\n *\n * @param value - The value to convert (must be in range [-2^31, 2^31 - 1])\n * @returns The value as `I32`\n * @throws {ConversionError} If the value is outside [-2^31, 2^31 - 1] or cannot be parsed\n *\n * @example\n * ```typescript\n * const offset = createI32(-1000);\n * const index = createI32(42);\n * ```\n *\n * @see {@link createI16} — for 16-bit signed integers\n * @see {@link createI64} — for 64-bit signed integers\n * @public\n */\nexport function createI32(value: IntegerInput): I32 {\n const bigIntValue = toBigIntValue(value, \"I32\");\n\n if (bigIntValue < I32_MIN || bigIntValue > I32_MAX) {\n throw new ConversionError(`Value ${String(bigIntValue)} is out of range for I32`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"I32\",\n reason: `Value must be in range [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n });\n }\n\n return bigIntValue as I32;\n}\n\n/**\n * Converts a value to a 64-bit signed integer (`I64`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `I64` — a bigint in [-2^63, 2^63 - 1].\n *\n * @param value - The value to convert (must be in range [-2^63, 2^63 - 1])\n * @returns The value as `I64`\n * @throws {ConversionError} If the value is outside [-2^63, 2^63 - 1] or cannot be parsed\n *\n * @example\n * ```typescript\n * const diff = createI64(-1000000000000n);\n * ```\n *\n * @see {@link createI32} — for 32-bit signed integers\n * @see {@link createI128} — for 128-bit signed integers\n * @public\n */\nexport function createI64(value: IntegerInput): I64 {\n const bigIntValue = toBigIntValue(value, \"I64\");\n\n if (bigIntValue < I64_MIN || bigIntValue > I64_MAX) {\n throw new ConversionError(`Value is out of range for I64`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"I64\",\n reason: \"Value must be in range [-2^63, 2^63 - 1]\",\n });\n }\n\n return bigIntValue as I64;\n}\n\n/**\n * Converts a value to a 128-bit signed integer (`I128`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `I128` — a bigint in [-2^127, 2^127 - 1].\n *\n * @param value - The value to convert (must be in range [-2^127, 2^127 - 1])\n * @returns The value as `I128`\n * @throws {ConversionError} If the value is outside [-2^127, 2^127 - 1] or cannot be parsed\n *\n * @example\n * ```typescript\n * const value = createI128(-170141183460469231731687303715884105728n);\n * ```\n *\n * @see {@link createI64} — for 64-bit signed integers\n * @see {@link createI256} — for 256-bit signed integers\n * @public\n */\nexport function createI128(value: IntegerInput): I128 {\n const bigIntValue = toBigIntValue(value, \"I128\");\n\n if (bigIntValue < I128_MIN || bigIntValue > I128_MAX) {\n throw new ConversionError(`Value is out of range for I128`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"I128\",\n reason: \"Value must be in range [-2^127, 2^127 - 1]\",\n });\n }\n\n return bigIntValue as I128;\n}\n\n/**\n * Converts a value to a 256-bit signed integer (`I256`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `I256` — a bigint in [-2^255, 2^255 - 1].\n *\n * @param value - The value to convert (must be in range [-2^255, 2^255 - 1])\n * @returns The value as `I256`\n * @throws {ConversionError} If the value is outside [-2^255, 2^255 - 1] or cannot be parsed\n *\n * @example\n * ```typescript\n * const signedScalar = createI256(-12345678901234567890n);\n * ```\n *\n * @see {@link createI128} — for 128-bit signed integers\n * @see {@link createI512} — for 512-bit signed integers\n * @public\n */\nexport function createI256(value: IntegerInput): I256 {\n const bigIntValue = toBigIntValue(value, \"I256\");\n\n if (bigIntValue < I256_MIN || bigIntValue > I256_MAX) {\n throw new ConversionError(`Value is out of range for I256`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"I256\",\n reason: \"Value must be in range [-2^255, 2^255 - 1]\",\n });\n }\n\n return bigIntValue as I256;\n}\n\n/**\n * Converts a value to a 512-bit signed integer (`I512`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `I512` — a bigint in [-2^511, 2^511 - 1].\n *\n * @param value - The value to convert (must be in range [-2^511, 2^511 - 1])\n * @returns The value as `I512`\n * @throws {ConversionError} If the value is outside [-2^511, 2^511 - 1] or cannot be parsed\n *\n * @example\n * ```typescript\n * const value = createI512(-1n);\n * ```\n *\n * @see {@link createI256} — for 256-bit signed integers\n * @see {@link createI1024} — for 1024-bit signed integers\n * @public\n */\nexport function createI512(value: IntegerInput): I512 {\n const bigIntValue = toBigIntValue(value, \"I512\");\n\n if (bigIntValue < I512_MIN || bigIntValue > I512_MAX) {\n throw new ConversionError(`Value is out of range for I512`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"I512\",\n reason: \"Value must be in range [-2^511, 2^511 - 1]\",\n });\n }\n\n return bigIntValue as I512;\n}\n\n/**\n * Converts a value to a 1024-bit signed integer (`I1024`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `I1024` — a bigint in [-2^1023, 2^1023 - 1].\n *\n * @param value - The value to convert (must be in range [-2^1023, 2^1023 - 1])\n * @returns The value as `I1024`\n * @throws {ConversionError} If the value is outside [-2^1023, 2^1023 - 1] or cannot be parsed\n *\n * @example\n * ```typescript\n * const value = createI1024(0n);\n * ```\n *\n * @see {@link createI512} — for 512-bit signed integers\n * @public\n */\nexport function createI1024(value: IntegerInput): I1024 {\n const bigIntValue = toBigIntValue(value, \"I1024\");\n\n if (bigIntValue < I1024_MIN || bigIntValue > I1024_MAX) {\n throw new ConversionError(`Value is out of range for I1024`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"I1024\",\n reason: \"Value must be in range [-2^1023, 2^1023 - 1]\",\n });\n }\n\n return bigIntValue as I1024;\n}\n\n/* =============================================================================\n * CRYPTOGRAPHIC TYPE CONVERTERS\n * ============================================================================= */\n\n/**\n * Converts a value to a BN254 field element (`Bn254FieldElement`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `Bn254FieldElement` — a non-negative bigint strictly less than the BN254\n * field prime: `21888242871839275222246405745257275088548364400416034343698204186575808495617`.\n *\n * The BN254 curve (also called alt_bn128) is used by Ethereum's pairing precompiles\n * and by Groth16 ZK proof systems. Its scalar field prime is approximately 2^254,\n * so not every U256 value is a valid BN254 field element.\n *\n * This is a **narrowing constructor** — values at or above the BN254 prime are rejected.\n *\n * @param value - The value to convert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @returns The value as `Bn254FieldElement`\n * @throws {ConversionError} If the value is negative, >= BN254_FIELD_PRIME, or cannot be parsed\n *\n * @example\n * ```typescript\n * const fieldElement = createBn254FieldElement(12345n);\n * const fromHex = createBn254FieldElement(\"0x1234\");\n * ```\n *\n * @see {@link createCurve25519FieldElement} — for Curve25519 field elements\n * @see {@link createPoseidonPlaintext} — for Poseidon plaintext values (same constraint)\n * @public\n */\nexport function createBn254FieldElement(value: IntegerInput): Bn254FieldElement {\n const bigIntValue = toBigIntValue(value, \"Bn254FieldElement\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"Bn254FieldElement\",\n reason: \"Field elements must be non-negative\",\n });\n }\n\n if (bigIntValue >= BN254_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds BN254 field prime`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"Bn254FieldElement\",\n reason: `Value must be < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n\n return bigIntValue as Bn254FieldElement;\n}\n\n/**\n * Converts a value to a Curve25519 field element (`Curve25519FieldElement`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `Curve25519FieldElement` — a non-negative bigint strictly less than\n * the Curve25519 field prime: `2^255 - 19`\n * (`57896044618658097711785492504343953926634992332820282019728792003956564819949`).\n *\n * Curve25519 is used for the X25519 key exchange and Rescue cipher encryption\n * in the Umbra protocol. Field elements must be in canonical form (strictly\n * less than the prime).\n *\n * This is a **narrowing constructor** — values at or above 2^255 - 19 are rejected.\n *\n * @param value - The value to convert (must be in range [0, 2^255 - 20])\n * @returns The value as `Curve25519FieldElement`\n * @throws {ConversionError} If the value is negative, >= 2^255 - 19, or cannot be parsed\n *\n * @example\n * ```typescript\n * const fieldElement = createCurve25519FieldElement(12345n);\n * ```\n *\n * @see {@link createBn254FieldElement} — for BN254 field elements\n * @see {@link createRcKey} — for Rescue cipher keys (same constraint)\n * @public\n */\nexport function createCurve25519FieldElement(value: IntegerInput): Curve25519FieldElement {\n const bigIntValue = toBigIntValue(value, \"Curve25519FieldElement\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"Curve25519FieldElement\",\n reason: \"Field elements must be non-negative\",\n });\n }\n\n if (bigIntValue >= CURVE25519_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds Curve25519 field prime`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"Curve25519FieldElement\",\n reason: `Value must be < 2^255 - 19`,\n });\n }\n\n return bigIntValue as Curve25519FieldElement;\n}\n\n/**\n * Converts a value to a Poseidon plaintext (`PoseidonPlaintext`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `PoseidonPlaintext` — a non-negative bigint strictly less than\n * `BN254_FIELD_PRIME`. Numerically equivalent to `Bn254FieldElement`; the brand\n * communicates semantic intent.\n *\n * Poseidon is a cryptographic hash/cipher function optimised for ZK proof systems.\n * It operates over the BN254 scalar field, so plaintexts must be valid field elements.\n *\n * @param value - The value to convert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @returns The value as `PoseidonPlaintext`\n * @throws {ConversionError} If the value is negative, >= BN254_FIELD_PRIME, or cannot be parsed\n *\n * @example\n * ```typescript\n * const plaintext = createPoseidonPlaintext(messageAsBigInt);\n * const fromHex = createPoseidonPlaintext(\"0x1234\");\n * ```\n *\n * @see {@link createPoseidonHash} — for hash output values\n * @see {@link createPoseidonKey} — for cipher keys\n * @see {@link createBn254FieldElement} — the base field element type\n * @public\n */\nexport function createPoseidonPlaintext(value: IntegerInput): PoseidonPlaintext {\n const bigIntValue = toBigIntValue(value, \"PoseidonPlaintext\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"PoseidonPlaintext\",\n reason: \"Poseidon plaintexts must be non-negative\",\n });\n }\n\n if (bigIntValue >= BN254_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds BN254 field prime`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"PoseidonPlaintext\",\n reason: `Poseidon plaintexts must be < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n\n return bigIntValue as PoseidonPlaintext;\n}\n\n/**\n * Converts a value to a Poseidon hash output (`PoseidonHash`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `PoseidonHash` — a non-negative bigint strictly less than `BN254_FIELD_PRIME`.\n *\n * Poseidon hash digests are elements of the BN254 scalar field. Use this type\n * to brand the output of a Poseidon hashing operation.\n *\n * @param value - The value to convert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @returns The value as `PoseidonHash`\n * @throws {ConversionError} If the value is negative, >= BN254_FIELD_PRIME, or cannot be parsed\n *\n * @example\n * ```typescript\n * const hash = createPoseidonHash(hashOutputBigInt);\n * ```\n *\n * @see {@link createPoseidonPlaintext} — for plaintext inputs\n * @see {@link createPoseidonCiphertext} — for cipher outputs\n * @public\n */\nexport function createPoseidonHash(value: IntegerInput): PoseidonHash {\n const bigIntValue = toBigIntValue(value, \"PoseidonHash\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"PoseidonHash\",\n reason: \"Poseidon hashes must be non-negative\",\n });\n }\n\n if (bigIntValue >= BN254_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds BN254 field prime`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"PoseidonHash\",\n reason: `Poseidon hashes must be < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n\n return bigIntValue as PoseidonHash;\n}\n\n/**\n * Converts a value to a Poseidon cipher key (`PoseidonKey`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `PoseidonKey` — a non-negative bigint strictly less than `BN254_FIELD_PRIME`.\n *\n * Poseidon cipher keys are BN254 field elements used to encrypt UTXO data\n * in the Umbra confidential token system. Keys must be derived securely\n * from shared secrets via a KDF.\n *\n * @param value - The value to convert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @returns The value as `PoseidonKey`\n * @throws {ConversionError} If the value is negative, >= BN254_FIELD_PRIME, or cannot be parsed\n *\n * @example\n * ```typescript\n * const key = createPoseidonKey(secretKeyBigInt);\n * ```\n *\n * @see {@link createPoseidonPlaintext} — for plaintext inputs\n * @see {@link createPoseidonCiphertext} — for cipher outputs\n * @public\n */\nexport function createPoseidonKey(value: IntegerInput): PoseidonKey {\n const bigIntValue = toBigIntValue(value, \"PoseidonKey\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"PoseidonKey\",\n reason: \"Poseidon keys must be non-negative\",\n });\n }\n\n if (bigIntValue >= BN254_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds BN254 field prime`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"PoseidonKey\",\n reason: `Poseidon keys must be < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n\n return bigIntValue as PoseidonKey;\n}\n\n/**\n * Converts a value to a Poseidon cipher output element (`PoseidonCiphertext`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `PoseidonCiphertext` — a non-negative bigint strictly less than `BN254_FIELD_PRIME`.\n *\n * Poseidon ciphertext elements are outputs of the Poseidon symmetric cipher\n * operating over the BN254 scalar field. Each element of the ciphertext array\n * is a separate `PoseidonCiphertext` branded value.\n *\n * @param value - The value to convert (must be in range [0, BN254_FIELD_PRIME - 1])\n * @returns The value as `PoseidonCiphertext`\n * @throws {ConversionError} If the value is negative, >= BN254_FIELD_PRIME, or cannot be parsed\n *\n * @example\n * ```typescript\n * const ciphertext = createPoseidonCiphertext(encryptedBigInt);\n * ```\n *\n * @see {@link createPoseidonPlaintext} — for plaintext inputs\n * @see {@link createPoseidonKey} — for cipher keys\n * @public\n */\nexport function createPoseidonCiphertext(value: IntegerInput): PoseidonCiphertext {\n const bigIntValue = toBigIntValue(value, \"PoseidonCiphertext\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"PoseidonCiphertext\",\n reason: \"Poseidon ciphertexts must be non-negative\",\n });\n }\n\n if (bigIntValue >= BN254_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds BN254 field prime`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"PoseidonCiphertext\",\n reason: `Poseidon ciphertexts must be < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n\n return bigIntValue as PoseidonCiphertext;\n}\n\n/**\n * Converts a value to a Rescue cipher ciphertext element (`RcCiphertext`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `RcCiphertext` — a non-negative bigint strictly less than\n * `CURVE25519_FIELD_PRIME` (2^255 - 19).\n *\n * The Rescue cipher operates over the Curve25519 scalar field. Ciphertext elements\n * are field elements produced by XOR-ing the keystream with plaintext in the field.\n * Used to encrypt token balances stored in confidential accounts on Solana.\n *\n * @param value - The value to convert (must be in range [0, 2^255 - 20])\n * @returns The value as `RcCiphertext`\n * @throws {ConversionError} If the value is negative, >= 2^255 - 19, or cannot be parsed\n *\n * @example\n * ```typescript\n * const ciphertext = createRcCiphertext(encryptedBigInt);\n * ```\n *\n * @see {@link createRcPlaintext} — for plaintext inputs\n * @see {@link createRcKey} — for Rescue cipher keys\n * @public\n */\nexport function createRcCiphertext(value: IntegerInput): RcCiphertext {\n const bigIntValue = toBigIntValue(value, \"RcCiphertext\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"RcCiphertext\",\n reason: \"Rescue ciphertexts must be non-negative\",\n });\n }\n\n if (bigIntValue >= CURVE25519_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds Curve25519 field prime`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"RcCiphertext\",\n reason: \"Rescue ciphertexts must be < 2^255 - 19\",\n });\n }\n\n return bigIntValue as RcCiphertext;\n}\n\n/**\n * Converts a value to a Rescue cipher plaintext element (`RcPlaintext`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `RcPlaintext` — a non-negative bigint strictly less than\n * `CURVE25519_FIELD_PRIME` (2^255 - 19).\n *\n * Rescue plaintext elements are field elements representing unencrypted token\n * balances or other secret data prior to Rescue cipher encryption.\n *\n * @param value - The value to convert (must be in range [0, 2^255 - 20])\n * @returns The value as `RcPlaintext`\n * @throws {ConversionError} If the value is negative, >= 2^255 - 19, or cannot be parsed\n *\n * @example\n * ```typescript\n * const plaintext = createRcPlaintext(messageBigInt);\n * ```\n *\n * @see {@link createRcCiphertext} — for encrypted outputs\n * @see {@link createRcKey} — for Rescue cipher keys\n * @public\n */\nexport function createRcPlaintext(value: IntegerInput): RcPlaintext {\n const bigIntValue = toBigIntValue(value, \"RcPlaintext\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"RcPlaintext\",\n reason: \"Rescue plaintexts must be non-negative\",\n });\n }\n\n if (bigIntValue >= CURVE25519_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds Curve25519 field prime`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"RcPlaintext\",\n reason: \"Rescue plaintexts must be < 2^255 - 19\",\n });\n }\n\n return bigIntValue as RcPlaintext;\n}\n\n/**\n * Converts a value to a Rescue cipher encryption key (`RcKey`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `RcKey` — a non-negative bigint strictly less than\n * `CURVE25519_FIELD_PRIME` (2^255 - 19).\n *\n * Rescue cipher keys are Curve25519 field elements. They are derived from\n * X25519 Diffie-Hellman shared secrets via a Key Derivation Function (KDF)\n * and used to encrypt token balances in confidential accounts.\n *\n * @param value - The value to convert (must be in range [0, 2^255 - 20])\n * @returns The value as `RcKey`\n * @throws {ConversionError} If the value is negative, >= 2^255 - 19, or cannot be parsed\n *\n * @example\n * ```typescript\n * const key = createRcKey(secretKeyBigInt);\n * ```\n *\n * @see {@link createRcCiphertext} — for cipher outputs\n * @see {@link createRcCounter} — for cipher counters\n * @public\n */\nexport function createRcKey(value: IntegerInput): RcKey {\n const bigIntValue = toBigIntValue(value, \"RcKey\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"RcKey\",\n reason: \"Rescue keys must be non-negative\",\n });\n }\n\n if (bigIntValue >= CURVE25519_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds Curve25519 field prime`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"RcKey\",\n reason: \"Rescue keys must be < 2^255 - 19\",\n });\n }\n\n return bigIntValue as RcKey;\n}\n\n/**\n * Converts a value to a Rescue cipher counter (`RcCounter`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `RcCounter` — a non-negative bigint strictly less than\n * `CURVE25519_FIELD_PRIME` (2^255 - 19).\n *\n * Rescue cipher counters are Curve25519 field elements used in counter-mode\n * encryption to produce a unique keystream for each plaintext block.\n * Counters are typically small non-negative integers (e.g., 0, 1, 2, ...) but\n * the type constraint allows any valid field element.\n *\n * @param value - The value to convert (must be in range [0, 2^255 - 20])\n * @returns The value as `RcCounter`\n * @throws {ConversionError} If the value is negative, >= 2^255 - 19, or cannot be parsed\n *\n * @example\n * ```typescript\n * const counter = createRcCounter(1n);\n * const counter2 = createRcCounter(0);\n * ```\n *\n * @see {@link createRcKey} — for cipher keys\n * @see {@link createRcEncryptionNonce} — for encryption nonces (128-bit, not field elements)\n * @public\n */\nexport function createRcCounter(value: IntegerInput): RcCounter {\n const bigIntValue = toBigIntValue(value, \"RcCounter\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"RcCounter\",\n reason: \"Rescue counters must be non-negative\",\n });\n }\n\n if (bigIntValue >= CURVE25519_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds Curve25519 field prime`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"RcCounter\",\n reason: \"Rescue counters must be < 2^255 - 19\",\n });\n }\n\n return bigIntValue as RcCounter;\n}\n\n/**\n * Converts a value to a Rescue cipher encryption nonce (`RcEncryptionNonce`).\n *\n * @remarks\n * Input type: any `IntegerInput`.\n * Output type: `RcEncryptionNonce` — a non-negative bigint in [0, 2^128 - 1].\n *\n * Unlike the other Rescue types (which are Curve25519 field elements), encryption\n * nonces are 128-bit unsigned integers. They are promoted to Curve25519 field\n * elements during cipher setup.\n *\n * A nonce must be unique for each encryption operation using the same key.\n * Reusing a nonce with the same key breaks semantic security. A 128-bit nonce\n * space is sufficient for random generation with negligible collision probability.\n *\n * @param value - The value to convert (must be in range [0, 2^128 - 1])\n * @returns The value as `RcEncryptionNonce`\n * @throws {ConversionError} If the value is negative, exceeds 2^128 - 1, or cannot be parsed\n *\n * @example\n * ```typescript\n * const nonce = createRcEncryptionNonce(12345n);\n * const nonce2 = createRcEncryptionNonce(crypto.getRandomValues(new Uint8Array(16)));\n * ```\n *\n * @see {@link createRcKey} — for cipher keys\n * @see {@link createRcCounter} — for cipher counters\n * @public\n */\nexport function createRcEncryptionNonce(value: IntegerInput): RcEncryptionNonce {\n const bigIntValue = toBigIntValue(value, \"RcEncryptionNonce\");\n\n if (bigIntValue < 0n) {\n throw new ConversionError(`Value is negative`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"RcEncryptionNonce\",\n reason: \"Rescue encryption nonces must be non-negative\",\n });\n }\n\n if (bigIntValue > U128_MAX) {\n throw new ConversionError(`Value exceeds U128 maximum`, {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"RcEncryptionNonce\",\n reason: \"Rescue encryption nonces must be <= 2^128 - 1\",\n });\n }\n\n return bigIntValue as RcEncryptionNonce;\n}\n\n/* =============================================================================\n * X25519 BYTE ARRAY CONVERTERS\n * ============================================================================= */\n\n/**\n * Converts a byte source to the base `Bytes` branded type.\n *\n * @remarks\n * Input type: `Uint8Array`, `ArrayBuffer`, `DataView`, or `number[]`.\n * Output type: `Bytes` — the base branded type for any-length byte arrays.\n *\n * This is the widest byte array type — no length constraint is applied.\n * Each element of a `number[]` input must be an integer in [0, 255].\n *\n * @param value - The byte source to convert\n * @returns The value as `Bytes`\n * @throws {ConversionError} If any `number[]` element is not a valid byte value,\n * or if the input type is unsupported\n *\n * @example\n * ```typescript\n * const bytes = createBytes(new Uint8Array([1, 2, 3]));\n * const bytes2 = createBytes([1, 2, 3]); // number array\n * const bytes3 = createBytes(new ArrayBuffer(10));\n * ```\n *\n * @see {@link createX25519Bytes} — for 32-byte X25519 byte arrays\n * @see {@link createLeBytes} — for unsized little-endian branded arrays\n * @public\n */\nexport function createBytes(value: Uint8Array | ArrayBuffer | DataView | number[]): Bytes {\n if (value instanceof Uint8Array) {\n return value as Bytes;\n }\n\n if (value instanceof ArrayBuffer) {\n return new Uint8Array(value) as Bytes;\n }\n\n if (value instanceof DataView) {\n return new Uint8Array(value.buffer, value.byteOffset, value.byteLength) as Bytes;\n }\n\n if (Array.isArray(value)) {\n // Validate all elements are valid bytes\n for (let index = 0; index < value.length; index++) {\n const byte = value[index];\n if (typeof byte !== \"number\" || !Number.isInteger(byte) || byte < 0 || byte > 255) {\n throw new ConversionError(`Invalid byte value at index ${String(index)}: ${String(byte)}`, {\n sourceValue: value,\n sourceType: \"number[]\",\n targetType: \"Bytes\",\n reason: \"All values must be integers in range [0, 255]\",\n });\n }\n }\n return new Uint8Array(value) as Bytes;\n }\n\n throw new ConversionError(`Cannot convert to Bytes`, {\n sourceValue: value,\n sourceType: typeof value,\n targetType: \"Bytes\",\n reason: \"Expected Uint8Array, ArrayBuffer, DataView, or number[]\",\n });\n}\n\n/**\n * Converts a byte source to an `X25519Bytes` type (exactly 32 bytes).\n *\n * @remarks\n * Input type: `Uint8Array`, `ArrayBuffer`, `DataView`, or `number[]`.\n * Output type: `X25519Bytes` — the base branded type for all 32-byte X25519 values,\n * including keys and shared secrets.\n *\n * X25519 byte arrays are the raw 32-byte representation of Curve25519 scalars\n * or curve points in little-endian form. The specific brand (`X25519PrivateKey`,\n * `X25519PublicKey`, or `SharedSecret`) signals the intended role.\n *\n * Padding behaviour:\n * - If the input is shorter than 32 bytes, zeros are appended on the right (LE padding).\n * - If the input is longer than 32 bytes, `ConversionError` is thrown.\n *\n * @param value - The byte source to convert (at most 32 bytes)\n * @returns The value as `X25519Bytes` (exactly 32 bytes)\n * @throws {ConversionError} If the input exceeds 32 bytes, contains invalid byte values,\n * or is an unsupported type\n *\n * @example\n * ```typescript\n * // Exact size\n * const x25519 = createX25519Bytes(new Uint8Array(32));\n *\n * // Undersized (will be zero-padded on the right)\n * const x25519Padded = createX25519Bytes(new Uint8Array([1, 2, 3]));\n *\n * // Oversized (will throw)\n * createX25519Bytes(new Uint8Array(33)); // throws ConversionError\n * ```\n *\n * @see {@link createX25519PrivateKey} — for 32-byte private keys\n * @see {@link createX25519PublicKey} — for 32-byte public keys\n * @see {@link createSharedSecret} — for 32-byte shared secrets\n * @public\n */\nexport function createX25519Bytes(\n value: Uint8Array | ArrayBuffer | DataView | number[],\n): X25519Bytes {\n let bytes: Uint8Array;\n\n if (value instanceof Uint8Array) {\n bytes = value;\n } else if (value instanceof ArrayBuffer) {\n bytes = new Uint8Array(value);\n } else if (value instanceof DataView) {\n bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n } else if (Array.isArray(value)) {\n // Validate all elements are valid bytes\n for (let index = 0; index < value.length; index++) {\n const byte = value[index];\n if (typeof byte !== \"number\" || !Number.isInteger(byte) || byte < 0 || byte > 255) {\n throw new ConversionError(`Invalid byte value at index ${String(index)}: ${String(byte)}`, {\n sourceValue: value,\n sourceType: \"number[]\",\n targetType: \"X25519Bytes\",\n reason: \"All values must be integers in range [0, 255]\",\n });\n }\n }\n bytes = new Uint8Array(value);\n } else {\n throw new ConversionError(`Cannot convert to X25519Bytes`, {\n sourceValue: value,\n sourceType: typeof value,\n targetType: \"X25519Bytes\",\n reason: \"Expected Uint8Array, ArrayBuffer, DataView, or number[]\",\n });\n }\n\n // Check size\n if (bytes.length > X25519_BYTE_LENGTH) {\n throw new ConversionError(\n `Value exceeds X25519 byte length (${String(bytes.length)} > ${String(X25519_BYTE_LENGTH)})`,\n {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"X25519Bytes\",\n reason: `X25519 values must be at most ${String(X25519_BYTE_LENGTH)} bytes`,\n },\n );\n }\n\n // Pad if undersized\n if (bytes.length < X25519_BYTE_LENGTH) {\n const padded = new Uint8Array(X25519_BYTE_LENGTH);\n padded.set(bytes, 0);\n return padded as X25519Bytes;\n }\n\n return bytes as X25519Bytes;\n}\n\n/**\n * Converts a byte source to an `X25519PrivateKey` (exactly 32 bytes).\n *\n * @remarks\n * Input type: `Uint8Array`, `ArrayBuffer`, `DataView`, or `number[]`.\n * Output type: `X25519PrivateKey` — a 32-byte little-endian scalar representing\n * the private component of an X25519 key pair.\n *\n * X25519 private keys are 32-byte scalars. The X25519 key agreement function\n * clamps certain bits (bits 0, 1, 2 of the first byte and bit 7 of the last byte)\n * before use, but the raw scalar is stored unclamped.\n *\n * Padding behaviour: inputs shorter than 32 bytes are zero-padded on the right.\n * Inputs longer than 32 bytes throw `ConversionError`.\n *\n * @param value - The byte source to convert (at most 32 bytes)\n * @returns The value as `X25519PrivateKey` (exactly 32 bytes)\n * @throws {ConversionError} If the input exceeds 32 bytes, contains invalid byte values,\n * or is an unsupported type\n *\n * @example\n * ```typescript\n * // Generate a new private key\n * const rawKey = crypto.getRandomValues(new Uint8Array(32));\n * const privateKey = createX25519PrivateKey(rawKey);\n * ```\n *\n * @see {@link createX25519PublicKey} — for public keys\n * @see {@link createX25519Bytes} — for the base 32-byte type\n * @public\n */\nexport function createX25519PrivateKey(\n value: Uint8Array | ArrayBuffer | DataView | number[],\n): X25519PrivateKey {\n let bytes: Uint8Array;\n\n if (value instanceof Uint8Array) {\n bytes = value;\n } else if (value instanceof ArrayBuffer) {\n bytes = new Uint8Array(value);\n } else if (value instanceof DataView) {\n bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n } else if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index++) {\n const byte = value[index];\n if (typeof byte !== \"number\" || !Number.isInteger(byte) || byte < 0 || byte > 255) {\n throw new ConversionError(`Invalid byte value at index ${String(index)}: ${String(byte)}`, {\n sourceValue: value,\n sourceType: \"number[]\",\n targetType: \"X25519PrivateKey\",\n reason: \"All values must be integers in range [0, 255]\",\n });\n }\n }\n bytes = new Uint8Array(value);\n } else {\n throw new ConversionError(`Cannot convert to X25519PrivateKey`, {\n sourceValue: value,\n sourceType: typeof value,\n targetType: \"X25519PrivateKey\",\n reason: \"Expected Uint8Array, ArrayBuffer, DataView, or number[]\",\n });\n }\n\n if (bytes.length > X25519_BYTE_LENGTH) {\n throw new ConversionError(\n `Value exceeds X25519 byte length (${String(bytes.length)} > ${String(X25519_BYTE_LENGTH)})`,\n {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"X25519PrivateKey\",\n reason: `X25519 private keys must be at most ${String(X25519_BYTE_LENGTH)} bytes`,\n },\n );\n }\n\n if (bytes.length < X25519_BYTE_LENGTH) {\n const padded = new Uint8Array(X25519_BYTE_LENGTH);\n padded.set(bytes, 0);\n return padded as X25519PrivateKey;\n }\n\n return bytes as X25519PrivateKey;\n}\n\n/**\n * Converts a byte source to an `X25519PublicKey` (exactly 32 bytes).\n *\n * @remarks\n * Input type: `Uint8Array`, `ArrayBuffer`, `DataView`, or `number[]`.\n * Output type: `X25519PublicKey` — a 32-byte little-endian encoding of the\n * u-coordinate of a Curve25519 point, representing the public component of\n * an X25519 key pair.\n *\n * X25519 public keys are the result of scalar multiplication of the private key\n * by the Curve25519 base point. In the Umbra protocol, public keys are stored\n * in on-chain user accounts split into two U128 halves for Solana storage.\n *\n * Padding behaviour: inputs shorter than 32 bytes are zero-padded on the right.\n * Inputs longer than 32 bytes throw `ConversionError`.\n *\n * @param value - The byte source to convert (at most 32 bytes)\n * @returns The value as `X25519PublicKey` (exactly 32 bytes)\n * @throws {ConversionError} If the input exceeds 32 bytes, contains invalid byte values,\n * or is an unsupported type\n *\n * @example\n * ```typescript\n * // Receive and convert a public key\n * const theirKey = receivePublicKey();\n * const publicKey = createX25519PublicKey(theirKey);\n * ```\n *\n * @see {@link createX25519PrivateKey} — for private keys\n * @see {@link createSharedSecret} — for Diffie-Hellman outputs\n * @see {@link createX25519Bytes} — for the base 32-byte type\n * @public\n */\nexport function createX25519PublicKey(\n value: Uint8Array | ArrayBuffer | DataView | number[],\n): X25519PublicKey {\n let bytes: Uint8Array;\n\n if (value instanceof Uint8Array) {\n bytes = value;\n } else if (value instanceof ArrayBuffer) {\n bytes = new Uint8Array(value);\n } else if (value instanceof DataView) {\n bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n } else if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index++) {\n const byte = value[index];\n if (typeof byte !== \"number\" || !Number.isInteger(byte) || byte < 0 || byte > 255) {\n throw new ConversionError(`Invalid byte value at index ${String(index)}: ${String(byte)}`, {\n sourceValue: value,\n sourceType: \"number[]\",\n targetType: \"X25519PublicKey\",\n reason: \"All values must be integers in range [0, 255]\",\n });\n }\n }\n bytes = new Uint8Array(value);\n } else {\n throw new ConversionError(`Cannot convert to X25519PublicKey`, {\n sourceValue: value,\n sourceType: typeof value,\n targetType: \"X25519PublicKey\",\n reason: \"Expected Uint8Array, ArrayBuffer, DataView, or number[]\",\n });\n }\n\n if (bytes.length > X25519_BYTE_LENGTH) {\n throw new ConversionError(\n `Value exceeds X25519 byte length (${String(bytes.length)} > ${String(X25519_BYTE_LENGTH)})`,\n {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"X25519PublicKey\",\n reason: `X25519 public keys must be at most ${String(X25519_BYTE_LENGTH)} bytes`,\n },\n );\n }\n\n if (bytes.length < X25519_BYTE_LENGTH) {\n const padded = new Uint8Array(X25519_BYTE_LENGTH);\n padded.set(bytes, 0);\n return padded as X25519PublicKey;\n }\n\n return bytes as X25519PublicKey;\n}\n\n/**\n * Converts a byte source to a `SharedSecret` (exactly 32 bytes).\n *\n * @remarks\n * Input type: `Uint8Array`, `ArrayBuffer`, `DataView`, or `number[]`.\n * Output type: `SharedSecret` — a 32-byte little-endian encoding of the\n * u-coordinate of the Diffie-Hellman output point from X25519 key agreement.\n *\n * The shared secret is the raw DH output and should NOT be used directly as an\n * encryption key. Always pass it through a Key Derivation Function (KDF) such\n * as HKDF to derive independent keys for encryption and MAC.\n *\n * Padding behaviour: inputs shorter than 32 bytes are zero-padded on the right.\n * Inputs longer than 32 bytes throw `ConversionError`.\n *\n * @param value - The byte source to convert (at most 32 bytes)\n * @returns The value as `SharedSecret` (exactly 32 bytes)\n * @throws {ConversionError} If the input exceeds 32 bytes, contains invalid byte values,\n * or is an unsupported type\n *\n * @example\n * ```typescript\n * // After X25519 key exchange\n * const rawSecret = x25519(privateKey, publicKey);\n * const sharedSecret = createSharedSecret(rawSecret);\n *\n * // Use with a KDF before using as an encryption key\n * const encryptionKey = hkdf(sharedSecret, salt, info);\n * ```\n *\n * @see {@link createX25519PublicKey} — for public keys used in key exchange\n * @see {@link createX25519PrivateKey} — for private keys used in key exchange\n * @see {@link createX25519Bytes} — for the base 32-byte type\n * @public\n */\nexport function createSharedSecret(\n value: Uint8Array | ArrayBuffer | DataView | number[],\n): SharedSecret {\n let bytes: Uint8Array;\n\n if (value instanceof Uint8Array) {\n bytes = value;\n } else if (value instanceof ArrayBuffer) {\n bytes = new Uint8Array(value);\n } else if (value instanceof DataView) {\n bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n } else if (Array.isArray(value)) {\n // Validate all elements are valid bytes\n for (let index = 0; index < value.length; index++) {\n const byte = value[index];\n if (typeof byte !== \"number\" || !Number.isInteger(byte) || byte < 0 || byte > 255) {\n throw new ConversionError(`Invalid byte value at index ${String(index)}: ${String(byte)}`, {\n sourceValue: value,\n sourceType: \"number[]\",\n targetType: \"SharedSecret\",\n reason: \"All values must be integers in range [0, 255]\",\n });\n }\n }\n bytes = new Uint8Array(value);\n } else {\n throw new ConversionError(`Cannot convert to SharedSecret`, {\n sourceValue: value,\n sourceType: typeof value,\n targetType: \"SharedSecret\",\n reason: \"Expected Uint8Array, ArrayBuffer, DataView, or number[]\",\n });\n }\n\n // Check size\n if (bytes.length > X25519_BYTE_LENGTH) {\n throw new ConversionError(\n `Value exceeds SharedSecret byte length (${String(bytes.length)} > ${String(X25519_BYTE_LENGTH)})`,\n {\n sourceValue: value,\n sourceType: getTypeName(value),\n targetType: \"SharedSecret\",\n reason: `Shared secrets must be at most ${String(X25519_BYTE_LENGTH)} bytes`,\n },\n );\n }\n\n // Pad if undersized\n if (bytes.length < X25519_BYTE_LENGTH) {\n const padded = new Uint8Array(X25519_BYTE_LENGTH);\n padded.set(bytes, 0);\n return padded as SharedSecret;\n }\n\n return bytes as SharedSecret;\n}\n","/**\n * Mathematics Type Converters\n *\n * This module provides converter functions between branded mathematical types.\n * All converters include:\n * - Input assertions to validate the source type\n * - Range/constraint validation to ensure lossless conversion\n * - Output assertions to validate the result type\n *\n * ## Conversion Categories\n *\n * ### Integer Conversions\n * - **Widening**: Convert smaller integers to larger (always safe, no range check)\n * - **Narrowing**: Convert larger integers to smaller (throws {@link ConversionError} if out of range)\n * - **Sign Conversions**: Convert between signed and unsigned (with validation)\n *\n * ### Byte Array Conversions\n * - **Endianness Swap**: Convert between LE and BE byte-order representations\n *\n * ### Encoding/Decoding\n * - **Encode**: Convert integers to typed byte arrays (LE or BE)\n * - **Decode**: Convert typed byte arrays back to integers\n *\n * @remarks\n * All types (U8, U16, U32, U64, U128, U256, U512, U1024, I8, …, I1024) are\n * `bigint` values with phantom brand tags enforced at runtime by assertion\n * functions imported from `../types`. The underlying JavaScript value is always\n * a plain `bigint`; the brand is a compile-time-only marker.\n *\n * Little-endian (LE) byte arrays place the least-significant byte at index 0\n * and are the canonical format for Solana on-chain account data.\n * Big-endian (BE) byte arrays place the most-significant byte at index 0 and\n * are used by some cryptographic primitives (e.g. BN254 field elements).\n *\n * @packageDocumentation\n * @module utils/convertors/mathematics\n */\n\nimport {\n // Byte array types\n type U8LeBytes,\n type U16LeBytes,\n type U32LeBytes,\n type U64LeBytes,\n type U128LeBytes,\n type U256LeBytes,\n type U512LeBytes,\n type U1024LeBytes,\n type U8BeBytes,\n type U16BeBytes,\n type U32BeBytes,\n type U64BeBytes,\n type U128BeBytes,\n type U256BeBytes,\n type U512BeBytes,\n type U1024BeBytes,\n // Integer types\n type U8,\n type U16,\n type U32,\n type U64,\n type U128,\n type U256,\n type U512,\n type U1024,\n type I8,\n type I16,\n type I32,\n type I64,\n type I128,\n type I256,\n type I512,\n type I1024,\n // Constants\n U8_MAX,\n U16_MAX,\n U32_MAX,\n U64_MAX,\n U128_MAX,\n U256_MAX,\n U512_MAX,\n I8_MIN,\n I8_MAX,\n I16_MIN,\n I16_MAX,\n I32_MIN,\n I32_MAX,\n I64_MIN,\n I64_MAX,\n I128_MIN,\n I128_MAX,\n I256_MIN,\n I256_MAX,\n I512_MIN,\n I512_MAX,\n I1024_MAX,\n U8_BYTE_LENGTH,\n U16_BYTE_LENGTH,\n U32_BYTE_LENGTH,\n U64_BYTE_LENGTH,\n U128_BYTE_LENGTH,\n U256_BYTE_LENGTH,\n U512_BYTE_LENGTH,\n U1024_BYTE_LENGTH,\n // Assertions\n assertU8,\n assertU16,\n assertU32,\n assertU64,\n assertU128,\n assertU256,\n assertU512,\n assertU1024,\n assertI8,\n assertI16,\n assertI32,\n assertI64,\n assertI128,\n assertI256,\n assertI512,\n assertI1024,\n assertU8LeBytes,\n assertU16LeBytes,\n assertU32LeBytes,\n assertU64LeBytes,\n assertU128LeBytes,\n assertU256LeBytes,\n assertU512LeBytes,\n assertU1024LeBytes,\n assertU8BeBytes,\n assertU16BeBytes,\n assertU32BeBytes,\n assertU64BeBytes,\n assertU128BeBytes,\n assertU256BeBytes,\n assertU512BeBytes,\n assertU1024BeBytes,\n} from \"../types\";\n\nimport { ConversionError } from \"./branded\";\n\n/* =============================================================================\n * UNSIGNED INTEGER WIDENING CONVERSIONS\n *\n * These conversions are always safe because the target type can hold all\n * values of the source type.\n * ============================================================================= */\n\n/**\n * Converts a U8 to U16 (widening conversion).\n *\n * @public\n * @param value - The U8 value to convert (range [0, 255])\n * @returns The identical numeric value re-branded as U16 (range [0, 65535])\n *\n * @remarks\n * Input type: U8 (bigint, range [0, 255]).\n * Output type: U16 (bigint, range [0, 65535]).\n * Direction: widening — all U8 values fit within U16; no range check is performed.\n * - Input assertion: Validates input is a valid U8.\n * - No range check needed (widening is always safe).\n * - Output assertion: Validates result is a valid U16.\n *\n * @example\n * ```typescript\n * const u8Value = assertU8(255n);\n * const u16Value = convertU8ToU16(u8Value); // 255n as U16\n * ```\n *\n * @see {@link convertU16ToU8} for the inverse narrowing conversion\n */\nexport function convertU8ToU16(value: U8): U16 {\n assertU8(value);\n assertU16(value);\n return value;\n}\n\n/**\n * Converts a U8 to U32 (widening conversion).\n *\n * @public\n * @param value - The U8 value to convert (range [0, 255])\n * @returns The identical numeric value re-branded as U32 (range [0, 2^32 - 1])\n *\n * @remarks\n * Input type: U8 (bigint, range [0, 255]).\n * Output type: U32 (bigint, range [0, 2^32 - 1]).\n * Direction: widening — every U8 value fits in U32; no range check is performed.\n *\n * @example\n * ```typescript\n * const u8Value = assertU8(200n);\n * const u32Value = convertU8ToU32(u8Value); // 200n as U32\n * ```\n *\n * @see {@link convertU32ToU8} for the inverse narrowing conversion\n */\nexport function convertU8ToU32(value: U8): U32 {\n assertU8(value);\n assertU32(value);\n return value;\n}\n\n/**\n * Converts a U8 to U64 (widening conversion).\n *\n * @public\n * @param value - The U8 value to convert (range [0, 255])\n * @returns The identical numeric value re-branded as U64 (range [0, 2^64 - 1])\n *\n * @remarks\n * Input type: U8 (bigint, range [0, 255]).\n * Output type: U64 (bigint, range [0, 2^64 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u8Value = assertU8(42n);\n * const u64Value = convertU8ToU64(u8Value); // 42n as U64\n * ```\n *\n * @see {@link convertU64ToU8} for the inverse narrowing conversion\n */\nexport function convertU8ToU64(value: U8): U64 {\n assertU8(value);\n assertU64(value);\n return value;\n}\n\n/**\n * Converts a U8 to U128 (widening conversion).\n *\n * @public\n * @param value - The U8 value to convert (range [0, 255])\n * @returns The identical numeric value re-branded as U128 (range [0, 2^128 - 1])\n *\n * @remarks\n * Input type: U8 (bigint, range [0, 255]).\n * Output type: U128 (bigint, range [0, 2^128 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u8Value = assertU8(1n);\n * const u128Value = convertU8ToU128(u8Value); // 1n as U128\n * ```\n *\n * @see {@link convertU128ToU8} for the inverse narrowing conversion\n */\nexport function convertU8ToU128(value: U8): U128 {\n assertU8(value);\n assertU128(value);\n return value;\n}\n\n/**\n * Converts a U8 to U256 (widening conversion).\n *\n * @public\n * @param value - The U8 value to convert (range [0, 255])\n * @returns The identical numeric value re-branded as U256 (range [0, 2^256 - 1])\n *\n * @remarks\n * Input type: U8 (bigint, range [0, 255]).\n * Output type: U256 (bigint, range [0, 2^256 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u8Value = assertU8(0n);\n * const u256Value = convertU8ToU256(u8Value); // 0n as U256\n * ```\n *\n * @see {@link convertU256ToU8} for the inverse narrowing conversion\n */\nexport function convertU8ToU256(value: U8): U256 {\n assertU8(value);\n assertU256(value);\n return value;\n}\n\n/**\n * Converts a U8 to U512 (widening conversion).\n *\n * @public\n * @param value - The U8 value to convert (range [0, 255])\n * @returns The identical numeric value re-branded as U512 (range [0, 2^512 - 1])\n *\n * @remarks\n * Input type: U8 (bigint, range [0, 255]).\n * Output type: U512 (bigint, range [0, 2^512 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u8Value = assertU8(255n);\n * const u512Value = convertU8ToU512(u8Value); // 255n as U512\n * ```\n *\n * @see {@link convertU512ToU8} for the inverse narrowing conversion\n */\nexport function convertU8ToU512(value: U8): U512 {\n assertU8(value);\n assertU512(value);\n return value;\n}\n\n/**\n * Converts a U8 to U1024 (widening conversion).\n *\n * @public\n * @param value - The U8 value to convert (range [0, 255])\n * @returns The identical numeric value re-branded as U1024 (range [0, 2^1024 - 1])\n *\n * @remarks\n * Input type: U8 (bigint, range [0, 255]).\n * Output type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u8Value = assertU8(100n);\n * const u1024Value = convertU8ToU1024(u8Value); // 100n as U1024\n * ```\n *\n * @see {@link convertU1024ToU8} for the inverse narrowing conversion\n */\nexport function convertU8ToU1024(value: U8): U1024 {\n assertU8(value);\n assertU1024(value);\n return value;\n}\n\n/**\n * Converts a U16 to U32 (widening conversion).\n *\n * @public\n * @param value - The U16 value to convert (range [0, 65535])\n * @returns The identical numeric value re-branded as U32 (range [0, 2^32 - 1])\n *\n * @remarks\n * Input type: U16 (bigint, range [0, 65535]).\n * Output type: U32 (bigint, range [0, 2^32 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u16Value = assertU16(1000n);\n * const u32Value = convertU16ToU32(u16Value); // 1000n as U32\n * ```\n *\n * @see {@link convertU32ToU16} for the inverse narrowing conversion\n */\nexport function convertU16ToU32(value: U16): U32 {\n assertU16(value);\n assertU32(value);\n return value;\n}\n\n/**\n * Converts a U16 to U64 (widening conversion).\n *\n * @public\n * @param value - The U16 value to convert (range [0, 65535])\n * @returns The identical numeric value re-branded as U64 (range [0, 2^64 - 1])\n *\n * @remarks\n * Input type: U16 (bigint, range [0, 65535]).\n * Output type: U64 (bigint, range [0, 2^64 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u16Value = assertU16(65535n);\n * const u64Value = convertU16ToU64(u16Value); // 65535n as U64\n * ```\n *\n * @see {@link convertU64ToU16} for the inverse narrowing conversion\n */\nexport function convertU16ToU64(value: U16): U64 {\n assertU16(value);\n assertU64(value);\n return value;\n}\n\n/**\n * Converts a U16 to U128 (widening conversion).\n *\n * @public\n * @param value - The U16 value to convert (range [0, 65535])\n * @returns The identical numeric value re-branded as U128 (range [0, 2^128 - 1])\n *\n * @remarks\n * Input type: U16 (bigint, range [0, 65535]).\n * Output type: U128 (bigint, range [0, 2^128 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u16Value = assertU16(500n);\n * const u128Value = convertU16ToU128(u16Value); // 500n as U128\n * ```\n *\n * @see {@link convertU128ToU16} for the inverse narrowing conversion\n */\nexport function convertU16ToU128(value: U16): U128 {\n assertU16(value);\n assertU128(value);\n return value;\n}\n\n/**\n * Converts a U16 to U256 (widening conversion).\n *\n * @public\n * @param value - The U16 value to convert (range [0, 65535])\n * @returns The identical numeric value re-branded as U256 (range [0, 2^256 - 1])\n *\n * @remarks\n * Input type: U16 (bigint, range [0, 65535]).\n * Output type: U256 (bigint, range [0, 2^256 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u16Value = assertU16(300n);\n * const u256Value = convertU16ToU256(u16Value); // 300n as U256\n * ```\n *\n * @see {@link convertU256ToU16} for the inverse narrowing conversion\n */\nexport function convertU16ToU256(value: U16): U256 {\n assertU16(value);\n assertU256(value);\n return value;\n}\n\n/**\n * Converts a U16 to U512 (widening conversion).\n *\n * @public\n * @param value - The U16 value to convert (range [0, 65535])\n * @returns The identical numeric value re-branded as U512 (range [0, 2^512 - 1])\n *\n * @remarks\n * Input type: U16 (bigint, range [0, 65535]).\n * Output type: U512 (bigint, range [0, 2^512 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u16Value = assertU16(1n);\n * const u512Value = convertU16ToU512(u16Value); // 1n as U512\n * ```\n *\n * @see {@link convertU512ToU16} for the inverse narrowing conversion\n */\nexport function convertU16ToU512(value: U16): U512 {\n assertU16(value);\n assertU512(value);\n return value;\n}\n\n/**\n * Converts a U16 to U1024 (widening conversion).\n *\n * @public\n * @param value - The U16 value to convert (range [0, 65535])\n * @returns The identical numeric value re-branded as U1024 (range [0, 2^1024 - 1])\n *\n * @remarks\n * Input type: U16 (bigint, range [0, 65535]).\n * Output type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u16Value = assertU16(9999n);\n * const u1024Value = convertU16ToU1024(u16Value); // 9999n as U1024\n * ```\n *\n * @see {@link convertU1024ToU16} for the inverse narrowing conversion\n */\nexport function convertU16ToU1024(value: U16): U1024 {\n assertU16(value);\n assertU1024(value);\n return value;\n}\n\n/**\n * Converts a U32 to U64 (widening conversion).\n *\n * @public\n * @param value - The U32 value to convert (range [0, 2^32 - 1])\n * @returns The identical numeric value re-branded as U64 (range [0, 2^64 - 1])\n *\n * @remarks\n * Input type: U32 (bigint, range [0, 4294967295]).\n * Output type: U64 (bigint, range [0, 2^64 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u32Value = assertU32(4294967295n);\n * const u64Value = convertU32ToU64(u32Value); // 4294967295n as U64\n * ```\n *\n * @see {@link convertU64ToU32} for the inverse narrowing conversion\n */\nexport function convertU32ToU64(value: U32): U64 {\n assertU32(value);\n assertU64(value);\n return value;\n}\n\n/**\n * Converts a U32 to U128 (widening conversion).\n *\n * @public\n * @param value - The U32 value to convert (range [0, 2^32 - 1])\n * @returns The identical numeric value re-branded as U128 (range [0, 2^128 - 1])\n *\n * @remarks\n * Input type: U32 (bigint, range [0, 4294967295]).\n * Output type: U128 (bigint, range [0, 2^128 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u32Value = assertU32(1000000n);\n * const u128Value = convertU32ToU128(u32Value); // 1000000n as U128\n * ```\n *\n * @see {@link convertU128ToU32} for the inverse narrowing conversion\n */\nexport function convertU32ToU128(value: U32): U128 {\n assertU32(value);\n assertU128(value);\n return value;\n}\n\n/**\n * Converts a U32 to U256 (widening conversion).\n *\n * @public\n * @param value - The U32 value to convert (range [0, 2^32 - 1])\n * @returns The identical numeric value re-branded as U256 (range [0, 2^256 - 1])\n *\n * @remarks\n * Input type: U32 (bigint, range [0, 4294967295]).\n * Output type: U256 (bigint, range [0, 2^256 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u32Value = assertU32(0n);\n * const u256Value = convertU32ToU256(u32Value); // 0n as U256\n * ```\n *\n * @see {@link convertU256ToU32} for the inverse narrowing conversion\n */\nexport function convertU32ToU256(value: U32): U256 {\n assertU32(value);\n assertU256(value);\n return value;\n}\n\n/**\n * Converts a U32 to U512 (widening conversion).\n *\n * @public\n * @param value - The U32 value to convert (range [0, 2^32 - 1])\n * @returns The identical numeric value re-branded as U512 (range [0, 2^512 - 1])\n *\n * @remarks\n * Input type: U32 (bigint, range [0, 4294967295]).\n * Output type: U512 (bigint, range [0, 2^512 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u32Value = assertU32(123456n);\n * const u512Value = convertU32ToU512(u32Value); // 123456n as U512\n * ```\n *\n * @see {@link convertU512ToU32} for the inverse narrowing conversion\n */\nexport function convertU32ToU512(value: U32): U512 {\n assertU32(value);\n assertU512(value);\n return value;\n}\n\n/**\n * Converts a U32 to U1024 (widening conversion).\n *\n * @public\n * @param value - The U32 value to convert (range [0, 2^32 - 1])\n * @returns The identical numeric value re-branded as U1024 (range [0, 2^1024 - 1])\n *\n * @remarks\n * Input type: U32 (bigint, range [0, 4294967295]).\n * Output type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u32Value = assertU32(7n);\n * const u1024Value = convertU32ToU1024(u32Value); // 7n as U1024\n * ```\n *\n * @see {@link convertU1024ToU32} for the inverse narrowing conversion\n */\nexport function convertU32ToU1024(value: U32): U1024 {\n assertU32(value);\n assertU1024(value);\n return value;\n}\n\n/**\n * Converts a U64 to U128 (widening conversion).\n *\n * @public\n * @param value - The U64 value to convert (range [0, 2^64 - 1])\n * @returns The identical numeric value re-branded as U128 (range [0, 2^128 - 1])\n *\n * @remarks\n * Input type: U64 (bigint, range [0, 2^64 - 1]).\n * Output type: U128 (bigint, range [0, 2^128 - 1]).\n * Direction: widening — always safe, no range check needed.\n * This conversion is commonly used when combining two U64 halves into a U128.\n *\n * @example\n * ```typescript\n * const u64Value = assertU64(18446744073709551615n); // U64_MAX\n * const u128Value = convertU64ToU128(u64Value); // 18446744073709551615n as U128\n * ```\n *\n * @see {@link convertU128ToU64} for the inverse narrowing conversion\n */\nexport function convertU64ToU128(value: U64): U128 {\n assertU64(value);\n assertU128(value);\n return value;\n}\n\n/**\n * Converts a U64 to U256 (widening conversion).\n *\n * @public\n * @param value - The U64 value to convert (range [0, 2^64 - 1])\n * @returns The identical numeric value re-branded as U256 (range [0, 2^256 - 1])\n *\n * @remarks\n * Input type: U64 (bigint, range [0, 2^64 - 1]).\n * Output type: U256 (bigint, range [0, 2^256 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u64Value = assertU64(1000n);\n * const u256Value = convertU64ToU256(u64Value); // 1000n as U256\n * ```\n *\n * @see {@link convertU256ToU64} for the inverse narrowing conversion\n */\nexport function convertU64ToU256(value: U64): U256 {\n assertU64(value);\n assertU256(value);\n return value;\n}\n\n/**\n * Converts a U64 to U512 (widening conversion).\n *\n * @public\n * @param value - The U64 value to convert (range [0, 2^64 - 1])\n * @returns The identical numeric value re-branded as U512 (range [0, 2^512 - 1])\n *\n * @remarks\n * Input type: U64 (bigint, range [0, 2^64 - 1]).\n * Output type: U512 (bigint, range [0, 2^512 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u64Value = assertU64(0n);\n * const u512Value = convertU64ToU512(u64Value); // 0n as U512\n * ```\n *\n * @see {@link convertU512ToU64} for the inverse narrowing conversion\n */\nexport function convertU64ToU512(value: U64): U512 {\n assertU64(value);\n assertU512(value);\n return value;\n}\n\n/**\n * Converts a U64 to U1024 (widening conversion).\n *\n * @public\n * @param value - The U64 value to convert (range [0, 2^64 - 1])\n * @returns The identical numeric value re-branded as U1024 (range [0, 2^1024 - 1])\n *\n * @remarks\n * Input type: U64 (bigint, range [0, 2^64 - 1]).\n * Output type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u64Value = assertU64(500n);\n * const u1024Value = convertU64ToU1024(u64Value); // 500n as U1024\n * ```\n *\n * @see {@link convertU1024ToU64} for the inverse narrowing conversion\n */\nexport function convertU64ToU1024(value: U64): U1024 {\n assertU64(value);\n assertU1024(value);\n return value;\n}\n\n/**\n * Converts a U128 to U256 (widening conversion).\n *\n * @public\n * @param value - The U128 value to convert (range [0, 2^128 - 1])\n * @returns The identical numeric value re-branded as U256 (range [0, 2^256 - 1])\n *\n * @remarks\n * Input type: U128 (bigint, range [0, 2^128 - 1]).\n * Output type: U256 (bigint, range [0, 2^256 - 1]).\n * Direction: widening — always safe, no range check needed.\n * Commonly used when assembling a U256 from two U128 halves.\n *\n * @example\n * ```typescript\n * const u128Value = assertU128(340282366920938463463374607431768211455n); // U128_MAX\n * const u256Value = convertU128ToU256(u128Value); // same value as U256\n * ```\n *\n * @see {@link convertU256ToU128} for the inverse narrowing conversion\n */\nexport function convertU128ToU256(value: U128): U256 {\n assertU128(value);\n assertU256(value);\n return value;\n}\n\n/**\n * Converts a U128 to U512 (widening conversion).\n *\n * @public\n * @param value - The U128 value to convert (range [0, 2^128 - 1])\n * @returns The identical numeric value re-branded as U512 (range [0, 2^512 - 1])\n *\n * @remarks\n * Input type: U128 (bigint, range [0, 2^128 - 1]).\n * Output type: U512 (bigint, range [0, 2^512 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u128Value = assertU128(1n);\n * const u512Value = convertU128ToU512(u128Value); // 1n as U512\n * ```\n *\n * @see {@link convertU512ToU128} for the inverse narrowing conversion\n */\nexport function convertU128ToU512(value: U128): U512 {\n assertU128(value);\n assertU512(value);\n return value;\n}\n\n/**\n * Converts a U128 to U1024 (widening conversion).\n *\n * @public\n * @param value - The U128 value to convert (range [0, 2^128 - 1])\n * @returns The identical numeric value re-branded as U1024 (range [0, 2^1024 - 1])\n *\n * @remarks\n * Input type: U128 (bigint, range [0, 2^128 - 1]).\n * Output type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u128Value = assertU128(999n);\n * const u1024Value = convertU128ToU1024(u128Value); // 999n as U1024\n * ```\n *\n * @see {@link convertU1024ToU128} for the inverse narrowing conversion\n */\nexport function convertU128ToU1024(value: U128): U1024 {\n assertU128(value);\n assertU1024(value);\n return value;\n}\n\n/**\n * Converts a U256 to U512 (widening conversion).\n *\n * @public\n * @param value - The U256 value to convert (range [0, 2^256 - 1])\n * @returns The identical numeric value re-branded as U512 (range [0, 2^512 - 1])\n *\n * @remarks\n * Input type: U256 (bigint, range [0, 2^256 - 1]).\n * Output type: U512 (bigint, range [0, 2^512 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u256Value = assertU256(2n ** 200n);\n * const u512Value = convertU256ToU512(u256Value); // same value as U512\n * ```\n *\n * @see {@link convertU512ToU256} for the inverse narrowing conversion\n */\nexport function convertU256ToU512(value: U256): U512 {\n assertU256(value);\n assertU512(value);\n return value;\n}\n\n/**\n * Converts a U256 to U1024 (widening conversion).\n *\n * @public\n * @param value - The U256 value to convert (range [0, 2^256 - 1])\n * @returns The identical numeric value re-branded as U1024 (range [0, 2^1024 - 1])\n *\n * @remarks\n * Input type: U256 (bigint, range [0, 2^256 - 1]).\n * Output type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u256Value = assertU256(42n);\n * const u1024Value = convertU256ToU1024(u256Value); // 42n as U1024\n * ```\n *\n * @see {@link convertU1024ToU256} for the inverse narrowing conversion\n */\nexport function convertU256ToU1024(value: U256): U1024 {\n assertU256(value);\n assertU1024(value);\n return value;\n}\n\n/**\n * Converts a U512 to U1024 (widening conversion).\n *\n * @public\n * @param value - The U512 value to convert (range [0, 2^512 - 1])\n * @returns The identical numeric value re-branded as U1024 (range [0, 2^1024 - 1])\n *\n * @remarks\n * Input type: U512 (bigint, range [0, 2^512 - 1]).\n * Output type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const u512Value = assertU512(2n ** 400n);\n * const u1024Value = convertU512ToU1024(u512Value); // same value as U1024\n * ```\n *\n * @see {@link convertU1024ToU512} for the inverse narrowing conversion\n */\nexport function convertU512ToU1024(value: U512): U1024 {\n assertU512(value);\n assertU1024(value);\n return value;\n}\n\n/* =============================================================================\n * UNSIGNED INTEGER NARROWING CONVERSIONS\n *\n * These conversions may fail if the value exceeds the target type's range.\n * ============================================================================= */\n\n/**\n * Converts a U16 to U8 (narrowing conversion).\n *\n * @public\n * @param value - The U16 value to convert (must be in range [0, 255])\n * @returns The value re-branded as U8\n * @throws {ConversionError} If value exceeds U8_MAX (255)\n *\n * @remarks\n * Input type: U16 (bigint, range [0, 65535]).\n * Output type: U8 (bigint, range [0, 255]).\n * Direction: narrowing — throws if value does not fit in the target range.\n * - Input assertion: Validates input is a valid U16.\n * - Range check: Ensures value <= 255 (U8_MAX).\n * - Output assertion: Validates result is a valid U8.\n *\n * @example\n * ```typescript\n * const u16Value = assertU16(100n);\n * const u8Value = convertU16ToU8(u16Value); // OK: 100 fits in U8\n *\n * const tooLarge = assertU16(300n);\n * convertU16ToU8(tooLarge); // Throws ConversionError: 300 > 255\n * ```\n *\n * @see {@link convertU8ToU16} for the inverse widening conversion\n */\nexport function convertU16ToU8(value: U16): U8 {\n assertU16(value);\n if (value > U8_MAX) {\n throw new ConversionError(`Value ${String(value)} exceeds U8 maximum of ${String(U8_MAX)}`, {\n sourceValue: value,\n sourceType: \"U16\",\n targetType: \"U8\",\n reason: `Value must be <= ${String(U8_MAX)}`,\n });\n }\n assertU8(value);\n return value;\n}\n\n/**\n * Converts a U32 to U8 (narrowing conversion).\n *\n * @public\n * @param value - The U32 value to convert (must be in range [0, 255])\n * @returns The value re-branded as U8\n * @throws {ConversionError} If value exceeds U8_MAX (255)\n *\n * @remarks\n * Input type: U32 (bigint, range [0, 2^32 - 1]).\n * Output type: U8 (bigint, range [0, 255]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u32Value = assertU32(200n);\n * const u8Value = convertU32ToU8(u32Value); // OK: 200 fits in U8\n *\n * convertU32ToU8(assertU32(1000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU8ToU32} for the inverse widening conversion\n */\nexport function convertU32ToU8(value: U32): U8 {\n assertU32(value);\n if (value > U8_MAX) {\n throw new ConversionError(`Value ${String(value)} exceeds U8 maximum of ${String(U8_MAX)}`, {\n sourceValue: value,\n sourceType: \"U32\",\n targetType: \"U8\",\n reason: `Value must be <= ${String(U8_MAX)}`,\n });\n }\n assertU8(value);\n return value;\n}\n\n/**\n * Converts a U32 to U16 (narrowing conversion).\n *\n * @public\n * @param value - The U32 value to convert (must be in range [0, 65535])\n * @returns The value re-branded as U16\n * @throws {ConversionError} If value exceeds U16_MAX (65535)\n *\n * @remarks\n * Input type: U32 (bigint, range [0, 2^32 - 1]).\n * Output type: U16 (bigint, range [0, 65535]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u32Value = assertU32(60000n);\n * const u16Value = convertU32ToU16(u32Value); // OK: 60000 fits in U16\n *\n * convertU32ToU16(assertU32(70000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU16ToU32} for the inverse widening conversion\n */\nexport function convertU32ToU16(value: U32): U16 {\n assertU32(value);\n if (value > U16_MAX) {\n throw new ConversionError(`Value ${String(value)} exceeds U16 maximum of ${String(U16_MAX)}`, {\n sourceValue: value,\n sourceType: \"U32\",\n targetType: \"U16\",\n reason: `Value must be <= ${String(U16_MAX)}`,\n });\n }\n assertU16(value);\n return value;\n}\n\n/**\n * Converts a U64 to U8 (narrowing conversion).\n *\n * @public\n * @param value - The U64 value to convert (must be in range [0, 255])\n * @returns The value re-branded as U8\n * @throws {ConversionError} If value exceeds U8_MAX (255)\n *\n * @remarks\n * Input type: U64 (bigint, range [0, 2^64 - 1]).\n * Output type: U8 (bigint, range [0, 255]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u64Value = assertU64(10n);\n * const u8Value = convertU64ToU8(u64Value); // OK\n *\n * convertU64ToU8(assertU64(256n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU8ToU64} for the inverse widening conversion\n */\nexport function convertU64ToU8(value: U64): U8 {\n assertU64(value);\n if (value > U8_MAX) {\n throw new ConversionError(`Value ${String(value)} exceeds U8 maximum of ${String(U8_MAX)}`, {\n sourceValue: value,\n sourceType: \"U64\",\n targetType: \"U8\",\n reason: `Value must be <= ${String(U8_MAX)}`,\n });\n }\n assertU8(value);\n return value;\n}\n\n/**\n * Converts a U64 to U16 (narrowing conversion).\n *\n * @public\n * @param value - The U64 value to convert (must be in range [0, 65535])\n * @returns The value re-branded as U16\n * @throws {ConversionError} If value exceeds U16_MAX (65535)\n *\n * @remarks\n * Input type: U64 (bigint, range [0, 2^64 - 1]).\n * Output type: U16 (bigint, range [0, 65535]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u64Value = assertU64(1024n);\n * const u16Value = convertU64ToU16(u64Value); // OK\n *\n * convertU64ToU16(assertU64(100000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU16ToU64} for the inverse widening conversion\n */\nexport function convertU64ToU16(value: U64): U16 {\n assertU64(value);\n if (value > U16_MAX) {\n throw new ConversionError(`Value ${String(value)} exceeds U16 maximum of ${String(U16_MAX)}`, {\n sourceValue: value,\n sourceType: \"U64\",\n targetType: \"U16\",\n reason: `Value must be <= ${String(U16_MAX)}`,\n });\n }\n assertU16(value);\n return value;\n}\n\n/**\n * Converts a U64 to U32 (narrowing conversion).\n *\n * @public\n * @param value - The U64 value to convert (must be in range [0, 2^32 - 1])\n * @returns The value re-branded as U32\n * @throws {ConversionError} If value exceeds U32_MAX (4294967295)\n *\n * @remarks\n * Input type: U64 (bigint, range [0, 2^64 - 1]).\n * Output type: U32 (bigint, range [0, 4294967295]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u64Value = assertU64(4294967295n); // U32_MAX\n * const u32Value = convertU64ToU32(u64Value); // OK\n *\n * convertU64ToU32(assertU64(4294967296n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU32ToU64} for the inverse widening conversion\n */\nexport function convertU64ToU32(value: U64): U32 {\n assertU64(value);\n if (value > U32_MAX) {\n throw new ConversionError(`Value ${String(value)} exceeds U32 maximum of ${String(U32_MAX)}`, {\n sourceValue: value,\n sourceType: \"U64\",\n targetType: \"U32\",\n reason: `Value must be <= ${String(U32_MAX)}`,\n });\n }\n assertU32(value);\n return value;\n}\n\n/**\n * Converts a U128 to U8 (narrowing conversion).\n *\n * @public\n * @param value - The U128 value to convert (must be in range [0, 255])\n * @returns The value re-branded as U8\n * @throws {ConversionError} If value exceeds U8_MAX (255)\n *\n * @remarks\n * Input type: U128 (bigint, range [0, 2^128 - 1]).\n * Output type: U8 (bigint, range [0, 255]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u128Value = assertU128(127n);\n * const u8Value = convertU128ToU8(u128Value); // OK\n *\n * convertU128ToU8(assertU128(256n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU8ToU128} for the inverse widening conversion\n */\nexport function convertU128ToU8(value: U128): U8 {\n assertU128(value);\n if (value > U8_MAX) {\n throw new ConversionError(`Value exceeds U8 maximum of ${String(U8_MAX)}`, {\n sourceValue: value,\n sourceType: \"U128\",\n targetType: \"U8\",\n reason: `Value must be <= ${String(U8_MAX)}`,\n });\n }\n assertU8(value);\n return value;\n}\n\n/**\n * Converts a U128 to U16 (narrowing conversion).\n *\n * @public\n * @param value - The U128 value to convert (must be in range [0, 65535])\n * @returns The value re-branded as U16\n * @throws {ConversionError} If value exceeds U16_MAX (65535)\n *\n * @remarks\n * Input type: U128 (bigint, range [0, 2^128 - 1]).\n * Output type: U16 (bigint, range [0, 65535]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u128Value = assertU128(50000n);\n * const u16Value = convertU128ToU16(u128Value); // OK\n *\n * convertU128ToU16(assertU128(70000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU16ToU128} for the inverse widening conversion\n */\nexport function convertU128ToU16(value: U128): U16 {\n assertU128(value);\n if (value > U16_MAX) {\n throw new ConversionError(`Value exceeds U16 maximum of ${String(U16_MAX)}`, {\n sourceValue: value,\n sourceType: \"U128\",\n targetType: \"U16\",\n reason: `Value must be <= ${String(U16_MAX)}`,\n });\n }\n assertU16(value);\n return value;\n}\n\n/**\n * Converts a U128 to U32 (narrowing conversion).\n *\n * @public\n * @param value - The U128 value to convert (must be in range [0, 2^32 - 1])\n * @returns The value re-branded as U32\n * @throws {ConversionError} If value exceeds U32_MAX (4294967295)\n *\n * @remarks\n * Input type: U128 (bigint, range [0, 2^128 - 1]).\n * Output type: U32 (bigint, range [0, 4294967295]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u128Value = assertU128(4000000000n);\n * const u32Value = convertU128ToU32(u128Value); // OK\n *\n * convertU128ToU32(assertU128(5000000000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU32ToU128} for the inverse widening conversion\n */\nexport function convertU128ToU32(value: U128): U32 {\n assertU128(value);\n if (value > U32_MAX) {\n throw new ConversionError(`Value exceeds U32 maximum of ${String(U32_MAX)}`, {\n sourceValue: value,\n sourceType: \"U128\",\n targetType: \"U32\",\n reason: `Value must be <= ${String(U32_MAX)}`,\n });\n }\n assertU32(value);\n return value;\n}\n\n/**\n * Converts a U128 to U64 (narrowing conversion).\n *\n * @public\n * @param value - The U128 value to convert (must be in range [0, 2^64 - 1])\n * @returns The value re-branded as U64\n * @throws {ConversionError} If value exceeds U64_MAX (2^64 - 1)\n *\n * @remarks\n * Input type: U128 (bigint, range [0, 2^128 - 1]).\n * Output type: U64 (bigint, range [0, 2^64 - 1]).\n * Direction: narrowing — throws if value does not fit in the target range.\n * Commonly used when extracting the low 64 bits of a U128 after an arithmetic operation.\n *\n * @example\n * ```typescript\n * const u128Value = assertU128(18446744073709551615n); // U64_MAX\n * const u64Value = convertU128ToU64(u128Value); // OK\n *\n * convertU128ToU64(assertU128(18446744073709551616n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU64ToU128} for the inverse widening conversion\n */\nexport function convertU128ToU64(value: U128): U64 {\n assertU128(value);\n if (value > U64_MAX) {\n throw new ConversionError(`Value exceeds U64 maximum`, {\n sourceValue: value,\n sourceType: \"U128\",\n targetType: \"U64\",\n reason: `Value must be <= 2^64 - 1`,\n });\n }\n assertU64(value);\n return value;\n}\n\n/**\n * Converts a U256 to U8 (narrowing conversion).\n *\n * @public\n * @param value - The U256 value to convert (must be in range [0, 255])\n * @returns The value re-branded as U8\n * @throws {ConversionError} If value exceeds U8_MAX (255)\n *\n * @remarks\n * Input type: U256 (bigint, range [0, 2^256 - 1]).\n * Output type: U8 (bigint, range [0, 255]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u256Value = assertU256(128n);\n * const u8Value = convertU256ToU8(u256Value); // OK\n *\n * convertU256ToU8(assertU256(300n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU8ToU256} for the inverse widening conversion\n */\nexport function convertU256ToU8(value: U256): U8 {\n assertU256(value);\n if (value > U8_MAX) {\n throw new ConversionError(`Value exceeds U8 maximum of ${String(U8_MAX)}`, {\n sourceValue: value,\n sourceType: \"U256\",\n targetType: \"U8\",\n reason: `Value must be <= ${String(U8_MAX)}`,\n });\n }\n assertU8(value);\n return value;\n}\n\n/**\n * Converts a U256 to U16 (narrowing conversion).\n *\n * @public\n * @param value - The U256 value to convert (must be in range [0, 65535])\n * @returns The value re-branded as U16\n * @throws {ConversionError} If value exceeds U16_MAX (65535)\n *\n * @remarks\n * Input type: U256 (bigint, range [0, 2^256 - 1]).\n * Output type: U16 (bigint, range [0, 65535]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u256Value = assertU256(1000n);\n * const u16Value = convertU256ToU16(u256Value); // OK\n *\n * convertU256ToU16(assertU256(100000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU16ToU256} for the inverse widening conversion\n */\nexport function convertU256ToU16(value: U256): U16 {\n assertU256(value);\n if (value > U16_MAX) {\n throw new ConversionError(`Value exceeds U16 maximum of ${String(U16_MAX)}`, {\n sourceValue: value,\n sourceType: \"U256\",\n targetType: \"U16\",\n reason: `Value must be <= ${String(U16_MAX)}`,\n });\n }\n assertU16(value);\n return value;\n}\n\n/**\n * Converts a U256 to U32 (narrowing conversion).\n *\n * @public\n * @param value - The U256 value to convert (must be in range [0, 2^32 - 1])\n * @returns The value re-branded as U32\n * @throws {ConversionError} If value exceeds U32_MAX (4294967295)\n *\n * @remarks\n * Input type: U256 (bigint, range [0, 2^256 - 1]).\n * Output type: U32 (bigint, range [0, 4294967295]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u256Value = assertU256(100000n);\n * const u32Value = convertU256ToU32(u256Value); // OK\n *\n * convertU256ToU32(assertU256(2n ** 33n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU32ToU256} for the inverse widening conversion\n */\nexport function convertU256ToU32(value: U256): U32 {\n assertU256(value);\n if (value > U32_MAX) {\n throw new ConversionError(`Value exceeds U32 maximum of ${String(U32_MAX)}`, {\n sourceValue: value,\n sourceType: \"U256\",\n targetType: \"U32\",\n reason: `Value must be <= ${String(U32_MAX)}`,\n });\n }\n assertU32(value);\n return value;\n}\n\n/**\n * Converts a U256 to U64 (narrowing conversion).\n *\n * @public\n * @param value - The U256 value to convert (must be in range [0, 2^64 - 1])\n * @returns The value re-branded as U64\n * @throws {ConversionError} If value exceeds U64_MAX (2^64 - 1)\n *\n * @remarks\n * Input type: U256 (bigint, range [0, 2^256 - 1]).\n * Output type: U64 (bigint, range [0, 2^64 - 1]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * const u256Value = assertU256(18446744073709551615n); // U64_MAX\n * const u64Value = convertU256ToU64(u256Value); // OK\n *\n * convertU256ToU64(assertU256(2n ** 64n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU64ToU256} for the inverse widening conversion\n */\nexport function convertU256ToU64(value: U256): U64 {\n assertU256(value);\n if (value > U64_MAX) {\n throw new ConversionError(`Value exceeds U64 maximum`, {\n sourceValue: value,\n sourceType: \"U256\",\n targetType: \"U64\",\n reason: `Value must be <= 2^64 - 1`,\n });\n }\n assertU64(value);\n return value;\n}\n\n/**\n * Converts a U256 to U128 (narrowing conversion).\n *\n * @public\n * @param value - The U256 value to convert (must be in range [0, 2^128 - 1])\n * @returns The value re-branded as U128\n * @throws {ConversionError} If value exceeds U128_MAX (2^128 - 1)\n *\n * @remarks\n * Input type: U256 (bigint, range [0, 2^256 - 1]).\n * Output type: U128 (bigint, range [0, 2^128 - 1]).\n * Direction: narrowing — throws if value does not fit in the target range.\n * Commonly used to extract the low 128 bits from a U256 after arithmetic.\n *\n * @example\n * ```typescript\n * const u256Value = assertU256(2n ** 100n);\n * const u128Value = convertU256ToU128(u256Value); // OK: 2^100 < 2^128\n *\n * convertU256ToU128(assertU256(2n ** 128n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU128ToU256} for the inverse widening conversion\n */\nexport function convertU256ToU128(value: U256): U128 {\n assertU256(value);\n if (value > U128_MAX) {\n throw new ConversionError(`Value exceeds U128 maximum`, {\n sourceValue: value,\n sourceType: \"U256\",\n targetType: \"U128\",\n reason: `Value must be <= 2^128 - 1`,\n });\n }\n assertU128(value);\n return value;\n}\n\n/**\n * Converts a U512 to U8 (narrowing conversion).\n *\n * @public\n * @param value - The U512 value to convert (must be in range [0, 255])\n * @returns The value re-branded as U8\n * @throws {ConversionError} If value exceeds U8_MAX (255)\n *\n * @remarks\n * Input type: U512 (bigint, range [0, 2^512 - 1]).\n * Output type: U8 (bigint, range [0, 255]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU512ToU8(assertU512(200n)); // OK\n * convertU512ToU8(assertU512(256n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU8ToU512} for the inverse widening conversion\n */\nexport function convertU512ToU8(value: U512): U8 {\n assertU512(value);\n if (value > U8_MAX) {\n throw new ConversionError(`Value exceeds U8 maximum of ${String(U8_MAX)}`, {\n sourceValue: value,\n sourceType: \"U512\",\n targetType: \"U8\",\n reason: `Value must be <= ${String(U8_MAX)}`,\n });\n }\n assertU8(value);\n return value;\n}\n\n/**\n * Converts a U512 to U16 (narrowing conversion).\n *\n * @public\n * @param value - The U512 value to convert (must be in range [0, 65535])\n * @returns The value re-branded as U16\n * @throws {ConversionError} If value exceeds U16_MAX (65535)\n *\n * @remarks\n * Input type: U512 (bigint, range [0, 2^512 - 1]).\n * Output type: U16 (bigint, range [0, 65535]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU512ToU16(assertU512(8080n)); // OK\n * convertU512ToU16(assertU512(70000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU16ToU512} for the inverse widening conversion\n */\nexport function convertU512ToU16(value: U512): U16 {\n assertU512(value);\n if (value > U16_MAX) {\n throw new ConversionError(`Value exceeds U16 maximum of ${String(U16_MAX)}`, {\n sourceValue: value,\n sourceType: \"U512\",\n targetType: \"U16\",\n reason: `Value must be <= ${String(U16_MAX)}`,\n });\n }\n assertU16(value);\n return value;\n}\n\n/**\n * Converts a U512 to U32 (narrowing conversion).\n *\n * @public\n * @param value - The U512 value to convert (must be in range [0, 2^32 - 1])\n * @returns The value re-branded as U32\n * @throws {ConversionError} If value exceeds U32_MAX (4294967295)\n *\n * @remarks\n * Input type: U512 (bigint, range [0, 2^512 - 1]).\n * Output type: U32 (bigint, range [0, 4294967295]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU512ToU32(assertU512(4294967295n)); // OK: U32_MAX\n * convertU512ToU32(assertU512(4294967296n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU32ToU512} for the inverse widening conversion\n */\nexport function convertU512ToU32(value: U512): U32 {\n assertU512(value);\n if (value > U32_MAX) {\n throw new ConversionError(`Value exceeds U32 maximum of ${String(U32_MAX)}`, {\n sourceValue: value,\n sourceType: \"U512\",\n targetType: \"U32\",\n reason: `Value must be <= ${String(U32_MAX)}`,\n });\n }\n assertU32(value);\n return value;\n}\n\n/**\n * Converts a U512 to U64 (narrowing conversion).\n *\n * @public\n * @param value - The U512 value to convert (must be in range [0, 2^64 - 1])\n * @returns The value re-branded as U64\n * @throws {ConversionError} If value exceeds U64_MAX (2^64 - 1)\n *\n * @remarks\n * Input type: U512 (bigint, range [0, 2^512 - 1]).\n * Output type: U64 (bigint, range [0, 2^64 - 1]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU512ToU64(assertU512(18446744073709551615n)); // OK: U64_MAX\n * convertU512ToU64(assertU512(2n ** 64n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU64ToU512} for the inverse widening conversion\n */\nexport function convertU512ToU64(value: U512): U64 {\n assertU512(value);\n if (value > U64_MAX) {\n throw new ConversionError(`Value exceeds U64 maximum`, {\n sourceValue: value,\n sourceType: \"U512\",\n targetType: \"U64\",\n reason: `Value must be <= 2^64 - 1`,\n });\n }\n assertU64(value);\n return value;\n}\n\n/**\n * Converts a U512 to U128 (narrowing conversion).\n *\n * @public\n * @param value - The U512 value to convert (must be in range [0, 2^128 - 1])\n * @returns The value re-branded as U128\n * @throws {ConversionError} If value exceeds U128_MAX (2^128 - 1)\n *\n * @remarks\n * Input type: U512 (bigint, range [0, 2^512 - 1]).\n * Output type: U128 (bigint, range [0, 2^128 - 1]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU512ToU128(assertU512(2n ** 100n)); // OK\n * convertU512ToU128(assertU512(2n ** 128n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU128ToU512} for the inverse widening conversion\n */\nexport function convertU512ToU128(value: U512): U128 {\n assertU512(value);\n if (value > U128_MAX) {\n throw new ConversionError(`Value exceeds U128 maximum`, {\n sourceValue: value,\n sourceType: \"U512\",\n targetType: \"U128\",\n reason: `Value must be <= 2^128 - 1`,\n });\n }\n assertU128(value);\n return value;\n}\n\n/**\n * Converts a U512 to U256 (narrowing conversion).\n *\n * @public\n * @param value - The U512 value to convert (must be in range [0, 2^256 - 1])\n * @returns The value re-branded as U256\n * @throws {ConversionError} If value exceeds U256_MAX (2^256 - 1)\n *\n * @remarks\n * Input type: U512 (bigint, range [0, 2^512 - 1]).\n * Output type: U256 (bigint, range [0, 2^256 - 1]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU512ToU256(assertU512(2n ** 200n)); // OK\n * convertU512ToU256(assertU512(2n ** 256n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU256ToU512} for the inverse widening conversion\n */\nexport function convertU512ToU256(value: U512): U256 {\n assertU512(value);\n if (value > U256_MAX) {\n throw new ConversionError(`Value exceeds U256 maximum`, {\n sourceValue: value,\n sourceType: \"U512\",\n targetType: \"U256\",\n reason: `Value must be <= 2^256 - 1`,\n });\n }\n assertU256(value);\n return value;\n}\n\n/**\n * Converts a U1024 to U8 (narrowing conversion).\n *\n * @public\n * @param value - The U1024 value to convert (must be in range [0, 255])\n * @returns The value re-branded as U8\n * @throws {ConversionError} If value exceeds U8_MAX (255)\n *\n * @remarks\n * Input type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Output type: U8 (bigint, range [0, 255]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU1024ToU8(assertU1024(100n)); // OK\n * convertU1024ToU8(assertU1024(256n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU8ToU1024} for the inverse widening conversion\n */\nexport function convertU1024ToU8(value: U1024): U8 {\n assertU1024(value);\n if (value > U8_MAX) {\n throw new ConversionError(`Value exceeds U8 maximum of ${String(U8_MAX)}`, {\n sourceValue: value,\n sourceType: \"U1024\",\n targetType: \"U8\",\n reason: `Value must be <= ${String(U8_MAX)}`,\n });\n }\n assertU8(value);\n return value;\n}\n\n/**\n * Converts a U1024 to U16 (narrowing conversion).\n *\n * @public\n * @param value - The U1024 value to convert (must be in range [0, 65535])\n * @returns The value re-branded as U16\n * @throws {ConversionError} If value exceeds U16_MAX (65535)\n *\n * @remarks\n * Input type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Output type: U16 (bigint, range [0, 65535]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU1024ToU16(assertU1024(9000n)); // OK\n * convertU1024ToU16(assertU1024(70000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU16ToU1024} for the inverse widening conversion\n */\nexport function convertU1024ToU16(value: U1024): U16 {\n assertU1024(value);\n if (value > U16_MAX) {\n throw new ConversionError(`Value exceeds U16 maximum of ${String(U16_MAX)}`, {\n sourceValue: value,\n sourceType: \"U1024\",\n targetType: \"U16\",\n reason: `Value must be <= ${String(U16_MAX)}`,\n });\n }\n assertU16(value);\n return value;\n}\n\n/**\n * Converts a U1024 to U32 (narrowing conversion).\n *\n * @public\n * @param value - The U1024 value to convert (must be in range [0, 2^32 - 1])\n * @returns The value re-branded as U32\n * @throws {ConversionError} If value exceeds U32_MAX (4294967295)\n *\n * @remarks\n * Input type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Output type: U32 (bigint, range [0, 4294967295]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU1024ToU32(assertU1024(4294967295n)); // OK: U32_MAX\n * convertU1024ToU32(assertU1024(4294967296n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU32ToU1024} for the inverse widening conversion\n */\nexport function convertU1024ToU32(value: U1024): U32 {\n assertU1024(value);\n if (value > U32_MAX) {\n throw new ConversionError(`Value exceeds U32 maximum of ${String(U32_MAX)}`, {\n sourceValue: value,\n sourceType: \"U1024\",\n targetType: \"U32\",\n reason: `Value must be <= ${String(U32_MAX)}`,\n });\n }\n assertU32(value);\n return value;\n}\n\n/**\n * Converts a U1024 to U64 (narrowing conversion).\n *\n * @public\n * @param value - The U1024 value to convert (must be in range [0, 2^64 - 1])\n * @returns The value re-branded as U64\n * @throws {ConversionError} If value exceeds U64_MAX (2^64 - 1)\n *\n * @remarks\n * Input type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Output type: U64 (bigint, range [0, 2^64 - 1]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU1024ToU64(assertU1024(18446744073709551615n)); // OK: U64_MAX\n * convertU1024ToU64(assertU1024(2n ** 64n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU64ToU1024} for the inverse widening conversion\n */\nexport function convertU1024ToU64(value: U1024): U64 {\n assertU1024(value);\n if (value > U64_MAX) {\n throw new ConversionError(`Value exceeds U64 maximum`, {\n sourceValue: value,\n sourceType: \"U1024\",\n targetType: \"U64\",\n reason: `Value must be <= 2^64 - 1`,\n });\n }\n assertU64(value);\n return value;\n}\n\n/**\n * Converts a U1024 to U128 (narrowing conversion).\n *\n * @public\n * @param value - The U1024 value to convert (must be in range [0, 2^128 - 1])\n * @returns The value re-branded as U128\n * @throws {ConversionError} If value exceeds U128_MAX (2^128 - 1)\n *\n * @remarks\n * Input type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Output type: U128 (bigint, range [0, 2^128 - 1]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU1024ToU128(assertU1024(2n ** 100n)); // OK\n * convertU1024ToU128(assertU1024(2n ** 128n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU128ToU1024} for the inverse widening conversion\n */\nexport function convertU1024ToU128(value: U1024): U128 {\n assertU1024(value);\n if (value > U128_MAX) {\n throw new ConversionError(`Value exceeds U128 maximum`, {\n sourceValue: value,\n sourceType: \"U1024\",\n targetType: \"U128\",\n reason: `Value must be <= 2^128 - 1`,\n });\n }\n assertU128(value);\n return value;\n}\n\n/**\n * Converts a U1024 to U256 (narrowing conversion).\n *\n * @public\n * @param value - The U1024 value to convert (must be in range [0, 2^256 - 1])\n * @returns The value re-branded as U256\n * @throws {ConversionError} If value exceeds U256_MAX (2^256 - 1)\n *\n * @remarks\n * Input type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Output type: U256 (bigint, range [0, 2^256 - 1]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU1024ToU256(assertU1024(2n ** 200n)); // OK\n * convertU1024ToU256(assertU1024(2n ** 256n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU256ToU1024} for the inverse widening conversion\n */\nexport function convertU1024ToU256(value: U1024): U256 {\n assertU1024(value);\n if (value > U256_MAX) {\n throw new ConversionError(`Value exceeds U256 maximum`, {\n sourceValue: value,\n sourceType: \"U1024\",\n targetType: \"U256\",\n reason: `Value must be <= 2^256 - 1`,\n });\n }\n assertU256(value);\n return value;\n}\n\n/**\n * Converts a U1024 to U512 (narrowing conversion).\n *\n * @public\n * @param value - The U1024 value to convert (must be in range [0, 2^512 - 1])\n * @returns The value re-branded as U512\n * @throws {ConversionError} If value exceeds U512_MAX (2^512 - 1)\n *\n * @remarks\n * Input type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Output type: U512 (bigint, range [0, 2^512 - 1]).\n * Direction: narrowing — throws if value does not fit in the target range.\n *\n * @example\n * ```typescript\n * convertU1024ToU512(assertU1024(2n ** 400n)); // OK\n * convertU1024ToU512(assertU1024(2n ** 512n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU512ToU1024} for the inverse widening conversion\n */\nexport function convertU1024ToU512(value: U1024): U512 {\n assertU1024(value);\n if (value > U512_MAX) {\n throw new ConversionError(`Value exceeds U512 maximum`, {\n sourceValue: value,\n sourceType: \"U1024\",\n targetType: \"U512\",\n reason: `Value must be <= 2^512 - 1`,\n });\n }\n assertU512(value);\n return value;\n}\n\n/* =============================================================================\n * SIGNED INTEGER WIDENING CONVERSIONS\n * ============================================================================= */\n\n/**\n * Converts an I8 to I16 (widening conversion).\n *\n * @public\n * @param value - The I8 value to convert (range [-128, 127])\n * @returns The identical numeric value re-branded as I16 (range [-32768, 32767])\n *\n * @remarks\n * Input type: I8 (bigint, range [-128, 127]).\n * Output type: I16 (bigint, range [-32768, 32767]).\n * Direction: widening — every I8 value fits in I16; no range check is performed.\n * Negative values remain negative; the sign is preserved.\n *\n * @example\n * ```typescript\n * const i8Value = assertI8(-100n);\n * const i16Value = convertI8ToI16(i8Value); // -100n as I16\n * ```\n *\n * @see {@link convertI16ToI8} for the inverse narrowing conversion\n */\nexport function convertI8ToI16(value: I8): I16 {\n assertI8(value);\n assertI16(value);\n return value;\n}\n\n/**\n * Converts an I8 to I32 (widening conversion).\n *\n * @public\n * @param value - The I8 value to convert (range [-128, 127])\n * @returns The identical numeric value re-branded as I32 (range [-2^31, 2^31 - 1])\n *\n * @remarks\n * Input type: I8 (bigint, range [-128, 127]).\n * Output type: I32 (bigint, range [-2147483648, 2147483647]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i8Value = assertI8(-1n);\n * const i32Value = convertI8ToI32(i8Value); // -1n as I32\n * ```\n *\n * @see {@link convertI32ToI8} for the inverse narrowing conversion\n */\nexport function convertI8ToI32(value: I8): I32 {\n assertI8(value);\n assertI32(value);\n return value;\n}\n\n/**\n * Converts an I8 to I64 (widening conversion).\n *\n * @public\n * @param value - The I8 value to convert (range [-128, 127])\n * @returns The identical numeric value re-branded as I64 (range [-2^63, 2^63 - 1])\n *\n * @remarks\n * Input type: I8 (bigint, range [-128, 127]).\n * Output type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i8Value = assertI8(127n);\n * const i64Value = convertI8ToI64(i8Value); // 127n as I64\n * ```\n *\n * @see {@link convertI64ToI8} for the inverse narrowing conversion\n */\nexport function convertI8ToI64(value: I8): I64 {\n assertI8(value);\n assertI64(value);\n return value;\n}\n\n/**\n * Converts an I8 to I128 (widening conversion).\n *\n * @public\n * @param value - The I8 value to convert (range [-128, 127])\n * @returns The identical numeric value re-branded as I128 (range [-2^127, 2^127 - 1])\n *\n * @remarks\n * Input type: I8 (bigint, range [-128, 127]).\n * Output type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i8Value = assertI8(-128n); // I8_MIN\n * const i128Value = convertI8ToI128(i8Value); // -128n as I128\n * ```\n *\n * @see {@link convertI128ToI8} for the inverse narrowing conversion\n */\nexport function convertI8ToI128(value: I8): I128 {\n assertI8(value);\n assertI128(value);\n return value;\n}\n\n/**\n * Converts an I8 to I256 (widening conversion).\n *\n * @public\n * @param value - The I8 value to convert (range [-128, 127])\n * @returns The identical numeric value re-branded as I256 (range [-2^255, 2^255 - 1])\n *\n * @remarks\n * Input type: I8 (bigint, range [-128, 127]).\n * Output type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i8Value = assertI8(0n);\n * const i256Value = convertI8ToI256(i8Value); // 0n as I256\n * ```\n *\n * @see {@link convertI256ToI8} for the inverse narrowing conversion\n */\nexport function convertI8ToI256(value: I8): I256 {\n assertI8(value);\n assertI256(value);\n return value;\n}\n\n/**\n * Converts an I8 to I512 (widening conversion).\n *\n * @public\n * @param value - The I8 value to convert (range [-128, 127])\n * @returns The identical numeric value re-branded as I512 (range [-2^511, 2^511 - 1])\n *\n * @remarks\n * Input type: I8 (bigint, range [-128, 127]).\n * Output type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i8Value = assertI8(50n);\n * const i512Value = convertI8ToI512(i8Value); // 50n as I512\n * ```\n *\n * @see {@link convertI512ToI8} for the inverse narrowing conversion\n */\nexport function convertI8ToI512(value: I8): I512 {\n assertI8(value);\n assertI512(value);\n return value;\n}\n\n/**\n * Converts an I8 to I1024 (widening conversion).\n *\n * @public\n * @param value - The I8 value to convert (range [-128, 127])\n * @returns The identical numeric value re-branded as I1024 (range [-2^1023, 2^1023 - 1])\n *\n * @remarks\n * Input type: I8 (bigint, range [-128, 127]).\n * Output type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i8Value = assertI8(-50n);\n * const i1024Value = convertI8ToI1024(i8Value); // -50n as I1024\n * ```\n *\n * @see {@link convertI1024ToI8} for the inverse narrowing conversion\n */\nexport function convertI8ToI1024(value: I8): I1024 {\n assertI8(value);\n assertI1024(value);\n return value;\n}\n\n/**\n * Converts an I16 to I32 (widening conversion).\n *\n * @public\n * @param value - The I16 value to convert (range [-32768, 32767])\n * @returns The identical numeric value re-branded as I32 (range [-2^31, 2^31 - 1])\n *\n * @remarks\n * Input type: I16 (bigint, range [-32768, 32767]).\n * Output type: I32 (bigint, range [-2^31, 2^31 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i16Value = assertI16(-32768n); // I16_MIN\n * const i32Value = convertI16ToI32(i16Value); // -32768n as I32\n * ```\n *\n * @see {@link convertI32ToI16} for the inverse narrowing conversion\n */\nexport function convertI16ToI32(value: I16): I32 {\n assertI16(value);\n assertI32(value);\n return value;\n}\n\n/**\n * Converts an I16 to I64 (widening conversion).\n *\n * @public\n * @param value - The I16 value to convert (range [-32768, 32767])\n * @returns The identical numeric value re-branded as I64 (range [-2^63, 2^63 - 1])\n *\n * @remarks\n * Input type: I16 (bigint, range [-32768, 32767]).\n * Output type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i16Value = assertI16(32767n); // I16_MAX\n * const i64Value = convertI16ToI64(i16Value); // 32767n as I64\n * ```\n *\n * @see {@link convertI64ToI16} for the inverse narrowing conversion\n */\nexport function convertI16ToI64(value: I16): I64 {\n assertI16(value);\n assertI64(value);\n return value;\n}\n\n/**\n * Converts an I16 to I128 (widening conversion).\n *\n * @public\n * @param value - The I16 value to convert (range [-32768, 32767])\n * @returns The identical numeric value re-branded as I128 (range [-2^127, 2^127 - 1])\n *\n * @remarks\n * Input type: I16 (bigint, range [-32768, 32767]).\n * Output type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i16Value = assertI16(-1n);\n * const i128Value = convertI16ToI128(i16Value); // -1n as I128\n * ```\n *\n * @see {@link convertI128ToI16} for the inverse narrowing conversion\n */\nexport function convertI16ToI128(value: I16): I128 {\n assertI16(value);\n assertI128(value);\n return value;\n}\n\n/**\n * Converts an I16 to I256 (widening conversion).\n *\n * @public\n * @param value - The I16 value to convert (range [-32768, 32767])\n * @returns The identical numeric value re-branded as I256 (range [-2^255, 2^255 - 1])\n *\n * @remarks\n * Input type: I16 (bigint, range [-32768, 32767]).\n * Output type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i16Value = assertI16(0n);\n * const i256Value = convertI16ToI256(i16Value); // 0n as I256\n * ```\n *\n * @see {@link convertI256ToI16} for the inverse narrowing conversion\n */\nexport function convertI16ToI256(value: I16): I256 {\n assertI16(value);\n assertI256(value);\n return value;\n}\n\n/**\n * Converts an I16 to I512 (widening conversion).\n *\n * @public\n * @param value - The I16 value to convert (range [-32768, 32767])\n * @returns The identical numeric value re-branded as I512 (range [-2^511, 2^511 - 1])\n *\n * @remarks\n * Input type: I16 (bigint, range [-32768, 32767]).\n * Output type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i16Value = assertI16(1000n);\n * const i512Value = convertI16ToI512(i16Value); // 1000n as I512\n * ```\n *\n * @see {@link convertI512ToI16} for the inverse narrowing conversion\n */\nexport function convertI16ToI512(value: I16): I512 {\n assertI16(value);\n assertI512(value);\n return value;\n}\n\n/**\n * Converts an I16 to I1024 (widening conversion).\n *\n * @public\n * @param value - The I16 value to convert (range [-32768, 32767])\n * @returns The identical numeric value re-branded as I1024 (range [-2^1023, 2^1023 - 1])\n *\n * @remarks\n * Input type: I16 (bigint, range [-32768, 32767]).\n * Output type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i16Value = assertI16(-500n);\n * const i1024Value = convertI16ToI1024(i16Value); // -500n as I1024\n * ```\n *\n * @see {@link convertI1024ToI16} for the inverse narrowing conversion\n */\nexport function convertI16ToI1024(value: I16): I1024 {\n assertI16(value);\n assertI1024(value);\n return value;\n}\n\n/**\n * Converts an I32 to I64 (widening conversion).\n *\n * @public\n * @param value - The I32 value to convert (range [-2^31, 2^31 - 1])\n * @returns The identical numeric value re-branded as I64 (range [-2^63, 2^63 - 1])\n *\n * @remarks\n * Input type: I32 (bigint, range [-2147483648, 2147483647]).\n * Output type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i32Value = assertI32(-2147483648n); // I32_MIN\n * const i64Value = convertI32ToI64(i32Value); // -2147483648n as I64\n * ```\n *\n * @see {@link convertI64ToI32} for the inverse narrowing conversion\n */\nexport function convertI32ToI64(value: I32): I64 {\n assertI32(value);\n assertI64(value);\n return value;\n}\n\n/**\n * Converts an I32 to I128 (widening conversion).\n *\n * @public\n * @param value - The I32 value to convert (range [-2^31, 2^31 - 1])\n * @returns The identical numeric value re-branded as I128 (range [-2^127, 2^127 - 1])\n *\n * @remarks\n * Input type: I32 (bigint, range [-2147483648, 2147483647]).\n * Output type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i32Value = assertI32(42n);\n * const i128Value = convertI32ToI128(i32Value); // 42n as I128\n * ```\n *\n * @see {@link convertI128ToI32} for the inverse narrowing conversion\n */\nexport function convertI32ToI128(value: I32): I128 {\n assertI32(value);\n assertI128(value);\n return value;\n}\n\n/**\n * Converts an I32 to I256 (widening conversion).\n *\n * @public\n * @param value - The I32 value to convert (range [-2^31, 2^31 - 1])\n * @returns The identical numeric value re-branded as I256 (range [-2^255, 2^255 - 1])\n *\n * @remarks\n * Input type: I32 (bigint, range [-2147483648, 2147483647]).\n * Output type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i32Value = assertI32(-1000n);\n * const i256Value = convertI32ToI256(i32Value); // -1000n as I256\n * ```\n *\n * @see {@link convertI256ToI32} for the inverse narrowing conversion\n */\nexport function convertI32ToI256(value: I32): I256 {\n assertI32(value);\n assertI256(value);\n return value;\n}\n\n/**\n * Converts an I32 to I512 (widening conversion).\n *\n * @public\n * @param value - The I32 value to convert (range [-2^31, 2^31 - 1])\n * @returns The identical numeric value re-branded as I512 (range [-2^511, 2^511 - 1])\n *\n * @remarks\n * Input type: I32 (bigint, range [-2147483648, 2147483647]).\n * Output type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i32Value = assertI32(2147483647n); // I32_MAX\n * const i512Value = convertI32ToI512(i32Value); // 2147483647n as I512\n * ```\n *\n * @see {@link convertI512ToI32} for the inverse narrowing conversion\n */\nexport function convertI32ToI512(value: I32): I512 {\n assertI32(value);\n assertI512(value);\n return value;\n}\n\n/**\n * Converts an I32 to I1024 (widening conversion).\n *\n * @public\n * @param value - The I32 value to convert (range [-2^31, 2^31 - 1])\n * @returns The identical numeric value re-branded as I1024 (range [-2^1023, 2^1023 - 1])\n *\n * @remarks\n * Input type: I32 (bigint, range [-2147483648, 2147483647]).\n * Output type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i32Value = assertI32(-100n);\n * const i1024Value = convertI32ToI1024(i32Value); // -100n as I1024\n * ```\n *\n * @see {@link convertI1024ToI32} for the inverse narrowing conversion\n */\nexport function convertI32ToI1024(value: I32): I1024 {\n assertI32(value);\n assertI1024(value);\n return value;\n}\n\n/**\n * Converts an I64 to I128 (widening conversion).\n *\n * @public\n * @param value - The I64 value to convert (range [-2^63, 2^63 - 1])\n * @returns The identical numeric value re-branded as I128 (range [-2^127, 2^127 - 1])\n *\n * @remarks\n * Input type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Output type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i64Value = assertI64(-9223372036854775808n); // I64_MIN\n * const i128Value = convertI64ToI128(i64Value); // same value as I128\n * ```\n *\n * @see {@link convertI128ToI64} for the inverse narrowing conversion\n */\nexport function convertI64ToI128(value: I64): I128 {\n assertI64(value);\n assertI128(value);\n return value;\n}\n\n/**\n * Converts an I64 to I256 (widening conversion).\n *\n * @public\n * @param value - The I64 value to convert (range [-2^63, 2^63 - 1])\n * @returns The identical numeric value re-branded as I256 (range [-2^255, 2^255 - 1])\n *\n * @remarks\n * Input type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Output type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i64Value = assertI64(1000n);\n * const i256Value = convertI64ToI256(i64Value); // 1000n as I256\n * ```\n *\n * @see {@link convertI256ToI64} for the inverse narrowing conversion\n */\nexport function convertI64ToI256(value: I64): I256 {\n assertI64(value);\n assertI256(value);\n return value;\n}\n\n/**\n * Converts an I64 to I512 (widening conversion).\n *\n * @public\n * @param value - The I64 value to convert (range [-2^63, 2^63 - 1])\n * @returns The identical numeric value re-branded as I512 (range [-2^511, 2^511 - 1])\n *\n * @remarks\n * Input type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Output type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i64Value = assertI64(-1n);\n * const i512Value = convertI64ToI512(i64Value); // -1n as I512\n * ```\n *\n * @see {@link convertI512ToI64} for the inverse narrowing conversion\n */\nexport function convertI64ToI512(value: I64): I512 {\n assertI64(value);\n assertI512(value);\n return value;\n}\n\n/**\n * Converts an I64 to I1024 (widening conversion).\n *\n * @public\n * @param value - The I64 value to convert (range [-2^63, 2^63 - 1])\n * @returns The identical numeric value re-branded as I1024 (range [-2^1023, 2^1023 - 1])\n *\n * @remarks\n * Input type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Output type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i64Value = assertI64(500n);\n * const i1024Value = convertI64ToI1024(i64Value); // 500n as I1024\n * ```\n *\n * @see {@link convertI1024ToI64} for the inverse narrowing conversion\n */\nexport function convertI64ToI1024(value: I64): I1024 {\n assertI64(value);\n assertI1024(value);\n return value;\n}\n\n/**\n * Converts an I128 to I256 (widening conversion).\n *\n * @public\n * @param value - The I128 value to convert (range [-2^127, 2^127 - 1])\n * @returns The identical numeric value re-branded as I256 (range [-2^255, 2^255 - 1])\n *\n * @remarks\n * Input type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Output type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i128Value = assertI128(-1n);\n * const i256Value = convertI128ToI256(i128Value); // -1n as I256\n * ```\n *\n * @see {@link convertI256ToI128} for the inverse narrowing conversion\n */\nexport function convertI128ToI256(value: I128): I256 {\n assertI128(value);\n assertI256(value);\n return value;\n}\n\n/**\n * Converts an I128 to I512 (widening conversion).\n *\n * @public\n * @param value - The I128 value to convert (range [-2^127, 2^127 - 1])\n * @returns The identical numeric value re-branded as I512 (range [-2^511, 2^511 - 1])\n *\n * @remarks\n * Input type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Output type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i128Value = assertI128(999n);\n * const i512Value = convertI128ToI512(i128Value); // 999n as I512\n * ```\n *\n * @see {@link convertI512ToI128} for the inverse narrowing conversion\n */\nexport function convertI128ToI512(value: I128): I512 {\n assertI128(value);\n assertI512(value);\n return value;\n}\n\n/**\n * Converts an I128 to I1024 (widening conversion).\n *\n * @public\n * @param value - The I128 value to convert (range [-2^127, 2^127 - 1])\n * @returns The identical numeric value re-branded as I1024 (range [-2^1023, 2^1023 - 1])\n *\n * @remarks\n * Input type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Output type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i128Value = assertI128(-42n);\n * const i1024Value = convertI128ToI1024(i128Value); // -42n as I1024\n * ```\n *\n * @see {@link convertI1024ToI128} for the inverse narrowing conversion\n */\nexport function convertI128ToI1024(value: I128): I1024 {\n assertI128(value);\n assertI1024(value);\n return value;\n}\n\n/**\n * Converts an I256 to I512 (widening conversion).\n *\n * @public\n * @param value - The I256 value to convert (range [-2^255, 2^255 - 1])\n * @returns The identical numeric value re-branded as I512 (range [-2^511, 2^511 - 1])\n *\n * @remarks\n * Input type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Output type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i256Value = assertI256(-(2n ** 200n));\n * const i512Value = convertI256ToI512(i256Value); // same value as I512\n * ```\n *\n * @see {@link convertI512ToI256} for the inverse narrowing conversion\n */\nexport function convertI256ToI512(value: I256): I512 {\n assertI256(value);\n assertI512(value);\n return value;\n}\n\n/**\n * Converts an I256 to I1024 (widening conversion).\n *\n * @public\n * @param value - The I256 value to convert (range [-2^255, 2^255 - 1])\n * @returns The identical numeric value re-branded as I1024 (range [-2^1023, 2^1023 - 1])\n *\n * @remarks\n * Input type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Output type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i256Value = assertI256(1n);\n * const i1024Value = convertI256ToI1024(i256Value); // 1n as I1024\n * ```\n *\n * @see {@link convertI1024ToI256} for the inverse narrowing conversion\n */\nexport function convertI256ToI1024(value: I256): I1024 {\n assertI256(value);\n assertI1024(value);\n return value;\n}\n\n/**\n * Converts an I512 to I1024 (widening conversion).\n *\n * @public\n * @param value - The I512 value to convert (range [-2^511, 2^511 - 1])\n * @returns The identical numeric value re-branded as I1024 (range [-2^1023, 2^1023 - 1])\n *\n * @remarks\n * Input type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Output type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Direction: widening — always safe, no range check needed.\n *\n * @example\n * ```typescript\n * const i512Value = assertI512(2n ** 300n);\n * const i1024Value = convertI512ToI1024(i512Value); // same value as I1024\n * ```\n *\n * @see {@link convertI1024ToI512} for the inverse narrowing conversion\n */\nexport function convertI512ToI1024(value: I512): I1024 {\n assertI512(value);\n assertI1024(value);\n return value;\n}\n\n/* =============================================================================\n * SIGNED INTEGER NARROWING CONVERSIONS\n * ============================================================================= */\n\n/**\n * Converts an I16 to I8 (narrowing conversion).\n *\n * @public\n * @param value - The I16 value to convert (must be in range [-128, 127])\n * @returns The value re-branded as I8\n * @throws {ConversionError} If value is outside I8 range ([-128, 127])\n *\n * @remarks\n * Input type: I16 (bigint, range [-32768, 32767]).\n * Output type: I8 (bigint, range [-128, 127]).\n * Direction: narrowing — throws if the value cannot be represented as I8.\n * Both the lower bound (< -128) and upper bound (> 127) are checked.\n *\n * @example\n * ```typescript\n * convertI16ToI8(assertI16(100n)); // OK: 100n as I8\n * convertI16ToI8(assertI16(-100n)); // OK: -100n as I8\n * convertI16ToI8(assertI16(200n)); // Throws ConversionError: 200 > 127\n * convertI16ToI8(assertI16(-200n)); // Throws ConversionError: -200 < -128\n * ```\n *\n * @see {@link convertI8ToI16} for the inverse widening conversion\n */\nexport function convertI16ToI8(value: I16): I8 {\n assertI16(value);\n if (value < I8_MIN || value > I8_MAX) {\n throw new ConversionError(\n `Value ${String(value)} is out of range for I8 [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I16\",\n targetType: \"I8\",\n reason: `Value must be in range [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n },\n );\n }\n assertI8(value);\n return value;\n}\n\n/**\n * Converts an I32 to I8 (narrowing conversion).\n *\n * @public\n * @param value - The I32 value to convert (must be in range [-128, 127])\n * @returns The value re-branded as I8\n * @throws {ConversionError} If value is outside I8 range ([-128, 127])\n *\n * @remarks\n * Input type: I32 (bigint, range [-2^31, 2^31 - 1]).\n * Output type: I8 (bigint, range [-128, 127]).\n * Direction: narrowing — throws if the value cannot be represented as I8.\n *\n * @example\n * ```typescript\n * convertI32ToI8(assertI32(-1n)); // OK: -1n as I8\n * convertI32ToI8(assertI32(1000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI8ToI32} for the inverse widening conversion\n */\nexport function convertI32ToI8(value: I32): I8 {\n assertI32(value);\n if (value < I8_MIN || value > I8_MAX) {\n throw new ConversionError(\n `Value ${String(value)} is out of range for I8 [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I32\",\n targetType: \"I8\",\n reason: `Value must be in range [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n },\n );\n }\n assertI8(value);\n return value;\n}\n\n/**\n * Converts an I32 to I16 (narrowing conversion).\n *\n * @public\n * @param value - The I32 value to convert (must be in range [-32768, 32767])\n * @returns The value re-branded as I16\n * @throws {ConversionError} If value is outside I16 range ([-32768, 32767])\n *\n * @remarks\n * Input type: I32 (bigint, range [-2^31, 2^31 - 1]).\n * Output type: I16 (bigint, range [-32768, 32767]).\n * Direction: narrowing — throws if the value cannot be represented as I16.\n *\n * @example\n * ```typescript\n * convertI32ToI16(assertI32(-30000n)); // OK\n * convertI32ToI16(assertI32(40000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI16ToI32} for the inverse widening conversion\n */\nexport function convertI32ToI16(value: I32): I16 {\n assertI32(value);\n if (value < I16_MIN || value > I16_MAX) {\n throw new ConversionError(\n `Value ${String(value)} is out of range for I16 [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I32\",\n targetType: \"I16\",\n reason: `Value must be in range [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n },\n );\n }\n assertI16(value);\n return value;\n}\n\n/**\n * Converts an I64 to I8 (narrowing conversion).\n *\n * @public\n * @param value - The I64 value to convert (must be in range [-128, 127])\n * @returns The value re-branded as I8\n * @throws {ConversionError} If value is outside I8 range ([-128, 127])\n *\n * @remarks\n * Input type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Output type: I8 (bigint, range [-128, 127]).\n * Direction: narrowing — throws if the value cannot be represented as I8.\n *\n * @example\n * ```typescript\n * convertI64ToI8(assertI64(0n)); // OK\n * convertI64ToI8(assertI64(1000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI8ToI64} for the inverse widening conversion\n */\nexport function convertI64ToI8(value: I64): I8 {\n assertI64(value);\n if (value < I8_MIN || value > I8_MAX) {\n throw new ConversionError(\n `Value ${String(value)} is out of range for I8 [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I64\",\n targetType: \"I8\",\n reason: `Value must be in range [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n },\n );\n }\n assertI8(value);\n return value;\n}\n\n/**\n * Converts an I64 to I16 (narrowing conversion).\n *\n * @public\n * @param value - The I64 value to convert (must be in range [-32768, 32767])\n * @returns The value re-branded as I16\n * @throws {ConversionError} If value is outside I16 range ([-32768, 32767])\n *\n * @remarks\n * Input type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Output type: I16 (bigint, range [-32768, 32767]).\n * Direction: narrowing — throws if the value cannot be represented as I16.\n *\n * @example\n * ```typescript\n * convertI64ToI16(assertI64(-1000n)); // OK\n * convertI64ToI16(assertI64(50000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI16ToI64} for the inverse widening conversion\n */\nexport function convertI64ToI16(value: I64): I16 {\n assertI64(value);\n if (value < I16_MIN || value > I16_MAX) {\n throw new ConversionError(\n `Value ${String(value)} is out of range for I16 [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I64\",\n targetType: \"I16\",\n reason: `Value must be in range [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n },\n );\n }\n assertI16(value);\n return value;\n}\n\n/**\n * Converts an I64 to I32 (narrowing conversion).\n *\n * @public\n * @param value - The I64 value to convert (must be in range [-2^31, 2^31 - 1])\n * @returns The value re-branded as I32\n * @throws {ConversionError} If value is outside I32 range ([-2147483648, 2147483647])\n *\n * @remarks\n * Input type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Output type: I32 (bigint, range [-2^31, 2^31 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I32.\n *\n * @example\n * ```typescript\n * convertI64ToI32(assertI64(2147483647n)); // OK: I32_MAX\n * convertI64ToI32(assertI64(2147483648n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI32ToI64} for the inverse widening conversion\n */\nexport function convertI64ToI32(value: I64): I32 {\n assertI64(value);\n if (value < I32_MIN || value > I32_MAX) {\n throw new ConversionError(\n `Value ${String(value)} is out of range for I32 [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I64\",\n targetType: \"I32\",\n reason: `Value must be in range [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n },\n );\n }\n assertI32(value);\n return value;\n}\n\n/**\n * Converts an I128 to I8 (narrowing conversion).\n *\n * @public\n * @param value - The I128 value to convert (must be in range [-128, 127])\n * @returns The value re-branded as I8\n * @throws {ConversionError} If value is outside I8 range ([-128, 127])\n *\n * @remarks\n * Input type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Output type: I8 (bigint, range [-128, 127]).\n * Direction: narrowing — throws if the value cannot be represented as I8.\n *\n * @example\n * ```typescript\n * convertI128ToI8(assertI128(-128n)); // OK: I8_MIN\n * convertI128ToI8(assertI128(128n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI8ToI128} for the inverse widening conversion\n */\nexport function convertI128ToI8(value: I128): I8 {\n assertI128(value);\n if (value < I8_MIN || value > I8_MAX) {\n throw new ConversionError(\n `Value is out of range for I8 [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I128\",\n targetType: \"I8\",\n reason: `Value must be in range [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n },\n );\n }\n assertI8(value);\n return value;\n}\n\n/**\n * Converts an I128 to I16 (narrowing conversion).\n *\n * @public\n * @param value - The I128 value to convert (must be in range [-32768, 32767])\n * @returns The value re-branded as I16\n * @throws {ConversionError} If value is outside I16 range ([-32768, 32767])\n *\n * @remarks\n * Input type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Output type: I16 (bigint, range [-32768, 32767]).\n * Direction: narrowing — throws if the value cannot be represented as I16.\n *\n * @example\n * ```typescript\n * convertI128ToI16(assertI128(32767n)); // OK: I16_MAX\n * convertI128ToI16(assertI128(32768n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI16ToI128} for the inverse widening conversion\n */\nexport function convertI128ToI16(value: I128): I16 {\n assertI128(value);\n if (value < I16_MIN || value > I16_MAX) {\n throw new ConversionError(\n `Value is out of range for I16 [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I128\",\n targetType: \"I16\",\n reason: `Value must be in range [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n },\n );\n }\n assertI16(value);\n return value;\n}\n\n/**\n * Converts an I128 to I32 (narrowing conversion).\n *\n * @public\n * @param value - The I128 value to convert (must be in range [-2^31, 2^31 - 1])\n * @returns The value re-branded as I32\n * @throws {ConversionError} If value is outside I32 range ([-2147483648, 2147483647])\n *\n * @remarks\n * Input type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Output type: I32 (bigint, range [-2^31, 2^31 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I32.\n *\n * @example\n * ```typescript\n * convertI128ToI32(assertI128(-2147483648n)); // OK: I32_MIN\n * convertI128ToI32(assertI128(-2147483649n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI32ToI128} for the inverse widening conversion\n */\nexport function convertI128ToI32(value: I128): I32 {\n assertI128(value);\n if (value < I32_MIN || value > I32_MAX) {\n throw new ConversionError(\n `Value is out of range for I32 [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I128\",\n targetType: \"I32\",\n reason: `Value must be in range [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n },\n );\n }\n assertI32(value);\n return value;\n}\n\n/**\n * Converts an I128 to I64 (narrowing conversion).\n *\n * @public\n * @param value - The I128 value to convert (must be in range [-2^63, 2^63 - 1])\n * @returns The value re-branded as I64\n * @throws {ConversionError} If value is outside I64 range ([-2^63, 2^63 - 1])\n *\n * @remarks\n * Input type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Output type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I64.\n *\n * @example\n * ```typescript\n * convertI128ToI64(assertI128(9223372036854775807n)); // OK: I64_MAX\n * convertI128ToI64(assertI128(9223372036854775808n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI64ToI128} for the inverse widening conversion\n */\nexport function convertI128ToI64(value: I128): I64 {\n assertI128(value);\n if (value < I64_MIN || value > I64_MAX) {\n throw new ConversionError(`Value is out of range for I64`, {\n sourceValue: value,\n sourceType: \"I128\",\n targetType: \"I64\",\n reason: `Value must be in range [-2^63, 2^63 - 1]`,\n });\n }\n assertI64(value);\n return value;\n}\n\n/**\n * Converts an I256 to I8 (narrowing conversion).\n *\n * @public\n * @param value - The I256 value to convert (must be in range [-128, 127])\n * @returns The value re-branded as I8\n * @throws {ConversionError} If value is outside I8 range ([-128, 127])\n *\n * @remarks\n * Input type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Output type: I8 (bigint, range [-128, 127]).\n * Direction: narrowing — throws if the value cannot be represented as I8.\n *\n * @example\n * ```typescript\n * convertI256ToI8(assertI256(-50n)); // OK\n * convertI256ToI8(assertI256(200n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI8ToI256} for the inverse widening conversion\n */\nexport function convertI256ToI8(value: I256): I8 {\n assertI256(value);\n if (value < I8_MIN || value > I8_MAX) {\n throw new ConversionError(\n `Value is out of range for I8 [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I256\",\n targetType: \"I8\",\n reason: `Value must be in range [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n },\n );\n }\n assertI8(value);\n return value;\n}\n\n/**\n * Converts an I256 to I16 (narrowing conversion).\n *\n * @public\n * @param value - The I256 value to convert (must be in range [-32768, 32767])\n * @returns The value re-branded as I16\n * @throws {ConversionError} If value is outside I16 range ([-32768, 32767])\n *\n * @remarks\n * Input type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Output type: I16 (bigint, range [-32768, 32767]).\n * Direction: narrowing — throws if the value cannot be represented as I16.\n *\n * @example\n * ```typescript\n * convertI256ToI16(assertI256(-32768n)); // OK: I16_MIN\n * convertI256ToI16(assertI256(32768n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI16ToI256} for the inverse widening conversion\n */\nexport function convertI256ToI16(value: I256): I16 {\n assertI256(value);\n if (value < I16_MIN || value > I16_MAX) {\n throw new ConversionError(\n `Value is out of range for I16 [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I256\",\n targetType: \"I16\",\n reason: `Value must be in range [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n },\n );\n }\n assertI16(value);\n return value;\n}\n\n/**\n * Converts an I256 to I32 (narrowing conversion).\n *\n * @public\n * @param value - The I256 value to convert (must be in range [-2^31, 2^31 - 1])\n * @returns The value re-branded as I32\n * @throws {ConversionError} If value is outside I32 range ([-2147483648, 2147483647])\n *\n * @remarks\n * Input type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Output type: I32 (bigint, range [-2^31, 2^31 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I32.\n *\n * @example\n * ```typescript\n * convertI256ToI32(assertI256(-1n)); // OK\n * convertI256ToI32(assertI256(2n ** 40n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI32ToI256} for the inverse widening conversion\n */\nexport function convertI256ToI32(value: I256): I32 {\n assertI256(value);\n if (value < I32_MIN || value > I32_MAX) {\n throw new ConversionError(\n `Value is out of range for I32 [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I256\",\n targetType: \"I32\",\n reason: `Value must be in range [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n },\n );\n }\n assertI32(value);\n return value;\n}\n\n/**\n * Converts an I256 to I64 (narrowing conversion).\n *\n * @public\n * @param value - The I256 value to convert (must be in range [-2^63, 2^63 - 1])\n * @returns The value re-branded as I64\n * @throws {ConversionError} If value is outside I64 range ([-2^63, 2^63 - 1])\n *\n * @remarks\n * Input type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Output type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I64.\n *\n * @example\n * ```typescript\n * convertI256ToI64(assertI256(-9223372036854775808n)); // OK: I64_MIN\n * convertI256ToI64(assertI256(-(2n ** 64n))); // Throws ConversionError\n * ```\n *\n * @see {@link convertI64ToI256} for the inverse widening conversion\n */\nexport function convertI256ToI64(value: I256): I64 {\n assertI256(value);\n if (value < I64_MIN || value > I64_MAX) {\n throw new ConversionError(`Value is out of range for I64`, {\n sourceValue: value,\n sourceType: \"I256\",\n targetType: \"I64\",\n reason: `Value must be in range [-2^63, 2^63 - 1]`,\n });\n }\n assertI64(value);\n return value;\n}\n\n/**\n * Converts an I256 to I128 (narrowing conversion).\n *\n * @public\n * @param value - The I256 value to convert (must be in range [-2^127, 2^127 - 1])\n * @returns The value re-branded as I128\n * @throws {ConversionError} If value is outside I128 range ([-2^127, 2^127 - 1])\n *\n * @remarks\n * Input type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Output type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I128.\n *\n * @example\n * ```typescript\n * convertI256ToI128(assertI256(2n ** 100n)); // OK\n * convertI256ToI128(assertI256(2n ** 128n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI128ToI256} for the inverse widening conversion\n */\nexport function convertI256ToI128(value: I256): I128 {\n assertI256(value);\n if (value < I128_MIN || value > I128_MAX) {\n throw new ConversionError(`Value is out of range for I128`, {\n sourceValue: value,\n sourceType: \"I256\",\n targetType: \"I128\",\n reason: `Value must be in range [-2^127, 2^127 - 1]`,\n });\n }\n assertI128(value);\n return value;\n}\n\n/**\n * Converts an I512 to I8 (narrowing conversion).\n *\n * @public\n * @param value - The I512 value to convert (must be in range [-128, 127])\n * @returns The value re-branded as I8\n * @throws {ConversionError} If value is outside I8 range ([-128, 127])\n *\n * @remarks\n * Input type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Output type: I8 (bigint, range [-128, 127]).\n * Direction: narrowing — throws if the value cannot be represented as I8.\n *\n * @example\n * ```typescript\n * convertI512ToI8(assertI512(50n)); // OK\n * convertI512ToI8(assertI512(200n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI8ToI512} for the inverse widening conversion\n */\nexport function convertI512ToI8(value: I512): I8 {\n assertI512(value);\n if (value < I8_MIN || value > I8_MAX) {\n throw new ConversionError(\n `Value is out of range for I8 [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I512\",\n targetType: \"I8\",\n reason: `Value must be in range [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n },\n );\n }\n assertI8(value);\n return value;\n}\n\n/**\n * Converts an I512 to I16 (narrowing conversion).\n *\n * @public\n * @param value - The I512 value to convert (must be in range [-32768, 32767])\n * @returns The value re-branded as I16\n * @throws {ConversionError} If value is outside I16 range ([-32768, 32767])\n *\n * @remarks\n * Input type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Output type: I16 (bigint, range [-32768, 32767]).\n * Direction: narrowing — throws if the value cannot be represented as I16.\n *\n * @example\n * ```typescript\n * convertI512ToI16(assertI512(10000n)); // OK\n * convertI512ToI16(assertI512(40000n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI16ToI512} for the inverse widening conversion\n */\nexport function convertI512ToI16(value: I512): I16 {\n assertI512(value);\n if (value < I16_MIN || value > I16_MAX) {\n throw new ConversionError(\n `Value is out of range for I16 [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I512\",\n targetType: \"I16\",\n reason: `Value must be in range [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n },\n );\n }\n assertI16(value);\n return value;\n}\n\n/**\n * Converts an I512 to I32 (narrowing conversion).\n *\n * @public\n * @param value - The I512 value to convert (must be in range [-2^31, 2^31 - 1])\n * @returns The value re-branded as I32\n * @throws {ConversionError} If value is outside I32 range ([-2147483648, 2147483647])\n *\n * @remarks\n * Input type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Output type: I32 (bigint, range [-2^31, 2^31 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I32.\n *\n * @example\n * ```typescript\n * convertI512ToI32(assertI512(2147483647n)); // OK: I32_MAX\n * convertI512ToI32(assertI512(2147483648n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI32ToI512} for the inverse widening conversion\n */\nexport function convertI512ToI32(value: I512): I32 {\n assertI512(value);\n if (value < I32_MIN || value > I32_MAX) {\n throw new ConversionError(\n `Value is out of range for I32 [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I512\",\n targetType: \"I32\",\n reason: `Value must be in range [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n },\n );\n }\n assertI32(value);\n return value;\n}\n\n/**\n * Converts an I512 to I64 (narrowing conversion).\n *\n * @public\n * @param value - The I512 value to convert (must be in range [-2^63, 2^63 - 1])\n * @returns The value re-branded as I64\n * @throws {ConversionError} If value is outside I64 range ([-2^63, 2^63 - 1])\n *\n * @remarks\n * Input type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Output type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I64.\n *\n * @example\n * ```typescript\n * convertI512ToI64(assertI512(-1n)); // OK\n * convertI512ToI64(assertI512(2n ** 63n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI64ToI512} for the inverse widening conversion\n */\nexport function convertI512ToI64(value: I512): I64 {\n assertI512(value);\n if (value < I64_MIN || value > I64_MAX) {\n throw new ConversionError(`Value is out of range for I64`, {\n sourceValue: value,\n sourceType: \"I512\",\n targetType: \"I64\",\n reason: `Value must be in range [-2^63, 2^63 - 1]`,\n });\n }\n assertI64(value);\n return value;\n}\n\n/**\n * Converts an I512 to I128 (narrowing conversion).\n *\n * @public\n * @param value - The I512 value to convert (must be in range [-2^127, 2^127 - 1])\n * @returns The value re-branded as I128\n * @throws {ConversionError} If value is outside I128 range ([-2^127, 2^127 - 1])\n *\n * @remarks\n * Input type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Output type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I128.\n *\n * @example\n * ```typescript\n * convertI512ToI128(assertI512(-(2n ** 100n))); // OK\n * convertI512ToI128(assertI512(2n ** 128n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI128ToI512} for the inverse widening conversion\n */\nexport function convertI512ToI128(value: I512): I128 {\n assertI512(value);\n if (value < I128_MIN || value > I128_MAX) {\n throw new ConversionError(`Value is out of range for I128`, {\n sourceValue: value,\n sourceType: \"I512\",\n targetType: \"I128\",\n reason: `Value must be in range [-2^127, 2^127 - 1]`,\n });\n }\n assertI128(value);\n return value;\n}\n\n/**\n * Converts an I512 to I256 (narrowing conversion).\n *\n * @public\n * @param value - The I512 value to convert (must be in range [-2^255, 2^255 - 1])\n * @returns The value re-branded as I256\n * @throws {ConversionError} If value is outside I256 range ([-2^255, 2^255 - 1])\n *\n * @remarks\n * Input type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Output type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I256.\n *\n * @example\n * ```typescript\n * convertI512ToI256(assertI512(2n ** 200n)); // OK\n * convertI512ToI256(assertI512(2n ** 256n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI256ToI512} for the inverse widening conversion\n */\nexport function convertI512ToI256(value: I512): I256 {\n assertI512(value);\n if (value < I256_MIN || value > I256_MAX) {\n throw new ConversionError(`Value is out of range for I256`, {\n sourceValue: value,\n sourceType: \"I512\",\n targetType: \"I256\",\n reason: `Value must be in range [-2^255, 2^255 - 1]`,\n });\n }\n assertI256(value);\n return value;\n}\n\n/**\n * Converts an I1024 to I8 (narrowing conversion).\n *\n * @public\n * @param value - The I1024 value to convert (must be in range [-128, 127])\n * @returns The value re-branded as I8\n * @throws {ConversionError} If value is outside I8 range ([-128, 127])\n *\n * @remarks\n * Input type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Output type: I8 (bigint, range [-128, 127]).\n * Direction: narrowing — throws if the value cannot be represented as I8.\n *\n * @example\n * ```typescript\n * convertI1024ToI8(assertI1024(100n)); // OK\n * convertI1024ToI8(assertI1024(200n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI8ToI1024} for the inverse widening conversion\n */\nexport function convertI1024ToI8(value: I1024): I8 {\n assertI1024(value);\n if (value < I8_MIN || value > I8_MAX) {\n throw new ConversionError(\n `Value is out of range for I8 [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I1024\",\n targetType: \"I8\",\n reason: `Value must be in range [${String(I8_MIN)}, ${String(I8_MAX)}]`,\n },\n );\n }\n assertI8(value);\n return value;\n}\n\n/**\n * Converts an I1024 to I16 (narrowing conversion).\n *\n * @public\n * @param value - The I1024 value to convert (must be in range [-32768, 32767])\n * @returns The value re-branded as I16\n * @throws {ConversionError} If value is outside I16 range ([-32768, 32767])\n *\n * @remarks\n * Input type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Output type: I16 (bigint, range [-32768, 32767]).\n * Direction: narrowing — throws if the value cannot be represented as I16.\n *\n * @example\n * ```typescript\n * convertI1024ToI16(assertI1024(-32768n)); // OK: I16_MIN\n * convertI1024ToI16(assertI1024(32768n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI16ToI1024} for the inverse widening conversion\n */\nexport function convertI1024ToI16(value: I1024): I16 {\n assertI1024(value);\n if (value < I16_MIN || value > I16_MAX) {\n throw new ConversionError(\n `Value is out of range for I16 [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I1024\",\n targetType: \"I16\",\n reason: `Value must be in range [${String(I16_MIN)}, ${String(I16_MAX)}]`,\n },\n );\n }\n assertI16(value);\n return value;\n}\n\n/**\n * Converts an I1024 to I32 (narrowing conversion).\n *\n * @public\n * @param value - The I1024 value to convert (must be in range [-2^31, 2^31 - 1])\n * @returns The value re-branded as I32\n * @throws {ConversionError} If value is outside I32 range ([-2147483648, 2147483647])\n *\n * @remarks\n * Input type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Output type: I32 (bigint, range [-2^31, 2^31 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I32.\n *\n * @example\n * ```typescript\n * convertI1024ToI32(assertI1024(0n)); // OK\n * convertI1024ToI32(assertI1024(2n ** 32n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI32ToI1024} for the inverse widening conversion\n */\nexport function convertI1024ToI32(value: I1024): I32 {\n assertI1024(value);\n if (value < I32_MIN || value > I32_MAX) {\n throw new ConversionError(\n `Value is out of range for I32 [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n {\n sourceValue: value,\n sourceType: \"I1024\",\n targetType: \"I32\",\n reason: `Value must be in range [${String(I32_MIN)}, ${String(I32_MAX)}]`,\n },\n );\n }\n assertI32(value);\n return value;\n}\n\n/**\n * Converts an I1024 to I64 (narrowing conversion).\n *\n * @public\n * @param value - The I1024 value to convert (must be in range [-2^63, 2^63 - 1])\n * @returns The value re-branded as I64\n * @throws {ConversionError} If value is outside I64 range ([-2^63, 2^63 - 1])\n *\n * @remarks\n * Input type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Output type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I64.\n *\n * @example\n * ```typescript\n * convertI1024ToI64(assertI1024(-1n)); // OK\n * convertI1024ToI64(assertI1024(2n ** 63n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI64ToI1024} for the inverse widening conversion\n */\nexport function convertI1024ToI64(value: I1024): I64 {\n assertI1024(value);\n if (value < I64_MIN || value > I64_MAX) {\n throw new ConversionError(`Value is out of range for I64`, {\n sourceValue: value,\n sourceType: \"I1024\",\n targetType: \"I64\",\n reason: `Value must be in range [-2^63, 2^63 - 1]`,\n });\n }\n assertI64(value);\n return value;\n}\n\n/**\n * Converts an I1024 to I128 (narrowing conversion).\n *\n * @public\n * @param value - The I1024 value to convert (must be in range [-2^127, 2^127 - 1])\n * @returns The value re-branded as I128\n * @throws {ConversionError} If value is outside I128 range ([-2^127, 2^127 - 1])\n *\n * @remarks\n * Input type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Output type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I128.\n *\n * @example\n * ```typescript\n * convertI1024ToI128(assertI1024(2n ** 100n)); // OK\n * convertI1024ToI128(assertI1024(2n ** 128n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI128ToI1024} for the inverse widening conversion\n */\nexport function convertI1024ToI128(value: I1024): I128 {\n assertI1024(value);\n if (value < I128_MIN || value > I128_MAX) {\n throw new ConversionError(`Value is out of range for I128`, {\n sourceValue: value,\n sourceType: \"I1024\",\n targetType: \"I128\",\n reason: `Value must be in range [-2^127, 2^127 - 1]`,\n });\n }\n assertI128(value);\n return value;\n}\n\n/**\n * Converts an I1024 to I256 (narrowing conversion).\n *\n * @public\n * @param value - The I1024 value to convert (must be in range [-2^255, 2^255 - 1])\n * @returns The value re-branded as I256\n * @throws {ConversionError} If value is outside I256 range ([-2^255, 2^255 - 1])\n *\n * @remarks\n * Input type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Output type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I256.\n *\n * @example\n * ```typescript\n * convertI1024ToI256(assertI1024(2n ** 200n)); // OK\n * convertI1024ToI256(assertI1024(2n ** 256n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI256ToI1024} for the inverse widening conversion\n */\nexport function convertI1024ToI256(value: I1024): I256 {\n assertI1024(value);\n if (value < I256_MIN || value > I256_MAX) {\n throw new ConversionError(`Value is out of range for I256`, {\n sourceValue: value,\n sourceType: \"I1024\",\n targetType: \"I256\",\n reason: `Value must be in range [-2^255, 2^255 - 1]`,\n });\n }\n assertI256(value);\n return value;\n}\n\n/**\n * Converts an I1024 to I512 (narrowing conversion).\n *\n * @public\n * @param value - The I1024 value to convert (must be in range [-2^511, 2^511 - 1])\n * @returns The value re-branded as I512\n * @throws {ConversionError} If value is outside I512 range ([-2^511, 2^511 - 1])\n *\n * @remarks\n * Input type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Output type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Direction: narrowing — throws if the value cannot be represented as I512.\n *\n * @example\n * ```typescript\n * convertI1024ToI512(assertI1024(2n ** 400n)); // OK\n * convertI1024ToI512(assertI1024(2n ** 512n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI512ToI1024} for the inverse widening conversion\n */\nexport function convertI1024ToI512(value: I1024): I512 {\n assertI1024(value);\n if (value < I512_MIN || value > I512_MAX) {\n throw new ConversionError(`Value is out of range for I512`, {\n sourceValue: value,\n sourceType: \"I1024\",\n targetType: \"I512\",\n reason: `Value must be in range [-2^511, 2^511 - 1]`,\n });\n }\n assertI512(value);\n return value;\n}\n\n/* =============================================================================\n * SIGNED TO UNSIGNED CONVERSIONS\n *\n * These conversions fail if the signed value is negative.\n * ============================================================================= */\n\n/**\n * Converts an I8 to U8 (sign conversion).\n *\n * @public\n * @param value - The I8 value to convert (must be in range [0, 127])\n * @returns The value re-branded as U8\n * @throws {ConversionError} If value is negative (< 0)\n *\n * @remarks\n * Input type: I8 (bigint, range [-128, 127]).\n * Output type: U8 (bigint, range [0, 255]).\n * Direction: sign conversion — the numeric value is preserved but the type brand changes.\n * Throws if the signed value is negative; non-negative I8 values always fit in U8\n * since I8_MAX (127) <= U8_MAX (255).\n *\n * @example\n * ```typescript\n * convertI8ToU8(assertI8(127n)); // OK: 127n as U8\n * convertI8ToU8(assertI8(-1n)); // Throws ConversionError: cannot convert negative value\n * ```\n *\n * @see {@link convertU8ToI8} for the inverse sign conversion\n */\nexport function convertI8ToU8(value: I8): U8 {\n assertI8(value);\n if (value < 0n) {\n throw new ConversionError(`Cannot convert negative value ${String(value)} to unsigned type`, {\n sourceValue: value,\n sourceType: \"I8\",\n targetType: \"U8\",\n reason: \"Value must be non-negative\",\n });\n }\n assertU8(value);\n return value;\n}\n\n/**\n * Converts an I16 to U16 (sign conversion).\n *\n * @public\n * @param value - The I16 value to convert (must be in range [0, 32767])\n * @returns The value re-branded as U16\n * @throws {ConversionError} If value is negative (< 0)\n *\n * @remarks\n * Input type: I16 (bigint, range [-32768, 32767]).\n * Output type: U16 (bigint, range [0, 65535]).\n * Direction: sign conversion — throws if the signed value is negative.\n * Non-negative I16 values always fit in U16 since I16_MAX (32767) <= U16_MAX (65535).\n *\n * @example\n * ```typescript\n * convertI16ToU16(assertI16(32767n)); // OK: I16_MAX as U16\n * convertI16ToU16(assertI16(-1n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU16ToI16} for the inverse sign conversion\n */\nexport function convertI16ToU16(value: I16): U16 {\n assertI16(value);\n if (value < 0n) {\n throw new ConversionError(`Cannot convert negative value ${String(value)} to unsigned type`, {\n sourceValue: value,\n sourceType: \"I16\",\n targetType: \"U16\",\n reason: \"Value must be non-negative\",\n });\n }\n assertU16(value);\n return value;\n}\n\n/**\n * Converts an I32 to U32 (sign conversion).\n *\n * @public\n * @param value - The I32 value to convert (must be in range [0, 2147483647])\n * @returns The value re-branded as U32\n * @throws {ConversionError} If value is negative (< 0)\n *\n * @remarks\n * Input type: I32 (bigint, range [-2^31, 2^31 - 1]).\n * Output type: U32 (bigint, range [0, 2^32 - 1]).\n * Direction: sign conversion — throws if the signed value is negative.\n * Non-negative I32 values always fit in U32 since I32_MAX (2^31 - 1) <= U32_MAX (2^32 - 1).\n *\n * @example\n * ```typescript\n * convertI32ToU32(assertI32(2147483647n)); // OK: I32_MAX as U32\n * convertI32ToU32(assertI32(-1n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU32ToI32} for the inverse sign conversion\n */\nexport function convertI32ToU32(value: I32): U32 {\n assertI32(value);\n if (value < 0n) {\n throw new ConversionError(`Cannot convert negative value ${String(value)} to unsigned type`, {\n sourceValue: value,\n sourceType: \"I32\",\n targetType: \"U32\",\n reason: \"Value must be non-negative\",\n });\n }\n assertU32(value);\n return value;\n}\n\n/**\n * Converts an I64 to U64 (sign conversion).\n *\n * @public\n * @param value - The I64 value to convert (must be in range [0, 2^63 - 1])\n * @returns The value re-branded as U64\n * @throws {ConversionError} If value is negative (< 0)\n *\n * @remarks\n * Input type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Output type: U64 (bigint, range [0, 2^64 - 1]).\n * Direction: sign conversion — throws if the signed value is negative.\n * Non-negative I64 values always fit in U64 since I64_MAX (2^63 - 1) <= U64_MAX (2^64 - 1).\n *\n * @example\n * ```typescript\n * convertI64ToU64(assertI64(0n)); // OK: 0n as U64\n * convertI64ToU64(assertI64(-1n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU64ToI64} for the inverse sign conversion\n */\nexport function convertI64ToU64(value: I64): U64 {\n assertI64(value);\n if (value < 0n) {\n throw new ConversionError(`Cannot convert negative value to unsigned type`, {\n sourceValue: value,\n sourceType: \"I64\",\n targetType: \"U64\",\n reason: \"Value must be non-negative\",\n });\n }\n assertU64(value);\n return value;\n}\n\n/**\n * Converts an I128 to U128 (sign conversion).\n *\n * @public\n * @param value - The I128 value to convert (must be in range [0, 2^127 - 1])\n * @returns The value re-branded as U128\n * @throws {ConversionError} If value is negative (< 0)\n *\n * @remarks\n * Input type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Output type: U128 (bigint, range [0, 2^128 - 1]).\n * Direction: sign conversion — throws if the signed value is negative.\n * Non-negative I128 values always fit in U128 since I128_MAX < U128_MAX.\n *\n * @example\n * ```typescript\n * convertI128ToU128(assertI128(1n)); // OK\n * convertI128ToU128(assertI128(-1n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU128ToI128} for the inverse sign conversion\n */\nexport function convertI128ToU128(value: I128): U128 {\n assertI128(value);\n if (value < 0n) {\n throw new ConversionError(`Cannot convert negative value to unsigned type`, {\n sourceValue: value,\n sourceType: \"I128\",\n targetType: \"U128\",\n reason: \"Value must be non-negative\",\n });\n }\n assertU128(value);\n return value;\n}\n\n/**\n * Converts an I256 to U256 (sign conversion).\n *\n * @public\n * @param value - The I256 value to convert (must be in range [0, 2^255 - 1])\n * @returns The value re-branded as U256\n * @throws {ConversionError} If value is negative (< 0)\n *\n * @remarks\n * Input type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Output type: U256 (bigint, range [0, 2^256 - 1]).\n * Direction: sign conversion — throws if the signed value is negative.\n * This conversion is often used when converting a scalar field element from the\n * signed I256 domain to the unsigned U256 domain for cryptographic operations.\n *\n * @example\n * ```typescript\n * convertI256ToU256(assertI256(2n ** 200n)); // OK\n * convertI256ToU256(assertI256(-1n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU256ToI256} for the inverse sign conversion\n */\nexport function convertI256ToU256(value: I256): U256 {\n assertI256(value);\n if (value < 0n) {\n throw new ConversionError(`Cannot convert negative value to unsigned type`, {\n sourceValue: value,\n sourceType: \"I256\",\n targetType: \"U256\",\n reason: \"Value must be non-negative\",\n });\n }\n assertU256(value);\n return value;\n}\n\n/**\n * Converts an I512 to U512 (sign conversion).\n *\n * @public\n * @param value - The I512 value to convert (must be in range [0, 2^511 - 1])\n * @returns The value re-branded as U512\n * @throws {ConversionError} If value is negative (< 0)\n *\n * @remarks\n * Input type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Output type: U512 (bigint, range [0, 2^512 - 1]).\n * Direction: sign conversion — throws if the signed value is negative.\n *\n * @example\n * ```typescript\n * convertI512ToU512(assertI512(2n ** 400n)); // OK\n * convertI512ToU512(assertI512(-1n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU512ToI512} for the inverse sign conversion\n */\nexport function convertI512ToU512(value: I512): U512 {\n assertI512(value);\n if (value < 0n) {\n throw new ConversionError(`Cannot convert negative value to unsigned type`, {\n sourceValue: value,\n sourceType: \"I512\",\n targetType: \"U512\",\n reason: \"Value must be non-negative\",\n });\n }\n assertU512(value);\n return value;\n}\n\n/**\n * Converts an I1024 to U1024 (sign conversion).\n *\n * @public\n * @param value - The I1024 value to convert (must be in range [0, 2^1023 - 1])\n * @returns The value re-branded as U1024\n * @throws {ConversionError} If value is negative (< 0)\n *\n * @remarks\n * Input type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Output type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Direction: sign conversion — throws if the signed value is negative.\n *\n * @example\n * ```typescript\n * convertI1024ToU1024(assertI1024(2n ** 900n)); // OK\n * convertI1024ToU1024(assertI1024(-1n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertU1024ToI1024} for the inverse sign conversion\n */\nexport function convertI1024ToU1024(value: I1024): U1024 {\n assertI1024(value);\n if (value < 0n) {\n throw new ConversionError(`Cannot convert negative value to unsigned type`, {\n sourceValue: value,\n sourceType: \"I1024\",\n targetType: \"U1024\",\n reason: \"Value must be non-negative\",\n });\n }\n assertU1024(value);\n return value;\n}\n\n/* =============================================================================\n * UNSIGNED TO SIGNED CONVERSIONS\n *\n * These conversions fail if the unsigned value exceeds the signed maximum.\n * ============================================================================= */\n\n/**\n * Converts a U8 to I8 (sign conversion).\n *\n * @public\n * @param value - The U8 value to convert (must be in range [0, 127])\n * @returns The value re-branded as I8\n * @throws {ConversionError} If value exceeds I8_MAX (127)\n *\n * @remarks\n * Input type: U8 (bigint, range [0, 255]).\n * Output type: I8 (bigint, range [-128, 127]).\n * Direction: sign conversion — throws if value > I8_MAX because unsigned values\n * in [128, 255] cannot be represented as a non-negative I8.\n *\n * @example\n * ```typescript\n * convertU8ToI8(assertU8(127n)); // OK: 127n as I8\n * convertU8ToI8(assertU8(128n)); // Throws ConversionError: 128 > I8_MAX\n * ```\n *\n * @see {@link convertI8ToU8} for the inverse sign conversion\n */\nexport function convertU8ToI8(value: U8): I8 {\n assertU8(value);\n if (value > I8_MAX) {\n throw new ConversionError(`Value ${String(value)} exceeds I8 maximum of ${String(I8_MAX)}`, {\n sourceValue: value,\n sourceType: \"U8\",\n targetType: \"I8\",\n reason: `Value must be <= ${String(I8_MAX)}`,\n });\n }\n assertI8(value);\n return value;\n}\n\n/**\n * Converts a U16 to I16 (sign conversion).\n *\n * @public\n * @param value - The U16 value to convert (must be in range [0, 32767])\n * @returns The value re-branded as I16\n * @throws {ConversionError} If value exceeds I16_MAX (32767)\n *\n * @remarks\n * Input type: U16 (bigint, range [0, 65535]).\n * Output type: I16 (bigint, range [-32768, 32767]).\n * Direction: sign conversion — throws if value > I16_MAX because values\n * in [32768, 65535] cannot be represented as non-negative I16.\n *\n * @example\n * ```typescript\n * convertU16ToI16(assertU16(32767n)); // OK: I16_MAX as I16\n * convertU16ToI16(assertU16(32768n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI16ToU16} for the inverse sign conversion\n */\nexport function convertU16ToI16(value: U16): I16 {\n assertU16(value);\n if (value > I16_MAX) {\n throw new ConversionError(`Value ${String(value)} exceeds I16 maximum of ${String(I16_MAX)}`, {\n sourceValue: value,\n sourceType: \"U16\",\n targetType: \"I16\",\n reason: `Value must be <= ${String(I16_MAX)}`,\n });\n }\n assertI16(value);\n return value;\n}\n\n/**\n * Converts a U32 to I32 (sign conversion).\n *\n * @public\n * @param value - The U32 value to convert (must be in range [0, 2147483647])\n * @returns The value re-branded as I32\n * @throws {ConversionError} If value exceeds I32_MAX (2147483647)\n *\n * @remarks\n * Input type: U32 (bigint, range [0, 2^32 - 1]).\n * Output type: I32 (bigint, range [-2^31, 2^31 - 1]).\n * Direction: sign conversion — throws if value > I32_MAX.\n *\n * @example\n * ```typescript\n * convertU32ToI32(assertU32(2147483647n)); // OK: I32_MAX as I32\n * convertU32ToI32(assertU32(2147483648n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI32ToU32} for the inverse sign conversion\n */\nexport function convertU32ToI32(value: U32): I32 {\n assertU32(value);\n if (value > I32_MAX) {\n throw new ConversionError(`Value ${String(value)} exceeds I32 maximum of ${String(I32_MAX)}`, {\n sourceValue: value,\n sourceType: \"U32\",\n targetType: \"I32\",\n reason: `Value must be <= ${String(I32_MAX)}`,\n });\n }\n assertI32(value);\n return value;\n}\n\n/**\n * Converts a U64 to I64 (sign conversion).\n *\n * @public\n * @param value - The U64 value to convert (must be in range [0, 2^63 - 1])\n * @returns The value re-branded as I64\n * @throws {ConversionError} If value exceeds I64_MAX (2^63 - 1)\n *\n * @remarks\n * Input type: U64 (bigint, range [0, 2^64 - 1]).\n * Output type: I64 (bigint, range [-2^63, 2^63 - 1]).\n * Direction: sign conversion — throws if value > I64_MAX.\n *\n * @example\n * ```typescript\n * convertU64ToI64(assertU64(9223372036854775807n)); // OK: I64_MAX as I64\n * convertU64ToI64(assertU64(9223372036854775808n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI64ToU64} for the inverse sign conversion\n */\nexport function convertU64ToI64(value: U64): I64 {\n assertU64(value);\n if (value > I64_MAX) {\n throw new ConversionError(`Value exceeds I64 maximum`, {\n sourceValue: value,\n sourceType: \"U64\",\n targetType: \"I64\",\n reason: `Value must be <= 2^63 - 1`,\n });\n }\n assertI64(value);\n return value;\n}\n\n/**\n * Converts a U128 to I128 (sign conversion).\n *\n * @public\n * @param value - The U128 value to convert (must be in range [0, 2^127 - 1])\n * @returns The value re-branded as I128\n * @throws {ConversionError} If value exceeds I128_MAX (2^127 - 1)\n *\n * @remarks\n * Input type: U128 (bigint, range [0, 2^128 - 1]).\n * Output type: I128 (bigint, range [-2^127, 2^127 - 1]).\n * Direction: sign conversion — throws if value > I128_MAX.\n *\n * @example\n * ```typescript\n * convertU128ToI128(assertU128(2n ** 100n)); // OK\n * convertU128ToI128(assertU128(2n ** 127n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI128ToU128} for the inverse sign conversion\n */\nexport function convertU128ToI128(value: U128): I128 {\n assertU128(value);\n if (value > I128_MAX) {\n throw new ConversionError(`Value exceeds I128 maximum`, {\n sourceValue: value,\n sourceType: \"U128\",\n targetType: \"I128\",\n reason: `Value must be <= 2^127 - 1`,\n });\n }\n assertI128(value);\n return value;\n}\n\n/**\n * Converts a U256 to I256 (sign conversion).\n *\n * @public\n * @param value - The U256 value to convert (must be in range [0, 2^255 - 1])\n * @returns The value re-branded as I256\n * @throws {ConversionError} If value exceeds I256_MAX (2^255 - 1)\n *\n * @remarks\n * Input type: U256 (bigint, range [0, 2^256 - 1]).\n * Output type: I256 (bigint, range [-2^255, 2^255 - 1]).\n * Direction: sign conversion — throws if value > I256_MAX.\n * This conversion is used when a U256 field element must be treated as a signed\n * value, e.g. when working with balanced representations in cryptographic protocols.\n *\n * @example\n * ```typescript\n * convertU256ToI256(assertU256(2n ** 200n)); // OK\n * convertU256ToI256(assertU256(2n ** 255n)); // Throws ConversionError: equals I256_MAX + 1\n * ```\n *\n * @see {@link convertI256ToU256} for the inverse sign conversion\n */\nexport function convertU256ToI256(value: U256): I256 {\n assertU256(value);\n if (value > I256_MAX) {\n throw new ConversionError(`Value exceeds I256 maximum`, {\n sourceValue: value,\n sourceType: \"U256\",\n targetType: \"I256\",\n reason: `Value must be <= 2^255 - 1`,\n });\n }\n assertI256(value);\n return value;\n}\n\n/**\n * Converts a U512 to I512 (sign conversion).\n *\n * @public\n * @param value - The U512 value to convert (must be in range [0, 2^511 - 1])\n * @returns The value re-branded as I512\n * @throws {ConversionError} If value exceeds I512_MAX (2^511 - 1)\n *\n * @remarks\n * Input type: U512 (bigint, range [0, 2^512 - 1]).\n * Output type: I512 (bigint, range [-2^511, 2^511 - 1]).\n * Direction: sign conversion — throws if value > I512_MAX.\n *\n * @example\n * ```typescript\n * convertU512ToI512(assertU512(2n ** 400n)); // OK\n * convertU512ToI512(assertU512(2n ** 511n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI512ToU512} for the inverse sign conversion\n */\nexport function convertU512ToI512(value: U512): I512 {\n assertU512(value);\n if (value > I512_MAX) {\n throw new ConversionError(`Value exceeds I512 maximum`, {\n sourceValue: value,\n sourceType: \"U512\",\n targetType: \"I512\",\n reason: `Value must be <= 2^511 - 1`,\n });\n }\n assertI512(value);\n return value;\n}\n\n/**\n * Converts a U1024 to I1024 (sign conversion).\n *\n * @public\n * @param value - The U1024 value to convert (must be in range [0, 2^1023 - 1])\n * @returns The value re-branded as I1024\n * @throws {ConversionError} If value exceeds I1024_MAX (2^1023 - 1)\n *\n * @remarks\n * Input type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Output type: I1024 (bigint, range [-2^1023, 2^1023 - 1]).\n * Direction: sign conversion — throws if value > I1024_MAX.\n *\n * @example\n * ```typescript\n * convertU1024ToI1024(assertU1024(2n ** 900n)); // OK\n * convertU1024ToI1024(assertU1024(2n ** 1023n)); // Throws ConversionError\n * ```\n *\n * @see {@link convertI1024ToU1024} for the inverse sign conversion\n */\nexport function convertU1024ToI1024(value: U1024): I1024 {\n assertU1024(value);\n if (value > I1024_MAX) {\n throw new ConversionError(`Value exceeds I1024 maximum`, {\n sourceValue: value,\n sourceType: \"U1024\",\n targetType: \"I1024\",\n reason: `Value must be <= 2^1023 - 1`,\n });\n }\n assertI1024(value);\n return value;\n}\n\n/* =============================================================================\n * ENDIANNESS SWAP CONVERSIONS\n *\n * Convert between little-endian and big-endian byte arrays.\n * ============================================================================= */\n\n/**\n * Converts U8LeBytes to U8BeBytes (endianness swap).\n *\n * @public\n * @param value - The 1-byte little-endian representation to convert\n * @returns The identical byte array re-branded as U8BeBytes\n *\n * @remarks\n * Input type: U8LeBytes (Uint8Array of length 1, little-endian).\n * Output type: U8BeBytes (Uint8Array of length 1, big-endian).\n * For a single byte there is no meaningful distinction between LE and BE;\n * this function copies the byte and re-brands the type, acting as a\n * type-safe no-op. The numeric value encoded is unchanged.\n *\n * @example\n * ```typescript\n * const leBytes = encodeU8ToU8LeBytes(assertU8(42n));\n * const beBytes = convertU8LeBytesToU8BeBytes(leBytes); // same content, BE brand\n * ```\n *\n * @see {@link convertU8BeBytesToU8LeBytes} for the inverse conversion\n * @see {@link encodeU8ToU8LeBytes} to produce U8LeBytes from a U8 integer\n * @see {@link decodeU8LeBytesToU8} to decode U8LeBytes back to U8\n */\nexport function convertU8LeBytesToU8BeBytes(value: U8LeBytes): U8BeBytes {\n assertU8LeBytes(value);\n // Single byte - no actual swap needed, just re-brand\n const result = new Uint8Array(value);\n assertU8BeBytes(result);\n return result;\n}\n\n/**\n * Converts U8BeBytes to U8LeBytes (endianness swap).\n *\n * @public\n * @param value - The 1-byte big-endian representation to convert\n * @returns The identical byte array re-branded as U8LeBytes\n *\n * @remarks\n * Input type: U8BeBytes (Uint8Array of length 1, big-endian).\n * Output type: U8LeBytes (Uint8Array of length 1, little-endian).\n * For a single byte this is a type-safe no-op; the byte content is copied unchanged.\n *\n * @example\n * ```typescript\n * const beBytes = encodeU8ToU8BeBytes(assertU8(42n));\n * const leBytes = convertU8BeBytesToU8LeBytes(beBytes); // same content, LE brand\n * ```\n *\n * @see {@link convertU8LeBytesToU8BeBytes} for the inverse conversion\n * @see {@link encodeU8ToU8BeBytes} to produce U8BeBytes from a U8 integer\n * @see {@link decodeU8BeBytesToU8} to decode U8BeBytes back to U8\n */\nexport function convertU8BeBytesToU8LeBytes(value: U8BeBytes): U8LeBytes {\n assertU8BeBytes(value);\n const result = new Uint8Array(value);\n assertU8LeBytes(result);\n return result;\n}\n\n/**\n * Converts U16LeBytes to U16BeBytes (endianness swap).\n *\n * @public\n * @param value - The 2-byte little-endian representation to convert\n * @returns A new Uint8Array of length 2 with bytes in reversed (big-endian) order\n *\n * @remarks\n * Input type: U16LeBytes (Uint8Array of length 2, little-endian — byte[0] is LSB).\n * Output type: U16BeBytes (Uint8Array of length 2, big-endian — byte[0] is MSB).\n * The reversal is performed by writing `value[LENGTH-1-i]` into `result[i]` for\n * each index. The encoded integer value is preserved.\n *\n * @example\n * ```typescript\n * // Encoding 0x0102 in LE: [0x02, 0x01]\n * const leBytes = encodeU16ToU16LeBytes(assertU16(0x0102n));\n * const beBytes = convertU16LeBytesToU16BeBytes(leBytes); // [0x01, 0x02]\n * ```\n *\n * @see {@link convertU16BeBytesToU16LeBytes} for the inverse conversion\n * @see {@link encodeU16ToU16LeBytes} to encode U16 to LE bytes\n * @see {@link decodeU16BeBytesToU16} to decode the resulting BE bytes back to U16\n */\nexport function convertU16LeBytesToU16BeBytes(value: U16LeBytes): U16BeBytes {\n assertU16LeBytes(value);\n const result = new Uint8Array(U16_BYTE_LENGTH);\n for (let index = 0; index < U16_BYTE_LENGTH; index++) {\n result[index] = value[U16_BYTE_LENGTH - 1 - index];\n }\n assertU16BeBytes(result);\n return result;\n}\n\n/**\n * Converts U16BeBytes to U16LeBytes (endianness swap).\n *\n * @public\n * @param value - The 2-byte big-endian representation to convert\n * @returns A new Uint8Array of length 2 with bytes in reversed (little-endian) order\n *\n * @remarks\n * Input type: U16BeBytes (Uint8Array of length 2, big-endian — byte[0] is MSB).\n * Output type: U16LeBytes (Uint8Array of length 2, little-endian — byte[0] is LSB).\n * The reversal is performed by writing `value[LENGTH-1-i]` into `result[i]`.\n * The encoded integer value is preserved.\n *\n * @example\n * ```typescript\n * // Encoding 0x0102 in BE: [0x01, 0x02]\n * const beBytes = encodeU16ToU16BeBytes(assertU16(0x0102n));\n * const leBytes = convertU16BeBytesToU16LeBytes(beBytes); // [0x02, 0x01]\n * ```\n *\n * @see {@link convertU16LeBytesToU16BeBytes} for the inverse conversion\n * @see {@link encodeU16ToU16BeBytes} to encode U16 to BE bytes\n * @see {@link decodeU16LeBytesToU16} to decode the resulting LE bytes back to U16\n */\nexport function convertU16BeBytesToU16LeBytes(value: U16BeBytes): U16LeBytes {\n assertU16BeBytes(value);\n const result = new Uint8Array(U16_BYTE_LENGTH);\n for (let index = 0; index < U16_BYTE_LENGTH; index++) {\n result[index] = value[U16_BYTE_LENGTH - 1 - index];\n }\n assertU16LeBytes(result);\n return result;\n}\n\n/**\n * Converts U32LeBytes to U32BeBytes (endianness swap).\n *\n * @public\n * @param value - The 4-byte little-endian representation to convert\n * @returns A new Uint8Array of length 4 with bytes in reversed (big-endian) order\n *\n * @remarks\n * Input type: U32LeBytes (Uint8Array of length 4, little-endian — byte[0] is LSB).\n * Output type: U32BeBytes (Uint8Array of length 4, big-endian — byte[0] is MSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n *\n * @example\n * ```typescript\n * const leBytes = encodeU32ToU32LeBytes(assertU32(0x01020304n));\n * // leBytes = [0x04, 0x03, 0x02, 0x01]\n * const beBytes = convertU32LeBytesToU32BeBytes(leBytes);\n * // beBytes = [0x01, 0x02, 0x03, 0x04]\n * ```\n *\n * @see {@link convertU32BeBytesToU32LeBytes} for the inverse conversion\n */\nexport function convertU32LeBytesToU32BeBytes(value: U32LeBytes): U32BeBytes {\n assertU32LeBytes(value);\n const result = new Uint8Array(U32_BYTE_LENGTH);\n for (let index = 0; index < U32_BYTE_LENGTH; index++) {\n result[index] = value[U32_BYTE_LENGTH - 1 - index];\n }\n assertU32BeBytes(result);\n return result;\n}\n\n/**\n * Converts U32BeBytes to U32LeBytes (endianness swap).\n *\n * @public\n * @param value - The 4-byte big-endian representation to convert\n * @returns A new Uint8Array of length 4 with bytes in reversed (little-endian) order\n *\n * @remarks\n * Input type: U32BeBytes (Uint8Array of length 4, big-endian — byte[0] is MSB).\n * Output type: U32LeBytes (Uint8Array of length 4, little-endian — byte[0] is LSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n *\n * @example\n * ```typescript\n * const beBytes = encodeU32ToU32BeBytes(assertU32(0x01020304n));\n * // beBytes = [0x01, 0x02, 0x03, 0x04]\n * const leBytes = convertU32BeBytesToU32LeBytes(beBytes);\n * // leBytes = [0x04, 0x03, 0x02, 0x01]\n * ```\n *\n * @see {@link convertU32LeBytesToU32BeBytes} for the inverse conversion\n */\nexport function convertU32BeBytesToU32LeBytes(value: U32BeBytes): U32LeBytes {\n assertU32BeBytes(value);\n const result = new Uint8Array(U32_BYTE_LENGTH);\n for (let index = 0; index < U32_BYTE_LENGTH; index++) {\n result[index] = value[U32_BYTE_LENGTH - 1 - index];\n }\n assertU32LeBytes(result);\n return result;\n}\n\n/**\n * Converts U64LeBytes to U64BeBytes (endianness swap).\n *\n * @public\n * @param value - The 8-byte little-endian representation to convert\n * @returns A new Uint8Array of length 8 with bytes in reversed (big-endian) order\n *\n * @remarks\n * Input type: U64LeBytes (Uint8Array of length 8, little-endian — byte[0] is LSB).\n * Output type: U64BeBytes (Uint8Array of length 8, big-endian — byte[0] is MSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n * U64 LE encoding is the canonical format for Solana account lamport amounts and\n * other on-chain 64-bit values; BE is used in some cross-chain message formats.\n *\n * @example\n * ```typescript\n * const leBytes = encodeU64ToU64LeBytes(assertU64(1000n));\n * const beBytes = convertU64LeBytesToU64BeBytes(leBytes);\n * ```\n *\n * @see {@link convertU64BeBytesToU64LeBytes} for the inverse conversion\n */\nexport function convertU64LeBytesToU64BeBytes(value: U64LeBytes): U64BeBytes {\n assertU64LeBytes(value);\n const result = new Uint8Array(U64_BYTE_LENGTH);\n for (let index = 0; index < U64_BYTE_LENGTH; index++) {\n result[index] = value[U64_BYTE_LENGTH - 1 - index];\n }\n assertU64BeBytes(result);\n return result;\n}\n\n/**\n * Converts U64BeBytes to U64LeBytes (endianness swap).\n *\n * @public\n * @param value - The 8-byte big-endian representation to convert\n * @returns A new Uint8Array of length 8 with bytes in reversed (little-endian) order\n *\n * @remarks\n * Input type: U64BeBytes (Uint8Array of length 8, big-endian — byte[0] is MSB).\n * Output type: U64LeBytes (Uint8Array of length 8, little-endian — byte[0] is LSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n *\n * @example\n * ```typescript\n * const beBytes = encodeU64ToU64BeBytes(assertU64(1000n));\n * const leBytes = convertU64BeBytesToU64LeBytes(beBytes);\n * ```\n *\n * @see {@link convertU64LeBytesToU64BeBytes} for the inverse conversion\n */\nexport function convertU64BeBytesToU64LeBytes(value: U64BeBytes): U64LeBytes {\n assertU64BeBytes(value);\n const result = new Uint8Array(U64_BYTE_LENGTH);\n for (let index = 0; index < U64_BYTE_LENGTH; index++) {\n result[index] = value[U64_BYTE_LENGTH - 1 - index];\n }\n assertU64LeBytes(result);\n return result;\n}\n\n/**\n * Converts U128LeBytes to U128BeBytes (endianness swap).\n *\n * @public\n * @param value - The 16-byte little-endian representation to convert\n * @returns A new Uint8Array of length 16 with bytes in reversed (big-endian) order\n *\n * @remarks\n * Input type: U128LeBytes (Uint8Array of length 16, little-endian — byte[0] is LSB).\n * Output type: U128BeBytes (Uint8Array of length 16, big-endian — byte[0] is MSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n *\n * @example\n * ```typescript\n * const leBytes = encodeU128ToU128LeBytes(assertU128(2n ** 64n));\n * const beBytes = convertU128LeBytesToU128BeBytes(leBytes);\n * ```\n *\n * @see {@link convertU128BeBytesToU128LeBytes} for the inverse conversion\n */\nexport function convertU128LeBytesToU128BeBytes(value: U128LeBytes): U128BeBytes {\n assertU128LeBytes(value);\n const result = new Uint8Array(U128_BYTE_LENGTH);\n for (let index = 0; index < U128_BYTE_LENGTH; index++) {\n result[index] = value[U128_BYTE_LENGTH - 1 - index];\n }\n assertU128BeBytes(result);\n return result;\n}\n\n/**\n * Converts U128BeBytes to U128LeBytes (endianness swap).\n *\n * @public\n * @param value - The 16-byte big-endian representation to convert\n * @returns A new Uint8Array of length 16 with bytes in reversed (little-endian) order\n *\n * @remarks\n * Input type: U128BeBytes (Uint8Array of length 16, big-endian — byte[0] is MSB).\n * Output type: U128LeBytes (Uint8Array of length 16, little-endian — byte[0] is LSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n *\n * @example\n * ```typescript\n * const beBytes = encodeU128ToU128BeBytes(assertU128(2n ** 64n));\n * const leBytes = convertU128BeBytesToU128LeBytes(beBytes);\n * ```\n *\n * @see {@link convertU128LeBytesToU128BeBytes} for the inverse conversion\n */\nexport function convertU128BeBytesToU128LeBytes(value: U128BeBytes): U128LeBytes {\n assertU128BeBytes(value);\n const result = new Uint8Array(U128_BYTE_LENGTH);\n for (let index = 0; index < U128_BYTE_LENGTH; index++) {\n result[index] = value[U128_BYTE_LENGTH - 1 - index];\n }\n assertU128LeBytes(result);\n return result;\n}\n\n/**\n * Converts U256LeBytes to U256BeBytes (endianness swap).\n *\n * @public\n * @param value - The 32-byte little-endian representation to convert\n * @returns A new Uint8Array of length 32 with bytes in reversed (big-endian) order\n *\n * @remarks\n * Input type: U256LeBytes (Uint8Array of length 32, little-endian — byte[0] is LSB).\n * Output type: U256BeBytes (Uint8Array of length 32, big-endian — byte[0] is MSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n * This conversion is commonly used when bridging between Solana's LE storage\n * format and BN254/Groth16 proof verification which expects BE field elements.\n *\n * @example\n * ```typescript\n * const leBytes = encodeU256ToU256LeBytes(assertU256(2n ** 200n));\n * const beBytes = convertU256LeBytesToU256BeBytes(leBytes);\n * ```\n *\n * @see {@link convertU256BeBytesToU256LeBytes} for the inverse conversion\n */\nexport function convertU256LeBytesToU256BeBytes(value: U256LeBytes): U256BeBytes {\n assertU256LeBytes(value);\n const result = new Uint8Array(U256_BYTE_LENGTH);\n for (let index = 0; index < U256_BYTE_LENGTH; index++) {\n result[index] = value[U256_BYTE_LENGTH - 1 - index];\n }\n assertU256BeBytes(result);\n return result;\n}\n\n/**\n * Converts U256BeBytes to U256LeBytes (endianness swap).\n *\n * @public\n * @param value - The 32-byte big-endian representation to convert\n * @returns A new Uint8Array of length 32 with bytes in reversed (little-endian) order\n *\n * @remarks\n * Input type: U256BeBytes (Uint8Array of length 32, big-endian — byte[0] is MSB).\n * Output type: U256LeBytes (Uint8Array of length 32, little-endian — byte[0] is LSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n * Commonly used after receiving a BE-encoded BN254 field element and converting\n * it to LE format for on-chain Solana storage or comparison.\n *\n * @example\n * ```typescript\n * const beBytes = encodeU256ToU256BeBytes(assertU256(2n ** 200n));\n * const leBytes = convertU256BeBytesToU256LeBytes(beBytes);\n * ```\n *\n * @see {@link convertU256LeBytesToU256BeBytes} for the inverse conversion\n */\nexport function convertU256BeBytesToU256LeBytes(value: U256BeBytes): U256LeBytes {\n assertU256BeBytes(value);\n const result = new Uint8Array(U256_BYTE_LENGTH);\n for (let index = 0; index < U256_BYTE_LENGTH; index++) {\n result[index] = value[U256_BYTE_LENGTH - 1 - index];\n }\n assertU256LeBytes(result);\n return result;\n}\n\n/**\n * Converts U512LeBytes to U512BeBytes (endianness swap).\n *\n * @public\n * @param value - The 64-byte little-endian representation to convert\n * @returns A new Uint8Array of length 64 with bytes in reversed (big-endian) order\n *\n * @remarks\n * Input type: U512LeBytes (Uint8Array of length 64, little-endian — byte[0] is LSB).\n * Output type: U512BeBytes (Uint8Array of length 64, big-endian — byte[0] is MSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n *\n * @example\n * ```typescript\n * const leBytes = encodeU512ToU512LeBytes(assertU512(2n ** 400n));\n * const beBytes = convertU512LeBytesToU512BeBytes(leBytes);\n * ```\n *\n * @see {@link convertU512BeBytesToU512LeBytes} for the inverse conversion\n */\nexport function convertU512LeBytesToU512BeBytes(value: U512LeBytes): U512BeBytes {\n assertU512LeBytes(value);\n const result = new Uint8Array(U512_BYTE_LENGTH);\n for (let index = 0; index < U512_BYTE_LENGTH; index++) {\n result[index] = value[U512_BYTE_LENGTH - 1 - index];\n }\n assertU512BeBytes(result);\n return result;\n}\n\n/**\n * Converts U512BeBytes to U512LeBytes (endianness swap).\n *\n * @public\n * @param value - The 64-byte big-endian representation to convert\n * @returns A new Uint8Array of length 64 with bytes in reversed (little-endian) order\n *\n * @remarks\n * Input type: U512BeBytes (Uint8Array of length 64, big-endian — byte[0] is MSB).\n * Output type: U512LeBytes (Uint8Array of length 64, little-endian — byte[0] is LSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n *\n * @example\n * ```typescript\n * const beBytes = encodeU512ToU512BeBytes(assertU512(2n ** 400n));\n * const leBytes = convertU512BeBytesToU512LeBytes(beBytes);\n * ```\n *\n * @see {@link convertU512LeBytesToU512BeBytes} for the inverse conversion\n */\nexport function convertU512BeBytesToU512LeBytes(value: U512BeBytes): U512LeBytes {\n assertU512BeBytes(value);\n const result = new Uint8Array(U512_BYTE_LENGTH);\n for (let index = 0; index < U512_BYTE_LENGTH; index++) {\n result[index] = value[U512_BYTE_LENGTH - 1 - index];\n }\n assertU512LeBytes(result);\n return result;\n}\n\n/**\n * Converts U1024LeBytes to U1024BeBytes (endianness swap).\n *\n * @public\n * @param value - The 128-byte little-endian representation to convert\n * @returns A new Uint8Array of length 128 with bytes in reversed (big-endian) order\n *\n * @remarks\n * Input type: U1024LeBytes (Uint8Array of length 128, little-endian — byte[0] is LSB).\n * Output type: U1024BeBytes (Uint8Array of length 128, big-endian — byte[0] is MSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n *\n * @example\n * ```typescript\n * const leBytes = encodeU1024ToU1024LeBytes(assertU1024(2n ** 900n));\n * const beBytes = convertU1024LeBytesToU1024BeBytes(leBytes);\n * ```\n *\n * @see {@link convertU1024BeBytesToU1024LeBytes} for the inverse conversion\n */\nexport function convertU1024LeBytesToU1024BeBytes(value: U1024LeBytes): U1024BeBytes {\n assertU1024LeBytes(value);\n const result = new Uint8Array(U1024_BYTE_LENGTH);\n for (let index = 0; index < U1024_BYTE_LENGTH; index++) {\n result[index] = value[U1024_BYTE_LENGTH - 1 - index];\n }\n assertU1024BeBytes(result);\n return result;\n}\n\n/**\n * Converts U1024BeBytes to U1024LeBytes (endianness swap).\n *\n * @public\n * @param value - The 128-byte big-endian representation to convert\n * @returns A new Uint8Array of length 128 with bytes in reversed (little-endian) order\n *\n * @remarks\n * Input type: U1024BeBytes (Uint8Array of length 128, big-endian — byte[0] is MSB).\n * Output type: U1024LeBytes (Uint8Array of length 128, little-endian — byte[0] is LSB).\n * Bytes are reversed by index. The encoded integer value is preserved.\n *\n * @example\n * ```typescript\n * const beBytes = encodeU1024ToU1024BeBytes(assertU1024(2n ** 900n));\n * const leBytes = convertU1024BeBytesToU1024LeBytes(beBytes);\n * ```\n *\n * @see {@link convertU1024LeBytesToU1024BeBytes} for the inverse conversion\n */\nexport function convertU1024BeBytesToU1024LeBytes(value: U1024BeBytes): U1024LeBytes {\n assertU1024BeBytes(value);\n const result = new Uint8Array(U1024_BYTE_LENGTH);\n for (let index = 0; index < U1024_BYTE_LENGTH; index++) {\n result[index] = value[U1024_BYTE_LENGTH - 1 - index];\n }\n assertU1024LeBytes(result);\n return result;\n}\n\n/* =============================================================================\n * INTEGER TO BYTE ARRAY ENCODING\n *\n * Encode integers as byte arrays in specified endianness.\n * ============================================================================= */\n\n/**\n * Encodes a U8 integer as a 1-byte little-endian byte array.\n *\n * @public\n * @param value - The U8 value to encode (range [0, 255])\n * @returns A Uint8Array of length 1 containing the single byte\n *\n * @remarks\n * Input type: U8 (bigint, range [0, 255]).\n * Output type: U8LeBytes (Uint8Array of length 1, little-endian).\n * For a single byte there is no endianness; byte[0] = value & 0xFF.\n * This is the canonical encoding for 8-bit values in Solana account data.\n *\n * @example\n * ```typescript\n * const bytes = encodeU8ToU8LeBytes(assertU8(42n)); // Uint8Array [42]\n * ```\n *\n * @see {@link decodeU8LeBytesToU8} for the inverse decoding\n * @see {@link encodeU8ToU8BeBytes} for the big-endian variant (identical for 1 byte)\n */\nexport function encodeU8ToU8LeBytes(value: U8): U8LeBytes {\n assertU8(value);\n const result = new Uint8Array(U8_BYTE_LENGTH);\n result[0] = Number(value);\n assertU8LeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U8 integer as a 1-byte big-endian byte array.\n *\n * @public\n * @param value - The U8 value to encode (range [0, 255])\n * @returns A Uint8Array of length 1 containing the single byte\n *\n * @remarks\n * Input type: U8 (bigint, range [0, 255]).\n * Output type: U8BeBytes (Uint8Array of length 1, big-endian).\n * For a single byte there is no endianness; byte[0] = value & 0xFF.\n *\n * @example\n * ```typescript\n * const bytes = encodeU8ToU8BeBytes(assertU8(255n)); // Uint8Array [255]\n * ```\n *\n * @see {@link decodeU8BeBytesToU8} for the inverse decoding\n * @see {@link encodeU8ToU8LeBytes} for the little-endian variant (identical for 1 byte)\n */\nexport function encodeU8ToU8BeBytes(value: U8): U8BeBytes {\n assertU8(value);\n const result = new Uint8Array(U8_BYTE_LENGTH);\n result[0] = Number(value);\n assertU8BeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U16 integer as a 2-byte little-endian byte array.\n *\n * @public\n * @param value - The U16 value to encode (range [0, 65535])\n * @returns A Uint8Array of length 2 in little-endian byte order (LSB at index 0)\n *\n * @remarks\n * Input type: U16 (bigint, range [0, 65535]).\n * Output type: U16LeBytes (Uint8Array of length 2, little-endian).\n * Encoding algorithm: iterates indices 0..1, writes `value & 0xff` to `result[index]`,\n * then shifts `value >>= 8n`. This places the least-significant byte at index 0.\n * Little-endian encoding matches Solana's on-chain data layout for u16 fields.\n *\n * @example\n * ```typescript\n * // 0x0102 = 258; LE = [0x02, 0x01]\n * const bytes = encodeU16ToU16LeBytes(assertU16(258n));\n * // bytes[0] = 2, bytes[1] = 1\n * ```\n *\n * @see {@link decodeU16LeBytesToU16} for the inverse decoding\n * @see {@link encodeU16ToU16BeBytes} for the big-endian variant\n */\nexport function encodeU16ToU16LeBytes(value: U16): U16LeBytes {\n assertU16(value);\n const result = new Uint8Array(U16_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = 0; index < U16_BYTE_LENGTH; index++) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU16LeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U16 integer as a 2-byte big-endian byte array.\n *\n * @public\n * @param value - The U16 value to encode (range [0, 65535])\n * @returns A Uint8Array of length 2 in big-endian byte order (MSB at index 0)\n *\n * @remarks\n * Input type: U16 (bigint, range [0, 65535]).\n * Output type: U16BeBytes (Uint8Array of length 2, big-endian).\n * Encoding algorithm: iterates indices from LENGTH-1 down to 0, writes `value & 0xff`\n * to `result[index]`, then shifts `value >>= 8n`. This places the most-significant\n * byte at index 0.\n *\n * @example\n * ```typescript\n * // 0x0102 = 258; BE = [0x01, 0x02]\n * const bytes = encodeU16ToU16BeBytes(assertU16(258n));\n * // bytes[0] = 1, bytes[1] = 2\n * ```\n *\n * @see {@link decodeU16BeBytesToU16} for the inverse decoding\n * @see {@link encodeU16ToU16LeBytes} for the little-endian variant\n */\nexport function encodeU16ToU16BeBytes(value: U16): U16BeBytes {\n assertU16(value);\n const result = new Uint8Array(U16_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = U16_BYTE_LENGTH - 1; index >= 0; index--) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU16BeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U32 integer as a 4-byte little-endian byte array.\n *\n * @public\n * @param value - The U32 value to encode (range [0, 2^32 - 1])\n * @returns A Uint8Array of length 4 in little-endian byte order (LSB at index 0)\n *\n * @remarks\n * Input type: U32 (bigint, range [0, 4294967295]).\n * Output type: U32LeBytes (Uint8Array of length 4, little-endian).\n * Iterates indices 0..3, writing low byte then shifting right by 8 bits each step.\n * This is the standard encoding for Solana u32 discriminators and lengths.\n *\n * @example\n * ```typescript\n * const bytes = encodeU32ToU32LeBytes(assertU32(0x01020304n));\n * // bytes = [0x04, 0x03, 0x02, 0x01]\n * ```\n *\n * @see {@link decodeU32LeBytesToU32} for the inverse decoding\n * @see {@link encodeU32ToU32BeBytes} for the big-endian variant\n */\nexport function encodeU32ToU32LeBytes(value: U32): U32LeBytes {\n assertU32(value);\n const result = new Uint8Array(U32_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = 0; index < U32_BYTE_LENGTH; index++) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU32LeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U32 integer as a 4-byte big-endian byte array.\n *\n * @public\n * @param value - The U32 value to encode (range [0, 2^32 - 1])\n * @returns A Uint8Array of length 4 in big-endian byte order (MSB at index 0)\n *\n * @remarks\n * Input type: U32 (bigint, range [0, 4294967295]).\n * Output type: U32BeBytes (Uint8Array of length 4, big-endian).\n * Iterates indices from 3 down to 0, writing low byte then shifting right by 8 bits.\n * This places the most-significant byte at index 0.\n *\n * @example\n * ```typescript\n * const bytes = encodeU32ToU32BeBytes(assertU32(0x01020304n));\n * // bytes = [0x01, 0x02, 0x03, 0x04]\n * ```\n *\n * @see {@link decodeU32BeBytesToU32} for the inverse decoding\n * @see {@link encodeU32ToU32LeBytes} for the little-endian variant\n */\nexport function encodeU32ToU32BeBytes(value: U32): U32BeBytes {\n assertU32(value);\n const result = new Uint8Array(U32_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = U32_BYTE_LENGTH - 1; index >= 0; index--) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU32BeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U64 integer as an 8-byte little-endian byte array.\n *\n * @public\n * @param value - The U64 value to encode (range [0, 2^64 - 1])\n * @returns A Uint8Array of length 8 in little-endian byte order (LSB at index 0)\n *\n * @remarks\n * Input type: U64 (bigint, range [0, 2^64 - 1]).\n * Output type: U64LeBytes (Uint8Array of length 8, little-endian).\n * Iterates indices 0..7, writing low byte then shifting right by 8 bits each step.\n * This is the canonical encoding for Solana lamport amounts, token quantities,\n * and other 64-bit on-chain values.\n *\n * @example\n * ```typescript\n * const bytes = encodeU64ToU64LeBytes(assertU64(1000000000n)); // 1 SOL in lamports\n * // bytes[0] is LSB; bytes[7] is MSB\n * ```\n *\n * @see {@link decodeU64LeBytesToU64} for the inverse decoding\n * @see {@link encodeU64ToU64BeBytes} for the big-endian variant\n */\nexport function encodeU64ToU64LeBytes(value: U64): U64LeBytes {\n assertU64(value);\n const result = new Uint8Array(U64_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = 0; index < U64_BYTE_LENGTH; index++) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU64LeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U64 integer as an 8-byte big-endian byte array.\n *\n * @public\n * @param value - The U64 value to encode (range [0, 2^64 - 1])\n * @returns A Uint8Array of length 8 in big-endian byte order (MSB at index 0)\n *\n * @remarks\n * Input type: U64 (bigint, range [0, 2^64 - 1]).\n * Output type: U64BeBytes (Uint8Array of length 8, big-endian).\n * Iterates indices from 7 down to 0, writing low byte then shifting right by 8 bits.\n * MSB is at index 0.\n *\n * @example\n * ```typescript\n * const bytes = encodeU64ToU64BeBytes(assertU64(0x0102030405060708n));\n * // bytes = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]\n * ```\n *\n * @see {@link decodeU64BeBytesToU64} for the inverse decoding\n * @see {@link encodeU64ToU64LeBytes} for the little-endian variant\n */\nexport function encodeU64ToU64BeBytes(value: U64): U64BeBytes {\n assertU64(value);\n const result = new Uint8Array(U64_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = U64_BYTE_LENGTH - 1; index >= 0; index--) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU64BeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U128 integer as a 16-byte little-endian byte array.\n *\n * @public\n * @param value - The U128 value to encode (range [0, 2^128 - 1])\n * @returns A Uint8Array of length 16 in little-endian byte order (LSB at index 0)\n *\n * @remarks\n * Input type: U128 (bigint, range [0, 2^128 - 1]).\n * Output type: U128LeBytes (Uint8Array of length 16, little-endian).\n * Iterates indices 0..15, writing low byte then shifting right by 8 bits each step.\n * Commonly used to encode 128-bit nonces, RcEncryptionNonce values, and token amounts\n * that exceed the U64 range.\n *\n * @example\n * ```typescript\n * const bytes = encodeU128ToU128LeBytes(assertU128(2n ** 64n));\n * // bytes[8] = 1; all others = 0 (since 2^64 = 1 at byte index 8)\n * ```\n *\n * @see {@link decodeU128LeBytesToU128} for the inverse decoding\n * @see {@link encodeU128ToU128BeBytes} for the big-endian variant\n */\nexport function encodeU128ToU128LeBytes(value: U128): U128LeBytes {\n assertU128(value);\n const result = new Uint8Array(U128_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = 0; index < U128_BYTE_LENGTH; index++) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU128LeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U128 integer as a 16-byte big-endian byte array.\n *\n * @public\n * @param value - The U128 value to encode (range [0, 2^128 - 1])\n * @returns A Uint8Array of length 16 in big-endian byte order (MSB at index 0)\n *\n * @remarks\n * Input type: U128 (bigint, range [0, 2^128 - 1]).\n * Output type: U128BeBytes (Uint8Array of length 16, big-endian).\n * Iterates indices from 15 down to 0, writing low byte then shifting right by 8 bits.\n * MSB is at index 0.\n *\n * @example\n * ```typescript\n * const bytes = encodeU128ToU128BeBytes(assertU128(1n));\n * // bytes = [0, 0, ..., 0, 1] (15 zero bytes then 0x01)\n * ```\n *\n * @see {@link decodeU128BeBytesToU128} for the inverse decoding\n * @see {@link encodeU128ToU128LeBytes} for the little-endian variant\n */\nexport function encodeU128ToU128BeBytes(value: U128): U128BeBytes {\n assertU128(value);\n const result = new Uint8Array(U128_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = U128_BYTE_LENGTH - 1; index >= 0; index--) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU128BeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U256 integer as a 32-byte little-endian byte array.\n *\n * @public\n * @param value - The U256 value to encode (range [0, 2^256 - 1])\n * @returns A Uint8Array of length 32 in little-endian byte order (LSB at index 0)\n *\n * @remarks\n * Input type: U256 (bigint, range [0, 2^256 - 1]).\n * Output type: U256LeBytes (Uint8Array of length 32, little-endian).\n * Iterates indices 0..31, writing low byte then shifting right by 8 bits each step.\n * This is the canonical Solana on-chain encoding for 256-bit values such as\n * X25519 public keys, Poseidon hash outputs, and UTXO commitments.\n *\n * @example\n * ```typescript\n * const bytes = encodeU256ToU256LeBytes(assertU256(1n));\n * // bytes[0] = 1; bytes[1..31] = 0\n * ```\n *\n * @see {@link decodeU256LeBytesToU256} for the inverse decoding\n * @see {@link encodeU256ToU256BeBytes} for the big-endian variant\n */\nexport function encodeU256ToU256LeBytes(value: U256): U256LeBytes {\n assertU256(value);\n const result = new Uint8Array(U256_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = 0; index < U256_BYTE_LENGTH; index++) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU256LeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U256 integer as a 32-byte big-endian byte array.\n *\n * @public\n * @param value - The U256 value to encode (range [0, 2^256 - 1])\n * @returns A Uint8Array of length 32 in big-endian byte order (MSB at index 0)\n *\n * @remarks\n * Input type: U256 (bigint, range [0, 2^256 - 1]).\n * Output type: U256BeBytes (Uint8Array of length 32, big-endian).\n * Iterates indices from 31 down to 0, writing low byte then shifting right by 8 bits.\n * MSB is at index 0. This is the standard format for BN254/Groth16 field elements\n * and EVM-compatible 32-byte word encoding.\n *\n * @example\n * ```typescript\n * const bytes = encodeU256ToU256BeBytes(assertU256(1n));\n * // bytes[0..30] = 0; bytes[31] = 1\n * ```\n *\n * @see {@link decodeU256BeBytesToU256} for the inverse decoding\n * @see {@link encodeU256ToU256LeBytes} for the little-endian variant\n */\nexport function encodeU256ToU256BeBytes(value: U256): U256BeBytes {\n assertU256(value);\n const result = new Uint8Array(U256_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = U256_BYTE_LENGTH - 1; index >= 0; index--) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU256BeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U512 integer as a 64-byte little-endian byte array.\n *\n * @public\n * @param value - The U512 value to encode (range [0, 2^512 - 1])\n * @returns A Uint8Array of length 64 in little-endian byte order (LSB at index 0)\n *\n * @remarks\n * Input type: U512 (bigint, range [0, 2^512 - 1]).\n * Output type: U512LeBytes (Uint8Array of length 64, little-endian).\n * Iterates indices 0..63, writing low byte then shifting right by 8 bits each step.\n *\n * @example\n * ```typescript\n * const bytes = encodeU512ToU512LeBytes(assertU512(2n ** 256n));\n * // bytes[32] = 1; all others = 0\n * ```\n *\n * @see {@link decodeU512LeBytesToU512} for the inverse decoding\n * @see {@link encodeU512ToU512BeBytes} for the big-endian variant\n */\nexport function encodeU512ToU512LeBytes(value: U512): U512LeBytes {\n assertU512(value);\n const result = new Uint8Array(U512_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = 0; index < U512_BYTE_LENGTH; index++) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU512LeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U512 integer as a 64-byte big-endian byte array.\n *\n * @public\n * @param value - The U512 value to encode (range [0, 2^512 - 1])\n * @returns A Uint8Array of length 64 in big-endian byte order (MSB at index 0)\n *\n * @remarks\n * Input type: U512 (bigint, range [0, 2^512 - 1]).\n * Output type: U512BeBytes (Uint8Array of length 64, big-endian).\n * Iterates indices from 63 down to 0, writing low byte then shifting right by 8 bits.\n * MSB is at index 0.\n *\n * @example\n * ```typescript\n * const bytes = encodeU512ToU512BeBytes(assertU512(1n));\n * // bytes[0..62] = 0; bytes[63] = 1\n * ```\n *\n * @see {@link decodeU512BeBytesToU512} for the inverse decoding\n * @see {@link encodeU512ToU512LeBytes} for the little-endian variant\n */\nexport function encodeU512ToU512BeBytes(value: U512): U512BeBytes {\n assertU512(value);\n const result = new Uint8Array(U512_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = U512_BYTE_LENGTH - 1; index >= 0; index--) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU512BeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U1024 integer as a 128-byte little-endian byte array.\n *\n * @public\n * @param value - The U1024 value to encode (range [0, 2^1024 - 1])\n * @returns A Uint8Array of length 128 in little-endian byte order (LSB at index 0)\n *\n * @remarks\n * Input type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Output type: U1024LeBytes (Uint8Array of length 128, little-endian).\n * Iterates indices 0..127, writing low byte then shifting right by 8 bits each step.\n *\n * @example\n * ```typescript\n * const bytes = encodeU1024ToU1024LeBytes(assertU1024(2n ** 512n));\n * // bytes[64] = 1; all others = 0\n * ```\n *\n * @see {@link decodeU1024LeBytesToU1024} for the inverse decoding\n * @see {@link encodeU1024ToU1024BeBytes} for the big-endian variant\n */\nexport function encodeU1024ToU1024LeBytes(value: U1024): U1024LeBytes {\n assertU1024(value);\n const result = new Uint8Array(U1024_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = 0; index < U1024_BYTE_LENGTH; index++) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU1024LeBytes(result);\n return result;\n}\n\n/**\n * Encodes a U1024 integer as a 128-byte big-endian byte array.\n *\n * @public\n * @param value - The U1024 value to encode (range [0, 2^1024 - 1])\n * @returns A Uint8Array of length 128 in big-endian byte order (MSB at index 0)\n *\n * @remarks\n * Input type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Output type: U1024BeBytes (Uint8Array of length 128, big-endian).\n * Iterates indices from 127 down to 0, writing low byte then shifting right by 8 bits.\n * MSB is at index 0.\n *\n * @example\n * ```typescript\n * const bytes = encodeU1024ToU1024BeBytes(assertU1024(1n));\n * // bytes[0..126] = 0; bytes[127] = 1\n * ```\n *\n * @see {@link decodeU1024BeBytesToU1024} for the inverse decoding\n * @see {@link encodeU1024ToU1024LeBytes} for the little-endian variant\n */\nexport function encodeU1024ToU1024BeBytes(value: U1024): U1024BeBytes {\n assertU1024(value);\n const result = new Uint8Array(U1024_BYTE_LENGTH);\n let temporary: bigint = value;\n for (let index = U1024_BYTE_LENGTH - 1; index >= 0; index--) {\n result[index] = Number(temporary & 0xffn);\n temporary >>= 8n;\n }\n assertU1024BeBytes(result);\n return result;\n}\n\n/* =============================================================================\n * BYTE ARRAY TO INTEGER DECODING\n *\n * Decode byte arrays to integers from specified endianness.\n * ============================================================================= */\n\n/**\n * Decodes a 1-byte little-endian byte array to a U8 integer.\n *\n * @public\n * @param value - The U8LeBytes array (Uint8Array of length 1) to decode\n * @returns The decoded value as U8\n *\n * @remarks\n * Input type: U8LeBytes (Uint8Array of length 1, little-endian).\n * Output type: U8 (bigint, range [0, 255]).\n * Decoding: `BigInt(value[0])`. For a single byte there is no endianness ambiguity.\n *\n * @example\n * ```typescript\n * const bytes = encodeU8ToU8LeBytes(assertU8(42n));\n * const u8Value = decodeU8LeBytesToU8(bytes); // 42n\n * ```\n *\n * @see {@link encodeU8ToU8LeBytes} for the inverse encoding\n * @see {@link decodeU8BeBytesToU8} for the big-endian variant (identical result)\n */\nexport function decodeU8LeBytesToU8(value: U8LeBytes): U8 {\n assertU8LeBytes(value);\n\n const result = BigInt(value[0]);\n assertU8(result);\n return result;\n}\n\n/**\n * Decodes a 1-byte big-endian byte array to a U8 integer.\n *\n * @public\n * @param value - The U8BeBytes array (Uint8Array of length 1) to decode\n * @returns The decoded value as U8\n *\n * @remarks\n * Input type: U8BeBytes (Uint8Array of length 1, big-endian).\n * Output type: U8 (bigint, range [0, 255]).\n * Decoding: `BigInt(value[0])`. For a single byte there is no endianness ambiguity.\n *\n * @example\n * ```typescript\n * const bytes = encodeU8ToU8BeBytes(assertU8(255n));\n * const u8Value = decodeU8BeBytesToU8(bytes); // 255n\n * ```\n *\n * @see {@link encodeU8ToU8BeBytes} for the inverse encoding\n * @see {@link decodeU8LeBytesToU8} for the little-endian variant (identical result)\n */\nexport function decodeU8BeBytesToU8(value: U8BeBytes): U8 {\n assertU8BeBytes(value);\n\n const result = BigInt(value[0]);\n assertU8(result);\n return result;\n}\n\n/**\n * Decodes a 2-byte little-endian byte array to a U16 integer.\n *\n * @public\n * @param value - The U16LeBytes array (Uint8Array of length 2, LSB at index 0) to decode\n * @returns The decoded value as U16\n *\n * @remarks\n * Input type: U16LeBytes (Uint8Array of length 2, little-endian — byte[0] is LSB).\n * Output type: U16 (bigint, range [0, 65535]).\n * Decoding algorithm: iterates from index LENGTH-1 down to 0, accumulating\n * `result = (result << 8n) | BigInt(value[index])`. Starting from the high index\n * of a LE array means the first byte consumed is the most-significant byte of the\n * stored value, producing the correct big-endian accumulation.\n *\n * @example\n * ```typescript\n * // [0x02, 0x01] in LE encodes 0x0102 = 258\n * const bytes = encodeU16ToU16LeBytes(assertU16(258n));\n * const u16Value = decodeU16LeBytesToU16(bytes); // 258n\n * ```\n *\n * @see {@link encodeU16ToU16LeBytes} for the inverse encoding\n * @see {@link decodeU16BeBytesToU16} for the big-endian variant\n */\nexport function decodeU16LeBytesToU16(value: U16LeBytes): U16 {\n assertU16LeBytes(value);\n let result = 0n;\n for (let index = U16_BYTE_LENGTH - 1; index >= 0; index--) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU16(result);\n return result;\n}\n\n/**\n * Decodes a 2-byte big-endian byte array to a U16 integer.\n *\n * @public\n * @param value - The U16BeBytes array (Uint8Array of length 2, MSB at index 0) to decode\n * @returns The decoded value as U16\n *\n * @remarks\n * Input type: U16BeBytes (Uint8Array of length 2, big-endian — byte[0] is MSB).\n * Output type: U16 (bigint, range [0, 65535]).\n * Decoding algorithm: iterates from index 0 to LENGTH-1, accumulating\n * `result = (result << 8n) | BigInt(value[index])`. Reading from the MSB first\n * produces the correct integer value.\n *\n * @example\n * ```typescript\n * // [0x01, 0x02] in BE encodes 0x0102 = 258\n * const bytes = encodeU16ToU16BeBytes(assertU16(258n));\n * const u16Value = decodeU16BeBytesToU16(bytes); // 258n\n * ```\n *\n * @see {@link encodeU16ToU16BeBytes} for the inverse encoding\n * @see {@link decodeU16LeBytesToU16} for the little-endian variant\n */\nexport function decodeU16BeBytesToU16(value: U16BeBytes): U16 {\n assertU16BeBytes(value);\n let result = 0n;\n for (let index = 0; index < U16_BYTE_LENGTH; index++) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU16(result);\n return result;\n}\n\n/**\n * Decodes a 4-byte little-endian byte array to a U32 integer.\n *\n * @public\n * @param value - The U32LeBytes array (Uint8Array of length 4, LSB at index 0) to decode\n * @returns The decoded value as U32\n *\n * @remarks\n * Input type: U32LeBytes (Uint8Array of length 4, little-endian — byte[0] is LSB).\n * Output type: U32 (bigint, range [0, 4294967295]).\n * Decoding algorithm: iterates from index LENGTH-1 down to 0, accumulating with\n * left-shift-8 and OR at each step.\n *\n * @example\n * ```typescript\n * const bytes = encodeU32ToU32LeBytes(assertU32(0x01020304n));\n * // bytes = [0x04, 0x03, 0x02, 0x01]\n * const u32Value = decodeU32LeBytesToU32(bytes); // 0x01020304n\n * ```\n *\n * @see {@link encodeU32ToU32LeBytes} for the inverse encoding\n * @see {@link decodeU32BeBytesToU32} for the big-endian variant\n */\nexport function decodeU32LeBytesToU32(value: U32LeBytes): U32 {\n assertU32LeBytes(value);\n let result = 0n;\n for (let index = U32_BYTE_LENGTH - 1; index >= 0; index--) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU32(result);\n return result;\n}\n\n/**\n * Decodes a 4-byte big-endian byte array to a U32 integer.\n *\n * @public\n * @param value - The U32BeBytes array (Uint8Array of length 4, MSB at index 0) to decode\n * @returns The decoded value as U32\n *\n * @remarks\n * Input type: U32BeBytes (Uint8Array of length 4, big-endian — byte[0] is MSB).\n * Output type: U32 (bigint, range [0, 4294967295]).\n * Decoding algorithm: iterates from index 0 to LENGTH-1, accumulating with\n * left-shift-8 and OR at each step.\n *\n * @example\n * ```typescript\n * const bytes = encodeU32ToU32BeBytes(assertU32(0x01020304n));\n * // bytes = [0x01, 0x02, 0x03, 0x04]\n * const u32Value = decodeU32BeBytesToU32(bytes); // 0x01020304n\n * ```\n *\n * @see {@link encodeU32ToU32BeBytes} for the inverse encoding\n * @see {@link decodeU32LeBytesToU32} for the little-endian variant\n */\nexport function decodeU32BeBytesToU32(value: U32BeBytes): U32 {\n assertU32BeBytes(value);\n let result = 0n;\n for (let index = 0; index < U32_BYTE_LENGTH; index++) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU32(result);\n return result;\n}\n\n/**\n * Decodes an 8-byte little-endian byte array to a U64 integer.\n *\n * @public\n * @param value - The U64LeBytes array (Uint8Array of length 8, LSB at index 0) to decode\n * @returns The decoded value as U64\n *\n * @remarks\n * Input type: U64LeBytes (Uint8Array of length 8, little-endian — byte[0] is LSB).\n * Output type: U64 (bigint, range [0, 2^64 - 1]).\n * Decoding algorithm: iterates from index LENGTH-1 down to 0, accumulating with\n * left-shift-8 and OR at each step.\n * Commonly used to read Solana lamport amounts and 64-bit fields from account data.\n *\n * @example\n * ```typescript\n * const bytes = encodeU64ToU64LeBytes(assertU64(1000n));\n * const u64Value = decodeU64LeBytesToU64(bytes); // 1000n\n * ```\n *\n * @see {@link encodeU64ToU64LeBytes} for the inverse encoding\n * @see {@link decodeU64BeBytesToU64} for the big-endian variant\n */\nexport function decodeU64LeBytesToU64(value: U64LeBytes): U64 {\n assertU64LeBytes(value);\n let result = 0n;\n for (let index = U64_BYTE_LENGTH - 1; index >= 0; index--) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU64(result);\n return result;\n}\n\n/**\n * Decodes an 8-byte big-endian byte array to a U64 integer.\n *\n * @public\n * @param value - The U64BeBytes array (Uint8Array of length 8, MSB at index 0) to decode\n * @returns The decoded value as U64\n *\n * @remarks\n * Input type: U64BeBytes (Uint8Array of length 8, big-endian — byte[0] is MSB).\n * Output type: U64 (bigint, range [0, 2^64 - 1]).\n * Decoding algorithm: iterates from index 0 to LENGTH-1, accumulating with\n * left-shift-8 and OR at each step.\n *\n * @example\n * ```typescript\n * const bytes = encodeU64ToU64BeBytes(assertU64(1000n));\n * const u64Value = decodeU64BeBytesToU64(bytes); // 1000n\n * ```\n *\n * @see {@link encodeU64ToU64BeBytes} for the inverse encoding\n * @see {@link decodeU64LeBytesToU64} for the little-endian variant\n */\nexport function decodeU64BeBytesToU64(value: U64BeBytes): U64 {\n assertU64BeBytes(value);\n let result = 0n;\n for (let index = 0; index < U64_BYTE_LENGTH; index++) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU64(result);\n return result;\n}\n\n/**\n * Decodes a 16-byte little-endian byte array to a U128 integer.\n *\n * @public\n * @param value - The U128LeBytes array (Uint8Array of length 16, LSB at index 0) to decode\n * @returns The decoded value as U128\n *\n * @remarks\n * Input type: U128LeBytes (Uint8Array of length 16, little-endian — byte[0] is LSB).\n * Output type: U128 (bigint, range [0, 2^128 - 1]).\n * Decoding algorithm: iterates from index LENGTH-1 down to 0, accumulating with\n * left-shift-8 and OR at each step.\n * Used to decode 128-bit nonces and RcEncryptionNonce values from on-chain data.\n *\n * @example\n * ```typescript\n * const bytes = encodeU128ToU128LeBytes(assertU128(2n ** 64n));\n * const u128Value = decodeU128LeBytesToU128(bytes); // 2n ** 64n\n * ```\n *\n * @see {@link encodeU128ToU128LeBytes} for the inverse encoding\n * @see {@link decodeU128BeBytesToU128} for the big-endian variant\n */\nexport function decodeU128LeBytesToU128(value: U128LeBytes): U128 {\n assertU128LeBytes(value);\n let result = 0n;\n for (let index = U128_BYTE_LENGTH - 1; index >= 0; index--) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU128(result);\n return result;\n}\n\n/**\n * Decodes a 16-byte big-endian byte array to a U128 integer.\n *\n * @public\n * @param value - The U128BeBytes array (Uint8Array of length 16, MSB at index 0) to decode\n * @returns The decoded value as U128\n *\n * @remarks\n * Input type: U128BeBytes (Uint8Array of length 16, big-endian — byte[0] is MSB).\n * Output type: U128 (bigint, range [0, 2^128 - 1]).\n * Decoding algorithm: iterates from index 0 to LENGTH-1, accumulating with\n * left-shift-8 and OR at each step.\n *\n * @example\n * ```typescript\n * const bytes = encodeU128ToU128BeBytes(assertU128(2n ** 64n));\n * const u128Value = decodeU128BeBytesToU128(bytes); // 2n ** 64n\n * ```\n *\n * @see {@link encodeU128ToU128BeBytes} for the inverse encoding\n * @see {@link decodeU128LeBytesToU128} for the little-endian variant\n */\nexport function decodeU128BeBytesToU128(value: U128BeBytes): U128 {\n assertU128BeBytes(value);\n let result = 0n;\n for (let index = 0; index < U128_BYTE_LENGTH; index++) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU128(result);\n return result;\n}\n\n/**\n * Decodes a 32-byte little-endian byte array to a U256 integer.\n *\n * @public\n * @param value - The U256LeBytes array (Uint8Array of length 32, LSB at index 0) to decode\n * @returns The decoded value as U256\n *\n * @remarks\n * Input type: U256LeBytes (Uint8Array of length 32, little-endian — byte[0] is LSB).\n * Output type: U256 (bigint, range [0, 2^256 - 1]).\n * Decoding algorithm: iterates from index LENGTH-1 down to 0, accumulating with\n * left-shift-8 and OR at each step.\n * Commonly used to read X25519 public keys, Poseidon hashes, and UTXO commitments\n * from Solana account data.\n *\n * @example\n * ```typescript\n * const bytes = encodeU256ToU256LeBytes(assertU256(2n ** 200n));\n * const u256Value = decodeU256LeBytesToU256(bytes); // 2n ** 200n\n * ```\n *\n * @see {@link encodeU256ToU256LeBytes} for the inverse encoding\n * @see {@link decodeU256BeBytesToU256} for the big-endian variant\n */\nexport function decodeU256LeBytesToU256(value: U256LeBytes): U256 {\n assertU256LeBytes(value);\n let result = 0n;\n for (let index = U256_BYTE_LENGTH - 1; index >= 0; index--) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU256(result);\n return result;\n}\n\n/**\n * Decodes a 32-byte big-endian byte array to a U256 integer.\n *\n * @public\n * @param value - The U256BeBytes array (Uint8Array of length 32, MSB at index 0) to decode\n * @returns The decoded value as U256\n *\n * @remarks\n * Input type: U256BeBytes (Uint8Array of length 32, big-endian — byte[0] is MSB).\n * Output type: U256 (bigint, range [0, 2^256 - 1]).\n * Decoding algorithm: iterates from index 0 to LENGTH-1, accumulating with\n * left-shift-8 and OR at each step.\n * Used to decode BN254/Groth16 field elements received in BE wire format.\n *\n * @example\n * ```typescript\n * const bytes = encodeU256ToU256BeBytes(assertU256(2n ** 200n));\n * const u256Value = decodeU256BeBytesToU256(bytes); // 2n ** 200n\n * ```\n *\n * @see {@link encodeU256ToU256BeBytes} for the inverse encoding\n * @see {@link decodeU256LeBytesToU256} for the little-endian variant\n */\nexport function decodeU256BeBytesToU256(value: U256BeBytes): U256 {\n assertU256BeBytes(value);\n let result = 0n;\n for (let index = 0; index < U256_BYTE_LENGTH; index++) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU256(result);\n return result;\n}\n\n/**\n * Decodes a 64-byte little-endian byte array to a U512 integer.\n *\n * @public\n * @param value - The U512LeBytes array (Uint8Array of length 64, LSB at index 0) to decode\n * @returns The decoded value as U512\n *\n * @remarks\n * Input type: U512LeBytes (Uint8Array of length 64, little-endian — byte[0] is LSB).\n * Output type: U512 (bigint, range [0, 2^512 - 1]).\n * Decoding algorithm: iterates from index LENGTH-1 down to 0, accumulating with\n * left-shift-8 and OR at each step.\n *\n * @example\n * ```typescript\n * const bytes = encodeU512ToU512LeBytes(assertU512(2n ** 400n));\n * const u512Value = decodeU512LeBytesToU512(bytes); // 2n ** 400n\n * ```\n *\n * @see {@link encodeU512ToU512LeBytes} for the inverse encoding\n * @see {@link decodeU512BeBytesToU512} for the big-endian variant\n */\nexport function decodeU512LeBytesToU512(value: U512LeBytes): U512 {\n assertU512LeBytes(value);\n let result = 0n;\n for (let index = U512_BYTE_LENGTH - 1; index >= 0; index--) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU512(result);\n return result;\n}\n\n/**\n * Decodes a 64-byte big-endian byte array to a U512 integer.\n *\n * @public\n * @param value - The U512BeBytes array (Uint8Array of length 64, MSB at index 0) to decode\n * @returns The decoded value as U512\n *\n * @remarks\n * Input type: U512BeBytes (Uint8Array of length 64, big-endian — byte[0] is MSB).\n * Output type: U512 (bigint, range [0, 2^512 - 1]).\n * Decoding algorithm: iterates from index 0 to LENGTH-1, accumulating with\n * left-shift-8 and OR at each step.\n *\n * @example\n * ```typescript\n * const bytes = encodeU512ToU512BeBytes(assertU512(2n ** 400n));\n * const u512Value = decodeU512BeBytesToU512(bytes); // 2n ** 400n\n * ```\n *\n * @see {@link encodeU512ToU512BeBytes} for the inverse encoding\n * @see {@link decodeU512LeBytesToU512} for the little-endian variant\n */\nexport function decodeU512BeBytesToU512(value: U512BeBytes): U512 {\n assertU512BeBytes(value);\n let result = 0n;\n for (let index = 0; index < U512_BYTE_LENGTH; index++) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU512(result);\n return result;\n}\n\n/**\n * Decodes a 128-byte little-endian byte array to a U1024 integer.\n *\n * @public\n * @param value - The U1024LeBytes array (Uint8Array of length 128, LSB at index 0) to decode\n * @returns The decoded value as U1024\n *\n * @remarks\n * Input type: U1024LeBytes (Uint8Array of length 128, little-endian — byte[0] is LSB).\n * Output type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Decoding algorithm: iterates from index LENGTH-1 down to 0, accumulating with\n * left-shift-8 and OR at each step.\n *\n * @example\n * ```typescript\n * const bytes = encodeU1024ToU1024LeBytes(assertU1024(2n ** 900n));\n * const u1024Value = decodeU1024LeBytesToU1024(bytes); // 2n ** 900n\n * ```\n *\n * @see {@link encodeU1024ToU1024LeBytes} for the inverse encoding\n * @see {@link decodeU1024BeBytesToU1024} for the big-endian variant\n */\nexport function decodeU1024LeBytesToU1024(value: U1024LeBytes): U1024 {\n assertU1024LeBytes(value);\n let result = 0n;\n for (let index = U1024_BYTE_LENGTH - 1; index >= 0; index--) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU1024(result);\n return result;\n}\n\n/**\n * Decodes a 128-byte big-endian byte array to a U1024 integer.\n *\n * @public\n * @param value - The U1024BeBytes array (Uint8Array of length 128, MSB at index 0) to decode\n * @returns The decoded value as U1024\n *\n * @remarks\n * Input type: U1024BeBytes (Uint8Array of length 128, big-endian — byte[0] is MSB).\n * Output type: U1024 (bigint, range [0, 2^1024 - 1]).\n * Decoding algorithm: iterates from index 0 to LENGTH-1, accumulating with\n * left-shift-8 and OR at each step.\n *\n * @example\n * ```typescript\n * const bytes = encodeU1024ToU1024BeBytes(assertU1024(2n ** 900n));\n * const u1024Value = decodeU1024BeBytesToU1024(bytes); // 2n ** 900n\n * ```\n *\n * @see {@link encodeU1024ToU1024BeBytes} for the inverse encoding\n * @see {@link decodeU1024LeBytesToU1024} for the little-endian variant\n */\nexport function decodeU1024BeBytesToU1024(value: U1024BeBytes): U1024 {\n assertU1024BeBytes(value);\n let result = 0n;\n for (let index = 0; index < U1024_BYTE_LENGTH; index++) {\n result = (result << 8n) | BigInt(value[index]);\n }\n assertU1024(result);\n return result;\n}\n","/**\n * Cryptography Type Converters\n *\n * This module provides converter functions between cryptographic branded types.\n * All converters include:\n * - Input assertions to validate the source type\n * - Range/constraint validation to ensure lossless conversion\n * - Output assertions to validate the result type\n *\n * ## Conversion Categories\n *\n * ### Field Element Conversions\n * - U256 <-> Bn254FieldElement\n * - U256 <-> Curve25519FieldElement\n * - Bn254FieldElement <-> Curve25519FieldElement (cross-field)\n *\n * ### Cipher Type Conversions\n * - Bn254FieldElement -> Poseidon types (promotion)\n * - Curve25519FieldElement -> Rescue types (promotion)\n * - Poseidon types -> Bn254FieldElement (extraction)\n * - Rescue types -> Curve25519FieldElement (extraction)\n *\n * ### X25519 Key Conversions\n * - X25519Bytes <-> X25519PrivateKey\n * - X25519Bytes <-> X25519PublicKey\n * - X25519Bytes <-> SharedSecret\n *\n * ### U256 Splitting Utilities\n * - U256 -> two U128 halves\n * - X25519PublicKey -> two U128 halves (little-endian)\n * - U256 -> Base85LimbTuple (three ~85-bit limbs for ZK circuits)\n *\n * @packageDocumentation\n * @module utils/convertors/cryptography\n * @public\n */\n\nimport {\n type U128,\n type U256,\n assertU128,\n assertU256,\n U128_BYTE_LENGTH,\n U256_BYTE_LENGTH,\n} from \"../types\";\n\nimport {\n type Base85LimbTuple,\n type Bn254FieldElement,\n type Curve25519FieldElement,\n type PoseidonPlaintext,\n type PoseidonHash,\n type PoseidonKey,\n type PoseidonCiphertext,\n type RcCiphertext,\n type RcPlaintext,\n type RcKey,\n type RcCounter,\n type RcEncryptionNonce,\n type X25519Bytes,\n type X25519PrivateKey,\n type X25519PublicKey,\n type SharedSecret,\n BN254_FIELD_PRIME,\n CURVE25519_FIELD_PRIME,\n assertBase85Limb,\n assertBn254FieldElement,\n assertCurve25519FieldElement,\n assertPoseidonPlaintext,\n assertPoseidonHash,\n assertPoseidonKey,\n assertPoseidonCiphertext,\n assertRcCiphertext,\n assertRcPlaintext,\n assertRcKey,\n assertRcCounter,\n assertRcEncryptionNonce,\n assertX25519Bytes,\n assertX25519PrivateKey,\n assertX25519PublicKey,\n assertSharedSecret,\n} from \"../../types/cryptography\";\n\nimport { ConversionError } from \"./branded\";\n\n/* =============================================================================\n * U256 <-> FIELD ELEMENT CONVERSIONS\n * ============================================================================= */\n\n/**\n * Converts a U256 to a Bn254FieldElement.\n *\n * @remarks\n * Input type: `U256` (bigint, range [0, 2^256 - 1]).\n * Output type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n *\n * This is a **narrowing conversion** — not every U256 is a valid BN254 field element,\n * because the BN254 prime (21888242871839275222246405745257275088548364400416034343698204186575808495617)\n * is less than 2^256. Any value at or above the prime is rejected.\n *\n * The BN254 curve (also called alt_bn128) is the elliptic curve used by Ethereum's\n * precompiled contracts for pairing-based ZK proofs. Its scalar field prime is\n * strictly less than 2^254, so all valid field elements fit in a U256.\n *\n * @param value - The U256 value to convert (must satisfy 0 <= value < BN254_FIELD_PRIME)\n * @returns The value as a `Bn254FieldElement`\n * @throws {ConversionError} If value >= BN254_FIELD_PRIME\n *\n * @example\n * ```typescript\n * const u256Value = assertU256(12345n);\n * const fieldElement = convertU256ToBn254FieldElement(u256Value);\n *\n * // Values at or above the BN254 prime are rejected:\n * const tooLarge = assertU256(BN254_FIELD_PRIME);\n * convertU256ToBn254FieldElement(tooLarge); // throws ConversionError\n * ```\n *\n * @see {@link convertBn254FieldElementToU256} — the inverse (always safe)\n * @public\n */\nexport function convertU256ToBn254FieldElement(value: U256): Bn254FieldElement {\n assertU256(value);\n if (value >= BN254_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds BN254 field prime`, {\n sourceValue: value,\n sourceType: \"U256\",\n targetType: \"Bn254FieldElement\",\n reason: `Value must be < ${String(BN254_FIELD_PRIME)}`,\n });\n }\n assertBn254FieldElement(value);\n return value;\n}\n\n/**\n * Converts a Bn254FieldElement to a U256.\n *\n * @remarks\n * Input type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n * Output type: `U256` (bigint, range [0, 2^256 - 1]).\n *\n * This is a **widening conversion** — all BN254 field elements are valid U256 values,\n * because BN254_FIELD_PRIME < 2^256. This conversion never throws.\n *\n * Use this when you need to pass a field element to a function that operates on\n * generic 256-bit integers, e.g. for byte encoding via {@link encodeU256ToU256LeBytes}.\n *\n * @param value - The Bn254FieldElement to convert\n * @returns The value as `U256`\n *\n * @example\n * ```typescript\n * const fieldElement = assertBn254FieldElement(12345n);\n * const u256Value = convertBn254FieldElementToU256(fieldElement);\n * // u256Value === 12345n as U256\n * ```\n *\n * @see {@link convertU256ToBn254FieldElement} — the inverse (may throw)\n * @public\n */\nexport function convertBn254FieldElementToU256(value: Bn254FieldElement): U256 {\n assertBn254FieldElement(value);\n assertU256(value);\n return value;\n}\n\n/**\n * Converts a U256 to a Curve25519FieldElement.\n *\n * @remarks\n * Input type: `U256` (bigint, range [0, 2^256 - 1]).\n * Output type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n *\n * This is a **narrowing conversion**. The Curve25519 field prime is 2^255 - 19,\n * which is strictly less than 2^256. Any U256 value >= 2^255 - 19 is rejected.\n *\n * Curve25519 is used in the Rescue cipher encryption and X25519 key exchange.\n * Field elements must be in canonical form (strictly less than the prime).\n *\n * @param value - The U256 value to convert (must satisfy 0 <= value < 2^255 - 19)\n * @returns The value as a `Curve25519FieldElement`\n * @throws {ConversionError} If value >= CURVE25519_FIELD_PRIME (2^255 - 19)\n *\n * @example\n * ```typescript\n * const u256Value = assertU256(12345n);\n * const fieldElement = convertU256ToCurve25519FieldElement(u256Value);\n *\n * // Values >= 2^255 - 19 are rejected:\n * const tooLarge = assertU256(CURVE25519_FIELD_PRIME);\n * convertU256ToCurve25519FieldElement(tooLarge); // throws ConversionError\n * ```\n *\n * @see {@link convertCurve25519FieldElementToU256} — the inverse (always safe)\n * @public\n */\nexport function convertU256ToCurve25519FieldElement(value: U256): Curve25519FieldElement {\n assertU256(value);\n if (value >= CURVE25519_FIELD_PRIME) {\n throw new ConversionError(`Value exceeds Curve25519 field prime`, {\n sourceValue: value,\n sourceType: \"U256\",\n targetType: \"Curve25519FieldElement\",\n reason: \"Value must be < 2^255 - 19\",\n });\n }\n assertCurve25519FieldElement(value);\n return value;\n}\n\n/**\n * Converts a Curve25519FieldElement to a U256.\n *\n * @remarks\n * Input type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n * Output type: `U256` (bigint, range [0, 2^256 - 1]).\n *\n * This is a **widening conversion** — all Curve25519 field elements are valid U256 values,\n * because CURVE25519_FIELD_PRIME (2^255 - 19) < 2^256. This conversion never throws.\n *\n * @param value - The Curve25519FieldElement to convert\n * @returns The value as `U256`\n *\n * @example\n * ```typescript\n * const fieldElement = assertCurve25519FieldElement(12345n);\n * const u256Value = convertCurve25519FieldElementToU256(fieldElement);\n * ```\n *\n * @see {@link convertU256ToCurve25519FieldElement} — the inverse (may throw)\n * @public\n */\nexport function convertCurve25519FieldElementToU256(value: Curve25519FieldElement): U256 {\n assertCurve25519FieldElement(value);\n assertU256(value);\n return value;\n}\n\n/* =============================================================================\n * CROSS-FIELD CONVERSIONS\n * ============================================================================= */\n\n/**\n * Converts a Bn254FieldElement to a Curve25519FieldElement.\n *\n * @remarks\n * Input type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n * Output type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n *\n * This is a **narrowing cross-field conversion**. Because BN254_FIELD_PRIME is\n * larger than CURVE25519_FIELD_PRIME, some BN254 field elements cannot be\n * represented in the Curve25519 field. Specifically, values in the range\n * [CURVE25519_FIELD_PRIME, BN254_FIELD_PRIME) are valid in BN254 but\n * invalid in Curve25519.\n *\n * This conversion is needed when a scalar computed in BN254 arithmetic\n * must be used as a Curve25519 field element (e.g. for Rescue cipher inputs).\n *\n * @param value - The Bn254FieldElement to convert (must satisfy value < 2^255 - 19)\n * @returns The value as a `Curve25519FieldElement`\n * @throws {ConversionError} If value >= CURVE25519_FIELD_PRIME\n *\n * @example\n * ```typescript\n * const bn254 = assertBn254FieldElement(12345n);\n * const curve25519 = convertBn254FieldElementToCurve25519FieldElement(bn254);\n *\n * // This would throw because BN254_FIELD_PRIME > CURVE25519_FIELD_PRIME:\n * const large = assertBn254FieldElement(CURVE25519_FIELD_PRIME);\n * convertBn254FieldElementToCurve25519FieldElement(large); // throws\n * ```\n *\n * @see {@link convertCurve25519FieldElementToBn254FieldElement} — the inverse (always safe)\n * @public\n */\nexport function convertBn254FieldElementToCurve25519FieldElement(\n value: Bn254FieldElement,\n): Curve25519FieldElement {\n assertBn254FieldElement(value);\n if (value >= CURVE25519_FIELD_PRIME) {\n throw new ConversionError(`BN254 field element exceeds Curve25519 field prime`, {\n sourceValue: value,\n sourceType: \"Bn254FieldElement\",\n targetType: \"Curve25519FieldElement\",\n reason: \"Value must be < 2^255 - 19\",\n });\n }\n assertCurve25519FieldElement(value);\n return value;\n}\n\n/**\n * Converts a Curve25519FieldElement to a Bn254FieldElement.\n *\n * @remarks\n * Input type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n * Output type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n *\n * This is a **widening cross-field conversion** — always safe because\n * CURVE25519_FIELD_PRIME (2^255 - 19) < BN254_FIELD_PRIME. Every Curve25519\n * field element is a valid BN254 field element.\n *\n * This conversion is needed when Rescue cipher outputs (Curve25519 elements)\n * must be fed into Poseidon hash inputs (BN254 elements).\n *\n * @param value - The Curve25519FieldElement to convert\n * @returns The value as a `Bn254FieldElement`\n *\n * @example\n * ```typescript\n * const curve25519 = assertCurve25519FieldElement(12345n);\n * const bn254 = convertCurve25519FieldElementToBn254FieldElement(curve25519);\n * ```\n *\n * @see {@link convertBn254FieldElementToCurve25519FieldElement} — the inverse (may throw)\n * @public\n */\nexport function convertCurve25519FieldElementToBn254FieldElement(\n value: Curve25519FieldElement,\n): Bn254FieldElement {\n assertCurve25519FieldElement(value);\n assertBn254FieldElement(value);\n return value;\n}\n\n/* =============================================================================\n * POSEIDON TYPE PROMOTIONS (Bn254FieldElement -> Poseidon*)\n * ============================================================================= */\n\n/**\n * Promotes a Bn254FieldElement to a PoseidonPlaintext.\n *\n * @remarks\n * Input type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n * Output type: `PoseidonPlaintext` (bigint, same range — a sub-brand of Bn254FieldElement).\n *\n * This is a **brand promotion** (type narrowing in semantic terms, not in value range).\n * Both types have identical numerical constraints; this function just attaches the\n * `PoseidonPlaintext` brand to signal that the value is intended as plaintext input\n * to a Poseidon encryption or hashing operation.\n *\n * The Poseidon hash function operates over the BN254 scalar field, so all valid\n * BN254 field elements are valid Poseidon plaintexts.\n *\n * @param value - The Bn254FieldElement to promote\n * @returns The value as `PoseidonPlaintext`\n *\n * @example\n * ```typescript\n * const fieldElement = assertBn254FieldElement(12345n);\n * const plaintext = convertBn254FieldElementToPoseidonPlaintext(fieldElement);\n * ```\n *\n * @see {@link convertPoseidonPlaintextToBn254FieldElement} — the inverse extraction\n * @public\n */\nexport function convertBn254FieldElementToPoseidonPlaintext(\n value: Bn254FieldElement,\n): PoseidonPlaintext {\n assertBn254FieldElement(value);\n assertPoseidonPlaintext(value);\n return value;\n}\n\n/**\n * Promotes a Bn254FieldElement to a PoseidonHash.\n *\n * @remarks\n * Input type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n * Output type: `PoseidonHash` (bigint, same range — a sub-brand of Bn254FieldElement).\n *\n * This is a **brand promotion** — attaches the `PoseidonHash` brand to indicate\n * the value is a Poseidon hash digest. Numerically equivalent to the input.\n *\n * @param value - The Bn254FieldElement to promote\n * @returns The value as `PoseidonHash`\n *\n * @example\n * ```typescript\n * const fieldElement = assertBn254FieldElement(hashOutputBigInt);\n * const hash = convertBn254FieldElementToPoseidonHash(fieldElement);\n * ```\n *\n * @see {@link convertPoseidonHashToBn254FieldElement} — the inverse extraction\n * @public\n */\nexport function convertBn254FieldElementToPoseidonHash(value: Bn254FieldElement): PoseidonHash {\n assertBn254FieldElement(value);\n assertPoseidonHash(value);\n return value;\n}\n\n/**\n * Promotes a Bn254FieldElement to a PoseidonKey.\n *\n * @remarks\n * Input type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n * Output type: `PoseidonKey` (bigint, same range — a sub-brand of Bn254FieldElement).\n *\n * This is a **brand promotion** — attaches the `PoseidonKey` brand to indicate\n * the value is a Poseidon encryption key. Numerically equivalent to the input.\n *\n * Poseidon keys are used in the Poseidon cipher to encrypt UTXO data.\n *\n * @param value - The Bn254FieldElement to promote\n * @returns The value as `PoseidonKey`\n *\n * @example\n * ```typescript\n * const fieldElement = assertBn254FieldElement(derivedKeyBigInt);\n * const key = convertBn254FieldElementToPoseidonKey(fieldElement);\n * ```\n *\n * @see {@link convertPoseidonKeyToBn254FieldElement} — the inverse extraction\n * @public\n */\nexport function convertBn254FieldElementToPoseidonKey(value: Bn254FieldElement): PoseidonKey {\n assertBn254FieldElement(value);\n assertPoseidonKey(value);\n return value;\n}\n\n/**\n * Promotes a Bn254FieldElement to a PoseidonCiphertext.\n *\n * @remarks\n * Input type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n * Output type: `PoseidonCiphertext` (bigint, same range — a sub-brand of Bn254FieldElement).\n *\n * This is a **brand promotion** — attaches the `PoseidonCiphertext` brand to indicate\n * the value is a Poseidon cipher output element. Numerically equivalent to the input.\n *\n * @param value - The Bn254FieldElement to promote\n * @returns The value as `PoseidonCiphertext`\n *\n * @example\n * ```typescript\n * const fieldElement = assertBn254FieldElement(encryptedBigInt);\n * const ciphertext = convertBn254FieldElementToPoseidonCiphertext(fieldElement);\n * ```\n *\n * @see {@link convertPoseidonCiphertextToBn254FieldElement} — the inverse extraction\n * @public\n */\nexport function convertBn254FieldElementToPoseidonCiphertext(\n value: Bn254FieldElement,\n): PoseidonCiphertext {\n assertBn254FieldElement(value);\n assertPoseidonCiphertext(value);\n return value;\n}\n\n/* =============================================================================\n * POSEIDON TYPE EXTRACTIONS (Poseidon* -> Bn254FieldElement)\n * ============================================================================= */\n\n/**\n * Extracts a Bn254FieldElement from a PoseidonPlaintext.\n *\n * @remarks\n * Input type: `PoseidonPlaintext` (bigint, sub-brand of Bn254FieldElement).\n * Output type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n *\n * This is a **brand extraction** — removes the `PoseidonPlaintext` brand and\n * returns the underlying `Bn254FieldElement`. The numeric value is unchanged.\n *\n * Use this when you need to pass a Poseidon plaintext value to a function that\n * accepts a generic `Bn254FieldElement`, e.g. for encoding or arithmetic.\n *\n * @param value - The PoseidonPlaintext to extract from\n * @returns The value as `Bn254FieldElement`\n *\n * @example\n * ```typescript\n * const plaintext = assertPoseidonPlaintext(12345n);\n * const fieldElement = convertPoseidonPlaintextToBn254FieldElement(plaintext);\n * ```\n *\n * @see {@link convertBn254FieldElementToPoseidonPlaintext} — the inverse promotion\n * @public\n */\nexport function convertPoseidonPlaintextToBn254FieldElement(\n value: PoseidonPlaintext,\n): Bn254FieldElement {\n assertPoseidonPlaintext(value);\n assertBn254FieldElement(value);\n return value;\n}\n\n/**\n * Extracts a Bn254FieldElement from a PoseidonHash.\n *\n * @remarks\n * Input type: `PoseidonHash` (bigint, sub-brand of Bn254FieldElement).\n * Output type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n *\n * This is a **brand extraction** — removes the `PoseidonHash` brand.\n * The numeric value is unchanged.\n *\n * @param value - The PoseidonHash to extract from\n * @returns The value as `Bn254FieldElement`\n *\n * @example\n * ```typescript\n * const hash = assertPoseidonHash(hashOutputBigInt);\n * const fieldElement = convertPoseidonHashToBn254FieldElement(hash);\n * ```\n *\n * @see {@link convertBn254FieldElementToPoseidonHash} — the inverse promotion\n * @public\n */\nexport function convertPoseidonHashToBn254FieldElement(value: PoseidonHash): Bn254FieldElement {\n assertPoseidonHash(value);\n assertBn254FieldElement(value);\n return value;\n}\n\n/**\n * Extracts a Bn254FieldElement from a PoseidonKey.\n *\n * @remarks\n * Input type: `PoseidonKey` (bigint, sub-brand of Bn254FieldElement).\n * Output type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n *\n * This is a **brand extraction** — removes the `PoseidonKey` brand.\n * The numeric value is unchanged.\n *\n * @param value - The PoseidonKey to extract from\n * @returns The value as `Bn254FieldElement`\n *\n * @example\n * ```typescript\n * const key = assertPoseidonKey(derivedKeyBigInt);\n * const fieldElement = convertPoseidonKeyToBn254FieldElement(key);\n * ```\n *\n * @see {@link convertBn254FieldElementToPoseidonKey} — the inverse promotion\n * @public\n */\nexport function convertPoseidonKeyToBn254FieldElement(value: PoseidonKey): Bn254FieldElement {\n assertPoseidonKey(value);\n assertBn254FieldElement(value);\n return value;\n}\n\n/**\n * Extracts a Bn254FieldElement from a PoseidonCiphertext.\n *\n * @remarks\n * Input type: `PoseidonCiphertext` (bigint, sub-brand of Bn254FieldElement).\n * Output type: `Bn254FieldElement` (bigint, range [0, BN254_FIELD_PRIME - 1]).\n *\n * This is a **brand extraction** — removes the `PoseidonCiphertext` brand.\n * The numeric value is unchanged.\n *\n * @param value - The PoseidonCiphertext to extract from\n * @returns The value as `Bn254FieldElement`\n *\n * @example\n * ```typescript\n * const ciphertext = assertPoseidonCiphertext(encryptedBigInt);\n * const fieldElement = convertPoseidonCiphertextToBn254FieldElement(ciphertext);\n * ```\n *\n * @see {@link convertBn254FieldElementToPoseidonCiphertext} — the inverse promotion\n * @public\n */\nexport function convertPoseidonCiphertextToBn254FieldElement(\n value: PoseidonCiphertext,\n): Bn254FieldElement {\n assertPoseidonCiphertext(value);\n assertBn254FieldElement(value);\n return value;\n}\n\n/* =============================================================================\n * RESCUE TYPE PROMOTIONS (Curve25519FieldElement -> Rc*)\n * ============================================================================= */\n\n/**\n * Promotes a Curve25519FieldElement to an RcPlaintext.\n *\n * @remarks\n * Input type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n * Output type: `RcPlaintext` (bigint, same range — a sub-brand of Curve25519FieldElement).\n *\n * This is a **brand promotion** — attaches the `RcPlaintext` brand to indicate\n * the value is plaintext input to the Rescue cipher (Rc) scheme. The Rescue cipher\n * operates over the Curve25519 field, so inputs must be valid Curve25519 elements.\n *\n * The Rescue cipher is used to encrypt confidential token balances in the Umbra protocol.\n *\n * @param value - The Curve25519FieldElement to promote\n * @returns The value as `RcPlaintext`\n *\n * @example\n * ```typescript\n * const fieldElement = assertCurve25519FieldElement(balanceBigInt);\n * const plaintext = convertCurve25519FieldElementToRcPlaintext(fieldElement);\n * ```\n *\n * @see {@link convertRcPlaintextToCurve25519FieldElement} — the inverse extraction\n * @public\n */\nexport function convertCurve25519FieldElementToRcPlaintext(\n value: Curve25519FieldElement,\n): RcPlaintext {\n assertCurve25519FieldElement(value);\n assertRcPlaintext(value);\n return value;\n}\n\n/**\n * Promotes a Curve25519FieldElement to an RcCiphertext.\n *\n * @remarks\n * Input type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n * Output type: `RcCiphertext` (bigint, same range — a sub-brand of Curve25519FieldElement).\n *\n * This is a **brand promotion** — attaches the `RcCiphertext` brand to indicate\n * the value is a Rescue cipher encrypted output element.\n *\n * @param value - The Curve25519FieldElement to promote\n * @returns The value as `RcCiphertext`\n *\n * @example\n * ```typescript\n * const fieldElement = assertCurve25519FieldElement(encryptedBigInt);\n * const ciphertext = convertCurve25519FieldElementToRcCiphertext(fieldElement);\n * ```\n *\n * @see {@link convertRcCiphertextToCurve25519FieldElement} — the inverse extraction\n * @public\n */\nexport function convertCurve25519FieldElementToRcCiphertext(\n value: Curve25519FieldElement,\n): RcCiphertext {\n assertCurve25519FieldElement(value);\n assertRcCiphertext(value);\n return value;\n}\n\n/**\n * Promotes a Curve25519FieldElement to an RcKey.\n *\n * @remarks\n * Input type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n * Output type: `RcKey` (bigint, same range — a sub-brand of Curve25519FieldElement).\n *\n * This is a **brand promotion** — attaches the `RcKey` brand to indicate the value\n * is a Rescue cipher key. Keys are derived from X25519 shared secrets and must be\n * valid Curve25519 field elements.\n *\n * @param value - The Curve25519FieldElement to promote\n * @returns The value as `RcKey`\n *\n * @example\n * ```typescript\n * const fieldElement = assertCurve25519FieldElement(derivedKeyBigInt);\n * const key = convertCurve25519FieldElementToRcKey(fieldElement);\n * ```\n *\n * @see {@link convertRcKeyToCurve25519FieldElement} — the inverse extraction\n * @public\n */\nexport function convertCurve25519FieldElementToRcKey(value: Curve25519FieldElement): RcKey {\n assertCurve25519FieldElement(value);\n assertRcKey(value);\n return value;\n}\n\n/**\n * Promotes a Curve25519FieldElement to an RcCounter.\n *\n * @remarks\n * Input type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n * Output type: `RcCounter` (bigint, same range — a sub-brand of Curve25519FieldElement).\n *\n * This is a **brand promotion** — attaches the `RcCounter` brand to indicate the\n * value is a Rescue cipher counter. Counters are used in counter-mode encryption\n * to generate unique keystream elements for each plaintext block.\n *\n * @param value - The Curve25519FieldElement to promote\n * @returns The value as `RcCounter`\n *\n * @example\n * ```typescript\n * const fieldElement = assertCurve25519FieldElement(1n);\n * const counter = convertCurve25519FieldElementToRcCounter(fieldElement);\n * ```\n *\n * @see {@link convertRcCounterToCurve25519FieldElement} — the inverse extraction\n * @public\n */\nexport function convertCurve25519FieldElementToRcCounter(value: Curve25519FieldElement): RcCounter {\n assertCurve25519FieldElement(value);\n assertRcCounter(value);\n return value;\n}\n\n/* =============================================================================\n * RESCUE TYPE EXTRACTIONS (Rc* -> Curve25519FieldElement)\n * ============================================================================= */\n\n/**\n * Extracts a Curve25519FieldElement from an RcPlaintext.\n *\n * @remarks\n * Input type: `RcPlaintext` (bigint, sub-brand of Curve25519FieldElement).\n * Output type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n *\n * This is a **brand extraction** — removes the `RcPlaintext` brand and returns\n * the underlying `Curve25519FieldElement`. The numeric value is unchanged.\n *\n * @param value - The RcPlaintext to extract from\n * @returns The value as `Curve25519FieldElement`\n *\n * @example\n * ```typescript\n * const plaintext = assertRcPlaintext(messageBigInt);\n * const fieldElement = convertRcPlaintextToCurve25519FieldElement(plaintext);\n * ```\n *\n * @see {@link convertCurve25519FieldElementToRcPlaintext} — the inverse promotion\n * @public\n */\nexport function convertRcPlaintextToCurve25519FieldElement(\n value: RcPlaintext,\n): Curve25519FieldElement {\n assertRcPlaintext(value);\n assertCurve25519FieldElement(value);\n return value;\n}\n\n/**\n * Extracts a Curve25519FieldElement from an RcCiphertext.\n *\n * @remarks\n * Input type: `RcCiphertext` (bigint, sub-brand of Curve25519FieldElement).\n * Output type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n *\n * This is a **brand extraction** — removes the `RcCiphertext` brand.\n * The numeric value is unchanged.\n *\n * @param value - The RcCiphertext to extract from\n * @returns The value as `Curve25519FieldElement`\n *\n * @example\n * ```typescript\n * const ciphertext = assertRcCiphertext(encryptedBigInt);\n * const fieldElement = convertRcCiphertextToCurve25519FieldElement(ciphertext);\n * ```\n *\n * @see {@link convertCurve25519FieldElementToRcCiphertext} — the inverse promotion\n * @public\n */\nexport function convertRcCiphertextToCurve25519FieldElement(\n value: RcCiphertext,\n): Curve25519FieldElement {\n assertRcCiphertext(value);\n assertCurve25519FieldElement(value);\n return value;\n}\n\n/**\n * Extracts a Curve25519FieldElement from an RcKey.\n *\n * @remarks\n * Input type: `RcKey` (bigint, sub-brand of Curve25519FieldElement).\n * Output type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n *\n * This is a **brand extraction** — removes the `RcKey` brand.\n * The numeric value is unchanged.\n *\n * @param value - The RcKey to extract from\n * @returns The value as `Curve25519FieldElement`\n *\n * @example\n * ```typescript\n * const key = assertRcKey(derivedKeyBigInt);\n * const fieldElement = convertRcKeyToCurve25519FieldElement(key);\n * ```\n *\n * @see {@link convertCurve25519FieldElementToRcKey} — the inverse promotion\n * @public\n */\nexport function convertRcKeyToCurve25519FieldElement(value: RcKey): Curve25519FieldElement {\n assertRcKey(value);\n assertCurve25519FieldElement(value);\n return value;\n}\n\n/**\n * Extracts a Curve25519FieldElement from an RcCounter.\n *\n * @remarks\n * Input type: `RcCounter` (bigint, sub-brand of Curve25519FieldElement).\n * Output type: `Curve25519FieldElement` (bigint, range [0, 2^255 - 20]).\n *\n * This is a **brand extraction** — removes the `RcCounter` brand.\n * The numeric value is unchanged.\n *\n * @param value - The RcCounter to extract from\n * @returns The value as `Curve25519FieldElement`\n *\n * @example\n * ```typescript\n * const counter = assertRcCounter(counterBigInt);\n * const fieldElement = convertRcCounterToCurve25519FieldElement(counter);\n * ```\n *\n * @see {@link convertCurve25519FieldElementToRcCounter} — the inverse promotion\n * @public\n */\nexport function convertRcCounterToCurve25519FieldElement(value: RcCounter): Curve25519FieldElement {\n assertRcCounter(value);\n assertCurve25519FieldElement(value);\n return value;\n}\n\n/**\n * Converts a U128 to an RcEncryptionNonce.\n *\n * @remarks\n * Input type: `U128` (bigint, range [0, 2^128 - 1]).\n * Output type: `RcEncryptionNonce` (bigint, same range — a sub-brand of U128).\n *\n * This is a **brand promotion** — attaches the `RcEncryptionNonce` brand to indicate\n * the value is a nonce for Rescue cipher encryption. Unlike the Rescue field element\n * types (which are sub-brands of Curve25519FieldElement), encryption nonces are\n * 128-bit integers that are promoted to the Curve25519 field during cipher setup.\n *\n * Nonces must be unique for each encryption operation with the same key to maintain\n * semantic security. A 128-bit nonce space is sufficient for random generation with\n * negligible collision probability across all practical usage volumes.\n *\n * @param value - The U128 to promote to an RcEncryptionNonce\n * @returns The value as `RcEncryptionNonce`\n *\n * @example\n * ```typescript\n * const nonce = assertU128(crypto.getRandomValues(new Uint8Array(16)));\n * const rcNonce = convertU128ToRcEncryptionNonce(nonce);\n * ```\n *\n * @see {@link convertRcEncryptionNonceToU128} — the inverse extraction\n * @public\n */\nexport function convertU128ToRcEncryptionNonce(value: U128): RcEncryptionNonce {\n assertU128(value);\n assertRcEncryptionNonce(value);\n return value;\n}\n\n/**\n * Extracts a U128 from an RcEncryptionNonce.\n *\n * @remarks\n * Input type: `RcEncryptionNonce` (bigint, sub-brand of U128, range [0, 2^128 - 1]).\n * Output type: `U128` (bigint, range [0, 2^128 - 1]).\n *\n * This is a **brand extraction** — removes the `RcEncryptionNonce` brand and returns\n * the underlying `U128`. The numeric value is unchanged.\n *\n * Use this when you need the raw 128-bit integer value of a nonce, e.g. to\n * encode it into a byte array for on-chain storage.\n *\n * @param value - The RcEncryptionNonce to extract from\n * @returns The value as `U128`\n *\n * @example\n * ```typescript\n * const rcNonce = assertRcEncryptionNonce(nonceBigInt);\n * const u128 = convertRcEncryptionNonceToU128(rcNonce);\n * const bytes = encodeU128ToU128LeBytes(u128); // store on-chain in LE\n * ```\n *\n * @see {@link convertU128ToRcEncryptionNonce} — the inverse promotion\n * @public\n */\nexport function convertRcEncryptionNonceToU128(value: RcEncryptionNonce): U128 {\n assertRcEncryptionNonce(value);\n assertU128(value);\n return value;\n}\n\n/* =============================================================================\n * X25519 BYTE ARRAY CONVERSIONS\n *\n * Conversions between X25519Bytes, SharedSecret, and related types.\n * ============================================================================= */\n\n/**\n * Converts X25519Bytes to an X25519PrivateKey.\n *\n * @remarks\n * Input type: `X25519Bytes` (Uint8Array, exactly 32 bytes).\n * Output type: `X25519PrivateKey` (Uint8Array, exactly 32 bytes — a sub-brand).\n *\n * This is a **brand promotion** — both types are exactly 32 raw bytes with identical\n * constraints. The brand distinction communicates intent: `X25519PrivateKey` signals\n * the bytes are a secret scalar (the private component of an X25519 key pair), while\n * `X25519Bytes` is the generic base type.\n *\n * X25519 private keys are 32-byte little-endian scalars. The X25519 key agreement\n * function clamps certain bits before use, but the raw bytes are stored unclamped.\n *\n * @param value - The X25519Bytes to promote (must be exactly 32 bytes)\n * @returns The value as `X25519PrivateKey`\n *\n * @example\n * ```typescript\n * const rawBytes = assertX25519Bytes(crypto.getRandomValues(new Uint8Array(32)));\n * const privateKey = convertX25519BytesToX25519PrivateKey(rawBytes);\n * ```\n *\n * @see {@link convertX25519PrivateKeyToX25519Bytes} — the inverse extraction\n * @see {@link convertX25519BytesToX25519PublicKey} — promotion to public key\n * @see {@link convertX25519BytesToSharedSecret} — promotion to shared secret\n * @public\n */\nexport function convertX25519BytesToX25519PrivateKey(value: X25519Bytes): X25519PrivateKey {\n assertX25519Bytes(value);\n assertX25519PrivateKey(value);\n return value;\n}\n\n/**\n * Converts X25519Bytes to an X25519PublicKey.\n *\n * @remarks\n * Input type: `X25519Bytes` (Uint8Array, exactly 32 bytes).\n * Output type: `X25519PublicKey` (Uint8Array, exactly 32 bytes — a sub-brand).\n *\n * This is a **brand promotion** — both types are exactly 32 raw bytes. The\n * `X25519PublicKey` brand signals the bytes are a public curve point (the result\n * of scalar multiplication of the private key by the curve's base point), encoded\n * in little-endian form per the Curve25519 specification.\n *\n * In the Umbra protocol, X25519 public keys are stored in on-chain user accounts\n * and used by senders to derive shared secrets for encrypting confidential transfers.\n *\n * @param value - The X25519Bytes to promote (must be exactly 32 bytes)\n * @returns The value as `X25519PublicKey`\n *\n * @example\n * ```typescript\n * const rawPublicKeyBytes = assertX25519Bytes(receivedKeyBytes);\n * const publicKey = convertX25519BytesToX25519PublicKey(rawPublicKeyBytes);\n * ```\n *\n * @see {@link convertX25519PublicKeyToX25519Bytes} — the inverse extraction\n * @see {@link splitX25519PublicKeyIntoTwoU128s} — split for on-chain storage\n * @public\n */\nexport function convertX25519BytesToX25519PublicKey(value: X25519Bytes): X25519PublicKey {\n assertX25519Bytes(value);\n assertX25519PublicKey(value);\n return value;\n}\n\n/**\n * Converts X25519Bytes to a SharedSecret.\n *\n * @remarks\n * Input type: `X25519Bytes` (Uint8Array, exactly 32 bytes).\n * Output type: `SharedSecret` (Uint8Array, exactly 32 bytes — a sub-brand).\n *\n * This is a **brand promotion** — attaches the `SharedSecret` brand to indicate\n * the bytes are the output of an X25519 Diffie-Hellman key exchange. The shared\n * secret is the u-coordinate of the resulting elliptic curve point, encoded as\n * a 32-byte little-endian integer.\n *\n * The shared secret should NOT be used directly as an encryption key. Instead,\n * pass it through a Key Derivation Function (KDF) to produce cryptographically\n * independent keys for different purposes.\n *\n * @param value - The X25519Bytes to promote (must be exactly 32 bytes)\n * @returns The value as `SharedSecret`\n *\n * @example\n * ```typescript\n * const dhOutput = assertX25519Bytes(x25519(privateKey, theirPublicKey));\n * const sharedSecret = convertX25519BytesToSharedSecret(dhOutput);\n * // Then derive keys: const encKey = hkdf(sharedSecret, ...);\n * ```\n *\n * @see {@link convertSharedSecretToX25519Bytes} — the inverse extraction\n * @public\n */\nexport function convertX25519BytesToSharedSecret(value: X25519Bytes): SharedSecret {\n assertX25519Bytes(value);\n assertSharedSecret(value);\n return value;\n}\n\n/**\n * Extracts X25519Bytes from an X25519PrivateKey.\n *\n * @remarks\n * Input type: `X25519PrivateKey` (Uint8Array, exactly 32 bytes).\n * Output type: `X25519Bytes` (Uint8Array, exactly 32 bytes — the base type).\n *\n * This is a **brand extraction** — removes the `X25519PrivateKey` brand and returns\n * the base `X25519Bytes` type. The byte content is unchanged.\n *\n * Use this when you need to pass a private key to a function that accepts the\n * generic `X25519Bytes` type.\n *\n * @param value - The X25519PrivateKey to extract from (must be exactly 32 bytes)\n * @returns The value as `X25519Bytes`\n *\n * @example\n * ```typescript\n * const privateKey = assertX25519PrivateKey(rawKeyBytes);\n * const x25519Bytes = convertX25519PrivateKeyToX25519Bytes(privateKey);\n * ```\n *\n * @see {@link convertX25519BytesToX25519PrivateKey} — the inverse promotion\n * @public\n */\nexport function convertX25519PrivateKeyToX25519Bytes(value: X25519PrivateKey): X25519Bytes {\n assertX25519PrivateKey(value);\n assertX25519Bytes(value);\n return value;\n}\n\n/**\n * Extracts X25519Bytes from an X25519PublicKey.\n *\n * @remarks\n * Input type: `X25519PublicKey` (Uint8Array, exactly 32 bytes).\n * Output type: `X25519Bytes` (Uint8Array, exactly 32 bytes — the base type).\n *\n * This is a **brand extraction** — removes the `X25519PublicKey` brand and returns\n * the base `X25519Bytes` type. The byte content is unchanged.\n *\n * @param value - The X25519PublicKey to extract from (must be exactly 32 bytes)\n * @returns The value as `X25519Bytes`\n *\n * @example\n * ```typescript\n * const publicKey = assertX25519PublicKey(rawKeyBytes);\n * const x25519Bytes = convertX25519PublicKeyToX25519Bytes(publicKey);\n * ```\n *\n * @see {@link convertX25519BytesToX25519PublicKey} — the inverse promotion\n * @public\n */\nexport function convertX25519PublicKeyToX25519Bytes(value: X25519PublicKey): X25519Bytes {\n assertX25519PublicKey(value);\n assertX25519Bytes(value);\n return value;\n}\n\n/**\n * Extracts X25519Bytes from a SharedSecret.\n *\n * @remarks\n * Input type: `SharedSecret` (Uint8Array, exactly 32 bytes).\n * Output type: `X25519Bytes` (Uint8Array, exactly 32 bytes — the base type).\n *\n * This is a **brand extraction** — removes the `SharedSecret` brand and returns\n * the base `X25519Bytes` type. The byte content is unchanged.\n *\n * @param value - The SharedSecret to extract from (must be exactly 32 bytes)\n * @returns The value as `X25519Bytes`\n *\n * @example\n * ```typescript\n * const sharedSecret = assertSharedSecret(dhOutput);\n * const x25519Bytes = convertSharedSecretToX25519Bytes(sharedSecret);\n * ```\n *\n * @see {@link convertX25519BytesToSharedSecret} — the inverse promotion\n * @public\n */\nexport function convertSharedSecretToX25519Bytes(value: SharedSecret): X25519Bytes {\n assertSharedSecret(value);\n assertX25519Bytes(value);\n return value;\n}\n\n/* =============================================================================\n * U256 SPLITTING CONVERSIONS\n *\n * Functions for splitting 256-bit values into smaller components for\n * cryptographic operations and ZK circuit compatibility.\n * ============================================================================= */\n\n/**\n * Splits a U256 into two U128 values representing the low and high 128-bit halves.\n *\n * @remarks\n * Input type: `U256` (bigint, range [0, 2^256 - 1]).\n * Output: `{ low: U128, high: U128 }` — two non-negative bigints each in [0, 2^128 - 1].\n *\n * The split is performed arithmetically at the 128-bit boundary using bitwise\n * operations (no byte-level manipulation). The decomposition satisfies:\n *\n * ```\n * value = low + high * 2^128\n * ```\n *\n * This representation is commonly required when passing 256-bit values into\n * Arcium MPC computations or Solana programs that accept two 128-bit fields.\n *\n * @param value - The U256 value to split\n * @returns An object with `low` (bits 0-127) and `high` (bits 128-255) as U128 values\n *\n * @example\n * ```typescript\n * const u256Value = assertU256(\n * 0x1234567890abcdef1234567890abcdefn * (2n ** 128n) +\n * 0xfedcba0987654321fedcba0987654321n\n * );\n * const { low, high } = splitU256IntoTwoU128s(u256Value);\n * // low === 0xfedcba0987654321fedcba0987654321n\n * // high === 0x1234567890abcdef1234567890abcdefn\n * ```\n *\n * @see {@link splitX25519PublicKeyIntoTwoU128s} — split a 32-byte key using little-endian byte interpretation\n * @public\n */\nexport function splitU256IntoTwoU128s(value: U256): { low: U128; high: U128 } {\n assertU256(value);\n\n const U128_MAX = (1n << 128n) - 1n;\n\n // Extract low 128 bits\n const lowValue = value & U128_MAX;\n assertU128(lowValue);\n\n // Extract high 128 bits\n const highValue = value >> 128n;\n assertU128(highValue);\n\n return { low: lowValue, high: highValue };\n}\n\n/**\n * Splits an X25519 public key into two U128 values using little-endian byte interpretation.\n *\n * @remarks\n * Input type: `X25519PublicKey` (Uint8Array, exactly 32 bytes in little-endian order).\n * Output: `{ low: U128, high: U128 }` — two non-negative bigints each in [0, 2^128 - 1].\n *\n * Unlike {@link splitU256IntoTwoU128s} which performs an arithmetic split on a bigint,\n * this function reads the raw bytes of the key in little-endian order and interprets\n * each 16-byte half as a little-endian U128.\n *\n * Byte layout:\n * ```\n * key: [b0, b1, ..., b15, b16, b17, ..., b31]\n * └─── low (LE) ──┘ └─── high (LE) ──┘\n *\n * low = b0 + b1*256 + b2*256^2 + ... + b15*256^15\n * high = b16 + b17*256 + b18*256^2 + ... + b31*256^15\n * ```\n *\n * This function is used to encode X25519 public keys into two U128 fields for\n * on-chain storage in Solana accounts (which require fixed-width integer fields).\n * The little-endian interpretation matches Curve25519's native encoding.\n *\n * @param key - The X25519PublicKey (exactly 32 bytes, little-endian encoded)\n * @returns An object with `low` (bytes 0-15 as LE U128) and `high` (bytes 16-31 as LE U128)\n *\n * @example\n * ```typescript\n * const publicKey = assertX25519PublicKey(keyBytes);\n * const { low, high } = splitX25519PublicKeyIntoTwoU128s(publicKey);\n * // Store low and high in two separate u128 fields in the on-chain account\n * ```\n *\n * @see {@link splitU256IntoTwoU128s} — arithmetic split of a U256 bigint\n * @public\n */\nexport function splitX25519PublicKeyIntoTwoU128s(key: X25519PublicKey): {\n low: U128;\n high: U128;\n} {\n assertX25519PublicKey(key);\n\n // bytes[0..16] in LE forms the low U128\n let low = 0n;\n for (let index = U128_BYTE_LENGTH - 1; index >= 0; index--) {\n low = (low << 8n) | BigInt(key[index]);\n }\n\n // bytes[16..32] in LE forms the high U128\n let high = 0n;\n for (let index = U256_BYTE_LENGTH - 1; index >= U128_BYTE_LENGTH; index--) {\n high = (high << 8n) | BigInt(key[index]);\n }\n\n assertU128(low);\n assertU128(high);\n\n return { low, high };\n}\n\n/**\n * Converts a U256 into a tuple of three Base85 limbs for ZK circuit compatibility.\n *\n * @remarks\n * Input type: `U256` (bigint, range [0, 2^256 - 1]).\n * Output type: `Base85LimbTuple` — three bigint limbs, each less than 2^86.\n *\n * ## What is Base85 limb decomposition?\n *\n * The BN254 (alt_bn128) elliptic curve used in Groth16 ZK proofs has a scalar\n * field of size approximately 2^254. Its field prime is:\n * `21888242871839275222246405745257275088548364400416034343698204186575808495617`\n *\n * Since this prime is greater than 2^253 but less than 2^254, a 256-bit value\n * cannot fit as a single field element in a BN254 ZK circuit — it would need to\n * be range-checked against the prime. Instead, the value is decomposed into three\n * limbs using 85-bit chunks (\"Base85\"), where each limb fits comfortably within\n * a BN254 field element (since 2^86 < BN254_FIELD_PRIME).\n *\n * The term \"Base85\" refers to the limb size (85 bits = the base of the number system\n * for the low and middle limbs), NOT the ASCII Base85 encoding. Each limb is at most\n * 85 bits (86 bits for the high limb), which is well within the BN254 scalar field.\n *\n * ## Decomposition formula\n *\n * ```\n * value = low + middle * 2^85 + high * 2^170\n * ```\n *\n * Limb sizes:\n * - `low`: bits 0-84 (85 bits, range [0, 2^85 - 1])\n * - `middle`: bits 85-169 (85 bits, range [0, 2^85 - 1])\n * - `high`: bits 170-255 (86 bits, range [0, 2^86 - 1])\n *\n * Total: 85 + 85 + 86 = 256 bits — sufficient to represent any U256.\n *\n * In ZK circuits, these three limbs are passed as separate field element witnesses,\n * and the circuit reconstructs the original value using the formula above.\n *\n * @param value - The U256 value to decompose into Base85 limbs\n * @returns A `Base85LimbTuple` with `low`, `middle`, and `high` limbs\n *\n * @example\n * ```typescript\n * const u256Value = assertU256(12345678901234567890123456789012345678901234567890n);\n * const limbs = convertU256ToBase85Limbs(u256Value);\n * // limbs.low < 2^85\n * // limbs.middle < 2^85\n * // limbs.high < 2^86\n * // Reconstructed: limbs.low + limbs.middle * 2n**85n + limbs.high * 2n**170n === u256Value\n * ```\n *\n * @see {@link convertU256ToBn254FieldElement} — for values that fit in a single BN254 field element\n * @public\n */\nexport function convertU256ToBase85Limbs(value: U256): Base85LimbTuple {\n assertU256(value);\n\n const BASE85_MASK = (1n << 85n) - 1n;\n\n // Extract low 85 bits\n const lowValue = value & BASE85_MASK;\n assertBase85Limb(lowValue);\n\n // Extract middle 85 bits (bits 85-169)\n const middleValue = (value >> 85n) & BASE85_MASK;\n assertBase85Limb(middleValue);\n\n // Extract high bits (bits 170-255, at most 86 bits)\n const highValue = value >> 170n;\n assertBase85Limb(highValue);\n\n return {\n low: lowValue,\n middle: middleValue,\n high: highValue,\n };\n}\n","/**\n * Mathematics Utility Functions\n *\n * Provides cryptographically secure random number generators for the SDK's branded\n * unsigned integer types, as well as bigint decomposition utilities used in Merkle\n * tree path derivation and multi-precision arithmetic.\n *\n * ## Random Number Generation\n *\n * All random generation functions use `crypto.getRandomValues()` — the Web Crypto API's\n * cryptographically secure pseudo-random number generator (CSPRNG). This is suitable for\n * generating nonces, salts, per-session identifiers, and other security-sensitive values.\n * The generated bytes are interpreted in **little-endian** order so that the resulting\n * `bigint` can be round-tripped back to a byte array using the standard LE encoders\n * found in `../common/converters/mathematics`.\n *\n * ## Merkle Tree Utilities\n *\n * `bigintToBinaryArrayLSB` converts a leaf index to the sequence of left/right turns\n * required to navigate from the root of an Indexed Merkle Tree to the corresponding\n * leaf. The LSB-first ordering matches the Circom circuit convention used in the Umbra\n * claim proofs.\n *\n * @packageDocumentation\n * @module common/math-utils\n */\n\nimport {\n type U64,\n type U128,\n type U256,\n U64_BYTE_LENGTH,\n U128_BYTE_LENGTH,\n U256_BYTE_LENGTH,\n} from \"./types\";\n\n/**\n * Generates a cryptographically secure random value branded as `U128`.\n *\n * @remarks\n * Allocates a 16-byte `Uint8Array`, fills it using `crypto.getRandomValues()`, then\n * accumulates the bytes into a `bigint` using little-endian interpretation:\n *\n * ```\n * result = bytes[0] | (bytes[1] << 8) | ... | (bytes[15] << 120)\n * ```\n *\n * The result is guaranteed to be in the range `[0, 2^128 - 1]` and is uniformly\n * distributed across that range, making it safe for use as a cryptographic nonce or\n * random seed.\n *\n * The little-endian byte order matches the on-chain account layout and the SDK's\n * `encodeU128ToU128LeBytes` encoder, so generated values can be serialised into PDA\n * seeds without byte swapping.\n *\n * Typical uses in the Umbra protocol:\n * - Generating the `randomGenerationSeed` field of a new `EncryptedUserAccount`\n * (as a U128 component before full 256-bit assembly).\n * - Creating per-instruction random nonces for off-chain computation scheduling.\n *\n * @returns A `U128`-branded `bigint` sampled uniformly from `[0, 2^128 - 1]`.\n *\n * @example\n * ```typescript\n * import { generateRandomU128 } from \"@umbra-privacy/sdk\";\n *\n * const nonce = generateRandomU128();\n * // nonce is a U128 — typed and safe to pass to PDA derivation or encryption helpers.\n * console.log(nonce); // e.g. 198234871236498712364987123649871234n\n * ```\n *\n * @see {@link generateRandomU64} for the 64-bit variant.\n * @see {@link generateRandomU256} for the 256-bit variant.\n * @public\n */\nexport function generateRandomU128(): U128 {\n const bytes = new Uint8Array(U128_BYTE_LENGTH);\n crypto.getRandomValues(bytes);\n\n // Convert bytes to bigint (little-endian)\n let result = 0n;\n for (let index = 0; index < U128_BYTE_LENGTH; index++) {\n result |= BigInt(bytes[index]) << BigInt(index * 8);\n }\n\n return result as U128;\n}\n\n/**\n * Generates a cryptographically secure random value branded as `U64`.\n *\n * @remarks\n * Allocates an 8-byte `Uint8Array`, fills it using `crypto.getRandomValues()`, then\n * accumulates the bytes into a `bigint` using little-endian interpretation:\n *\n * ```\n * result = bytes[0] | (bytes[1] << 8) | ... | (bytes[7] << 56)\n * ```\n *\n * The result is guaranteed to be in the range `[0, 2^64 - 1]` and is uniformly\n * distributed across that range.\n *\n * Typical uses in the Umbra protocol:\n * - Generating unique identifiers for off-chain computation jobs.\n * - Producing random counters for testing or benchmarking.\n *\n * @returns A `U64`-branded `bigint` sampled uniformly from `[0, 2^64 - 1]`.\n *\n * @example\n * ```typescript\n * import { generateRandomU64 } from \"@umbra-privacy/sdk\";\n *\n * const jobId = generateRandomU64();\n * // jobId is a U64 — typed and safe to use as a computation identifier.\n * console.log(jobId); // e.g. 12345678901234567890n\n * ```\n *\n * @see {@link generateRandomU128} for the 128-bit variant.\n * @see {@link generateRandomU256} for the 256-bit variant.\n * @public\n */\nexport function generateRandomU64(): U64 {\n const bytes = new Uint8Array(U64_BYTE_LENGTH);\n crypto.getRandomValues(bytes);\n\n // Convert bytes to bigint (little-endian)\n let result = 0n;\n for (let index = 0; index < U64_BYTE_LENGTH; index++) {\n result |= BigInt(bytes[index]) << BigInt(index * 8);\n }\n\n return result as U64;\n}\n\n/**\n * Generates a cryptographically secure random value branded as `U256`.\n *\n * @remarks\n * Allocates a 32-byte `Uint8Array`, fills it using `crypto.getRandomValues()`, then\n * accumulates the bytes into a `bigint` using little-endian interpretation:\n *\n * ```\n * result = bytes[0] | (bytes[1] << 8) | ... | (bytes[31] << 248)\n * ```\n *\n * The result is guaranteed to be in the range `[0, 2^256 - 1]` and is uniformly\n * distributed across that range.\n *\n * Note that a uniformly random 256-bit value is NOT guaranteed to be a valid BN254\n * or Curve25519 field element (since both field primes are less than 2^256). If a\n * random field element is needed, use the field-specific samplers in\n * `../math/bn254/field-element-sampler` or `../math/curve25519/field-arithmetic`.\n *\n * Typical uses in the Umbra protocol:\n * - Generating the `randomGenerationSeed` (`U256LeBytes`) stored in `EncryptedUserAccount`\n * to provide additional entropy during nonce derivation.\n * - Producing random blinding factors for UTXO commitment construction.\n *\n * @returns A `U256`-branded `bigint` sampled uniformly from `[0, 2^256 - 1]`.\n *\n * @example\n * ```typescript\n * import { generateRandomU256 } from \"@umbra-privacy/sdk\";\n *\n * const randomSeed = generateRandomU256();\n * // randomSeed is a U256 — typed and safe to use as a random generation seed.\n * console.log(randomSeed); // e.g. a very large 256-bit integer\n * ```\n *\n * @see {@link generateRandomU64} for the 64-bit variant.\n * @see {@link generateRandomU128} for the 128-bit variant.\n * @public\n */\nexport function generateRandomU256(): U256 {\n const bytes = new Uint8Array(U256_BYTE_LENGTH);\n crypto.getRandomValues(bytes);\n\n // Convert bytes to bigint (little-endian)\n let result = 0n;\n for (let index = 0; index < U256_BYTE_LENGTH; index++) {\n result |= BigInt(bytes[index]) << BigInt(index * 8);\n }\n\n return result as U256;\n}\n\n/**\n * Converts a non-negative `bigint` to its binary representation as an array of bits\n * in LSB-first (least-significant-bit-first) order, zero-padded to `length` elements.\n *\n * @remarks\n * The Umbra Indexed Merkle Tree stores UTXO commitments in a binary tree. To locate a\n * leaf at a given index, the prover must compute the path from the root to that leaf.\n * Each bit of the leaf index selects the left (0) or right (1) child at each tree level.\n *\n * Circom circuits conventionally process bits starting from the least significant bit\n * (i.e. the deepest level of the tree first). `bigintToBinaryArrayLSB` produces exactly\n * this ordering so that the resulting array can be passed directly to the circuit's\n * path selector inputs without reversal.\n *\n * The function extracts bits using repeated bitwise AND with `1n` and right-shifts,\n * which is efficient for arbitrary-precision `bigint` values. If `value` has fewer than\n * `length` bits, the remaining positions are padded with `0`.\n *\n * @param value - A non-negative `bigint` representing the leaf index or any integer\n * whose binary decomposition is needed. Negative values are not validated and will\n * produce implementation-defined output from the bitwise operations.\n * @param length - The desired output array length. The function always returns exactly\n * this many elements. If `value` requires more bits than `length`, the most\n * significant bits are silently truncated.\n * @returns An array of `length` integers, each either `0` or `1`, representing the\n * binary digits of `value` from least significant to most significant.\n *\n * @example\n * ```typescript\n * import { bigintToBinaryArrayLSB } from \"@umbra-privacy/sdk\";\n *\n * // 5 in binary is 0b101. LSB first with padding to length 4:\n * bigintToBinaryArrayLSB(5n, 4);\n * // => [1, 0, 1, 0]\n * // ^ bit 0 (LSB, value & 1 = 1)\n * // ^ bit 1 (value >> 1 & 1 = 0)\n * // ^ bit 2 (value >> 2 & 1 = 1)\n * // ^ bit 3 (value >> 3 & 1 = 0, padding)\n *\n * // Zero is all zeros:\n * bigintToBinaryArrayLSB(0n, 8);\n * // => [0, 0, 0, 0, 0, 0, 0, 0]\n *\n * // Powers of two have exactly one set bit:\n * bigintToBinaryArrayLSB(8n, 5);\n * // => [0, 0, 0, 1, 0]\n * // ^ bit 3 (the only set bit in 0b1000)\n * ```\n *\n * @privateRemarks\n * The Circom `MerkleTreeInclusionProof` component expects `pathIndices` as an array of\n * 0/1 selectors ordered from leaf to root (i.e. LSB first when the leaf index encodes\n * the path). This matches the output of this function directly.\n *\n * @public\n */\nexport function bigintToBinaryArrayLSB(value: bigint, length: number): number[] {\n const result: number[] = [];\n let remaining = value;\n\n for (let index = 0; index < length; index++) {\n result.push(Number(remaining & 1n));\n remaining >>= 1n;\n }\n\n return result;\n}\n","/**\n * Arcium Cryptography Utilities\n *\n * This module provides cryptographic utility functions for the Arcium MPC\n * protocol layer of the Umbra SDK. It covers two distinct concerns:\n *\n * - **Nonce generation** for Rescue cipher (`Rc`) encryption. The Rescue\n * cipher is used by the Arcium network to encrypt confidential token\n * account balances before they are stored on Solana. Every encryption\n * operation requires a fresh, unpredictable 128-bit nonce.\n *\n * - **Computation offset generation** for identifying individual MPC\n * computations queued on the Arcium network. Each MPC job is given a\n * unique 64-bit offset that is used to derive the computation account PDA\n * and the associated MPC callback data PDA.\n *\n * ## Randomness Source\n *\n * All values produced by this module are generated using the Web Crypto API's\n * `crypto.getRandomValues()`, which is available in modern browsers and in\n * Node.js v15+. This is the only acceptable source of randomness for\n * cryptographic nonces; non-cryptographic alternatives such as `Math.random()`\n * MUST NOT be used.\n *\n * @packageDocumentation\n * @module utils/cryptography/arcium\n */\n\nimport { assertRcEncryptionNonce, type RcEncryptionNonce, type U64 } from \"../types\";\nimport { generateRandomU128, generateRandomU64 } from \"./math-utils\";\n\n/**\n * Generates a cryptographically secure random nonce for Rescue cipher\n * encryption.\n *\n * The nonce is a 128-bit (16-byte) value sampled uniformly at random using\n * `crypto.getRandomValues()`. It is validated against the `RcEncryptionNonce`\n * branded type before being returned, ensuring it satisfies any range\n * constraints imposed by the Rescue cipher implementation.\n *\n * @returns A cryptographically secure random {@link RcEncryptionNonce}\n * representing a 128-bit unsigned integer suitable for immediate use as a\n * Rescue cipher nonce.\n * @throws `CryptographyAssertionError` if the generated value fails the\n * `assertRcEncryptionNonce` validation. Under correct library invariants this\n * should never happen; the throw is a defense-in-depth guard.\n *\n * @remarks\n * ## Threat Model and Nonce Uniqueness\n *\n * The Rescue cipher is a symmetric stream cipher. Like all stream ciphers it\n * provides confidentiality only when a given key is paired with a unique nonce.\n * Reusing the same (key, nonce) pair for two distinct plaintexts allows a\n * passive adversary to recover the XOR of the two plaintexts, completely\n * compromising confidentiality.\n *\n * With 128-bit random nonces the probability of a collision after `n`\n * independent encryptions under the same key is approximately `n² / 2^129`\n * by the birthday bound. For the volumes expected in the Umbra protocol this\n * risk is negligible; however, callers MUST still generate a fresh nonce for\n * every encryption operation.\n *\n * ## Security Requirements\n *\n * - Generate a new nonce for **every** encryption operation, even if the key\n * and plaintext are the same as a previous call.\n * - Never derive a nonce deterministically from non-secret data (e.g. a\n * transaction counter visible on-chain) without a proper key-derivation step,\n * as this may allow an adversary to predict future nonces.\n * - Nonces are **not secret** — they are stored alongside the ciphertext in\n * the on-chain `ArciumEncryptedUserAccount`. Do not treat them as key\n * material.\n * - For high-volume applications that exceed 2^64 encryptions per key, rotate\n * the encryption key.\n *\n * ## Randomness Quality\n *\n * This function delegates to {@link generateRandomU128}, which calls\n * `crypto.getRandomValues()`. Do NOT substitute `Math.random()` or any\n * seeded pseudo-random number generator; they do not provide the unpredictability\n * required for cryptographic nonces.\n *\n * @example\n * ```typescript\n * import { generateRandomNonce } from \"@umbra-privacy/sdk\";\n *\n * // Generate a fresh nonce for each encryption — never reuse\n * const nonce = generateRandomNonce();\n *\n * // Pair the nonce with the ciphertext for storage on-chain\n * const encryptedBalance = rescueEncrypt(plaintextBalance, accountKey, nonce);\n * const record = { ciphertext: encryptedBalance, nonce };\n * ```\n *\n * @see {@link RcEncryptionNonce} for the branded nonce type definition\n * @see {@link generateRandomU128} for the underlying random 128-bit generation\n * @see {@link getRandomComputationOffset} for the analogous 64-bit MPC offset\n * @public\n */\nexport function generateRandomNonce(): RcEncryptionNonce {\n // Generate cryptographically secure random 128-bit value\n const nonce = generateRandomU128();\n\n // Validate the generated nonce meets RcEncryptionNonce constraints\n // This assertion should never fail for a valid U128, but we include it\n // for defense-in-depth and to satisfy the type system\n assertRcEncryptionNonce(nonce);\n\n return nonce;\n}\n\n/**\n * Generates a cryptographically secure random computation offset for use as\n * an Arcium MPC computation identifier.\n *\n * The offset is a 64-bit unsigned integer sampled uniformly at random using\n * `crypto.getRandomValues()`. It serves as the seed for deriving two on-chain\n * program-derived addresses (PDAs):\n *\n * - The **computation account PDA** at offset `computationOffset`.\n * - The **MPC callback data PDA** at offset `computationOffset + 1n`.\n *\n * Callers must pass the same offset value to both the queue-computation\n * instruction handler and the corresponding callback instruction so that the\n * Arcium network can route the MPC result to the correct account.\n *\n * @returns A cryptographically secure random {@link U64} value representing\n * the 64-bit computation offset. The value is suitable for immediate use\n * as the `computationOffset` parameter in Arcium instruction builders.\n *\n * @remarks\n * ## Why 64 Bits?\n *\n * The Arcium on-chain program uses a `u64` field for computation offsets when\n * deriving PDAs. A 64-bit random value gives a collision probability of\n * approximately `n² / 2^65` after `n` independent calls, which is sufficient\n * for the expected throughput of the Umbra protocol.\n *\n * ## Uniqueness Requirement\n *\n * Two concurrent MPC computations MUST NOT share the same offset because their\n * PDAs would collide, causing one instruction to overwrite or fail against the\n * account created by the other. Generating a fresh random offset per operation\n * makes such collisions negligibly unlikely.\n *\n * ## Randomness Quality\n *\n * This function delegates to {@link generateRandomU64}, which uses\n * `crypto.getRandomValues()`. Do NOT substitute predictable or sequential\n * values; they would allow an adversary to front-run PDA derivation.\n *\n * @example\n * ```typescript\n * import { getRandomComputationOffset } from \"@umbra-privacy/sdk\";\n *\n * // Generate a unique offset for each MPC computation\n * const computationOffset = getRandomComputationOffset();\n *\n * // The MPC callback data account uses the next offset\n * const mpcCallbackDataOffset = computationOffset + 1n;\n *\n * // Pass both offsets to the instruction builder\n * const ix = buildConfidentialDepositInstruction({\n * computationOffset,\n * mpcCallbackDataOffset,\n * // ...\n * });\n * ```\n *\n * @see {@link U64} for the branded 64-bit unsigned integer type\n * @see {@link generateRandomU64} for the underlying random 64-bit generation\n * @see {@link generateRandomNonce} for the analogous 128-bit Rescue cipher nonce\n * @public\n */\nexport function getRandomComputationOffset(): U64 {\n return generateRandomU64();\n}\n","/**\n * Address Utilities\n *\n * This module provides utility functions for working with Solana public-key\n * addresses in the context of zero-knowledge proof circuits used by the Umbra\n * protocol.\n *\n * ## Problem Statement\n *\n * Solana addresses are 32-byte (256-bit) values. BN254-based ZK circuits\n * (used by Groth16) operate over a scalar field whose prime is slightly less\n * than 254 bits, making it impossible to represent a full 256-bit address in a\n * single field element. To work around this, the SDK splits each address into\n * two 128-bit halves that each fit comfortably within the BN254 field.\n *\n * ## Split Convention\n *\n * Given a 32-byte address `A`:\n *\n * ```\n * low = little-endian U128 of bytes A[0..15]\n * high = little-endian U128 of bytes A[16..31]\n * ```\n *\n * The original value can be reconstructed as:\n * ```\n * address_value = (high << 128) | low\n * ```\n *\n * This convention is used consistently across Circom circuit inputs, on-chain\n * Poseidon hash calls, and the TypeScript SDK.\n *\n * @packageDocumentation\n * @module utils/miscellaneous/addresses\n */\n\nimport { type Address, getAddressEncoder } from \"@solana/kit\";\nimport type { U128 } from \"./types\";\nimport { createU128LeBytes } from \"./converters/branded\";\nimport { decodeU128LeBytesToU128 } from \"./converters/mathematics\";\n\n/**\n * Result of splitting a 32-byte Solana address into two 128-bit halves.\n *\n * Both halves are unsigned 128-bit integers interpreted from their respective\n * byte ranges in little-endian order. Together they represent the full 256-bit\n * address and can be passed independently as BN254 field element inputs to\n * Poseidon hash functions or Groth16 circuit public inputs.\n *\n * @example\n * ```typescript\n * import { splitAddressToLowHigh } from \"@umbra-privacy/sdk\";\n * import { address } from \"@solana/kit\";\n *\n * const { low, high } = splitAddressToLowHigh(\n * address(\"So11111111111111111111111111111111111111112\"),\n * );\n *\n * // Pass both halves as separate field elements to a Poseidon hash\n * const digest = await poseidonHash([masterViewingKey, low, high]);\n * ```\n *\n * @see {@link splitAddressToLowHigh} for the function that produces this result\n * @public\n */\nexport interface AddressSplitResult {\n /**\n * Lower 128 bits of the address.\n *\n * Derived by taking bytes 0–15 of the 32-byte address encoding and\n * interpreting them as a little-endian 128-bit unsigned integer.\n *\n * @readonly\n */\n readonly low: U128;\n\n /**\n * Upper 128 bits of the address.\n *\n * Derived by taking bytes 16–31 of the 32-byte address encoding and\n * interpreting them as a little-endian 128-bit unsigned integer.\n *\n * @readonly\n */\n readonly high: U128;\n}\n\n/**\n * Module-level cache for the Solana address encoder singleton.\n *\n * `getAddressEncoder()` constructs an encoder object with a fixed codec\n * configuration. Calling it repeatedly would create unnecessary allocations;\n * caching the result avoids that overhead.\n *\n * @internal\n */\nlet cachedAddressEncoder: ReturnType<typeof getAddressEncoder> | null = null;\n\n/**\n * Returns the module-level Solana address encoder, initialising it on the\n * first call (lazy singleton pattern).\n *\n * @returns The shared `@solana/kit` address encoder instance.\n *\n * @example\n * ```typescript\n * // Internal usage only — not exported\n * const encoder = getEncoder();\n * const bytes = encoder.encode(someAddress);\n * ```\n *\n * @privateRemarks\n * This helper exists solely to encapsulate the null-coalescing initialisation\n * of `cachedAddressEncoder` and to keep `splitAddressToLowHigh` readable.\n *\n * @internal\n */\nfunction getEncoder(): ReturnType<typeof getAddressEncoder> {\n cachedAddressEncoder ??= getAddressEncoder();\n return cachedAddressEncoder;\n}\n\n/**\n * Splits a 32-byte Solana address into two little-endian 128-bit unsigned\n * integers for use as BN254 circuit inputs.\n *\n * Solana addresses are 256-bit public keys. The BN254 scalar field used by\n * Groth16 circuits cannot hold a full 256-bit value in a single field element,\n * so addresses must be split into two 128-bit halves before being hashed or\n * supplied as circuit public inputs. This function performs that split using\n * the little-endian convention that matches the Umbra Circom circuit\n * definitions.\n *\n * ## Algorithm\n *\n * 1. Encode `address` to its canonical 32-byte representation using\n * `@solana/kit`'s address encoder.\n * 2. Slice bytes 0–15; interpret them as a little-endian `U128` → `low`.\n * 3. Slice bytes 16–31; interpret them as a little-endian `U128` → `high`.\n * 4. Return `{ low, high }`.\n *\n * ## Reconstruction\n *\n * The original 256-bit address integer can be recovered as:\n * ```\n * address_value = (high << 128n) | low\n * ```\n *\n * This reconstruction is used by the on-chain Poseidon hash and the Circom\n * circuits to verify that a claimed address matches the committed value.\n *\n * @param address - A Solana `Address` (base-58 encoded 32-byte public key).\n * The value must be a valid Solana address; the encoder will throw if the\n * input is malformed.\n * @returns An {@link AddressSplitResult} containing the `low` and `high`\n * 128-bit halves of the address, each expressed as a branded {@link U128}.\n *\n * @example\n * ```typescript\n * import { splitAddressToLowHigh } from \"@umbra-privacy/sdk\";\n * import { address } from \"@solana/kit\";\n *\n * const mintAddress = address(\"So11111111111111111111111111111111111111112\");\n * const { low, high } = splitAddressToLowHigh(mintAddress);\n *\n * // Supply both halves as independent BN254 field elements in a Poseidon hash\n * const viewingKeyForMint = await poseidonHash([masterViewingKey, low, high]);\n * ```\n *\n * @example\n * ```typescript\n * // Reconstruct the original 256-bit address value from the split result\n * const { low, high } = splitAddressToLowHigh(someAddress);\n * const fullValue = (BigInt(high) << 128n) | BigInt(low);\n * ```\n *\n * @see {@link AddressSplitResult} for the returned type\n * @see {@link createU128LeBytes} for the byte-slice branding step\n * @see {@link decodeU128LeBytesToU128} for the little-endian decode step\n * @public\n */\nexport function splitAddressToLowHigh(address: Address): AddressSplitResult {\n // Encode the address to bytes using Solana Kit's encoder\n const encoder = getEncoder();\n const addressBytes = encoder.encode(address);\n\n // Extract low bytes (0-15) and interpret as little-endian U128\n const lowBytes = createU128LeBytes(addressBytes.slice(0, 16));\n const low = decodeU128LeBytesToU128(lowBytes);\n\n // Extract high bytes (16-31) and interpret as little-endian U128\n const highBytes = createU128LeBytes(addressBytes.slice(16, 32));\n const high = decodeU128LeBytesToU128(highBytes);\n\n return { low, high };\n}\n","/**\n * Umbra PDA (Program Derived Address) Generator Utilities\n *\n * This module provides functions for deriving Umbra protocol account addresses,\n * specifically for mixer tree accounts used in the privacy-preserving UTXO system.\n *\n * @remarks\n * ## Mixer Tree Overview\n *\n * The mixer tree is an Indexed Merkle Tree (IMT) that stores Poseidon H2 hash\n * commitments to UTXOs. Multiple mixer trees can exist, with each tree indexed\n * sequentially (0, 1, 2, ...). When a tree reaches capacity, a new tree is\n * created and becomes the active tree. Old trees remain readable for proof\n * generation and claiming.\n *\n * ## Treap Overview\n *\n * Each mixer tree has five associated treap accounts (variants 0–4). These\n * treaps form an Indexed Merkle Tree of nullifiers and serve as the primary\n * double-spend prevention mechanism: before a UTXO can be claimed its\n * nullifier is checked against — and then inserted into — the treap.\n *\n * ## UTXO Burner Accounts\n *\n * Confidential and public UTXO burner accounts act as temporary storage for\n * nullifiers during relayer-submitted claim transactions. They are scoped to\n * a `(relayer, ephemeral_signer, offset)` triple and are created and closed\n * within the same transaction.\n *\n * ## Utility Functions\n *\n * `structSeed` is re-exported from this module because every other PDA module\n * depends on it to compute seed constants.\n *\n * @see {@link getMixerTreeAddress}\n * @see {@link getActiveMixerTreeAddress}\n * @see {@link getTreapPdas}\n * @see {@link getConfUtxoBurnerPda}\n * @see {@link getPubUtxoBurnerPda}\n * @see {@link structSeed}\n *\n * @packageDocumentation\n * @module utils/pda/umbra\n */\n\nimport { type Address, getAddressEncoder, getProgramDerivedAddress } from \"@solana/kit\";\nimport { getAccountOffsetEncoder } from \"@umbra-privacy/codama\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport type { U128 } from \"../../types\";\nimport { encodeU128ToU128LeBytes } from \"../converters/mathematics\";\n\n/**\n * Computes the SHA-256 hash of a struct/seed name string and returns the\n * result as a 32-byte `Uint8Array`.\n *\n * This mirrors the `sha256_seed!` macro and the `#[umbra_account]` macro used\n * in the Rust smart contract. Every PDA seed constant in the Umbra program is\n * derived as `SHA-256(struct_name_utf8)`.\n *\n * This function is also exported from the barrel (`index.ts`) for callers that\n * need to compute arbitrary struct seeds outside the SDK, for example when\n * verifying a PDA derivation manually or in tests.\n *\n * @param name - The struct or domain name to hash (UTF-8 string, e.g. `\"Pool\"`).\n * @returns A 32-byte `Uint8Array` containing the SHA-256 digest.\n *\n * @example\n * ```typescript\n * import { structSeed } from \"@umbra-privacy/sdk\";\n *\n * const poolSeed = structSeed(\"Pool\");\n * // poolSeed is SHA-256(\"Pool\") as a 32-byte Uint8Array\n * ```\n *\n * @privateRemarks\n * Uses `@noble/hashes/sha2` for a pure-JS, audited SHA-256 implementation.\n * The encoder step converts the JS string to UTF-8 bytes before hashing.\n *\n * @public\n */\nexport function structSeed(name: string): Uint8Array {\n return sha256(new TextEncoder().encode(name));\n}\n\n/**\n * SHA-256 of the string `\"MixerTree\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `sha256_seed!(\"MixerTree\")` in the Rust smart contract. Used as\n * the first seed when deriving `MixerTree` PDAs.\n *\n * @internal\n */\nconst MIXER_TREE_SEED = structSeed(\"MixerTree\");\n\n/**\n * SHA-256 of the string `\"ConfidentialUtxoBurner\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `sha256_seed!(\"ConfidentialUtxoBurner\")` in the Rust smart contract.\n * Used as the first seed when deriving confidential UTXO burner PDAs.\n *\n * @internal\n */\nconst CONF_UTXO_BURNER_SEED = structSeed(\"ConfidentialUtxoBurner\");\n\n/**\n * SHA-256 of the string `\"PublicUtxoBurner\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `sha256_seed!(\"PublicUtxoBurner\")` in the Rust smart contract.\n * Used as the first seed when deriving public UTXO burner PDAs.\n *\n * @internal\n */\nconst PUB_UTXO_BURNER_SEED = structSeed(\"PublicUtxoBurner\");\n\n/**\n * SHA-256 of the string `\"Treap\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `sha256_seed!(\"Treap\")` in the Rust smart contract. Used as the\n * first seed when deriving treap account PDAs.\n *\n * @internal\n */\nconst TREAP_SEED = structSeed(\"Treap\");\n\n/**\n * Derives the PDA for a mixer tree account at the given index.\n *\n * The mixer tree is an Indexed Merkle Tree (IMT) that stores Poseidon H2 hash\n * commitments for UTXOs in the Umbra privacy protocol. Multiple trees can\n * exist simultaneously, each identified by a sequential integer index. The\n * `ProgramInformation` account tracks which tree index is currently active\n * (i.e. the one that accepts new UTXO insertions).\n *\n * @param index - The mixer tree index, starting from `0n`. Must be a valid\n * U128 bigint. Tree 0 is the genesis tree; subsequent trees are created\n * when the previous one reaches leaf capacity.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"MixerTree\")` — 32-byte hash seed\n * 2. `index` — the tree index as a 16-byte little-endian U128\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `MixerTree` struct containing:\n * - The Indexed Merkle Tree root hash\n * - The number of leaves currently inserted\n * - The maximum leaf capacity\n * - `bump: u8` — canonical PDA bump\n *\n * ## Tree Lifecycle\n *\n * 1. Tree index 0 is initialized first and becomes the active tree.\n * 2. UTXOs are inserted until the tree reaches leaf capacity.\n * 3. A migration instruction creates tree index 1, which becomes active.\n * 4. Old trees remain accessible: users can still generate and verify Merkle\n * proofs against them to claim UTXOs inserted before the rollover.\n *\n * ## Instructions that Use This PDA\n *\n * - `InitialiseMixerTree` — creates the account\n * - UTXO creation instructions — insert new H2 commitments into this tree\n * - Claim instructions — accept Merkle proofs against this tree's root\n * - Mixer tree migration/rollover instructions\n *\n * @example\n * ```typescript\n * import { getMixerTreeAddress } from \"@umbra-privacy/sdk\";\n *\n * // Get the first (genesis) mixer tree address\n * const mixerTree0 = await getMixerTreeAddress(0n as U128, networkConfig.programId);\n *\n * // Get a subsequent mixer tree (if it exists after a rollover)\n * const mixerTree1 = await getMixerTreeAddress(1n as U128, networkConfig.programId);\n * ```\n *\n * @see {@link getActiveMixerTreeAddress} for the convenience wrapper that always returns tree index 0\n * @see {@link getTreapPdas} for the nullifier storage accounts associated with each tree\n * @see {@link getProgramInformationPda} for the global account that stores the active tree index\n *\n * @public\n */\nexport async function getMixerTreeAddress(index: U128, umbraProgram: Address): Promise<Address> {\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [MIXER_TREE_SEED, encodeU128ToU128LeBytes(index)],\n });\n\n return pda;\n}\n\n/**\n * Gets the address of the currently active mixer tree (tree index 0).\n *\n * This is a convenience wrapper around `getMixerTreeAddress(0n)` for the\n * common case where a caller needs the genesis tree address without having\n * to track the active index separately.\n *\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the PDA `Address` of tree index 0.\n *\n * @remarks\n * This function always returns the address for index `0n`. If the protocol\n * has performed a mixer tree rollover and the active tree is no longer index 0,\n * callers should read `ProgramInformation.active_tree_index` and call\n * `getMixerTreeAddress` with that index instead.\n *\n * @example\n * ```typescript\n * import { getActiveMixerTreeAddress } from \"@umbra-privacy/sdk\";\n *\n * const activeMixer = await getActiveMixerTreeAddress(networkConfig.programId);\n * ```\n *\n * @see {@link getMixerTreeAddress} for arbitrary tree index derivation\n * @see {@link getProgramInformationPda} for the account that tracks the true active index\n *\n * @public\n */\nexport async function getActiveMixerTreeAddress(umbraProgram: Address): Promise<Address> {\n return getMixerTreeAddress(0n as U128, umbraProgram);\n}\n\n/**\n * Derives the PDA for a confidential UTXO burner account.\n *\n * Confidential UTXO burner accounts are temporary storage PDAs that hold the\n * nullifier set for a batch of confidential UTXOs being claimed in a single\n * relayer-submitted transaction. Each account is uniquely scoped to a\n * `(relayer, ephemeral_signer, offset)` triple so that concurrent claim\n * transactions from the same relayer do not collide.\n *\n * The burner account is created at the start of the claim flow, the nullifiers\n * are validated against the treap in the MPC callback, and the account is\n * closed at the end of the callback to reclaim rent.\n *\n * @param relayerAddress - The public key of the relayer (transaction forwarder\n * / signer) submitting the claim.\n * @param ephemeralAddress - The ephemeral signer public key for this specific\n * claim batch (the `user_address` in on-chain terminology).\n * @param burnerAccountOffset - The U128 offset discriminator that allows the\n * same `(relayer, ephemeral)` pair to have multiple concurrent burner accounts.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"ConfidentialUtxoBurner\")` — 32-byte hash seed\n * 2. `relayerAddress` — 32-byte relayer public key\n * 3. `ephemeralAddress` — 32-byte ephemeral signer public key\n * 4. `burnerAccountOffset` — 16-byte little-endian U128 offset\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `ConfidentialUtxoBurner` struct\n * containing the nullifier bytes for all UTXOs being simultaneously claimed,\n * along with metadata needed by the MPC callback.\n *\n * ## Instructions that Use This PDA\n *\n * - Confidential claim setup instructions — create the burner account and\n * populate it with nullifiers\n * - MPC callback for confidential claims — validate and burn nullifiers into\n * the treap, then close the burner account\n *\n * @example\n * ```typescript\n * import { getConfUtxoBurnerPda } from \"@umbra-privacy/sdk\";\n *\n * const burnerPda = await getConfUtxoBurnerPda(\n * relayerAddress,\n * ephemeralSignerAddress,\n * 0n as U128,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getPubUtxoBurnerPda} for the public-balance variant\n * @see {@link getTreapPdas} for the nullifier storage accounts the burner writes into\n *\n * @public\n */\n// eslint-disable-next-line unicorn/prevent-abbreviations\nexport async function getConfUtxoBurnerPda(\n relayerAddress: Address,\n ephemeralAddress: Address,\n burnerAccountOffset: U128,\n umbraProgram: Address,\n): Promise<Address> {\n const addressEncoder = getAddressEncoder();\n\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n CONF_UTXO_BURNER_SEED,\n addressEncoder.encode(relayerAddress),\n addressEncoder.encode(ephemeralAddress),\n getAccountOffsetEncoder().encode({\n first: BigInt(burnerAccountOffset),\n }),\n ],\n });\n\n return pda;\n}\n\n/**\n * Derives the PDA for a public UTXO burner account.\n *\n * Public UTXO burner accounts serve the same purpose as confidential UTXO\n * burner accounts but for claims that deposit into a public ATA rather than\n * an encrypted balance. They are scoped to a `(relayer, ephemeral_signer,\n * offset)` triple and are closed after the MPC callback executes.\n *\n * @param relayerAddress - The public key of the relayer (transaction forwarder\n * / signer) submitting the claim.\n * @param ephemeralAddress - The ephemeral signer public key for this specific\n * claim batch (the `user_address` in on-chain terminology).\n * @param burnerAccountOffset - The U128 offset discriminator that allows the\n * same `(relayer, ephemeral)` pair to have multiple concurrent burner accounts.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"PublicUtxoBurner\")` — 32-byte hash seed\n * 2. `relayerAddress` — 32-byte relayer public key\n * 3. `ephemeralAddress` — 32-byte ephemeral signer public key\n * 4. `burnerAccountOffset` — 16-byte little-endian U128 offset\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `PublicUtxoBurner` struct\n * containing the nullifier bytes for the UTXOs being claimed into a public\n * ATA, plus the destination ATA address and other callback metadata.\n *\n * ## Instructions that Use This PDA\n *\n * - Public claim setup instructions — create the burner account\n * - MPC callback for public claims — validate and burn nullifiers, release\n * tokens to the destination ATA, then close the burner account\n *\n * @example\n * ```typescript\n * import { getPubUtxoBurnerPda } from \"@umbra-privacy/sdk\";\n *\n * const burnerPda = await getPubUtxoBurnerPda(\n * relayerAddress,\n * ephemeralSignerAddress,\n * 0n as U128,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getConfUtxoBurnerPda} for the confidential-balance variant\n * @see {@link getTreapPdas} for the nullifier storage accounts the burner writes into\n *\n * @public\n */\nexport async function getPubUtxoBurnerPda(\n relayerAddress: Address,\n ephemeralAddress: Address,\n burnerAccountOffset: U128,\n umbraProgram: Address,\n): Promise<Address> {\n const addressEncoder = getAddressEncoder();\n\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n PUB_UTXO_BURNER_SEED,\n addressEncoder.encode(relayerAddress),\n addressEncoder.encode(ephemeralAddress),\n getAccountOffsetEncoder().encode({\n first: BigInt(burnerAccountOffset),\n }),\n ],\n });\n\n return pda;\n}\n\n/**\n * Return type for `getTreapPdas` containing all five treap account addresses\n * for a given mixer tree index.\n *\n * @remarks\n * Each mixer tree has exactly five associated treap accounts (variants 0–4).\n * Together they form the Indexed Merkle Tree of nullifiers that prevents\n * double-spending. All five accounts must be passed to claim instructions\n * so the program can update the correct treap node.\n *\n * @see {@link getTreapPdas}\n *\n * @public\n */\nexport interface TreapPdas {\n /** Treap account variant 0 (first segment of the nullifier IMT). @readonly */\n readonly treap0: Address;\n /** Treap account variant 1 (second segment of the nullifier IMT). @readonly */\n readonly treap1: Address;\n /** Treap account variant 2 (third segment of the nullifier IMT). @readonly */\n readonly treap2: Address;\n /** Treap account variant 3 (fourth segment of the nullifier IMT). @readonly */\n readonly treap3: Address;\n /** Treap account variant 4 (fifth segment of the nullifier IMT). @readonly */\n readonly treap4: Address;\n}\n\n/**\n * Derives all five treap PDAs for a given mixer tree index.\n *\n * Treap accounts implement the Indexed Merkle Tree (IMT) of nullifiers used\n * to prevent double-spending of UTXOs. There are exactly five treap accounts\n * per mixer tree, addressed by variant byte 0–4. All five must be passed to\n * any instruction that inserts or validates nullifiers (claim instructions and\n * their MPC callbacks).\n *\n * The five PDAs are derived in parallel via `Promise.all` for efficiency.\n *\n * @param mixerTreeIndex - The mixer tree index whose treap PDAs to derive\n * (usually `0n as U128` for the genesis tree). Must match the index of an\n * existing, initialised `MixerTree` account.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to a {@link TreapPdas} object containing all\n * five treap account addresses (`treap0` through `treap4`).\n *\n * @remarks\n * ## PDA Seeds (per variant)\n *\n * Each treap PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"Treap\")` — 32-byte hash seed\n * 2. `mixerTreeIndex` — 16-byte little-endian U128 tree index\n * 3. `variant` — single byte (0, 1, 2, 3, or 4)\n *\n * The variant byte is the final seed element so that all five treap PDAs\n * share the same `(TREAP_SEED, index)` prefix while remaining distinct.\n *\n * ## Instructions that Use This PDA\n *\n * - `InitialiseTreap` — creates all five accounts for a new mixer tree\n * - All UTXO claim instructions (confidential and public) — both handler and\n * callback pass all five treap accounts to insert the spent nullifiers\n *\n * @example\n * ```typescript\n * import { getTreapPdas } from \"@umbra-privacy/sdk\";\n *\n * const treapPdas = await getTreapPdas(0n as U128, networkConfig.programId);\n * console.log(treapPdas.treap0, treapPdas.treap1, treapPdas.treap2);\n * ```\n *\n * @see {@link getMixerTreeAddress} for the Merkle commitment tree PDAs\n * @see {@link TreapPdas} for the return type shape\n *\n * @public\n */\nexport async function getTreapPdas(\n mixerTreeIndex: U128,\n umbraProgram: Address,\n): Promise<TreapPdas> {\n const treapSeedBytes = TREAP_SEED;\n const indexBytes = encodeU128ToU128LeBytes(mixerTreeIndex);\n\n const derivePda = async (variant: number): Promise<Address> => {\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [treapSeedBytes, indexBytes, new Uint8Array([variant])],\n });\n return pda;\n };\n\n const [treap0, treap1, treap2, treap3, treap4] = await Promise.all([\n derivePda(0),\n derivePda(1),\n derivePda(2),\n derivePda(3),\n derivePda(4),\n ]);\n\n return { treap0, treap1, treap2, treap3, treap4 };\n}\n","/**\n * User PDA Utilities\n *\n * This module provides functions to derive Program Derived Addresses (PDAs)\n * for user-related accounts in the Umbra protocol.\n *\n * @remarks\n * Umbra users have two distinct on-chain account types, both stored as\n * Arcium-encrypted accounts so their contents are opaque to on-chain\n * observers:\n *\n * - **`ArciumEncryptedUserAccount`** — stores the user's protocol-level state,\n * including their registered X25519 public key and account generation index.\n * Created once per user wallet via `RegisterUser`. Referenced by all\n * confidential and compliance instructions that need to look up the user's\n * encryption key.\n *\n * - **`ArciumEncryptedTokenAccount`** — stores the user's encrypted SPL token\n * balance for a specific mint. Created once per `(user, mint)` pair via\n * `InitialiseUserTokenAccount`. Modified by deposit, withdrawal, transfer,\n * and claim instructions.\n *\n * Both PDAs are keyed under the Umbra program address (not the Arcium program)\n * because the Umbra program owns and manages these accounts through its\n * instruction handlers and Arcium callbacks.\n *\n * @see {@link getArciumEncryptedUserAccountPda}\n * @see {@link getArciumEncryptedTokenAccountPda}\n *\n * @packageDocumentation\n * @module utils/pda/user\n */\n\nimport { type Address, getAddressEncoder, getProgramDerivedAddress } from \"@solana/kit\";\nimport { structSeed } from \"./umbra\";\n\n/**\n * SHA-256 of the string `\"ArciumEncryptedUserAccount\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `ArciumEncryptedUserAccount::SEED` as generated by the\n * `#[umbra_account]` macro in `state/arcium/arcium_encrypted_user_account.rs`.\n * Used as the first seed when deriving encrypted user account PDAs.\n *\n * @internal\n */\nconst ARCIUM_ENCRYPTED_USER_ACCOUNT_SEED = structSeed(\"ArciumEncryptedUserAccount\");\n\n/**\n * SHA-256 of the string `\"ArciumEncryptedTokenAccount\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `ArciumEncryptedTokenAccount::SEED` as generated by the\n * `#[umbra_account]` macro in `state/arcium/arcium_encrypted_token_account.rs`.\n * Used as the first seed when deriving encrypted token account PDAs.\n *\n * @internal\n */\nconst ARCIUM_ENCRYPTED_TOKEN_ACCOUNT_SEED = structSeed(\"ArciumEncryptedTokenAccount\");\n\n/**\n * Derives the PDA for a user's `ArciumEncryptedUserAccount`.\n *\n * The `ArciumEncryptedUserAccount` is the user's top-level protocol identity\n * within Umbra. It is a singleton per user wallet and stores:\n *\n * - The user's registered X25519 public key (used for encryption by\n * counterparties in transfers and compliance grants)\n * - The account's `generation_index`, which drives nonce derivation for\n * encrypted account operations, preventing replay attacks across multiple\n * MPC computation rounds\n * - Bump and other administrative metadata\n *\n * This account must be created before a user can open any encrypted token\n * accounts or participate in confidential operations.\n *\n * @param userPubkey - The user's wallet public key (Solana Ed25519 address,\n * not the X25519 encryption key). This is the `user_address` seed used\n * on-chain.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"ArciumEncryptedUserAccount\")` — 32-byte hash prefix\n * 2. `userPubkey` — 32-byte user wallet public key\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores an `ArciumEncryptedUserAccount`\n * struct (Arcium-encrypted) containing:\n * - `x25519_pubkey: [u8; 32]` — the user's registered X25519 public key\n * - `generation_index: u64` — monotonically increasing nonce generation counter\n * - `bump: u8` — canonical PDA bump\n *\n * ## Instructions that Use This PDA\n *\n * - `RegisterUser` — creates the account and registers the X25519 key\n * - All confidential deposit, withdrawal, transfer, and claim instructions —\n * read the user's encryption key\n * - Compliance grant instructions — look up the granter's X25519 key\n *\n * @example\n * ```typescript\n * import { getArciumEncryptedUserAccountPda } from \"@umbra-privacy/sdk\";\n *\n * const userAccountPda = await getArciumEncryptedUserAccountPda(\n * userWalletAddress,\n * networkConfig.programId,\n * );\n * // userAccountPda is the on-chain address of the user's protocol identity account\n * ```\n *\n * @see {@link getArciumEncryptedTokenAccountPda} for per-mint encrypted balance accounts\n *\n * @public\n */\nexport async function getArciumEncryptedUserAccountPda(\n userPubkey: Address,\n umbraProgram: Address,\n): Promise<Address> {\n const addressEncoder = getAddressEncoder();\n\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [ARCIUM_ENCRYPTED_USER_ACCOUNT_SEED, addressEncoder.encode(userPubkey)],\n });\n\n return pda;\n}\n\n/**\n * Derives the PDA for a user's `ArciumEncryptedTokenAccount` for a specific mint.\n *\n * The `ArciumEncryptedTokenAccount` holds the user's encrypted SPL token\n * balance for a specific mint. The balance is stored in ciphertext form using\n * X25519 encryption so that only the user (and, for MXE-mode accounts, the\n * Arcium network) can decrypt and verify the value. A separate account exists\n * for each `(user, mint)` pair.\n *\n * @param userPubkey - The user's wallet public key (Solana Ed25519 address).\n * @param mintPubkey - The SPL token mint address for which to derive the\n * encrypted balance account.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"ArciumEncryptedTokenAccount\")` — 32-byte hash prefix\n * 2. `userPubkey` — 32-byte user wallet public key\n * 3. `mintPubkey` — 32-byte SPL token mint public key\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores an `ArciumEncryptedTokenAccount`\n * struct (Arcium-encrypted) containing:\n * - `balance: EncryptedU64` — the user's shielded token balance (AES-GCM ciphertext)\n * - `mode: AccountMode` — either `MxeOnly` (network-decryptable) or `Shared`\n * (also user-decryptable via their X25519 key)\n * - `generation_index: u64` — nonce generation counter for this account\n * - `bump: u8` — canonical PDA bump\n *\n * ## Instructions that Use This PDA\n *\n * - `InitialiseUserTokenAccount` — creates the account for a given mint\n * - `DepositIntoExistingMxeV3` — increases the encrypted balance\n * - `WithdrawFromMxeV3` — decreases the encrypted balance\n * - `TransferBetweenMxeAccountsV3` — moves value between two encrypted accounts\n * - Claim instructions — optionally deliver UTXO value into this account\n * - UTXO creation instructions — deduct from this account to fund the UTXO\n *\n * @example\n * ```typescript\n * import { getArciumEncryptedTokenAccountPda } from \"@umbra-privacy/sdk\";\n *\n * const usdcMint = address(\"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\");\n * const tokenAccountPda = await getArciumEncryptedTokenAccountPda(\n * userWalletAddress,\n * usdcMint,\n * networkConfig.programId,\n * );\n * // tokenAccountPda is the on-chain address of the user's encrypted USDC balance\n * ```\n *\n * @example\n * ```typescript\n * // Derive encrypted accounts for multiple mints in parallel\n * const mints = [usdcMint, usdtMint];\n * const tokenAccountPdas = await Promise.all(\n * mints.map((mint) =>\n * getArciumEncryptedTokenAccountPda(userWalletAddress, mint, networkConfig.programId),\n * ),\n * );\n * ```\n *\n * @see {@link getArciumEncryptedUserAccountPda} for the top-level user identity account\n * @see {@link getPoolPda} for the per-mint pool configuration that governs this account's features\n *\n * @public\n */\nexport async function getArciumEncryptedTokenAccountPda(\n userPubkey: Address,\n mintPubkey: Address,\n umbraProgram: Address,\n): Promise<Address> {\n const addressEncoder = getAddressEncoder();\n\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n ARCIUM_ENCRYPTED_TOKEN_ACCOUNT_SEED,\n addressEncoder.encode(userPubkey),\n addressEncoder.encode(mintPubkey),\n ],\n });\n\n return pda;\n}\n","/**\n * Arcium PDA (Program Derived Address) Generator Utilities\n *\n * This module provides functions for deriving Arcium protocol account addresses.\n * These PDAs are used to locate various Arcium accounts on-chain, including\n * MXE accounts, computation accounts, and cluster accounts.\n *\n * @remarks\n * ## Arcium Protocol Overview\n *\n * Arcium is a Multi-party Execution (MXE) protocol that enables confidential\n * computations on Solana. The Umbra privacy protocol uses Arcium for:\n *\n * - Encrypted balance computations (deposit, withdrawal, transfer)\n * - Confidential token operations (claim into MXE balance)\n * - ZK proof verification coordination and nullifier burning\n *\n * ## Account Types\n *\n * - **MXE Account** — the main Arcium protocol account; holds the registered\n * program's public key and is the entry point for all Arcium interactions.\n * Derived from `(ARCIUM_MXE_ACCOUNT_SEED, umbra_program_address)` against\n * the Arcium program.\n * - **Mempool Account** — a queue that holds pending computations waiting to\n * be picked up by cluster nodes. Per-cluster.\n * - **Executing Pool Account** — tracks computations that are currently being\n * processed by cluster nodes. Per-cluster.\n * - **Computation Account** — individual state for a single computation request.\n * Created when `queue_computation` is called; closed when the callback\n * executes.\n * - **Computation Definition Account** (`comp_def`) — stores the circuit\n * definition (encrypted instruction program) for a specific instruction.\n * One `comp_def` account exists per Umbra instruction that uses Arcium.\n * - **Cluster Account** — represents a group of MXE nodes that jointly\n * process computations using multi-party computation.\n *\n * ## Seed Schemes\n *\n * Unlike Umbra PDAs, Arcium PDAs use UTF-8 string seeds (not SHA-256 hashes)\n * for their prefix constants. The prefix strings are imported from\n * `../../constants/arcium` and correspond to the string constants defined in\n * the Arcium SDK.\n *\n * Numeric seeds (cluster offset, computation offset, comp-def offset) are\n * encoded as little-endian u32 or u64 byte arrays.\n *\n * @see {@link getMxeAccountAddress}\n * @see {@link getMempoolAccountAddress}\n * @see {@link getExecutingPoolAccountAddress}\n * @see {@link getComputationAccountAddress}\n * @see {@link getCompDefAccountAddress}\n * @see {@link getClusterAccountAddress}\n * @see {@link getArciumAccountAddresses}\n * @see {@link getCompDefOffset}\n *\n * @packageDocumentation\n * @module utils/pda/arcium\n */\n\nimport { type Address, getAddressEncoder, getProgramDerivedAddress } from \"@solana/kit\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport {\n ARCIUM_MXE_ACCOUNT_SEED,\n ARCIUM_MEMPOOL_SEED,\n ARCIUM_EXEC_POOL_SEED,\n ARCIUM_COMPUTATION_SEED,\n ARCIUM_COMP_DEF_SEED,\n ARCIUM_CLUSTER_SEED,\n} from \"../../constants/arcium\";\nimport { type U32, assertU32, assertU64 } from \"../../types\";\nimport { encodeU32ToU32LeBytes, encodeU64ToU64LeBytes } from \"../converters/mathematics\";\n\n/* =============================================================================\n * COMPUTATION DEFINITION OFFSET DERIVATION\n * ============================================================================= */\n\n/**\n * Computes the computation definition offset from an Arcium instruction name.\n *\n * The computation definition (comp-def) offset uniquely identifies which\n * comp-def account corresponds to a given Umbra instruction. It is derived\n * deterministically from the instruction name so that both the on-chain program\n * and the SDK always agree on the offset without any additional configuration.\n *\n * The derivation takes the SHA-256 hash of the UTF-8 instruction name and\n * interprets the first four bytes as a little-endian unsigned 32-bit integer.\n * The result is returned as a JavaScript `number` (safe for u32 range).\n *\n * @param instructionName - The Arcium instruction name in snake_case format,\n * matching the function name as defined in the encrypted instruction (`arcis`)\n * source (e.g. `\"register_user\"`, `\"deposit_into_existing_mxe_v3\"`).\n * @returns The computation definition offset as an unsigned 32-bit integer\n * (`number`). Safe to use directly as `compDefOffset` in PDA derivations.\n *\n * @remarks\n * ## Derivation Algorithm\n *\n * 1. Encode `instructionName` as UTF-8 bytes.\n * 2. Compute `SHA-256(utf8_bytes)` — yields a 32-byte digest.\n * 3. Interpret bytes `[0..3]` (inclusive) as a little-endian u32.\n * 4. Return as a JavaScript `number` via unsigned right-shift (`>>> 0`).\n *\n * This matches the `comp_def_offset!` macro used in the Rust smart contract\n * to locate comp-def accounts.\n *\n * @example\n * ```typescript\n * import { getCompDefOffset } from \"@umbra-privacy/sdk\";\n *\n * // SHA256(\"register_user\") first 4 bytes interpreted as LE u32\n * const offset = getCompDefOffset(\"register_user\");\n *\n * // Use with getCompDefAccountAddress to locate the comp-def PDA\n * const compDefPda = await getCompDefAccountAddress(\n * networkConfig.programId,\n * networkConfig.arciumProgramAddress,\n * offset,\n * );\n * ```\n *\n * @see {@link getCompDefAccountAddress} for deriving the full comp-def PDA\n * @see {@link getArciumAccountAddresses} for deriving all Arcium accounts at once\n *\n * @public\n */\n// eslint-disable-next-line unicorn/prevent-abbreviations\nexport function getCompDefOffset(instructionName: string): number {\n // Hash the instruction name with SHA256\n const hash = sha256(new TextEncoder().encode(instructionName));\n\n // Take first 4 bytes and interpret as little-endian u32\n\n const byte0 = hash[0];\n\n const byte1 = hash[1];\n\n const byte2 = hash[2];\n\n const byte3 = hash[3];\n\n const offset = byte0 | (byte1 << 8) | (byte2 << 16) | (byte3 << 24);\n\n // Return as unsigned 32-bit integer\n return offset >>> 0;\n}\n\n/* =============================================================================\n * PDA DERIVATION FUNCTIONS\n * ============================================================================= */\n\n/**\n * Derives the MXE account address for the Umbra program.\n *\n * The MXE account is the Arcium protocol's main registration account for a\n * guest program (Umbra). It stores the guest program's public key and\n * cryptographic metadata used by Arcium cluster nodes to verify that\n * computations originate from a registered, authorised program.\n *\n * This account is required as a read-only account on every Arcium-integrated\n * Umbra instruction.\n *\n * @param umbraProgram - The Umbra program address, used as a seed to tie the\n * MXE account to a specific guest program deployment.\n * @param arciumProgram - The Arcium program address. The PDA is derived\n * against the Arcium program (not Umbra).\n * @returns A Promise resolving to the derived MXE account `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived against the **Arcium program** using:\n * 1. `ARCIUM_MXE_ACCOUNT_SEED` — UTF-8 string seed (not SHA-256)\n * 2. `umbraProgram` — 32-byte Umbra program public key\n *\n * ## On-chain Account\n *\n * The Arcium program stores MXE registration data at this address, including\n * the Umbra program's registered X25519 public key used for encrypted\n * instruction delivery.\n *\n * @example\n * ```typescript\n * import { getMxeAccountAddress } from \"@umbra-privacy/sdk\";\n *\n * const mxeAccount = await getMxeAccountAddress(\n * networkConfig.programId,\n * networkConfig.arciumProgramAddress,\n * );\n * ```\n *\n * @see {@link getArciumAccountAddresses} for deriving all Arcium accounts at once\n *\n * @public\n */\nexport async function getMxeAccountAddress(\n umbraProgram: Address,\n arciumProgram: Address,\n): Promise<Address> {\n const [address] = await getProgramDerivedAddress({\n programAddress: arciumProgram,\n seeds: [\n new TextEncoder().encode(ARCIUM_MXE_ACCOUNT_SEED),\n getAddressEncoder().encode(umbraProgram),\n ],\n });\n return address;\n}\n\n/**\n * Derives the mempool account address for a given Arcium cluster.\n *\n * The mempool account is a queue that holds pending computation requests\n * waiting to be picked up and processed by cluster nodes. When an Umbra\n * instruction calls `queue_computation`, the computation is added to the\n * mempool of the cluster identified by `clusterOffset`.\n *\n * @param arciumProgram - The Arcium program address. The PDA is derived\n * against the Arcium program.\n * @param clusterOffset - The numeric offset identifying the cluster whose\n * mempool to derive. Must be a valid u32 value.\n * @returns A Promise resolving to the derived mempool account `Address`.\n *\n * @throws {Error} If `clusterOffset` is outside the valid u32 range (0 to 2^32 - 1).\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived against the **Arcium program** using:\n * 1. `ARCIUM_MEMPOOL_SEED` — UTF-8 string seed (not SHA-256)\n * 2. `clusterOffset` — 4-byte little-endian u32 cluster offset\n *\n * @example\n * ```typescript\n * import { getMempoolAccountAddress } from \"@umbra-privacy/sdk\";\n *\n * const mempoolAccount = await getMempoolAccountAddress(\n * networkConfig.arciumProgramAddress,\n * networkConfig.clusterOffset,\n * );\n * ```\n *\n * @see {@link getClusterAccountAddress} for the parent cluster account\n * @see {@link getExecutingPoolAccountAddress} for the executing pool\n *\n * @public\n */\nexport async function getMempoolAccountAddress(\n arciumProgram: Address,\n clusterOffset: number,\n): Promise<Address> {\n assertU32(BigInt(clusterOffset));\n const [address] = await getProgramDerivedAddress({\n programAddress: arciumProgram,\n seeds: [\n new TextEncoder().encode(ARCIUM_MEMPOOL_SEED),\n encodeU32ToU32LeBytes(BigInt(clusterOffset) as U32),\n ],\n });\n return address;\n}\n\n/**\n * Derives the executing pool account address for a given Arcium cluster.\n *\n * The executing pool account tracks computations that are currently being\n * actively processed by cluster nodes. It is required as an account in\n * `queue_computation` calls so the Arcium program can update the pool's state.\n *\n * @param arciumProgram - The Arcium program address. The PDA is derived\n * against the Arcium program.\n * @param clusterOffset - The numeric offset identifying the cluster whose\n * executing pool to derive. Must be a valid u32 value.\n * @returns A Promise resolving to the derived executing pool account `Address`.\n *\n * @throws {Error} If `clusterOffset` is outside the valid u32 range (0 to 2^32 - 1).\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived against the **Arcium program** using:\n * 1. `ARCIUM_EXEC_POOL_SEED` — UTF-8 string seed (not SHA-256)\n * 2. `clusterOffset` — 4-byte little-endian u32 cluster offset\n *\n * @example\n * ```typescript\n * import { getExecutingPoolAccountAddress } from \"@umbra-privacy/sdk\";\n *\n * const execPoolAccount = await getExecutingPoolAccountAddress(\n * networkConfig.arciumProgramAddress,\n * networkConfig.clusterOffset,\n * );\n * ```\n *\n * @see {@link getMempoolAccountAddress} for the pending computation queue\n * @see {@link getClusterAccountAddress} for the parent cluster account\n *\n * @public\n */\nexport async function getExecutingPoolAccountAddress(\n arciumProgram: Address,\n clusterOffset: number,\n): Promise<Address> {\n assertU32(BigInt(clusterOffset));\n const [address] = await getProgramDerivedAddress({\n programAddress: arciumProgram,\n seeds: [\n new TextEncoder().encode(ARCIUM_EXEC_POOL_SEED),\n encodeU32ToU32LeBytes(BigInt(clusterOffset) as U32),\n ],\n });\n return address;\n}\n\n/**\n * Derives the computation account address for an individual Arcium computation.\n *\n * Each computation request submitted to the Arcium network gets its own\n * account that stores the computation's state and intermediate data. The\n * account is created by `queue_computation` and closed when the MPC callback\n * (`arcium_callback`) executes, returning rent to the relayer.\n *\n * @param arciumProgram - The Arcium program address. The PDA is derived\n * against the Arcium program.\n * @param clusterOffset - The numeric offset identifying the cluster processing\n * this computation. Must be a valid u32 value.\n * @param computationOffset - A unique u64 offset identifying this specific\n * computation request within the cluster. Typically the current cluster\n * computation counter value at the time of submission.\n * @returns A Promise resolving to the derived computation account `Address`.\n *\n * @throws {Error} If `clusterOffset` is outside u32 range or `computationOffset`\n * is outside u64 range.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived against the **Arcium program** using:\n * 1. `ARCIUM_COMPUTATION_SEED` — UTF-8 string seed (not SHA-256)\n * 2. `clusterOffset` — 4-byte little-endian u32 cluster offset\n * 3. `computationOffset` — 8-byte little-endian u64 computation offset\n *\n * @example\n * ```typescript\n * import { getComputationAccountAddress } from \"@umbra-privacy/sdk\";\n *\n * const computationAccount = await getComputationAccountAddress(\n * networkConfig.arciumProgramAddress,\n * networkConfig.clusterOffset,\n * computationOffset,\n * );\n * ```\n *\n * @see {@link getArciumAccountAddresses} for deriving all required accounts at once\n * @see {@link getCompDefAccountAddress} for the computation definition account\n *\n * @public\n */\nexport async function getComputationAccountAddress(\n arciumProgram: Address,\n clusterOffset: number,\n computationOffset: bigint,\n): Promise<Address> {\n assertU32(BigInt(clusterOffset));\n assertU64(computationOffset);\n const [address] = await getProgramDerivedAddress({\n programAddress: arciumProgram,\n seeds: [\n new TextEncoder().encode(ARCIUM_COMPUTATION_SEED),\n encodeU32ToU32LeBytes(BigInt(clusterOffset) as U32),\n encodeU64ToU64LeBytes(computationOffset),\n ],\n });\n return address;\n}\n\n/**\n * Derives the computation definition (comp-def) account address.\n *\n * A computation definition account stores the encrypted circuit program that\n * cluster nodes execute when processing a specific Arcium instruction. One\n * comp-def account exists per Umbra instruction that uses Arcium MPC. The\n * `compDefOffset` uniquely identifies which instruction's circuit this is,\n * derived via `getCompDefOffset(instructionName)`.\n *\n * The comp-def account is passed as a read-only account on every\n * `queue_computation` call so Arcium can locate and verify the correct circuit.\n *\n * @param umbraProgram - The Umbra program address. Scopes the comp-def to this\n * specific guest program deployment.\n * @param arciumProgram - The Arcium program address. The PDA is derived\n * against the Arcium program.\n * @param compDefOffset - The computation definition offset, typically derived\n * via `getCompDefOffset(instructionName)`. Must be a valid u32 value.\n * @returns A Promise resolving to the derived comp-def account `Address`.\n *\n * @throws {Error} If `compDefOffset` is outside the valid u32 range.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived against the **Arcium program** using:\n * 1. `ARCIUM_COMP_DEF_SEED` — UTF-8 string seed (not SHA-256)\n * 2. `umbraProgram` — 32-byte Umbra program public key\n * 3. `compDefOffset` — 4-byte little-endian u32 offset\n *\n * @example\n * ```typescript\n * import { getCompDefOffset, getCompDefAccountAddress } from \"@umbra-privacy/sdk\";\n *\n * const offset = getCompDefOffset(\"deposit_into_existing_mxe_v3\");\n * const compDefAccount = await getCompDefAccountAddress(\n * networkConfig.programId,\n * networkConfig.arciumProgramAddress,\n * offset,\n * );\n * ```\n *\n * @see {@link getCompDefOffset} for computing the offset from an instruction name\n * @see {@link getArciumAccountAddresses} for deriving all required accounts at once\n *\n * @public\n */\n// eslint-disable-next-line unicorn/prevent-abbreviations\nexport async function getCompDefAccountAddress(\n umbraProgram: Address,\n arciumProgram: Address,\n // eslint-disable-next-line unicorn/prevent-abbreviations\n compDefOffset: number,\n): Promise<Address> {\n assertU32(BigInt(compDefOffset));\n const [address] = await getProgramDerivedAddress({\n programAddress: arciumProgram,\n seeds: [\n new TextEncoder().encode(ARCIUM_COMP_DEF_SEED),\n getAddressEncoder().encode(umbraProgram),\n encodeU32ToU32LeBytes(BigInt(compDefOffset) as U32),\n ],\n });\n return address;\n}\n\n/**\n * Derives the cluster account address for a given Arcium cluster.\n *\n * A cluster account represents a group of Arcium MXE nodes that jointly\n * process computations using multi-party computation (MPC). The cluster\n * account stores the cluster's public key set and configuration. It is\n * required as a read-only account on every `queue_computation` call.\n *\n * @param arciumProgram - The Arcium program address. The PDA is derived\n * against the Arcium program.\n * @param clusterOffset - The numeric offset identifying the cluster. Must be\n * a valid u32 value. Provided by the Arcium network configuration.\n * @returns A Promise resolving to the derived cluster account `Address`.\n *\n * @throws {Error} If `clusterOffset` is outside the valid u32 range (0 to 2^32 - 1).\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived against the **Arcium program** using:\n * 1. `ARCIUM_CLUSTER_SEED` — UTF-8 string seed (not SHA-256)\n * 2. `clusterOffset` — 4-byte little-endian u32 cluster offset\n *\n * @example\n * ```typescript\n * import { getClusterAccountAddress } from \"@umbra-privacy/sdk\";\n *\n * const clusterAccount = await getClusterAccountAddress(\n * networkConfig.arciumProgramAddress,\n * networkConfig.clusterOffset,\n * );\n * ```\n *\n * @see {@link getMempoolAccountAddress} for the cluster's pending computation queue\n * @see {@link getExecutingPoolAccountAddress} for the cluster's active computation pool\n *\n * @public\n */\nexport async function getClusterAccountAddress(\n arciumProgram: Address,\n clusterOffset: number,\n): Promise<Address> {\n assertU32(BigInt(clusterOffset));\n const [address] = await getProgramDerivedAddress({\n programAddress: arciumProgram,\n seeds: [\n new TextEncoder().encode(ARCIUM_CLUSTER_SEED),\n encodeU32ToU32LeBytes(BigInt(clusterOffset) as U32),\n ],\n });\n return address;\n}\n\n/* =============================================================================\n * AGGREGATE ADDRESS GENERATION\n * ============================================================================= */\n\n/**\n * Collection of all Arcium account addresses needed to submit a computation\n * to the Arcium MPC network.\n *\n * @remarks\n * Every Arcium-integrated Umbra instruction requires these six accounts. This\n * interface groups them for convenient passing through instruction builders.\n *\n * @see {@link getArciumAccountAddresses} for the function that produces this object\n *\n * @public\n */\nexport interface ArciumAccountAddresses {\n /**\n * The MXE protocol account address for the Umbra program.\n * @readonly\n */\n readonly mxeAccount: Address;\n\n /**\n * The mempool account address for the cluster — holds pending computations.\n * @readonly\n */\n readonly mempoolAccount: Address;\n\n /**\n * The executing pool account address for the cluster — tracks active computations.\n * @readonly\n */\n readonly executingPoolAccount: Address;\n\n /**\n * The computation account address for this specific computation request.\n * Created by `queue_computation`; closed by the MPC callback.\n * @readonly\n */\n readonly computationAccount: Address;\n\n /**\n * The computation definition account address for the target instruction.\n * Stores the encrypted circuit that cluster nodes will execute.\n * @readonly\n */\n readonly compDefAccount: Address;\n\n /**\n * The cluster account address — represents the group of MXE nodes.\n * @readonly\n */\n readonly clusterAccount: Address;\n}\n\n/**\n * Derives all Arcium account addresses required for a single computation request.\n *\n * This is a convenience function that computes all six required Arcium PDAs in\n * parallel and returns them as an {@link ArciumAccountAddresses} object. Every\n * Arcium-integrated Umbra instruction (those using `queue_computation`) requires\n * exactly these six accounts.\n *\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @param arciumProgram - The Arcium program address (e.g. `networkConfig.arciumProgramAddress`).\n * @param clusterOffset - The cluster offset identifying which Arcium cluster to use.\n * @param computationOffset - The unique u64 offset for this specific computation.\n * Callers typically obtain this from the Arcium cluster's current computation\n * counter before constructing the instruction.\n * @param instructionName - The snake_case Arcium instruction name used to derive\n * the comp-def offset (e.g. `\"deposit_into_existing_mxe_v3\"`).\n * @returns A Promise resolving to an {@link ArciumAccountAddresses} object\n * containing all six required account addresses.\n *\n * @remarks\n * Internally calls the six individual derivation functions in parallel via\n * `Promise.all` for efficiency. The comp-def offset is derived via\n * `getCompDefOffset(instructionName)` before the parallel derivations begin.\n *\n * @example\n * ```typescript\n * import { getArciumAccountAddresses } from \"@umbra-privacy/sdk\";\n *\n * const arciumAccounts = await getArciumAccountAddresses(\n * networkConfig.programId,\n * networkConfig.arciumProgramAddress,\n * networkConfig.clusterOffset,\n * computationOffset,\n * \"deposit_into_existing_mxe_v3\",\n * );\n *\n * const instruction = await getDepositIntoExistingMxeV3InstructionAsync({\n * ...arciumAccounts,\n * // ... other required inputs\n * });\n * ```\n *\n * @see {@link getCompDefOffset} for the comp-def offset derivation\n * @see {@link ArciumAccountAddresses} for the return type shape\n *\n * @public\n */\nexport async function getArciumAccountAddresses(\n umbraProgram: Address,\n arciumProgram: Address,\n clusterOffset: number,\n computationOffset: bigint,\n instructionName: string,\n): Promise<ArciumAccountAddresses> {\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const compDefOffset = getCompDefOffset(instructionName);\n\n // Derive all addresses in parallel for efficiency\n const [\n mxeAccount,\n mempoolAccount,\n executingPoolAccount,\n computationAccount,\n compDefAccount, // eslint-disable-line unicorn/prevent-abbreviations\n clusterAccount,\n ] = await Promise.all([\n getMxeAccountAddress(umbraProgram, arciumProgram),\n getMempoolAccountAddress(arciumProgram, clusterOffset),\n getExecutingPoolAccountAddress(arciumProgram, clusterOffset),\n getComputationAccountAddress(arciumProgram, clusterOffset, computationOffset),\n getCompDefAccountAddress(umbraProgram, arciumProgram, compDefOffset),\n getClusterAccountAddress(arciumProgram, clusterOffset),\n ]);\n\n return {\n mxeAccount,\n mempoolAccount,\n executingPoolAccount,\n computationAccount,\n compDefAccount,\n clusterAccount,\n };\n}\n","/**\n * Compliance Grant PDA Utilities\n *\n * This module provides functions to derive Program Derived Addresses (PDAs)\n * for compliance grant accounts in the Umbra protocol.\n *\n * @remarks\n * Umbra implements a master viewing key system that allows authorised parties\n * to decrypt encrypted user data without gaining control over funds. Three\n * grant variants exist, each modelling a different trust relationship:\n *\n * - **Network MXE grant** — the Arcium MXE network itself can decrypt the\n * user's data; the granter is implicitly the network. Used for regulatory\n * or protocol-level compliance.\n * - **Network shared grant** — the user explicitly shares a re-encrypted view\n * key with the network for a specific receiver, scoped to a nonce to\n * prevent replay.\n * - **User grant** — the user directly grants a named receiver (e.g. an\n * auditor) the ability to read their encrypted data by re-encrypting the\n * view key under the receiver's X25519 public key.\n *\n * All three grant PDAs share a common prefix (`ARCIUM_COMPLIANCE_GRANT_SEED`)\n * and are disambiguated by a variant seed (`USER_GRANT_VARIANT_SEED`, etc.).\n * The nonce component prevents one grant from accidentally overwriting another.\n *\n * The seed values are SHA-256 hashes stored as hardcoded 32-byte `Uint8Array`\n * literals — this avoids a runtime `sha256` call on the hot path and matches\n * the seed constants defined in the Rust smart contract.\n *\n * @see {@link getUserGrantedComplianceGrantPda}\n * @see {@link getNetworkMxeComplianceGrantPda}\n * @see {@link getNetworkSharedComplianceGrantPda}\n *\n * @packageDocumentation\n * @module utils/pda/compliance\n */\n\nimport { type Address, getProgramDerivedAddress } from \"@solana/kit\";\nimport { getArciumX25519NonceEncoder, getArciumX25519PublicKeyEncoder } from \"@umbra-privacy/codama\";\nimport type { RcEncryptionNonce } from \"../../types\";\n\n/**\n * Seed prefix shared by all compliance grant PDAs.\n *\n * This is the SHA-256 hash of the UTF-8 string `\"ArciumComplianceGrant\"`,\n * encoded as a 32-byte `Uint8Array`. It matches the `SEED` constant generated\n * by the `#[umbra_account]` macro on the `ArciumComplianceGrant` struct in\n * `state/arcium/arcium_compliance_grant.rs`.\n *\n * All three grant variant PDAs include this as their first seed, providing a\n * common namespace prefix that prevents collisions with other PDA types.\n *\n * @internal\n */\nconst ARCIUM_COMPLIANCE_GRANT_SEED = new Uint8Array([\n 112, 51, 91, 80, 182, 130, 183, 114, 130, 126, 192, 174, 103, 176, 96, 111, 39, 197, 11, 178,\n 95, 176, 244, 219, 178, 162, 167, 166, 191, 89, 196, 197,\n]);\n\n/**\n * Variant discriminator seed for user-granted compliance grants.\n *\n * This is the SHA-256 hash of the UTF-8 string `\"UserGrant\"`, encoded as a\n * 32-byte `Uint8Array`. It is placed as the second seed in user-grant PDAs to\n * distinguish them from network-MXE and network-shared grant PDAs that share\n * the same `ARCIUM_COMPLIANCE_GRANT_SEED` prefix.\n *\n * Matches the `VARIANT_SEED` constant on the `UserGrant` variant in the Rust\n * smart contract's compliance module.\n *\n * @internal\n */\nconst USER_GRANT_VARIANT_SEED = new Uint8Array([\n 184, 137, 63, 24, 18, 54, 138, 200, 151, 217, 219, 241, 119, 150, 66, 8, 27, 105, 131, 187, 58,\n 182, 24, 203, 146, 119, 188, 210, 197, 104, 238, 33,\n]);\n\n/**\n * Variant discriminator seed for network MXE compliance grants.\n *\n * This is the SHA-256 hash of the UTF-8 string `\"NetworkMxeGrant\"`, encoded\n * as a 32-byte `Uint8Array`. It is placed as the second seed in network-MXE\n * grant PDAs to distinguish them from user-grant and network-shared grant PDAs.\n *\n * Matches the `VARIANT_SEED` constant on the `NetworkMxeGrant` variant in the\n * Rust smart contract's compliance module.\n *\n * @internal\n */\nconst NETWORK_MXE_GRANT_VARIANT_SEED = new Uint8Array([\n 142, 219, 209, 143, 158, 68, 71, 58, 193, 244, 116, 159, 48, 68, 160, 95, 175, 131, 151, 209,\n 81, 213, 51, 159, 98, 98, 138, 109, 254, 69, 221, 95,\n]);\n\n/**\n * Variant discriminator seed for network shared compliance grants.\n *\n * This is the SHA-256 hash of the UTF-8 string `\"NetworkSharedGrant\"`, encoded\n * as a 32-byte `Uint8Array`. It is placed as the second seed in network-shared\n * grant PDAs to distinguish them from user-grant and network-MXE grant PDAs.\n *\n * Matches the `VARIANT_SEED` constant on the `NetworkSharedGrant` variant in\n * the Rust smart contract's compliance module.\n *\n * @internal\n */\nconst NETWORK_SHARED_GRANT_VARIANT_SEED = new Uint8Array([\n 172, 245, 86, 61, 89, 235, 170, 92, 253, 117, 241, 14, 2, 33, 164, 107, 22, 131, 100, 113, 39,\n 173, 185, 55, 254, 100, 108, 218, 180, 105, 75, 184,\n]);\n\n/**\n * Derives the PDA for a user-granted compliance grant.\n *\n * A user-granted compliance grant stores a re-encrypted view of the granter's\n * private data under the receiver's X25519 public key. It enables a specific\n * named party (e.g. an auditor) to decrypt the granter's encrypted balances or\n * transaction history without gaining spending authority.\n *\n * The `nonce` seed ensures that a granter can issue multiple independent grants\n * to the same receiver (or revoke and re-issue) without colliding PDA addresses.\n *\n * @param granterX25519 - The 32-byte X25519 public key of the user issuing the\n * grant (the granter). This is the user's Arcium ephemeral or registered\n * X25519 key, not their Ed25519 wallet key.\n * @param nonce - A `RcEncryptionNonce` (u128) that uniquely identifies this\n * particular grant issuance. Encoded as 16 bytes little-endian in the seeds.\n * @param receiverX25519 - The 32-byte X25519 public key of the party receiving\n * the compliance grant (e.g. auditor or compliance officer).\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"ArciumComplianceGrant\")` — 32-byte struct prefix\n * 2. `SHA-256(\"UserGrant\")` — 32-byte variant discriminator\n * 3. `granterX25519` — 32-byte granter X25519 public key (Arcium-encoded)\n * 4. `nonce` — u128 encoded as 16 bytes little-endian (Arcium-encoded)\n * 5. `receiverX25519` — 32-byte receiver X25519 public key (Arcium-encoded)\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores an `ArciumComplianceGrant` (user\n * variant) struct containing the re-encrypted payload and metadata required\n * for the receiver to decrypt the granter's private data.\n *\n * ## Instructions that Use This PDA\n *\n * - `GrantUserComplianceAccess` — creates or updates the account\n * - `RevokeUserComplianceAccess` — closes the account\n *\n * @example\n * ```typescript\n * import { getUserGrantedComplianceGrantPda } from \"@umbra-privacy/sdk\";\n *\n * const grantPda = await getUserGrantedComplianceGrantPda(\n * granterX25519PublicKey,\n * nonce,\n * auditorX25519PublicKey,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getNetworkMxeComplianceGrantPda} for network-level MXE grants\n * @see {@link getNetworkSharedComplianceGrantPda} for network shared grants\n *\n * @public\n */\nexport async function getUserGrantedComplianceGrantPda(\n granterX25519: Uint8Array,\n nonce: RcEncryptionNonce,\n receiverX25519: Uint8Array,\n umbraProgram: Address,\n): Promise<Address> {\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n ARCIUM_COMPLIANCE_GRANT_SEED,\n USER_GRANT_VARIANT_SEED,\n getArciumX25519PublicKeyEncoder().encode({ first: granterX25519 }),\n getArciumX25519NonceEncoder().encode({ first: nonce }),\n getArciumX25519PublicKeyEncoder().encode({ first: receiverX25519 }),\n ],\n });\n return pda;\n}\n\n/**\n * Derives the PDA for a network MXE compliance grant.\n *\n * A network MXE compliance grant allows the Arcium MXE network itself to\n * decrypt a user's encrypted data. Unlike a user grant, there is no explicit\n * granter key in the PDA seeds — the granter is implicitly the protocol/network.\n * This grant variant is used for regulatory compliance at the network level.\n *\n * The `nonce` distinguishes multiple independent network-level grants issued\n * for the same receiver.\n *\n * @param nonce - A `RcEncryptionNonce` (u128) that uniquely identifies this\n * particular grant issuance. Encoded as 16 bytes little-endian in the seeds.\n * @param receiverX25519 - The 32-byte X25519 public key of the network entity\n * or compliance system that will decrypt the data.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"ArciumComplianceGrant\")` — 32-byte struct prefix\n * 2. `SHA-256(\"NetworkMxeGrant\")` — 32-byte variant discriminator\n * 3. `nonce` — u128 encoded as 16 bytes little-endian (Arcium-encoded)\n * 4. `receiverX25519` — 32-byte receiver X25519 public key (Arcium-encoded)\n *\n * Note that unlike the user grant and network shared grant, there is no\n * `granterX25519` seed — the granter is the implicit MXE network identity.\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores an `ArciumComplianceGrant`\n * (network-MXE variant) containing the network-decryptable payload.\n *\n * ## Instructions that Use This PDA\n *\n * - `GrantNetworkMxeComplianceAccess` — creates or updates the account\n * - `RevokeNetworkMxeComplianceAccess` — closes the account\n *\n * @example\n * ```typescript\n * import { getNetworkMxeComplianceGrantPda } from \"@umbra-privacy/sdk\";\n *\n * const grantPda = await getNetworkMxeComplianceGrantPda(\n * nonce,\n * networkX25519PublicKey,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getUserGrantedComplianceGrantPda} for user-to-auditor grants\n * @see {@link getNetworkSharedComplianceGrantPda} for network shared grants\n *\n * @public\n */\nexport async function getNetworkMxeComplianceGrantPda(\n nonce: RcEncryptionNonce,\n receiverX25519: Uint8Array,\n umbraProgram: Address,\n): Promise<Address> {\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n ARCIUM_COMPLIANCE_GRANT_SEED,\n NETWORK_MXE_GRANT_VARIANT_SEED,\n getArciumX25519NonceEncoder().encode({ first: nonce }),\n getArciumX25519PublicKeyEncoder().encode({ first: receiverX25519 }),\n ],\n });\n return pda;\n}\n\n/**\n * Derives the PDA for a network shared compliance grant.\n *\n * A network shared compliance grant is issued by a specific user (identified\n * by their `granterX25519` key) to share a re-encrypted view key with a named\n * receiver via the Arcium network. Unlike the network MXE grant, this variant\n * does include the granter's key so multiple different users can each issue\n * independent shared grants to the same receiver.\n *\n * @param granterX25519 - The 32-byte X25519 public key of the user issuing the\n * grant (the granter). Must be the granter's Arcium X25519 key.\n * @param nonce - A `RcEncryptionNonce` (u128) that uniquely identifies this\n * grant issuance. Encoded as 16 bytes little-endian in the seeds.\n * @param receiverX25519 - The 32-byte X25519 public key of the party receiving\n * the compliance grant.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"ArciumComplianceGrant\")` — 32-byte struct prefix\n * 2. `SHA-256(\"NetworkSharedGrant\")` — 32-byte variant discriminator\n * 3. `granterX25519` — 32-byte granter X25519 public key (Arcium-encoded)\n * 4. `nonce` — u128 encoded as 16 bytes little-endian (Arcium-encoded)\n * 5. `receiverX25519` — 32-byte receiver X25519 public key (Arcium-encoded)\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores an `ArciumComplianceGrant`\n * (network-shared variant) containing the re-encrypted payload and metadata\n * needed for the Arcium network to forward decryptable data to the receiver.\n *\n * ## Instructions that Use This PDA\n *\n * - `GrantNetworkSharedComplianceAccess` — creates or updates the account\n * - `RevokeNetworkSharedComplianceAccess` — closes the account\n *\n * @example\n * ```typescript\n * import { getNetworkSharedComplianceGrantPda } from \"@umbra-privacy/sdk\";\n *\n * const grantPda = await getNetworkSharedComplianceGrantPda(\n * granterX25519PublicKey,\n * nonce,\n * receiverX25519PublicKey,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getUserGrantedComplianceGrantPda} for direct user-to-auditor grants\n * @see {@link getNetworkMxeComplianceGrantPda} for implicit network-level grants\n *\n * @public\n */\nexport async function getNetworkSharedComplianceGrantPda(\n granterX25519: Uint8Array,\n nonce: RcEncryptionNonce,\n receiverX25519: Uint8Array,\n umbraProgram: Address,\n): Promise<Address> {\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n ARCIUM_COMPLIANCE_GRANT_SEED,\n NETWORK_SHARED_GRANT_VARIANT_SEED,\n getArciumX25519PublicKeyEncoder().encode({ first: granterX25519 }),\n getArciumX25519NonceEncoder().encode({ first: nonce }),\n getArciumX25519PublicKeyEncoder().encode({ first: receiverX25519 }),\n ],\n });\n return pda;\n}\n","/**\n * Global PDA Utilities\n *\n * This module provides functions to derive Program Derived Addresses (PDAs)\n * for singleton program-level accounts in the Umbra protocol.\n *\n * Mirrors the smart contract's `state/global/` module, which holds\n * `ProgramInformation` — a singleton account storing protocol-wide state.\n *\n * @remarks\n * There is exactly one `ProgramInformation` account per Umbra program\n * deployment. It acts as the canonical source of truth for cross-instruction\n * protocol state: the index of the currently active mixer tree, global\n * feature activation flags, and the program upgrade authority. Most\n * instructions pass it as a read-only account for validation.\n *\n * @see {@link getProgramInformationPda} for the derivation function\n * @see {@link getPoolPda} for per-mint pool configuration\n *\n * @packageDocumentation\n * @module utils/pda/global\n */\n\nimport { type Address, getProgramDerivedAddress } from \"@solana/kit\";\nimport { structSeed } from \"./umbra\";\n\n/**\n * SHA-256 of the string `\"ProgramInformation\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `ProgramInformation::SEED` as generated by the `#[umbra_account]`\n * macro in `state/global/program_information.rs`. This is the sole seed used\n * when deriving the singleton `ProgramInformation` PDA.\n *\n * @internal\n */\nconst PROGRAM_INFORMATION_SEED = structSeed(\"ProgramInformation\");\n\n/**\n * Derives the PDA for the singleton `ProgramInformation` account.\n *\n * The `ProgramInformation` account is a protocol-wide singleton that stores\n * global configuration state, including:\n *\n * - The index of the currently active mixer tree (used by UTXO creation\n * and claim instructions to locate the correct `MixerTree` account)\n * - Protocol-level feature activation flags\n * - The canonical program upgrade authority public key\n * - Miscellaneous administrative parameters\n *\n * Because it is a singleton keyed only by the SEED constant, every caller\n * that has the program ID can deterministically locate this account.\n *\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"ProgramInformation\")` — 32-byte hash seed\n *\n * No additional entity-specific seed is needed because there is at most one\n * `ProgramInformation` account per program deployment.\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `ProgramInformation` struct\n * containing, among other fields:\n * - `active_tree_index: u128` — index of the currently writable mixer tree\n * - `authority: Pubkey` — upgrade authority allowed to migrate state\n * - `bump: u8` — canonical PDA bump stored for CPI signing\n *\n * ## Instructions that Use This PDA\n *\n * This account is passed as a read-only account in the vast majority of\n * Umbra instructions, including:\n * - All confidential deposit, withdrawal, transfer, and claim instructions\n * - All public UTXO creation and claim instructions\n * - Mixer tree migration and rollover instructions\n *\n * @example\n * ```typescript\n * import { getProgramInformationPda } from \"@umbra-privacy/sdk\";\n *\n * const programInformation = await getProgramInformationPda(networkConfig.programId);\n * // programInformation is now the on-chain address of the global singleton account\n * ```\n *\n * @see {@link getPoolPda} for per-mint pool configuration\n * @see {@link getMixerTreeAddress} for per-index mixer tree accounts\n *\n * @public\n */\nexport async function getProgramInformationPda(umbraProgram: Address): Promise<Address> {\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [PROGRAM_INFORMATION_SEED],\n });\n return pda;\n}\n","/**\n * Pool PDA Utilities\n *\n * This module provides functions to derive Program Derived Addresses (PDAs)\n * for pool-related accounts in the Umbra protocol.\n *\n * Mirrors the smart contract's `state/pool/` module, which holds the `Pool`\n * account — a per-mint configuration account that enables confidentiality and\n * mixer features for a specific SPL token.\n *\n * @remarks\n * The `Pool` account is a singleton per SPL token mint. It is created by the\n * protocol administrator and acts as the root configuration object for all\n * privacy operations involving that mint. Instructions that add or remove\n * privacy features (confidentiality, mixer) modify this account.\n *\n * @see {@link getPoolPda} for the derivation function\n * @see {@link getProgramInformationPda} for the global singleton that tracks active tree index\n *\n * @packageDocumentation\n * @module utils/pda/pool\n */\n\nimport { type Address, getAddressEncoder, getProgramDerivedAddress } from \"@solana/kit\";\nimport { structSeed } from \"./umbra\";\n\n/**\n * SHA-256 of the string `\"Pool\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `Pool::SEED` as generated by the `#[umbra_account]` macro\n * in `state/pool/pool.rs`. Used as the first seed when deriving Pool PDAs.\n *\n * Also re-exported from the barrel (`index.ts`) as `POOL_SEED` for callers\n * that need the raw bytes — for example, to verify a PDA server-side without\n * calling `getPoolPda`.\n *\n * @internal\n */\nexport const POOL_SEED = structSeed(\"Pool\");\n\n/**\n * Derives the PDA for a `Pool` account for a specific token mint.\n *\n * The `Pool` account is a per-mint singleton that stores pool-level\n * configuration for a specific SPL token, including:\n *\n * - Whether the confidentiality feature is activated for the mint\n * - Whether the mixer/UTXO feature is activated for the mint\n * - Pool-level authority and administrative parameters\n *\n * Every deposit, withdrawal, claim, and UTXO operation requires the pool\n * account for the relevant mint as a read (or write) account so the program\n * can validate that the operation is permitted for that token.\n *\n * @param mintAddress - The SPL token mint address for this pool.\n * Must be a valid base58-encoded Solana public key.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"Pool\")` — 32-byte struct seed (`POOL_SEED`)\n * 2. `mintAddress` — 32-byte token mint public key\n *\n * The bump is not returned because Pool PDAs are always looked up by\n * address; the on-chain program stores the canonical bump inside the\n * account itself.\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `Pool` struct containing:\n * - `confidentiality_enabled: bool`\n * - `mixer_enabled: bool`\n * - `authority: Pubkey`\n * - `bump: u8`\n *\n * ## Instructions that Use This PDA\n *\n * - `InitialisePool` — creates the account\n * - `EnableConfidentiality` / `DisableConfidentiality`\n * - `EnableMixer` / `DisableMixer`\n * - All confidential and public deposit, withdrawal, claim, and UTXO instructions\n *\n * @example\n * ```typescript\n * import { getPoolPda } from \"@umbra-privacy/sdk\";\n *\n * const pool = await getPoolPda(mintAddress, networkConfig.programId);\n * // pool is now the on-chain address of the Pool config account for this mint\n * ```\n *\n * @see {@link POOL_SEED} for the raw seed bytes\n * @see {@link getProgramInformationPda} for the global singleton account\n *\n * @public\n */\nexport async function getPoolPda(mintAddress: Address, umbraProgram: Address): Promise<Address> {\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [POOL_SEED, getAddressEncoder().encode(mintAddress)],\n });\n return pda;\n}\n","/**\n * Relayer PDA Utilities\n *\n * This module provides functions to derive Program Derived Addresses (PDAs)\n * for relayer-related accounts in the Umbra protocol.\n *\n * Mirrors the smart contract's `state/relayer/` module, which holds:\n * - `RelayerAccount` — a per-relayer, per-mint account that stores the\n * relayer's registration state and fee configuration references.\n *\n * @remarks\n * Relayers are permissioned transaction forwarders in the Umbra privacy\n * protocol. They submit user-generated proofs and encrypted payloads\n * on-chain, collecting a commission fee for the service. Each relayer must\n * register a `RelayerAccount` for every SPL token mint they wish to support.\n *\n * The `RelayerAccount` PDA is scoped to a `(relayer, mint)` pair so that a\n * single relayer wallet can independently manage fee configurations for\n * multiple mints without conflicting accounts.\n *\n * @see {@link getRelayerAccountPda} for the derivation function\n * @see {@link getRelayerUnifiedFeesPoolPda} for the associated fee pool derivation\n *\n * @packageDocumentation\n * @module utils/pda/relayer\n */\n\nimport { type Address, getAddressEncoder, getProgramDerivedAddress } from \"@solana/kit\";\nimport { structSeed } from \"./umbra\";\n\n/**\n * SHA-256 of the string `\"RelayerAccount\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `RelayerAccount::SEED` as generated by the `#[umbra_account]`\n * macro in `state/relayer/relayer_account.rs`. Used as the first seed when\n * deriving `RelayerAccount` PDAs.\n *\n * @internal\n */\nconst RELAYER_ACCOUNT_SEED = structSeed(\"RelayerAccount\");\n\n/**\n * Derives the PDA for a `RelayerAccount`.\n *\n * The `RelayerAccount` stores a relayer's registration data and fee\n * configuration for a specific SPL token mint. A unique account exists per\n * `(relayer, mint)` pair, allowing one relayer wallet to support multiple\n * tokens with independent fee schedules.\n *\n * The account is required as a validated account in all claim instructions\n * (both confidential and public) to:\n * 1. Confirm the relayer is registered and active for the given mint\n * 2. Resolve the relayer's fee configuration (fixed SOL fee + SPL commission)\n * 3. Verify that the relayer's fee pool accounts are correctly derived\n *\n * @param relayerAddress - The relayer's wallet public key. This is the\n * signer address that will submit claim transactions.\n * @param mintAddress - The SPL token mint address that this relayer supports.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"RelayerAccount\")` — 32-byte struct seed\n * 2. `relayerAddress` — 32-byte relayer public key\n * 3. `mintAddress` — 32-byte token mint public key\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `RelayerAccount` struct\n * containing:\n * - `relayer: Pubkey` — the registered relayer wallet\n * - `mint: Pubkey` — the SPL token mint\n * - `is_active: bool` — whether the relayer is currently accepting work\n * - `fee_config_offset: u128` — pointer to the associated fee config account\n * - `bump: u8` — canonical PDA bump\n *\n * ## Instructions that Use This PDA\n *\n * - `RegisterRelayer` — creates the account\n * - `DeactivateRelayer` / `ActivateRelayer` — toggle `is_active`\n * - All confidential claim instructions (`AnonymouslyClaimIntoExistingTokenMxeV3`, etc.)\n * - All public claim instructions (`AnonymouslyClaimIntoPublicBalanceMxeV3`, etc.)\n *\n * @example\n * ```typescript\n * import { getRelayerAccountPda } from \"@umbra-privacy/sdk\";\n *\n * const relayerAccount = await getRelayerAccountPda(\n * relayerPublicKey,\n * mintAddress,\n * networkConfig.programId,\n * );\n * // relayerAccount is the on-chain address of this relayer's registration for this mint\n * ```\n *\n * @see {@link getRelayerUnifiedFeesPoolPda} for the associated unified fee pool\n * @see {@link getProtocolFeesConfigurationPda} for the fee rate configuration account\n *\n * @public\n */\nexport async function getRelayerAccountPda(\n relayerAddress: Address,\n mintAddress: Address,\n umbraProgram: Address,\n): Promise<Address> {\n const addressEncoder = getAddressEncoder();\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n RELAYER_ACCOUNT_SEED,\n addressEncoder.encode(relayerAddress),\n addressEncoder.encode(mintAddress),\n ],\n });\n return pda;\n}\n","/**\n * Fees PDA Utilities\n *\n * This module provides functions to derive Program Derived Addresses (PDAs)\n * for protocol and relayer fee accounts in the Umbra protocol.\n *\n * Mirrors the smart contract's `state/fees/` module, which holds:\n * - `UnifiedFeesPool` — a single account storing both protocol and relayer fees,\n * partitioned by a domain seed into two variants:\n * - Protocol-only pools (deposits, withdrawals, public UTXO creation)\n * - Relayer pools (transfers, confidential/public claims)\n * - `ProtocolFeesConfiguration` — admin-managed fee rate config per mint\n *\n * @remarks\n * Umbra separates fee collection from fee disbursement by accumulating fees in\n * dedicated PDA accounts (`UnifiedFeesPool`) that can be swept by the protocol\n * treasury or relayer at any time. The fee amount charged per instruction is\n * governed by the `ProtocolFeesConfiguration` account for that instruction + mint\n * pair.\n *\n * Both `UnifiedFeesPool` variants and `ProtocolFeesConfiguration` include an\n * `offset` seed, following the canonical seed pattern:\n *\n * `SEED → domain_seed (for fees pool) → instructionSeed → entity_key → mint → offset`\n *\n * The `offset` allows the protocol to create multiple fee pool or config\n * accounts for the same instruction + mint combination if needed in future.\n * Currently `offset` is always `0n` for `ProtocolFeesConfiguration` and an\n * instruction-specific constant for `UnifiedFeesPool`.\n *\n * @see {@link getProtocolOnlyUnifiedFeesPoolPda}\n * @see {@link getRelayerUnifiedFeesPoolPda}\n * @see {@link getProtocolFeesConfigurationPda}\n *\n * @packageDocumentation\n * @module utils/pda/fees\n */\n\nimport { type Address, getAddressEncoder, getProgramDerivedAddress } from \"@solana/kit\";\nimport { getAccountOffsetEncoder } from \"@umbra-privacy/codama\";\nimport type { U128 } from \"../../types\";\nimport { encodeU128ToU128LeBytes } from \"../converters/mathematics\";\nimport { structSeed } from \"./umbra\";\n\n/**\n * SHA-256 of the string `\"UnifiedFeesPool\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `UnifiedFeesPool::SEED` as generated by the `#[umbra_account]`\n * macro in `state/fees/unified_fees_pool.rs`. Used as the first seed when\n * deriving all `UnifiedFeesPool` PDAs (both protocol-only and relayer variants).\n *\n * @internal\n */\nconst UNIFIED_FEES_POOL_SEED = structSeed(\"UnifiedFeesPool\");\n\n/**\n * Domain separator that identifies protocol-only fee pools.\n *\n * This is the SHA-256 hash of `\"ProtocolFees\"`, matching\n * `UnifiedFeesPool::DOMAIN_PROTOCOL_FEES` (`sha256_seed!(\"ProtocolFees\")`)\n * in `state/fees/unified_fees_pool.rs`.\n *\n * It is placed as the second seed in protocol-only `UnifiedFeesPool` PDAs to\n * partition them from relayer pools that use `DOMAIN_PROTOCOL_RELAYER_FEES`.\n *\n * Protocol-only fee pools are used in instructions that collect no relayer\n * commission: deposits, withdrawals, and public UTXO creation.\n *\n * @internal\n */\nconst DOMAIN_PROTOCOL_FEES = structSeed(\"ProtocolFees\");\n\n/**\n * Domain separator that identifies combined protocol + relayer fee pools.\n *\n * This is the SHA-256 hash of `\"ProtocolRelayerFees\"`, matching\n * `UnifiedFeesPool::DOMAIN_PROTOCOL_RELAYER_FEES`\n * (`sha256_seed!(\"ProtocolRelayerFees\")`) in `state/fees/unified_fees_pool.rs`.\n *\n * It is placed as the second seed in relayer `UnifiedFeesPool` PDAs to\n * distinguish them from protocol-only pools.\n *\n * Relayer fee pools are used in confidential and public claim instructions\n * where the relayer receives a commission alongside the protocol fee.\n *\n * @internal\n */\nconst DOMAIN_PROTOCOL_RELAYER_FEES = structSeed(\"ProtocolRelayerFees\");\n\n/**\n * SHA-256 of the string `\"ProtocolFeesConfiguration\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `ProtocolFeesConfiguration::SEED` as generated by the\n * `#[umbra_account]` macro in `state/fees/protocol_fees_configuration.rs`.\n * Used as the first seed when deriving `ProtocolFeesConfiguration` PDAs.\n *\n * @internal\n */\nconst PROTOCOL_FEES_CONFIGURATION_SEED = structSeed(\"ProtocolFeesConfiguration\");\n\n/**\n * Derives the PDA for a protocol-only `UnifiedFeesPool` account.\n *\n * Protocol-only fee pools accumulate the protocol's share of fees for\n * instructions that have no relayer commission component — specifically:\n * - Confidential and public deposits\n * - Confidential and public withdrawals\n * - Public UTXO creation\n *\n * The `DOMAIN_PROTOCOL_FEES` domain seed partitions these pools from relayer\n * pools so that a single fee-sweep transaction can target the correct pool.\n *\n * @param instructionSeed - The instruction-specific U128 seed constant (e.g.\n * `INITIALISE_DEPOSIT_INTO_EXISTING_MXE_V3_SEED as U128`). This ties the\n * fee pool uniquely to the instruction it was initialised for.\n * @param mintAddress - The SPL token mint address for this pool. Each pool is\n * per-mint so the protocol can sweep fees in individual tokens.\n * @param offset - The account offset discriminator (U128). Currently always\n * the instruction-specific offset constant (e.g. `PROTOCOL_FEES_POOL_OFFSET`).\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the `[pda, bump]` tuple. The bump is\n * returned because callers may need to pass it as an instruction argument\n * when closing or sweeping the pool.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"UnifiedFeesPool\")` — 32-byte struct seed\n * 2. `SHA-256(\"ProtocolFees\")` — 32-byte domain separator\n * 3. `instructionSeed` — 16-byte little-endian U128\n * 4. `mintAddress` — 32-byte token mint public key\n * 5. `offset` — 16-byte little-endian U128 account offset\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `UnifiedFeesPool` struct\n * (protocol-only variant) accumulating the SPL tokens collected as protocol\n * fees for the given instruction + mint combination.\n *\n * ## Instructions that Use This PDA\n *\n * - `InitialiseProtocolFeesPool` — creates the account\n * - All deposit and withdrawal instructions — write fees into the pool\n * - Protocol fee sweep instructions — drain the pool to the treasury\n *\n * @example\n * ```typescript\n * import { getProtocolOnlyUnifiedFeesPoolPda } from \"@umbra-privacy/sdk\";\n *\n * const [feesPoolPda] = await getProtocolOnlyUnifiedFeesPoolPda(\n * INITIALISE_DEPOSIT_INTO_EXISTING_MXE_V3_SEED as U128,\n * mintAddress,\n * PROTOCOL_FEES_POOL_OFFSET as U128,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getRelayerUnifiedFeesPoolPda} for the relayer commission pool variant\n * @see {@link getProtocolFeesConfigurationPda} for the fee rate configuration account\n *\n * @public\n */\nexport async function getProtocolOnlyUnifiedFeesPoolPda(\n instructionSeed: U128,\n mintAddress: Address,\n offset: U128,\n umbraProgram: Address,\n): Promise<readonly [Address, number]> {\n const addressEncoder = getAddressEncoder();\n return getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n UNIFIED_FEES_POOL_SEED,\n DOMAIN_PROTOCOL_FEES,\n encodeU128ToU128LeBytes(instructionSeed),\n addressEncoder.encode(mintAddress),\n getAccountOffsetEncoder().encode({ first: BigInt(offset) }),\n ],\n });\n}\n\n/**\n * Derives the PDA for a relayer `UnifiedFeesPool` account.\n *\n * Relayer fee pools accumulate both the protocol's share and the relayer's\n * commission for instructions that involve a relayer — specifically:\n * - Confidential claim instructions\n * - Public claim instructions\n * - Confidential transfer instructions\n *\n * The pool is scoped to a specific relayer address so that each relayer has\n * an isolated pool they can sweep independently. The `DOMAIN_PROTOCOL_RELAYER_FEES`\n * domain seed partitions these accounts from protocol-only pools.\n *\n * @param instructionSeed - The instruction-specific U128 seed constant (e.g.\n * `ANONYMOUSLY_CLAIM_INTO_EXISTING_TOKEN_MXE_V3_SEED as U128`).\n * @param relayerAddress - The relayer's wallet public key. Used to scope the\n * pool to this specific relayer so they are the only one who can sweep it.\n * @param mintAddress - The SPL token mint address for this pool.\n * @param offset - The account offset discriminator (U128). Currently always\n * the instruction-specific offset constant.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the `[pda, bump]` tuple. The bump is\n * returned for use in relayer sweep instruction arguments.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"UnifiedFeesPool\")` — 32-byte struct seed\n * 2. `SHA-256(\"ProtocolRelayerFees\")` — 32-byte domain separator\n * 3. `instructionSeed` — 16-byte little-endian U128\n * 4. `relayerAddress` — 32-byte relayer public key\n * 5. `mintAddress` — 32-byte token mint public key\n * 6. `offset` — 16-byte little-endian U128 account offset\n *\n * Note that `relayerAddress` precedes `mintAddress` in this variant,\n * consistent with the canonical seed ordering (entity key before mint).\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `UnifiedFeesPool` struct\n * (relayer variant) accumulating SPL tokens as combined protocol + relayer\n * commission for the given instruction + relayer + mint combination.\n *\n * ## Instructions that Use This PDA\n *\n * - `InitialiseRelayerFeesPool` — creates the account\n * - All claim instructions — write fees into the pool\n * - Relayer fee sweep instructions — drain the pool to the relayer wallet\n *\n * @example\n * ```typescript\n * import { getRelayerUnifiedFeesPoolPda } from \"@umbra-privacy/sdk\";\n *\n * const [unifiedFeesPoolPda] = await getRelayerUnifiedFeesPoolPda(\n * instructionSeed as U128,\n * relayerPublicKey,\n * mintAddress,\n * PROTOCOL_FEES_POOL_OFFSET as U128,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getProtocolOnlyUnifiedFeesPoolPda} for the protocol-only pool variant\n * @see {@link getRelayerAccountPda} for the relayer registration account\n *\n * @public\n */\nexport async function getRelayerUnifiedFeesPoolPda(\n instructionSeed: U128,\n relayerAddress: Address,\n mintAddress: Address,\n offset: U128,\n umbraProgram: Address,\n): Promise<readonly [Address, number]> {\n const addressEncoder = getAddressEncoder();\n return getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n UNIFIED_FEES_POOL_SEED,\n DOMAIN_PROTOCOL_RELAYER_FEES,\n encodeU128ToU128LeBytes(instructionSeed),\n addressEncoder.encode(relayerAddress),\n addressEncoder.encode(mintAddress),\n getAccountOffsetEncoder().encode({ first: BigInt(offset) }),\n ],\n });\n}\n\n/**\n * Derives the PDA for a `ProtocolFeesConfiguration` account.\n *\n * The `ProtocolFeesConfiguration` account is an admin-managed configuration\n * object that defines the fee rates for a specific instruction variant and\n * SPL token mint. It is consulted during instruction validation to calculate\n * how much the user must pay in both SOL (fixed fee) and SPL tokens\n * (percentage commission).\n *\n * A separate `ProtocolFeesConfiguration` account exists for each\n * `(instructionSeed, mint)` pair, allowing the protocol admin to set\n * different fee structures for different mints and instruction types.\n *\n * @param instructionSeed - The instruction-specific U128 seed constant that\n * uniquely identifies the instruction type this fee config applies to.\n * @param mintAddress - The SPL token mint address for this fee configuration.\n * @param offset - The account offset discriminator (U128). Currently always\n * `0n as U128` for all fee configurations.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the `[pda, bump]` tuple.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"ProtocolFeesConfiguration\")` — 32-byte struct seed\n * 2. `instructionSeed` — 16-byte little-endian U128\n * 3. `mintAddress` — 32-byte token mint public key\n * 4. `offset` — 16-byte little-endian U128 account offset\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `ProtocolFeesConfiguration`\n * struct containing:\n * - `fixed_sol_fee: u64` — the flat SOL fee in lamports charged per instruction\n * - `spl_commission_bps: u16` — the SPL commission in basis points\n * - `authority: Pubkey` — admin who can update the config\n * - `bump: u8` — canonical PDA bump\n *\n * ## Instructions that Use This PDA\n *\n * - `InitialiseProtocolFeesConfiguration` — creates the account\n * - `UpdateProtocolFeesConfiguration` — modifies fee rates\n * - All fee-paying instructions — read this account to compute fees owed\n *\n * @example\n * ```typescript\n * import { getProtocolFeesConfigurationPda } from \"@umbra-privacy/sdk\";\n *\n * const [feeConfigPda] = await getProtocolFeesConfigurationPda(\n * instructionSeed as U128,\n * mintAddress,\n * 0n as U128,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getProtocolOnlyUnifiedFeesPoolPda} for the corresponding fee collection account\n * @see {@link getRelayerUnifiedFeesPoolPda} for the relayer fee collection account\n *\n * @public\n */\nexport async function getProtocolFeesConfigurationPda(\n instructionSeed: U128,\n mintAddress: Address,\n offset: U128,\n umbraProgram: Address,\n): Promise<readonly [Address, number]> {\n const addressEncoder = getAddressEncoder();\n return getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n PROTOCOL_FEES_CONFIGURATION_SEED,\n encodeU128ToU128LeBytes(instructionSeed),\n addressEncoder.encode(mintAddress),\n getAccountOffsetEncoder().encode({ first: BigInt(offset) }),\n ],\n });\n}\n","/**\n * ZK and MPC Callback PDA Utilities\n *\n * This module provides functions to derive Program Derived Addresses (PDAs)\n * for zero-knowledge proof accounts and MPC callback data accounts in the\n * Umbra protocol.\n *\n * Mirrors the smart contract's `state/zk/` module, which holds:\n * - `ZkVerifyingKey` — stores the Groth16 verifying key for a specific proof circuit\n * - `ConfidentialClaimProofAccount` — temporary buffer for confidential claim proof data\n * - `ConfidentialUtxoProofAccount` — temporary buffer for confidential UTXO proof data\n * - `PublicClaimProofAccount` — temporary buffer for public claim proof data\n * - `PublicClaimMxeMpcCallbackData` — MPC callback data for public-balance MXE claims\n *\n * @remarks\n * ## ZK Proof Flow\n *\n * Claim and UTXO operations in Umbra use Groth16 zero-knowledge proofs to\n * assert that a UTXO commitment is valid and that the claimer knows the\n * preimage (nullifier, value, receiver). The proof flow is:\n *\n * 1. **Client** generates a Groth16 proof off-chain using the Circom circuit.\n * 2. **Client / relayer** uploads the proof to a temporary proof buffer PDA\n * (`ConfidentialClaimProofAccount`, `ConfidentialUtxoProofAccount`, or\n * `PublicClaimProofAccount`) in a setup transaction.\n * 3. **Claim instruction** reads the proof buffer and the `ZkVerifyingKey`\n * account for the relevant circuit, verifies the proof on-chain using\n * `groth16-solana`, then proceeds to queue the Arcium MPC computation.\n * 4. **MPC callback** burns the nullifiers and updates balances/UTXOs.\n * 5. The proof buffer and MPC callback data accounts are closed to reclaim rent.\n *\n * ## Verifying Key Account\n *\n * The `ZkVerifyingKey` account stores the Groth16 alpha, beta, gamma, delta,\n * and IC (input commitments) for a given circuit variant. Different circuits\n * exist for different numbers of UTXO inputs (leaves), so the `instructionSeed`\n * encodes both the base circuit type and the leaf count.\n *\n * ## Proof Buffer Accounts\n *\n * Proof buffer accounts are ephemeral: they are created in a setup transaction,\n * consumed (read and validated) in the claim instruction, and closed in the\n * MPC callback to reclaim rent. The `payer` (relayer or depositor) is included\n * in the seeds to prevent one party from stomping on another's proof buffer.\n *\n * @see {@link getZkVerifyingKeyPda}\n * @see {@link getConfidentialClaimProofAccountPda}\n * @see {@link getConfidentialUtxoProofAccountPda}\n * @see {@link getPublicClaimProofAccountPda}\n * @see {@link getPublicClaimMxeMpcCallbackDataPda}\n *\n * @packageDocumentation\n * @module utils/pda/zk\n */\n\nimport { type Address, getAddressEncoder, getProgramDerivedAddress } from \"@solana/kit\";\nimport { getAccountOffsetEncoder } from \"@umbra-privacy/codama\";\nimport type { U128 } from \"../../types\";\nimport { encodeU128ToU128LeBytes } from \"../converters/mathematics\";\nimport { structSeed } from \"./umbra\";\n\n/**\n * SHA-256 of the string `\"ZkVerifyingKey\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `ZkVerifyingKey::SEED` as generated by the `#[umbra_account]`\n * macro in `state/zk/zk_verifying_key.rs`. Used as the first seed when\n * deriving `ZkVerifyingKey` PDAs.\n *\n * @internal\n */\nconst ZK_VERIFYING_KEY_SEED = structSeed(\"ZkVerifyingKey\");\n\n/**\n * SHA-256 of the string `\"ConfidentialClaimProofAccount\"`, stored as a\n * 32-byte `Uint8Array`.\n *\n * Matches `ConfidentialClaimProofAccount::SEED` as generated by the\n * `#[umbra_account]` macro in `state/zk/confidential_claim_proof_account.rs`.\n *\n * @internal\n */\nconst CONFIDENTIAL_CLAIM_PROOF_ACCOUNT_SEED = structSeed(\"ConfidentialClaimProofAccount\");\n\n/**\n * SHA-256 of the string `\"ConfidentialUtxoProofAccount\"`, stored as a\n * 32-byte `Uint8Array`.\n *\n * Matches `ConfidentialUtxoProofAccount::SEED` as generated by the\n * `#[umbra_account]` macro in `state/zk/confidential_utxo_proof_account.rs`.\n *\n * @internal\n */\nconst CONFIDENTIAL_UTXO_PROOF_ACCOUNT_SEED = structSeed(\"ConfidentialUtxoProofAccount\");\n\n/**\n * SHA-256 of the string `\"PublicClaimProofAccount\"`, stored as a 32-byte `Uint8Array`.\n *\n * Matches `PublicClaimProofAccount::SEED` as generated by the\n * `#[umbra_account]` macro in `state/zk/public_claim_proof_account.rs`.\n *\n * @internal\n */\nconst PUBLIC_CLAIM_PROOF_ACCOUNT_SEED = structSeed(\"PublicClaimProofAccount\");\n\n/**\n * SHA-256 of the string `\"PublicClaimMxeMpcCallbackData\"`, stored as a\n * 32-byte `Uint8Array`.\n *\n * Matches `PublicClaimMxeMpcCallbackData::SEED` as generated by the\n * `#[umbra_account]` macro in `state/zk/other_mpc_callback_data.rs`.\n *\n * @internal\n */\nconst PUBLIC_CLAIM_MXE_MPC_CALLBACK_DATA_SEED = structSeed(\"PublicClaimMxeMpcCallbackData\");\n\n/**\n * Derives the PDA for a `ZkVerifyingKey` account.\n *\n * The `ZkVerifyingKey` account stores the on-chain Groth16 verifying key for\n * a specific proof circuit variant. The `instructionSeed` encodes both the\n * base circuit type (e.g. \"claim into confidential balance\") and the number\n * of UTXO inputs (leaves), so different verifying keys can be stored for\n * circuits of varying input sizes without collision.\n *\n * These accounts are set up by the protocol administrator via an\n * `InitialiseZkVerifyingKey` instruction and are read as immutable inputs in\n * claim and UTXO instructions.\n *\n * @param instructionSeed - The U128 seed that uniquely identifies the specific\n * verifying key. Typically composed as\n * `ZK_CLAIM_INTO_CONFIDENTIAL_BALANCE_BASE_SEED + BigInt(nLeaves)`.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"ZkVerifyingKey\")` — 32-byte struct seed\n * 2. `instructionSeed` — 16-byte little-endian U128\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `ZkVerifyingKey` struct\n * containing the Groth16 verifying key components (alpha_g1, beta_g2,\n * gamma_g2, delta_g2, ic[]) for the identified circuit variant.\n *\n * ## Instructions that Use This PDA\n *\n * - `InitialiseZkVerifyingKey` — creates or replaces the account (admin only)\n * - All confidential and public claim instructions — read the verifying key\n * to verify the Groth16 proof submitted in the proof buffer account\n * - UTXO creation instructions that require ZK proofs\n *\n * @example\n * ```typescript\n * import { getZkVerifyingKeyPda } from \"@umbra-privacy/sdk\";\n *\n * // For a claim circuit with 1 UTXO input leaf\n * const nLeaves = 1;\n * const zkSeed = ZK_CLAIM_INTO_CONFIDENTIAL_BALANCE_BASE_SEED + BigInt(nLeaves);\n * const zkVerifyingKeyAccount = await getZkVerifyingKeyPda(\n * zkSeed as U128,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getConfidentialClaimProofAccountPda} for the proof buffer read alongside this account\n *\n * @public\n */\nexport async function getZkVerifyingKeyPda(\n instructionSeed: U128,\n umbraProgram: Address,\n): Promise<Address> {\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [ZK_VERIFYING_KEY_SEED, encodeU128ToU128LeBytes(instructionSeed)],\n });\n return pda;\n}\n\n/**\n * Derives the PDA for a `ConfidentialClaimProofAccount`.\n *\n * The `ConfidentialClaimProofAccount` is an ephemeral buffer account that\n * holds the Groth16 proof bytes and encrypted public inputs required for a\n * confidential claim instruction (claiming UTXOs into an encrypted MXE\n * balance). It is created by the relayer in a separate setup transaction,\n * read and validated by the claim instruction, and closed in the MPC callback\n * to reclaim rent back to the relayer.\n *\n * The `payerAddress` (relayer) is included in the seeds so that different\n * relayers cannot write to each other's proof accounts, and so the payer is\n * unambiguous when closing the account.\n *\n * @param payerAddress - The public key of the account creator (the relayer in\n * all production flows). Scopes the proof buffer to this specific creator.\n * @param offset - The U128 offset discriminator that makes this proof account\n * unique even if the same relayer has multiple in-flight claim transactions.\n * Typically chosen randomly per claim batch.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"ConfidentialClaimProofAccount\")` — 32-byte struct seed\n * 2. `payerAddress` — 32-byte public key of the proof account creator\n * 3. `offset` — 16-byte little-endian U128 account offset\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `ConfidentialClaimProofAccount`\n * struct containing:\n * - The serialised Groth16 proof (pi_a, pi_b, pi_c)\n * - The Fiat-Shamir transcript elements and aggregated hash for ZK public inputs\n * - The `nLeaves` count (how many UTXOs are being claimed)\n *\n * ## Lifecycle\n *\n * 1. Relayer creates the account via `InitialiseConfidentialClaimProofAccount`.\n * 2. Claim instruction reads the proof and verifies it against `ZkVerifyingKey`.\n * 3. MPC callback closes the account, returning rent to the relayer.\n *\n * @example\n * ```typescript\n * import { getConfidentialClaimProofAccountPda } from \"@umbra-privacy/sdk\";\n *\n * const proofAccountPda = await getConfidentialClaimProofAccountPda(\n * relayerPublicKey,\n * proofAccountOffset as U128,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getZkVerifyingKeyPda} for the verifying key used to check this proof\n * @see {@link getPublicClaimProofAccountPda} for the public-balance claim variant\n *\n * @public\n */\nexport async function getConfidentialClaimProofAccountPda(\n payerAddress: Address,\n offset: U128,\n umbraProgram: Address,\n): Promise<Address> {\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n CONFIDENTIAL_CLAIM_PROOF_ACCOUNT_SEED,\n getAddressEncoder().encode(payerAddress),\n getAccountOffsetEncoder().encode({ first: BigInt(offset) }),\n ],\n });\n return pda;\n}\n\n/**\n * Derives the PDA for a `ConfidentialUtxoProofAccount`.\n *\n * The `ConfidentialUtxoProofAccount` is an ephemeral buffer account that\n * holds the Groth16 proof data required to create a new confidential UTXO\n * from an existing encrypted MXE balance. It is created by the user (or the\n * user-side SDK) in a setup transaction, consumed by the UTXO creation\n * instruction, and closed in the MPC callback.\n *\n * Unlike the claim proof accounts (which are always created by the relayer),\n * this account is created by the depositor/user who is converting their\n * confidential balance into a UTXO commitment.\n *\n * @param depositorAddress - The public key of the user creating the UTXO.\n * Scopes the proof buffer to this specific depositor.\n * @param offset - The U128 offset discriminator. Typically chosen randomly\n * per UTXO creation to allow concurrent operations.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"ConfidentialUtxoProofAccount\")` — 32-byte struct seed\n * 2. `depositorAddress` — 32-byte depositor public key\n * 3. `offset` — 16-byte little-endian U128 account offset\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `ConfidentialUtxoProofAccount`\n * struct containing the Groth16 proof that demonstrates the depositor knows\n * valid UTXO preimage data (nullifier, value, commitment) while keeping those\n * values hidden from on-chain observers.\n *\n * ## Lifecycle\n *\n * 1. Depositor creates the account via `InitialiseConfidentialUtxoProofAccount`.\n * 2. UTXO creation instruction reads and verifies the proof.\n * 3. MPC callback inserts the commitment into the mixer tree and closes this account.\n *\n * @example\n * ```typescript\n * import { getConfidentialUtxoProofAccountPda } from \"@umbra-privacy/sdk\";\n *\n * const proofAccountPda = await getConfidentialUtxoProofAccountPda(\n * client.signer.address,\n * offset as U128,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getZkVerifyingKeyPda} for the verifying key used to check this proof\n * @see {@link getConfidentialClaimProofAccountPda} for the claim-side proof buffer\n *\n * @public\n */\nexport async function getConfidentialUtxoProofAccountPda(\n depositorAddress: Address,\n offset: U128,\n umbraProgram: Address,\n): Promise<Address> {\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n CONFIDENTIAL_UTXO_PROOF_ACCOUNT_SEED,\n getAddressEncoder().encode(depositorAddress),\n getAccountOffsetEncoder().encode({ first: BigInt(offset) }),\n ],\n });\n return pda;\n}\n\n/**\n * Derives the PDA for a `PublicClaimProofAccount`.\n *\n * The `PublicClaimProofAccount` is an ephemeral buffer account that holds\n * the Groth16 proof data for a public-balance claim instruction — i.e. a\n * claim that deposits UTXO value into a standard SPL token ATA rather than\n * an encrypted MXE balance. It is structurally analogous to\n * `ConfidentialClaimProofAccount` but used by the public claim flow.\n *\n * @param relayerAddress - The relayer's public key (proof account creator).\n * Scopes the account to this specific relayer.\n * @param offset - The U128 offset discriminator. Typically chosen randomly\n * per claim batch to allow concurrent public claims by the same relayer.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the derived PDA `Address`.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"PublicClaimProofAccount\")` — 32-byte struct seed\n * 2. `relayerAddress` — 32-byte relayer public key\n * 3. `offset` — 16-byte little-endian U128 account offset\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `PublicClaimProofAccount`\n * struct containing the Groth16 proof and public inputs for the public\n * claim circuit variant.\n *\n * ## Lifecycle\n *\n * 1. Relayer creates the account via `InitialisePublicClaimProofAccount`.\n * 2. Public claim instruction reads and verifies the proof.\n * 3. MPC callback releases tokens to the destination ATA and closes this account.\n *\n * @example\n * ```typescript\n * import { getPublicClaimProofAccountPda } from \"@umbra-privacy/sdk\";\n *\n * const proofAccountPda = await getPublicClaimProofAccountPda(\n * relayerPublicKey,\n * proofAccountOffset as U128,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getZkVerifyingKeyPda} for the verifying key used to check this proof\n * @see {@link getConfidentialClaimProofAccountPda} for the confidential-balance claim variant\n * @see {@link getPublicClaimMxeMpcCallbackDataPda} for the companion MPC callback data account\n *\n * @public\n */\nexport async function getPublicClaimProofAccountPda(\n relayerAddress: Address,\n offset: U128,\n umbraProgram: Address,\n): Promise<Address> {\n const [pda] = await getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n PUBLIC_CLAIM_PROOF_ACCOUNT_SEED,\n getAddressEncoder().encode(relayerAddress),\n getAccountOffsetEncoder().encode({ first: BigInt(offset) }),\n ],\n });\n return pda;\n}\n\n/**\n * Derives the PDA for a `PublicClaimMxeMpcCallbackData` account.\n *\n * The `PublicClaimMxeMpcCallbackData` account stores all data needed by the\n * Arcium MPC callback handler for an `AnonymouslyClaimIntoPublicBalanceMxeV3`\n * instruction. It is initialised in the handler (alongside the\n * `queue_computation` call) and closed — with rent returned to the relayer —\n * when the callback executes.\n *\n * This function returns the full `[address, bump]` tuple because the\n * canonical bump must be passed as the `mpcCallbackDataCanonicalBump`\n * instruction argument so the program can sign CPI calls into the account.\n *\n * @param relayerAddress - The relayer's public key. Scopes the callback data\n * account to this relayer so concurrent claim requests do not collide.\n * @param offset - The U128 offset discriminator. Currently always `0n` for\n * the `AnonymouslyClaimIntoPublicBalanceMxeV3` instruction, but included\n * for forward-compatibility.\n * @param umbraProgram - The Umbra program address (e.g. `networkConfig.programId`).\n * @returns A Promise resolving to the `[pda, bump]` tuple, where `bump` is\n * the canonical PDA bump needed as an instruction argument.\n *\n * @remarks\n * ## PDA Seeds\n *\n * The PDA is derived using the following seeds (in order):\n * 1. `SHA-256(\"PublicClaimMxeMpcCallbackData\")` — 32-byte struct seed\n * 2. `relayerAddress` — 32-byte relayer public key\n * 3. `offset` — 16-byte little-endian U128 account offset\n *\n * ## On-chain Account\n *\n * At this address the Umbra program stores a `PublicClaimMxeMpcCallbackData`\n * struct containing all state that the MPC callback needs to finalise the\n * public claim: the destination ATA, nullifier set, mixer tree index, and\n * fee pool references. The callback reads this account, updates on-chain\n * state, and closes it.\n *\n * ## Why the bump is returned\n *\n * The canonical bump is required by the claim instruction as\n * `mpcCallbackDataCanonicalBump` so that the program can sign PDA-based CPI\n * calls during the callback. Callers should destructure:\n * ```typescript\n * const [callbackDataPda, callbackDataBump] = await getPublicClaimMxeMpcCallbackDataPda(...);\n * ```\n *\n * @example\n * ```typescript\n * import { getPublicClaimMxeMpcCallbackDataPda } from \"@umbra-privacy/sdk\";\n *\n * const [callbackDataPda, mpcCallbackDataCanonicalBump] =\n * await getPublicClaimMxeMpcCallbackDataPda(\n * relayerPublicKey,\n * 0n as U128,\n * networkConfig.programId,\n * );\n * ```\n *\n * @see {@link getPublicClaimProofAccountPda} for the companion proof buffer account\n *\n * @public\n */\nexport async function getPublicClaimMxeMpcCallbackDataPda(\n relayerAddress: Address,\n offset: U128,\n umbraProgram: Address,\n): Promise<readonly [Address, number]> {\n return getProgramDerivedAddress({\n programAddress: umbraProgram,\n seeds: [\n PUBLIC_CLAIM_MXE_MPC_CALLBACK_DATA_SEED,\n getAddressEncoder().encode(relayerAddress),\n getAccountOffsetEncoder().encode({ first: BigInt(offset) }),\n ],\n });\n}\n","/**\n * Temporal Utilities\n *\n * This module provides utility functions for working with UTC timestamps\n * and extracting calendar components. These utilities are used for\n * time-scoped viewing key derivation and other temporal operations.\n *\n * @remarks\n * All functions in this module work exclusively with UTC timestamps to ensure consistent\n * key derivation regardless of the local timezone of the machine running the SDK.\n *\n * The dependency-injection pattern (`getUtcNowFunction`, `getExtractUtcComponentsFunction`)\n * allows tests to inject a fixed `dateProvider` so that time-based key derivation is\n * deterministic in test environments.\n *\n * @packageDocumentation\n * @module common/temporal\n */\n\nimport {\n type Year,\n type Month,\n type Day,\n type Hour,\n type Minute,\n type Second,\n assertYear,\n assertMonth,\n assertDay,\n assertHour,\n assertMinute,\n assertSecond,\n} from \"../../types\";\n\n/* =============================================================================\n * INTERFACES\n * ============================================================================= */\n\n/**\n * UTC timestamp components decomposed into individually branded fields.\n *\n * Contains all six calendar components extracted from a UTC timestamp. Each field is\n * a branded type that enforces the correct range at compile time and runtime.\n *\n * @remarks\n * This interface is produced by `extractUtcComponents` and `getUtcNow`. It is consumed\n * by time-scoped viewing key derivation functions to select the correct time granularity\n * (yearly, monthly, daily, etc.).\n *\n * @example\n * ```typescript\n * const now: UtcTimestampComponents = getUtcNow();\n * // now.year is a Year, now.month is a Month, etc.\n * const yearKey = deriveYearlyViewingKey(masterViewingKey, now.year);\n * ```\n *\n * @see {@link extractUtcComponents}\n * @see {@link getUtcNow}\n * @public\n */\nexport interface UtcTimestampComponents {\n /**\n * The year component in the range [0, 9999].\n * @see {@link Year}\n */\n year: Year;\n\n /**\n * The month component in the range [1, 12] (1 = January, 12 = December).\n * @see {@link Month}\n */\n month: Month;\n\n /**\n * The day-of-month component in the range [1, 31].\n * @see {@link Day}\n */\n day: Day;\n\n /**\n * The hour component in 24-hour format, in the range [0, 23].\n * @see {@link Hour}\n */\n hour: Hour;\n\n /**\n * The minute component in the range [0, 59].\n * @see {@link Minute}\n */\n minute: Minute;\n\n /**\n * The second component in the range [0, 59].\n * @see {@link Second}\n */\n second: Second;\n}\n\n/**\n * Function type for getting the current UTC timestamp components.\n *\n * @remarks\n * Implementations should return the current moment in UTC. The default implementation calls\n * `new Date()`, but tests can substitute a fixed-time provider via `getUtcNowFunction`.\n *\n * @returns The current UTC timestamp decomposed into branded calendar components\n *\n * @see {@link getUtcNowFunction}\n * @see {@link defaultGetUtcNow}\n * @public\n */\nexport type GetUtcNowFunction = () => UtcTimestampComponents;\n\n/**\n * Function type for extracting UTC components from a `Date` object.\n *\n * @remarks\n * Useful when working with a specific historical timestamp rather than the current time.\n *\n * @param date - A JavaScript `Date` object (any timezone; UTC getters are always used)\n * @returns The timestamp decomposed into branded UTC calendar components\n *\n * @see {@link getExtractUtcComponentsFunction}\n * @see {@link defaultExtractUtcComponents}\n * @public\n */\nexport type ExtractUtcComponentsFunction = (date: Date) => UtcTimestampComponents;\n\n/* =============================================================================\n * IMPLEMENTATION\n * ============================================================================= */\n\n/**\n * Extracts UTC timestamp components from a `Date` object.\n *\n * @remarks\n * All calendar components are extracted using the `getUTC*` family of methods, so the\n * result is independent of the local timezone setting of the host machine.\n *\n * Month is adjusted from the 0-indexed `Date.getUTCMonth()` (0–11) to the 1-indexed\n * `Month` branded type (1–12).\n *\n * @param date - The `Date` object to extract components from\n * @returns The six UTC calendar components as branded `UtcTimestampComponents`\n * @throws {TemporalAssertionError} If any extracted component is out of range (should not\n * occur with valid `Date` objects produced by the JavaScript runtime)\n *\n * @example\n * ```typescript\n * const date = new Date('2024-06-15T14:30:45Z');\n * const components = extractUtcComponents(date);\n * // { year: 2024n, month: 6n, day: 15n, hour: 14n, minute: 30n, second: 45n }\n * ```\n *\n * @see {@link UtcTimestampComponents}\n * @see {@link getUtcNow}\n * @public\n */\nexport function extractUtcComponents(date: Date): UtcTimestampComponents {\n const yearValue = BigInt(date.getUTCFullYear());\n const monthValue = BigInt(date.getUTCMonth() + 1); // getUTCMonth is 0-indexed\n const dayValue = BigInt(date.getUTCDate());\n const hourValue = BigInt(date.getUTCHours());\n const minuteValue = BigInt(date.getUTCMinutes());\n const secondValue = BigInt(date.getUTCSeconds());\n\n // Validate and assert all components\n assertYear(yearValue);\n assertMonth(monthValue);\n assertDay(dayValue);\n assertHour(hourValue);\n assertMinute(minuteValue);\n assertSecond(secondValue);\n\n return {\n year: yearValue,\n month: monthValue,\n day: dayValue,\n hour: hourValue,\n minute: minuteValue,\n second: secondValue,\n };\n}\n\n/**\n * Gets the current UTC timestamp components.\n *\n * @remarks\n * Equivalent to calling `extractUtcComponents(new Date())`. Provided as a convenience\n * function for the common case of deriving keys for the current moment.\n *\n * @returns The current UTC timestamp decomposed into branded calendar components\n *\n * @example\n * ```typescript\n * const now = getUtcNow();\n * console.log(`Current UTC: ${now.year}-${now.month}-${now.day} ${now.hour}:${now.minute}:${now.second}`);\n * ```\n *\n * @see {@link extractUtcComponents}\n * @see {@link defaultGetUtcNow}\n * @public\n */\nexport function getUtcNow(): UtcTimestampComponents {\n return extractUtcComponents(new Date());\n}\n\n/**\n * Creates a UTC timestamp components getter with optional dependency injection.\n *\n * @remarks\n * Use this factory when you need to inject a custom date source for testing or for\n * deterministic key derivation in non-interactive scripts. The returned function captures\n * `dateProvider` in its closure.\n *\n * @param deps - Optional dependency overrides\n * @param deps.dateProvider - A zero-argument function returning the current `Date`. Defaults\n * to `() => new Date()`.\n * @defaultValue `deps` — `undefined` (uses real system clock)\n * @returns A `GetUtcNowFunction` that calls `dateProvider` on each invocation\n *\n * @example\n * ```typescript\n * // Default usage\n * const getUtc = getUtcNowFunction();\n * const now = getUtc();\n *\n * // With custom date provider (for testing)\n * const getUtc = getUtcNowFunction({\n * dateProvider: () => new Date('2024-06-15T14:30:45Z')\n * });\n * const fixedTime = getUtc();\n * ```\n *\n * @see {@link GetUtcNowFunction}\n * @see {@link defaultGetUtcNow}\n * @public\n */\nexport function getUtcNowFunction(deps?: { dateProvider?: () => Date }): GetUtcNowFunction {\n const dateProvider = deps?.dateProvider ?? (() => new Date());\n\n return () => extractUtcComponents(dateProvider());\n}\n\n/**\n * Creates an extractor function for UTC components with optional dependency injection.\n *\n * @remarks\n * Currently a pass-through to `extractUtcComponents`. The `deps` parameter is reserved\n * for future use (e.g., injecting a custom calendar implementation). Prefer\n * `defaultExtractUtcComponents` unless you need the factory pattern for consistency with\n * other injectable utilities in the SDK.\n *\n * @param deps - Reserved for future dependency overrides; currently unused\n * @returns An `ExtractUtcComponentsFunction` backed by the built-in `extractUtcComponents`\n *\n * @example\n * ```typescript\n * const extract = getExtractUtcComponentsFunction();\n * const components = extract(new Date());\n * ```\n *\n * @see {@link ExtractUtcComponentsFunction}\n * @see {@link defaultExtractUtcComponents}\n * @public\n */\nexport function getExtractUtcComponentsFunction(\n deps?: Record<string, never>,\n): ExtractUtcComponentsFunction {\n void deps;\n return extractUtcComponents;\n}\n\n/* =============================================================================\n * DEFAULT INSTANCES\n * ============================================================================= */\n\n/**\n * Default `GetUtcNowFunction` using the real system clock.\n *\n * @remarks\n * This is the pre-built instance of `getUtcNowFunction()` for use throughout the SDK.\n * Pass `defaultGetUtcNow` as the `getUtcNow` dependency when constructing SDK services\n * in production. Substitute a custom function in tests.\n *\n * @see {@link GetUtcNowFunction}\n * @see {@link getUtcNowFunction}\n * @public\n */\nexport const defaultGetUtcNow: GetUtcNowFunction = getUtcNowFunction();\n\n/**\n * Default `ExtractUtcComponentsFunction` backed by `extractUtcComponents`.\n *\n * @remarks\n * This is the pre-built instance for use throughout the SDK when an\n * `ExtractUtcComponentsFunction` is required. Equivalent to calling\n * `getExtractUtcComponentsFunction()` with no arguments.\n *\n * @see {@link ExtractUtcComponentsFunction}\n * @see {@link getExtractUtcComponentsFunction}\n * @public\n */\nexport const defaultExtractUtcComponents: ExtractUtcComponentsFunction =\n getExtractUtcComponentsFunction();\n","/**\n * Token Utilities Module\n *\n * This module provides utilities for working with Solana SPL Token and Token-2022\n * programs, with a focus on the Transfer Fee extension used by some Token-2022 tokens.\n *\n * **Token Programs on Solana:**\n *\n * ```\n * ┌─────────────────────────────────────────────────────────────────────────┐\n * │ Solana Token Programs │\n * ├─────────────────────────────────────────────────────────────────────────┤\n * │ │\n * │ ┌───────────────────────────┐ ┌───────────────────────────┐ │\n * │ │ SPL Token (Legacy) │ │ Token-2022 │ │\n * │ ├───────────────────────────┤ ├───────────────────────────┤ │\n * │ │ • Standard fungible │ │ • All SPL Token features │ │\n * │ │ tokens │ │ • Transfer fees │ │\n * │ │ • USDC, BONK, etc. │ │ • Interest-bearing │ │\n * │ │ • No extensions │ │ • Confidential transfers │ │\n * │ │ │ │ • Transfer hooks │ │\n * │ │ │ │ • Non-transferable │ │\n * │ └───────────────────────────┘ └───────────────────────────┘ │\n * │ │\n * └─────────────────────────────────────────────────────────────────────────┘\n * ```\n *\n * **Transfer Fee Extension:**\n *\n * Token-2022 tokens can have a transfer fee that is automatically deducted\n * on every transfer. This module provides utilities to:\n * - Extract transfer fee configuration from mint account data\n * - Calculate the fee for a given transfer amount\n * - Handle epoch-based fee schedule transitions\n *\n * **Fee Calculation Formula:**\n *\n * ```\n * fee = ceil((amount × basisPoints) / 10000)\n * actualFee = min(fee, maximumFee)\n * ```\n *\n * Where:\n * - `basisPoints`: Fee percentage × 100 (e.g., 1% = 100 bps)\n * - `maximumFee`: Cap on the fee regardless of amount\n *\n * @example\n * Checking if a token has transfer fees:\n * ```typescript\n * import { extractTransferFeeConfig, calculateTransferFee } from \"@umbra-privacy/sdk\";\n *\n * // Fetch mint account data\n * const mintAccount = await accountInfoProvider([mintAddress]);\n * const feeConfig = extractTransferFeeConfig(mintAccount.get(mintAddress)?.data);\n *\n * if (feeConfig) {\n * const epochInfo = await getEpochInfo();\n * const fee = calculateTransferFee(feeConfig, epochInfo.epoch, amount);\n * console.log(`Transfer fee: ${fee} tokens`);\n * } else {\n * console.log(\"No transfer fee on this token\");\n * }\n * ```\n *\n * @packageDocumentation\n * @module common/token\n */\n\nimport { address, type Address } from \"@solana/kit\";\n\n/* =============================================================================\n * TRANSFER FEE EXTENSION TYPES\n * ============================================================================= */\n\n/**\n * Transfer fee schedule configuration.\n *\n * Defines the fee parameters that apply during a specific epoch range.\n * Token-2022 mints can have two fee schedules (older and newer) to allow\n * gradual fee changes without disruption.\n *\n * **Schedule Activation:**\n * - The `olderTransferFee` is active when `currentEpoch < newerTransferFee.epoch`\n * - The `newerTransferFee` becomes active when `currentEpoch >= newerTransferFee.epoch`\n *\n * **Basis Points:**\n * Fees are specified in basis points (bps) where 1 bps = 0.01%.\n *\n * | Basis Points | Percentage |\n * |--------------|------------|\n * | 1 | 0.01% |\n * | 10 | 0.1% |\n * | 100 | 1% |\n * | 1000 | 10% |\n * | 10000 | 100% |\n *\n * @see {@link TransferFeeConfig}\n * @see {@link calculateTransferFee}\n * @public\n */\nexport interface TransferFeeSchedule {\n /**\n * Solana epoch at which this fee schedule becomes active.\n *\n * @remarks\n * Solana epochs are approximately 2–3 days. When the cluster reaches this epoch number,\n * this schedule's fee parameters replace the older schedule.\n */\n epoch: bigint;\n\n /**\n * Maximum fee that can be charged per transfer, in token base units.\n *\n * @remarks\n * Caps the fee regardless of transfer amount. For example, if\n * `maximumFee = 1_000_000` and the token has 6 decimals, the cap is 1 token.\n * A value of `BigInt.MAX_VALUE` effectively removes the cap.\n */\n maximumFee: bigint;\n\n /**\n * Fee in basis points (hundredths of a percent).\n *\n * @remarks\n * A value of 100 bps equals 1%. Valid range is 0–10000 (0%–100%).\n * The fee formula is: `ceil((amount * transferFeeBasisPoints) / 10000)`, capped at `maximumFee`.\n */\n transferFeeBasisPoints: number;\n}\n\n/**\n * Transfer Fee Config extension data.\n *\n * Complete transfer fee configuration for a Token-2022 mint.\n * Contains authorities, withheld amounts, and both fee schedules.\n *\n * **Extension Layout:**\n *\n * ```\n * ┌────────────────────────────────────────┐\n * │ Transfer Fee Config (108 bytes) │\n * ├────────────────────────────────────────┤\n * │ transferFeeConfigAuthority (36 bytes) │ COption<Pubkey>\n * │ withdrawWithheldAuthority (36 bytes) │ COption<Pubkey>\n * │ withheldAmount (8 bytes) │ u64\n * │ olderTransferFee (18 bytes) │ TransferFeeSchedule\n * │ newerTransferFee (18 bytes) │ TransferFeeSchedule\n * └────────────────────────────────────────┘\n * ```\n *\n * **Fee Collection:**\n * When transfers occur, fees are \"withheld\" in the recipient's token account.\n * The `withdrawWithheldAuthority` can collect these fees using the\n * `WithdrawWithheldTokensFromAccounts` instruction.\n *\n * @see {@link TransferFeeSchedule}\n * @see {@link extractTransferFeeConfig}\n * @see {@link calculateTransferFee}\n * @public\n */\nexport interface TransferFeeConfig {\n /**\n * Authority that can modify the transfer fee configuration.\n *\n * @remarks\n * If `null`, the transfer fee is permanently immutable (no one can change it).\n */\n transferFeeConfigAuthority: Address | null;\n\n /**\n * Authority that can withdraw fees that have been withheld in token accounts.\n *\n * @remarks\n * If `null`, withheld fees can never be withdrawn and are effectively burned.\n * Use `HarvestWithheldTokensToMint` followed by `WithdrawWithheldTokensFromMint`\n * to collect fees if this authority is set.\n */\n withdrawWithheldAuthority: Address | null;\n\n /**\n * Total amount of fees currently withheld on the mint account itself (in token base units).\n *\n * @remarks\n * Individual token accounts accumulate fees in their own `withheldAmount` field.\n * Calling `HarvestWithheldTokensToMint` transfers those per-account fees to this\n * mint-level accumulator.\n */\n withheldAmount: bigint;\n\n /**\n * The older (currently active if epoch has not advanced) transfer fee schedule.\n *\n * @remarks\n * This schedule is active when `currentEpoch < newerTransferFee.epoch`.\n */\n olderTransferFee: TransferFeeSchedule;\n\n /**\n * The newer (pending or active) transfer fee schedule.\n *\n * @remarks\n * This schedule becomes active when `currentEpoch >= newerTransferFee.epoch`.\n */\n newerTransferFee: TransferFeeSchedule;\n}\n\n/* =============================================================================\n * EXTENSION TYPE CONSTANTS\n * ============================================================================= */\n\n/**\n * Extension type discriminator byte value for the Transfer Fee Config extension.\n *\n * @remarks\n * In the Token-2022 extension binary format, each extension block is prefixed with a\n * 2-byte little-endian type discriminator. Value 1 identifies the Transfer Fee Config.\n *\n * @internal\n */\nconst EXTENSION_TYPE_TRANSFER_FEE_CONFIG = 1;\n\n/**\n * Byte length of the base (non-extended) Token-2022 mint account layout.\n *\n * @remarks\n * The 82 bytes cover: mint authority (COption<Pubkey>, 36 bytes), supply (u64, 8 bytes),\n * decimals (u8, 1 byte), is_initialized (bool, 1 byte), freeze authority (COption<Pubkey>,\n * 36 bytes). Token-2022 mints with extensions will be larger than this.\n *\n * @internal\n */\nconst MINT_SIZE = 82;\n\n/**\n * Byte offset of the account type discriminator byte in a Token-2022 mint account.\n *\n * @remarks\n * Immediately follows the 82-byte base mint layout. Value 1 means \"Mint\" (as opposed to\n * \"TokenAccount\" = 2 or uninitialized = 0).\n *\n * @internal\n */\nconst ACCOUNT_TYPE_OFFSET = MINT_SIZE;\n\n/**\n * Byte offset where the extension data region begins in a Token-2022 mint account.\n *\n * @remarks\n * Immediately follows the single account-type discriminator byte at `ACCOUNT_TYPE_OFFSET`.\n *\n * @internal\n */\nconst EXTENSIONS_OFFSET = ACCOUNT_TYPE_OFFSET + 1;\n\n/**\n * Expected byte length of the Transfer Fee Config extension data payload (excluding the\n * 4-byte type+length prefix).\n *\n * @remarks\n * Layout: transferFeeConfigAuthority (36) + withdrawWithheldAuthority (36) +\n * withheldAmount (8) + olderTransferFee (18) + newerTransferFee (18) = 108 bytes.\n *\n * @internal\n */\nconst TRANSFER_FEE_CONFIG_SIZE = 108;\n\n/* =============================================================================\n * TRANSFER FEE CONFIG EXTRACTION\n * ============================================================================= */\n\n/**\n * Extracts the Transfer Fee Config extension from mint account data.\n *\n * Parses raw mint account bytes to find and decode the Transfer Fee Config\n * extension if present. This function handles the Token-2022 extension\n * serialization format.\n *\n * **Extension Detection Flow:**\n *\n * ```\n * mintData\n * │\n * ▼\n * ┌──────────────────────────────────────┐\n * │ 1. Check minimum length (> 83 bytes) │\n * └──────────────────────────────────────┘\n * │\n * ▼\n * ┌──────────────────────────────────────┐\n * │ 2. Verify account type = 1 (Mint) │\n * └──────────────────────────────────────┘\n * │\n * ▼\n * ┌──────────────────────────────────────┐\n * │ 3. Iterate through extensions │\n * │ • Read type (2 bytes) │\n * │ • Read length (2 bytes) │\n * │ • Check if type = 1 (TransferFee) │\n * └──────────────────────────────────────┘\n * │\n * ▼\n * ┌──────────────────────────────────────┐\n * │ 4. Parse Transfer Fee Config data │\n * └──────────────────────────────────────┘\n * ```\n *\n * **Return Conditions:**\n * - Returns `null` if mint data is too short for extensions\n * - Returns `null` if account type is not Mint (1)\n * - Returns `null` if Transfer Fee Config extension not found\n * - Returns `null` if extension data is malformed\n * - Returns `TransferFeeConfig` if successfully parsed\n *\n * @param mintData - Raw bytes of the on-chain mint account (`accountInfo.data`)\n * @returns The parsed `TransferFeeConfig` if the extension is present and valid,\n * or `null` if not found or the data is malformed\n *\n * @example\n * ```typescript\n * import { extractTransferFeeConfig } from \"@umbra-privacy/sdk\";\n *\n * const mintAccount = await accountInfoProvider([mintAddress]);\n * const mintData = mintAccount.get(mintAddress)?.data;\n *\n * if (mintData) {\n * const feeConfig = extractTransferFeeConfig(mintData);\n * if (feeConfig) {\n * console.log(\"Token has transfer fees\");\n * console.log(`Fee: ${feeConfig.olderTransferFee.transferFeeBasisPoints} bps`);\n * }\n * }\n * ```\n *\n * @see {@link TransferFeeConfig}\n * @see {@link calculateTransferFee}\n * @public\n */\nexport function extractTransferFeeConfig(\n mintData: Uint8Array | undefined,\n): TransferFeeConfig | null {\n // Validate input\n if (mintData === undefined || mintData.length === 0) {\n return null;\n }\n\n // Must be larger than base mint to have extensions\n if (mintData.length <= EXTENSIONS_OFFSET) {\n return null;\n }\n\n // Check account type byte (should be 1 for Mint)\n const accountType = mintData[ACCOUNT_TYPE_OFFSET];\n if (accountType !== 1) {\n return null;\n }\n\n // Parse extensions\n let offset = EXTENSIONS_OFFSET;\n\n while (offset + 4 <= mintData.length) {\n // Read extension type (2 bytes, little endian)\n const extensionType = (mintData[offset] ?? 0) | ((mintData[offset + 1] ?? 0) << 8);\n offset += 2;\n\n // Read extension length (2 bytes, little endian)\n const extensionLength = (mintData[offset] ?? 0) | ((mintData[offset + 1] ?? 0) << 8);\n offset += 2;\n\n // Validate extension length is reasonable\n if (extensionLength === 0 || extensionLength > 10_000) {\n // Extension length seems invalid, stop parsing\n break;\n }\n\n // Check if we have enough data for this extension\n if (offset + extensionLength > mintData.length) {\n break;\n }\n\n if (extensionType === EXTENSION_TYPE_TRANSFER_FEE_CONFIG) {\n return parseTransferFeeConfig(mintData.slice(offset, offset + extensionLength));\n }\n\n // Skip to next extension\n offset += extensionLength;\n }\n\n return null;\n}\n\n/**\n * Parses the raw 108-byte Transfer Fee Config extension payload into a typed object.\n *\n * @param data - The extension payload bytes (must be at least `TRANSFER_FEE_CONFIG_SIZE` bytes)\n * @returns The parsed `TransferFeeConfig`, or `null` if the data is too short or contains\n * invalid values (e.g., basis points > 10000)\n *\n * @privateRemarks\n * This function is called by `extractTransferFeeConfig` once the correct extension has been\n * located in the account data. It does not validate the extension type prefix — that is\n * handled by the caller.\n *\n * @internal\n */\nfunction parseTransferFeeConfig(data: Uint8Array): TransferFeeConfig | null {\n // Validate minimum size\n if (data.length < TRANSFER_FEE_CONFIG_SIZE) {\n return null;\n }\n\n let offset = 0;\n\n // Parse transferFeeConfigAuthority (COption<Pubkey>)\n const transferFeeConfigAuthority = parseOptionalPubkey(data, offset);\n offset += 36; // 4 byte discriminator + 32 byte pubkey\n\n // Parse withdrawWithheldAuthority (COption<Pubkey>)\n const withdrawWithheldAuthority = parseOptionalPubkey(data, offset);\n offset += 36;\n\n // Parse withheldAmount (u64, little endian)\n const withheldAmount = readU64LE(data, offset);\n offset += 8;\n\n // Parse olderTransferFee\n const olderTransferFee = parseTransferFeeSchedule(data, offset);\n offset += 18;\n\n // Parse newerTransferFee\n const newerTransferFee = parseTransferFeeSchedule(data, offset);\n\n // Validate parsed data\n if (\n olderTransferFee.transferFeeBasisPoints > 10_000 ||\n newerTransferFee.transferFeeBasisPoints > 10_000\n ) {\n // Basis points cannot exceed 100%\n return null;\n }\n\n return {\n transferFeeConfigAuthority,\n withdrawWithheldAuthority,\n withheldAmount,\n olderTransferFee,\n newerTransferFee,\n };\n}\n\n/**\n * Parses a Borsh-encoded `COption<Pubkey>` (36 bytes) at the given offset.\n *\n * @remarks\n * In Borsh serialization, `COption<T>` is encoded as a 4-byte little-endian discriminator\n * (0 = None, 1 = Some) followed by the serialized `T`. For `Pubkey`, `T` is 32 bytes.\n *\n * @param data - The byte buffer containing the serialized data\n * @param offset - Byte offset into `data` where the `COption<Pubkey>` begins\n * @returns The decoded `Address` if the discriminator is 1 (Some), or `null` if 0 (None)\n *\n * @internal\n */\nfunction parseOptionalPubkey(data: Uint8Array, offset: number): Address | null {\n // First 4 bytes are the discriminator: 0 = None, 1 = Some\n const discriminator =\n (data[offset] ?? 0) |\n ((data[offset + 1] ?? 0) << 8) |\n ((data[offset + 2] ?? 0) << 16) |\n ((data[offset + 3] ?? 0) << 24);\n\n if (discriminator === 0) {\n return null;\n }\n\n // Extract 32-byte pubkey and convert to Address\n const pubkeyBytes = data.slice(offset + 4, offset + 36);\n return pubkeyBytesToAddress(pubkeyBytes);\n}\n\n/**\n * Converts a 32-byte raw public key into a Base58-encoded Solana `Address` string.\n *\n * @remarks\n * Uses the Base58 alphabet used by Bitcoin and Solana (no 0, O, I, l). Leading zero bytes\n * in the input produce leading '1' characters in the output, which matches the Solana\n * address encoding convention.\n *\n * @param bytes - Exactly 32 bytes representing the public key\n * @returns A Base58Check-encoded `Address` string\n *\n * @internal\n */\nfunction pubkeyBytesToAddress(bytes: Uint8Array): Address {\n const ALPHABET = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\n\n // Convert bytes to big integer\n let numericValue = 0n;\n for (const byte of bytes) {\n numericValue = numericValue * 256n + BigInt(byte);\n }\n\n // Convert to base58\n let encoded = \"\";\n while (numericValue > 0n) {\n const remainder = Number(numericValue % 58n);\n numericValue = numericValue / 58n;\n encoded = (ALPHABET[remainder] ?? \"\") + encoded;\n }\n\n // Add leading '1's for leading zeros in the bytes\n for (const byte of bytes) {\n if (byte === 0) {\n encoded = `1${encoded}`;\n } else {\n break;\n }\n }\n\n return address(encoded);\n}\n\n/**\n * Parses a single `TransferFeeSchedule` from binary data at the given offset.\n *\n * @remarks\n * The 18-byte layout is: epoch (u64 LE, 8 bytes) + maximumFee (u64 LE, 8 bytes) +\n * transferFeeBasisPoints (u16 LE, 2 bytes).\n *\n * @param data - The byte buffer containing the serialized schedule\n * @param offset - Byte offset into `data` where the schedule begins\n * @returns The decoded `TransferFeeSchedule`\n *\n * @internal\n */\nfunction parseTransferFeeSchedule(data: Uint8Array, offset: number): TransferFeeSchedule {\n // epoch: u64 (8 bytes, little endian)\n const epoch = readU64LE(data, offset);\n\n // maximumFee: u64 (8 bytes, little endian)\n const maximumFee = readU64LE(data, offset + 8);\n\n // transferFeeBasisPoints: u16 (2 bytes, little endian)\n const transferFeeBasisPoints = (data[offset + 16] ?? 0) | ((data[offset + 17] ?? 0) << 8);\n\n return {\n epoch,\n maximumFee,\n transferFeeBasisPoints,\n };\n}\n\n/**\n * Reads a little-endian `u64` (8 bytes) from a byte buffer at the given offset.\n *\n * @remarks\n * Accumulates 8 bytes from most-significant to least-significant using bit-shifts to\n * avoid potential sign-extension issues with 32-bit intermediates.\n *\n * @param data - The byte buffer to read from\n * @param offset - Byte offset into `data` where the u64 begins\n * @returns The decoded `bigint` value in range [0, 2^64 - 1]\n *\n * @internal\n */\nfunction readU64LE(data: Uint8Array, offset: number): bigint {\n let result = 0n;\n for (let index = 7; index >= 0; index--) {\n result = (result << 8n) | BigInt(data[offset + index] ?? 0);\n }\n return result;\n}\n\n/* =============================================================================\n * TRANSFER FEE CALCULATION\n * ============================================================================= */\n\n/**\n * Calculates the transfer fee for a given amount based on the fee configuration.\n *\n * Computes the fee that will be deducted from a transfer based on the\n * active fee schedule. The fee is calculated using basis points and\n * capped at the maximum fee.\n *\n * **Fee Calculation:**\n *\n * ```\n * rawFee = ceil((amount × basisPoints) / 10000)\n * actualFee = min(rawFee, maximumFee)\n * ```\n *\n * **Schedule Selection:**\n * - If `currentEpoch >= newerTransferFee.epoch`: Use `newerTransferFee`\n * - Otherwise: Use `olderTransferFee`\n *\n * **Rounding:**\n * The fee is rounded UP (ceiling) to ensure the protocol always collects\n * at least the calculated fee amount.\n *\n * **Examples:**\n *\n * | Amount | Basis Points | Max Fee | Raw Fee | Actual Fee |\n * |--------|--------------|---------|---------|------------|\n * | 1000 | 100 (1%) | 500 | 10 | 10 |\n * | 100000 | 100 (1%) | 500 | 1000 | 500 (capped) |\n * | 50 | 100 (1%) | 500 | 1 | 1 (ceil) |\n * | 1000 | 0 | 0 | 0 | 0 |\n *\n * @param feeConfig - The transfer fee configuration from the mint\n * @param currentEpoch - The current Solana epoch (determines which schedule is active)\n * @param amount - The transfer amount in token base units (before fee)\n * @returns The fee amount in token base units to be withheld\n *\n * @example\n * ```typescript\n * import { extractTransferFeeConfig, calculateTransferFee } from \"@umbra-privacy/sdk\";\n *\n * const feeConfig = extractTransferFeeConfig(mintData)!;\n * const epochInfo = await getEpochInfo();\n *\n * const transferAmount = 1_000_000n; // 1 token (6 decimals)\n * const fee = calculateTransferFee(feeConfig, epochInfo.epoch, transferAmount);\n *\n * console.log(`Transfer: ${transferAmount}`);\n * console.log(`Fee: ${fee}`);\n * console.log(`Recipient receives: ${transferAmount - fee}`);\n * ```\n *\n * @see {@link extractTransferFeeConfig}\n * @see {@link calculateNetAmountAfterFee}\n * @public\n */\nexport function calculateTransferFee(\n feeConfig: TransferFeeConfig,\n currentEpoch: bigint,\n amount: bigint,\n): bigint {\n // Handle edge cases\n if (amount <= 0n) {\n return 0n;\n }\n\n // Determine which fee schedule to use based on epoch\n const schedule =\n currentEpoch >= feeConfig.newerTransferFee.epoch\n ? feeConfig.newerTransferFee\n : feeConfig.olderTransferFee;\n\n // If no fee configured, return 0\n if (schedule.transferFeeBasisPoints === 0) {\n return 0n;\n }\n\n // Calculate fee: (amount * basisPoints) / 10000, rounded up\n const fee = ceilDiv(amount * BigInt(schedule.transferFeeBasisPoints), 10_000n);\n\n // Cap at maximum fee (Math.min does not support bigint)\n // eslint-disable-next-line unicorn/prefer-math-min-max\n return fee < schedule.maximumFee ? fee : schedule.maximumFee;\n}\n\n/**\n * Performs ceiling (round-up) integer division for `bigint` values.\n *\n * @remarks\n * Equivalent to `Math.ceil(Number(numerator) / Number(denominator))` but exact for arbitrary\n * precision integers. Formula: `(numerator + denominator - 1) / denominator`.\n *\n * @param numerator - The dividend (must be non-negative)\n * @param denominator - The divisor (must be non-zero and positive)\n * @returns `ceil(numerator / denominator)` as a `bigint`\n * @throws {Error} If `denominator` is zero\n *\n * @internal\n */\nfunction ceilDiv(numerator: bigint, denominator: bigint): bigint {\n if (denominator === 0n) {\n throw new Error(\"Division by zero\");\n }\n return (numerator + denominator - 1n) / denominator;\n}\n\n/* =============================================================================\n * UTILITY FUNCTIONS\n * ============================================================================= */\n\n/**\n * Calculates the net amount received by the recipient after the transfer fee is withheld.\n *\n * @remarks\n * This is a convenience wrapper around `calculateTransferFee`. The relationship is:\n * ```\n * netAmount = grossAmount - calculateTransferFee(feeConfig, currentEpoch, grossAmount)\n * ```\n *\n * Use this when you know the gross send amount and need to display the effective receive\n * amount. For the inverse (computing a gross amount that results in a specific net receive),\n * a different calculation is needed.\n *\n * @param feeConfig - The transfer fee configuration parsed from the mint account\n * @param currentEpoch - The current Solana epoch (used to select the active fee schedule)\n * @param grossAmount - The amount being transferred in token base units (before fee deduction)\n * @returns The net amount the recipient receives, in token base units\n *\n * @example\n * ```typescript\n * const netAmount = calculateNetAmountAfterFee(feeConfig, currentEpoch, 1_000_000n);\n * console.log(`Sending 1,000,000 tokens, recipient gets ${netAmount}`);\n * ```\n *\n * @see {@link calculateTransferFee}\n * @see {@link extractTransferFeeConfig}\n * @public\n */\nexport function calculateNetAmountAfterFee(\n feeConfig: TransferFeeConfig,\n currentEpoch: bigint,\n grossAmount: bigint,\n): bigint {\n const fee = calculateTransferFee(feeConfig, currentEpoch, grossAmount);\n return grossAmount - fee;\n}\n","/**\n * Type Helper Utilities\n *\n * Provides a set of thin wrapper functions that validate a raw `bigint` (or `Uint8Array`)\n * value and return it typed as one of the SDK's branded types. Each helper delegates to the\n * corresponding `assert*` function from `../types` and then returns the value — the return\n * type narrowing is what makes these helpers useful at call sites.\n *\n * ## Why helpers instead of direct `assert*` calls?\n *\n * The `assert*` functions throw on invalid input and return `void`. When you need the\n * branded result in an expression context (e.g. as a function argument or in an arrow\n * function), you would otherwise need:\n *\n * ```typescript\n * // Without helpers — verbose and requires a temporary variable:\n * assertU64(rawValue, \"amount\");\n * const amount = rawValue as unknown as U64; // Unsafe cast\n *\n * // With helpers — single expression, type-safe:\n * const amount = asU64(rawValue, \"amount\");\n * ```\n *\n * The helpers eliminate the unsafe `as unknown as` pattern while keeping assertion\n * semantics (an invalid value throws rather than silently narrowing).\n *\n * ## Organisation\n *\n * Helpers are grouped into four sections:\n * 1. **Mathematics** — `asU64`, `asU128`, `asU256`\n * 2. **Field elements** — `asBn254FieldElement`, `asCurve25519FieldElement`, `asPoseidonKey`\n * 3. **Rescue Cipher** — `asRcPlaintext`, `asRcCiphertext`, `asRcKey`, `asRcEncryptionNonce`\n * 4. **Limbs** — `asBase85Limb`\n * 5. **Array indexing** — `getByteAt`\n *\n * @packageDocumentation\n * @module common/type-helpers\n */\n\nimport {\n // Mathematics types and assertions\n type U64,\n type U128,\n type U256,\n assertU64,\n assertU128,\n assertU256,\n // Cryptography types and assertions\n type Bn254FieldElement,\n type Curve25519FieldElement,\n type PoseidonKey,\n type RcPlaintext,\n type RcCiphertext,\n type RcKey,\n type RcEncryptionNonce,\n type Base85Limb,\n assertBn254FieldElement,\n assertPoseidonKey,\n assertCurve25519FieldElement,\n assertRcPlaintext,\n assertRcCiphertext,\n assertRcKey,\n assertRcEncryptionNonce,\n assertBase85Limb,\n} from \"../types\";\n\n/* =============================================================================\n * MATHEMATICS TYPE HELPERS\n * ============================================================================= */\n\n/**\n * Validates a `bigint` as a 64-bit unsigned integer and returns it branded as `U64`.\n *\n * @remarks\n * Delegates to `assertU64` from `../types`. The assertion verifies that `value` is a\n * `bigint` in the closed range `[0, 2^64 - 1]`. If the value is out of range or is\n * not a `bigint`, a `MathematicsAssertionError` is thrown with a message that includes\n * `name` when provided.\n *\n * Prefer this helper over a raw `as U64` cast whenever you do not already hold a\n * branded value — it preserves the runtime safety guarantee that the type implies.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @param name - Optional variable name to include in the error message for easier debugging.\n * @returns The same `bigint` value, branded as {@link U64}.\n * @throws `MathematicsAssertionError` if `value` is not a `bigint` or exceeds `2^64 - 1`.\n *\n * @example\n * ```typescript\n * import { asU64 } from \"@umbra-privacy/sdk\";\n *\n * const raw = 1_000_000n;\n * const amount: U64 = asU64(raw, \"amount\");\n *\n * // Throws for negative or oversized values:\n * asU64(-1n); // MathematicsAssertionError\n * asU64(2n ** 64n); // MathematicsAssertionError\n * ```\n *\n * @see {@link assertU64} for the underlying assertion.\n * @see {@link asU128} for 128-bit variant.\n * @see {@link asU256} for 256-bit variant.\n * @public\n */\nexport function asU64(value: bigint, name?: string): U64 {\n assertU64(value, name);\n return value;\n}\n\n/**\n * Validates a `bigint` as a 128-bit unsigned integer and returns it branded as `U128`.\n *\n * @remarks\n * Delegates to `assertU128` from `../types`. The assertion verifies that `value` is a\n * `bigint` in the closed range `[0, 2^128 - 1]`. If the value is out of range or is\n * not a `bigint`, a `MathematicsAssertionError` is thrown.\n *\n * In the Umbra protocol, `U128` values appear as instruction seeds (e.g.\n * `ANONYMOUSLY_CLAIM_INTO_EXISTING_TOKEN_MXE_V3_SEED`), generation indices in\n * `EncryptedUserAccount.generationIndex`, and fee offset discriminators.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @param name - Optional variable name to include in the error message for easier debugging.\n * @returns The same `bigint` value, branded as {@link U128}.\n * @throws `MathematicsAssertionError` if `value` is not a `bigint` or exceeds `2^128 - 1`.\n *\n * @example\n * ```typescript\n * import { asU128 } from \"@umbra-privacy/sdk\";\n *\n * const seed = asU128(340282366920938463463374607431768211455n, \"instructionSeed\");\n * // seed is now typed as U128 and safe to pass to PDA derivation helpers.\n *\n * // Throws for oversized values:\n * asU128(2n ** 128n); // MathematicsAssertionError\n * ```\n *\n * @see {@link assertU128} for the underlying assertion.\n * @see {@link asU64} for the 64-bit variant.\n * @see {@link asU256} for the 256-bit variant.\n * @public\n */\nexport function asU128(value: bigint, name?: string): U128 {\n assertU128(value, name);\n return value;\n}\n\n/**\n * Validates a `bigint` as a 256-bit unsigned integer and returns it branded as `U256`.\n *\n * @remarks\n * Delegates to `assertU256` from `../types`. The assertion verifies that `value` is a\n * `bigint` in the closed range `[0, 2^256 - 1]`. If the value is out of range or is\n * not a `bigint`, a `MathematicsAssertionError` is thrown.\n *\n * `U256` values are used throughout the SDK for 256-bit cryptographic scalars, such as\n * UTXO commitment preimages, random generation seeds (`randomGenerationSeed`), and\n * Poseidon hash inputs that require full 256-bit precision.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @param name - Optional variable name to include in the error message for easier debugging.\n * @returns The same `bigint` value, branded as {@link U256}.\n * @throws `MathematicsAssertionError` if `value` is not a `bigint` or exceeds `2^256 - 1`.\n *\n * @example\n * ```typescript\n * import { asU256 } from \"@umbra-privacy/sdk\";\n *\n * const scalar = asU256(commitment, \"utxoCommitment\");\n * // scalar is now typed as U256 and safe to pass to Poseidon hash functions.\n * ```\n *\n * @see {@link assertU256} for the underlying assertion.\n * @see {@link asU64} for the 64-bit variant.\n * @see {@link asU128} for the 128-bit variant.\n * @public\n */\nexport function asU256(value: bigint, name?: string): U256 {\n assertU256(value, name);\n return value;\n}\n\n/* =============================================================================\n * FIELD ELEMENT TYPE HELPERS\n * ============================================================================= */\n\n/**\n * Validates a `bigint` as a BN254 (alt_bn128) scalar field element and returns it\n * branded as `Bn254FieldElement`.\n *\n * @remarks\n * Delegates to `assertBn254FieldElement` from `../types`. The assertion verifies that\n * `value` is a `bigint` strictly less than the BN254 scalar field prime\n * (21888242871839275222246405745257275088548364400416034343698204186575808495617).\n *\n * `Bn254FieldElement` values are inputs to Groth16 ZK proof verification and Poseidon\n * hash computations performed on the BN254 curve. Passing an out-of-field value would\n * produce incorrect results in the verifier circuit, so this assertion is a critical\n * safety gate.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @param name - Optional variable name to include in the error message for easier debugging.\n * @returns The same `bigint` value, branded as {@link Bn254FieldElement}.\n * @throws `CryptographyAssertionError` if `value` is not a `bigint` or is >= the BN254 field prime.\n *\n * @example\n * ```typescript\n * import { asBn254FieldElement } from \"@umbra-privacy/sdk\";\n *\n * const publicInput = asBn254FieldElement(leafCommitment, \"leafCommitment\");\n * // publicInput can now be safely passed to a Poseidon hash or Groth16 verifier.\n *\n * // Throws for values outside the field:\n * asBn254FieldElement(BN254_FIELD_PRIME); // CryptographyAssertionError (not strictly less than)\n * ```\n *\n * @see {@link assertBn254FieldElement} for the underlying assertion.\n * @see {@link asCurve25519FieldElement} for the Curve25519 variant.\n * @see {@link asPoseidonKey} for Poseidon key validation.\n * @public\n */\nexport function asBn254FieldElement(value: bigint, name?: string): Bn254FieldElement {\n assertBn254FieldElement(value, name);\n return value;\n}\n\n/**\n * Validates a `bigint` as a Curve25519 scalar field element and returns it branded as\n * `Curve25519FieldElement`.\n *\n * @remarks\n * Delegates to `assertCurve25519FieldElement` from `../types`. The assertion verifies\n * that `value` is a `bigint` strictly less than the Curve25519 field prime (2^255 - 19).\n *\n * `Curve25519FieldElement` values are used for X25519 Diffie-Hellman key exchange,\n * which underpins the encrypted balance sharing system in Umbra. The X25519 private and\n * public keys are Curve25519 field elements. Passing an out-of-field scalar to a key\n * exchange function would produce incorrect shared secrets, so this assertion is a\n * safety requirement before any cryptographic operation.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @param name - Optional variable name to include in the error message for easier debugging.\n * @returns The same `bigint` value, branded as {@link Curve25519FieldElement}.\n * @throws `CryptographyAssertionError` if `value` is not a `bigint` or is >= `2^255 - 19`.\n *\n * @example\n * ```typescript\n * import { asCurve25519FieldElement } from \"@umbra-privacy/sdk\";\n *\n * const privKey = asCurve25519FieldElement(rawKey, \"x25519PrivateKey\");\n * // privKey is now safely typed for use in X25519 key exchange.\n * ```\n *\n * @see {@link assertCurve25519FieldElement} for the underlying assertion.\n * @see {@link asBn254FieldElement} for the BN254 variant.\n * @public\n */\nexport function asCurve25519FieldElement(value: bigint, name?: string): Curve25519FieldElement {\n assertCurve25519FieldElement(value, name);\n return value;\n}\n\n/**\n * Validates a `bigint` as a Poseidon hash key and returns it branded as `PoseidonKey`.\n *\n * @remarks\n * Delegates to `assertPoseidonKey` from `../types`. A `PoseidonKey` is a specialisation\n * of `Bn254FieldElement` used specifically as a key input to the Poseidon encryption\n * scheme. The assertion enforces the same field prime constraint as BN254.\n *\n * In the Umbra protocol, Poseidon keys are derived from the user's master seed and are\n * used to encrypt/decrypt on-chain token account balance ciphertexts. Treating Poseidon\n * keys as a distinct brand (rather than generic `Bn254FieldElement`) prevents them from\n * being accidentally used as public inputs to ZK proofs or vice versa.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @returns The same `bigint` value, branded as {@link PoseidonKey}.\n * @throws `CryptographyAssertionError` if `value` is not a valid BN254 field element.\n *\n * @example\n * ```typescript\n * import { asPoseidonKey } from \"@umbra-privacy/sdk\";\n *\n * const key = asPoseidonKey(derivedKeyBigint);\n * // key can now be safely passed to the Poseidon encryptor.\n * ```\n *\n * @see {@link assertPoseidonKey} for the underlying assertion.\n * @see {@link asBn254FieldElement} for the parent field element helper.\n * @public\n */\nexport function asPoseidonKey(value: bigint): PoseidonKey {\n assertPoseidonKey(value);\n return value;\n}\n\n/* =============================================================================\n * RESCUE CIPHER TYPE HELPERS\n * ============================================================================= */\n\n/**\n * Validates a `bigint` as a Rescue Cipher plaintext and returns it branded as `RcPlaintext`.\n *\n * @remarks\n * Delegates to `assertRcPlaintext` from `../types`. The Rescue Cipher is an algebraic\n * cipher used in the Arcium MPC network to encrypt token account balances. A plaintext\n * is a field element (BN254 scalar) representing an unencrypted balance or intermediate\n * value.\n *\n * Branding plaintexts separately from ciphertexts and keys prevents the common\n * mistake of accidentally passing an encrypted value where a plain one is expected,\n * which would silently corrupt balance computations.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @param name - Optional variable name to include in the error message for easier debugging.\n * @returns The same `bigint` value, branded as {@link RcPlaintext}.\n * @throws `CryptographyAssertionError` if `value` is not a valid Rescue Cipher plaintext.\n *\n * @example\n * ```typescript\n * import { asRcPlaintext } from \"@umbra-privacy/sdk\";\n *\n * const balance = asRcPlaintext(rawBalance, \"mxeBalance\");\n * // balance is now correctly typed for the Rescue Cipher encrypt call.\n * ```\n *\n * @see {@link assertRcPlaintext} for the underlying assertion.\n * @see {@link asRcCiphertext} for the ciphertext variant.\n * @see {@link asRcKey} for the key variant.\n * @public\n */\nexport function asRcPlaintext(value: bigint, name?: string): RcPlaintext {\n assertRcPlaintext(value, name);\n return value;\n}\n\n/**\n * Validates a `bigint` as a Rescue Cipher ciphertext and returns it branded as\n * `RcCiphertext`.\n *\n * @remarks\n * Delegates to `assertRcCiphertext` from `../types`. A Rescue Cipher ciphertext is the\n * encrypted output of the Rescue Cipher applied to an `RcPlaintext`. It is a BN254 field\n * element stored in the on-chain `ArciumEncryptedTokenAccount` structure.\n *\n * Keeping ciphertexts distinctly branded from plaintexts ensures that encrypted values\n * cannot be inadvertently passed to functions that expect plaintext, or vice versa.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @param name - Optional variable name to include in the error message for easier debugging.\n * @returns The same `bigint` value, branded as {@link RcCiphertext}.\n * @throws `CryptographyAssertionError` if `value` is not a valid Rescue Cipher ciphertext.\n *\n * @example\n * ```typescript\n * import { asRcCiphertext } from \"@umbra-privacy/sdk\";\n *\n * const ct = asRcCiphertext(rawCiphertext, \"encryptedBalance\");\n * // ct is now correctly typed for the Rescue Cipher decrypt call.\n * ```\n *\n * @see {@link assertRcCiphertext} for the underlying assertion.\n * @see {@link asRcPlaintext} for the plaintext variant.\n * @see {@link asRcEncryptionNonce} for the nonce variant.\n * @public\n */\nexport function asRcCiphertext(value: bigint, name?: string): RcCiphertext {\n assertRcCiphertext(value, name);\n return value;\n}\n\n/**\n * Validates a `bigint` as a Rescue Cipher encryption key and returns it branded as\n * `RcKey`.\n *\n * @remarks\n * Delegates to `assertRcKey` from `../types`. A Rescue Cipher key is derived from the\n * user's Poseidon private key and the account's nonce, producing a session-scoped\n * encryption key that is used to encrypt/decrypt the balance stored in\n * `ArciumEncryptedTokenAccount`.\n *\n * Branding the key separately from other field elements prevents it from being\n * accidentally used as a Poseidon hash input or a ZK proof public signal.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @param name - Optional variable name to include in the error message for easier debugging.\n * @returns The same `bigint` value, branded as {@link RcKey}.\n * @throws `CryptographyAssertionError` if `value` is not a valid Rescue Cipher key.\n *\n * @example\n * ```typescript\n * import { asRcKey } from \"@umbra-privacy/sdk\";\n *\n * const sessionKey = asRcKey(derivedKey, \"rcKey\");\n * // sessionKey can now be safely passed to the Rescue Cipher.\n * ```\n *\n * @see {@link assertRcKey} for the underlying assertion.\n * @see {@link asRcPlaintext} for the plaintext variant.\n * @see {@link asRcCiphertext} for the ciphertext variant.\n * @public\n */\nexport function asRcKey(value: bigint, name?: string): RcKey {\n assertRcKey(value, name);\n return value;\n}\n\n/**\n * Validates a `bigint` as a Rescue Cipher encryption nonce and returns it branded as\n * `RcEncryptionNonce`.\n *\n * @remarks\n * Delegates to `assertRcEncryptionNonce` from `../types`. The Rescue Cipher nonce (also\n * referred to as the counter) is a per-account, monotonically-increasing value used to\n * ensure that every encryption operation produces a distinct ciphertext, even if the\n * plaintext is identical. It is derived from the `generationIndex` stored in the user's\n * `EncryptedUserAccount`.\n *\n * Branding the nonce separately from plaintext, ciphertext, and key values prevents the\n * highly dangerous mistake of passing the nonce as the key or vice versa, which would\n * silently break the encryption scheme.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @param name - Optional variable name to include in the error message for easier debugging.\n * @returns The same `bigint` value, branded as {@link RcEncryptionNonce}.\n * @throws `CryptographyAssertionError` if `value` is not a valid `RcEncryptionNonce`.\n *\n * @example\n * ```typescript\n * import { asRcEncryptionNonce } from \"@umbra-privacy/sdk\";\n *\n * const nonce = asRcEncryptionNonce(generationIndex, \"encryptionNonce\");\n * // nonce is now correctly typed for the Rescue Cipher nonce parameter.\n * ```\n *\n * @see {@link assertRcEncryptionNonce} for the underlying assertion.\n * @see {@link asRcKey} for the key variant.\n * @see {@link EncryptedUserAccount.generationIndex} for the source of nonce values.\n * @public\n */\nexport function asRcEncryptionNonce(value: bigint, name?: string): RcEncryptionNonce {\n assertRcEncryptionNonce(value, name);\n return value;\n}\n\n/* =============================================================================\n * LIMB TYPE HELPERS\n * ============================================================================= */\n\n/**\n * Validates a `bigint` as a Base85 limb and returns it branded as `Base85Limb`.\n *\n * @remarks\n * Delegates to `assertBase85Limb` from `../types`. A Base85 limb is a non-negative\n * `bigint` that is strictly less than 2^85. The SDK decomposes 256-bit values into\n * three 85-bit limbs for efficient arithmetic in elliptic curve operations and ZK\n * circuit inputs, where 85-bit decomposition fits neatly within the BN254 scalar field.\n *\n * A `Base85Limb` must satisfy `0 <= value < 2^85`. Values that exceed this bound would\n * overflow the limb arithmetic and silently corrupt multi-precision computations.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @param name - Optional variable name to include in the error message for easier debugging.\n * @returns The same `bigint` value, branded as {@link Base85Limb}.\n * @throws `MathematicsAssertionError` if `value` is not a `bigint` or is >= `2^85`.\n *\n * @example\n * ```typescript\n * import { asBase85Limb } from \"@umbra-privacy/sdk\";\n *\n * const limb0 = asBase85Limb(value & ((1n << 85n) - 1n), \"limb0\");\n * const limb1 = asBase85Limb((value >> 85n) & ((1n << 85n) - 1n), \"limb1\");\n * const limb2 = asBase85Limb(value >> 170n, \"limb2\");\n * // All three limbs are now correctly typed as Base85Limb.\n * ```\n *\n * @see {@link assertBase85Limb} for the underlying assertion.\n * @public\n */\nexport function asBase85Limb(value: bigint, name?: string): Base85Limb {\n assertBase85Limb(value, name);\n return value;\n}\n\n/* =============================================================================\n * ARRAY INDEXING HELPERS\n * ============================================================================= */\n\n/**\n * Safely retrieves a single byte from a `Uint8Array` at the specified index.\n *\n * @remarks\n * TypeScript does not narrow the return type of `Uint8Array[index]` to `number` —\n * it remains `number | undefined`. In practice many SDK functions need to iterate over\n * raw byte arrays (e.g. when converting little-endian bytes to `bigint`) and calling\n * `getByteAt` instead of a direct index access provides two benefits:\n *\n * 1. **Bounds checking** — throws an explicit, descriptive `Error` rather than silently\n * returning `undefined`, which would cause a `NaN` in arithmetic or a confusing\n * downstream assertion failure.\n * 2. **Type narrowing** — the return type is `number` (not `number | undefined`), so\n * callers receive a type-safe value without needing a non-null assertion (`!`).\n *\n * This helper is used extensively in byte-to-`bigint` conversion loops throughout the\n * SDK, such as in `query-encrypted-balance.ts` and `math-utils.ts`.\n *\n * @param bytes - The source `Uint8Array` to read from.\n * @param index - Zero-based byte index to read. Must satisfy `0 <= index < bytes.length`.\n * @param name - Optional label for the array, used in the error message.\n * @defaultValue `name` — `\"array\"`\n * @returns The numeric byte value (0–255) at `bytes[index]`.\n * @throws `Error` if `index < 0`, `index >= bytes.length`, or `bytes[index]` is `undefined`.\n *\n * @example\n * ```typescript\n * import { getByteAt } from \"@umbra-privacy/sdk\";\n *\n * const bytes = new Uint8Array([0x01, 0x02, 0x03]);\n *\n * // Safe indexed access:\n * const first = getByteAt(bytes, 0, \"myArray\"); // 1\n *\n * // Bounds-checked — throws rather than returning undefined:\n * getByteAt(bytes, 5, \"myArray\");\n * // Error: myArray: Index 5 out of bounds for Uint8Array of length 3\n * ```\n *\n * @example\n * ```typescript\n * // Typical usage in a little-endian bytes → bigint conversion:\n * function bytesToBigIntLe(bytes: Uint8Array): bigint {\n * let result = 0n;\n * for (let i = bytes.length - 1; i >= 0; i--) {\n * const byte = getByteAt(bytes, i, \"leBytes\");\n * result = (result << 8n) | BigInt(byte);\n * }\n * return result;\n * }\n * ```\n *\n * @public\n */\nexport function getByteAt(bytes: Uint8Array, index: number, name = \"array\"): number {\n if (index < 0 || index >= bytes.length) {\n throw new Error(\n `${name}: Index ${String(index)} out of bounds for Uint8Array of length ${String(bytes.length)}`,\n );\n }\n const byte = bytes[index];\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (byte === undefined) {\n throw new Error(\n `${name}: Byte at index ${String(index)} is undefined (array length: ${String(bytes.length)})`,\n );\n }\n return byte;\n}\n"]}