@umbra-privacy/sdk 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -25
- package/dist/{addresses-Brzgurv_.d.ts → addresses-B7HybtbJ.d.ts} +2 -1
- package/dist/{addresses-D_0YAS6B.d.cts → addresses-CTVY1oi7.d.cts} +2 -1
- package/dist/arcium-BXXlryfe.d.cts +20 -0
- package/dist/arcium-BXXlryfe.d.ts +20 -0
- package/dist/chunk-3LS5P32X.cjs +10892 -0
- package/dist/chunk-3LS5P32X.cjs.map +1 -0
- package/dist/chunk-4RHXVBNI.js +203 -0
- package/dist/chunk-4RHXVBNI.js.map +1 -0
- package/dist/chunk-4TZVXB5G.js +324 -0
- package/dist/chunk-4TZVXB5G.js.map +1 -0
- package/dist/chunk-5GUSMQ74.cjs +549 -0
- package/dist/chunk-5GUSMQ74.cjs.map +1 -0
- package/dist/chunk-5KPQXPQM.js +36 -0
- package/dist/chunk-5KPQXPQM.js.map +1 -0
- package/dist/chunk-AXD7LXYY.cjs +405 -0
- package/dist/chunk-AXD7LXYY.cjs.map +1 -0
- package/dist/{chunk-HOEXDXRC.cjs → chunk-BL6WXLPV.cjs} +32 -360
- package/dist/chunk-BL6WXLPV.cjs.map +1 -0
- package/dist/chunk-CFFLOE7D.cjs +598 -0
- package/dist/chunk-CFFLOE7D.cjs.map +1 -0
- package/dist/{chunk-BM7N6N7E.js → chunk-CFTW5WNG.js} +3 -325
- package/dist/chunk-CFTW5WNG.js.map +1 -0
- package/dist/chunk-DD2WCK4C.js +327 -0
- package/dist/chunk-DD2WCK4C.js.map +1 -0
- package/dist/chunk-DMPMQ74B.cjs +246 -0
- package/dist/chunk-DMPMQ74B.cjs.map +1 -0
- package/dist/{chunk-2Q75CQQJ.js → chunk-EEKF4553.js} +2 -2
- package/dist/chunk-EEKF4553.js.map +1 -0
- package/dist/chunk-ENVYYEM4.cjs +113 -0
- package/dist/chunk-ENVYYEM4.cjs.map +1 -0
- package/dist/chunk-FQX6ZYGJ.js +500 -0
- package/dist/chunk-FQX6ZYGJ.js.map +1 -0
- package/dist/chunk-FSK2ICMB.cjs +39 -0
- package/dist/chunk-FSK2ICMB.cjs.map +1 -0
- package/dist/chunk-FZYWLQAF.cjs +355 -0
- package/dist/chunk-FZYWLQAF.cjs.map +1 -0
- package/dist/chunk-GP26R377.js +436 -0
- package/dist/chunk-GP26R377.js.map +1 -0
- package/dist/chunk-HA5FLM63.js +393 -0
- package/dist/chunk-HA5FLM63.js.map +1 -0
- package/dist/chunk-INJ73LXQ.js +1107 -0
- package/dist/chunk-INJ73LXQ.js.map +1 -0
- package/dist/chunk-KMRROOME.js +10750 -0
- package/dist/chunk-KMRROOME.js.map +1 -0
- package/dist/{chunk-MDFSBU5W.cjs → chunk-LTCKPTZC.cjs} +2 -351
- package/dist/chunk-LTCKPTZC.cjs.map +1 -0
- package/dist/chunk-MKNCBUFA.js +564 -0
- package/dist/chunk-MKNCBUFA.js.map +1 -0
- package/dist/chunk-NKVMSABR.cjs +207 -0
- package/dist/chunk-NKVMSABR.cjs.map +1 -0
- package/dist/chunk-OFDWNWCL.js +70 -0
- package/dist/chunk-OFDWNWCL.js.map +1 -0
- package/dist/chunk-QJAUUYZU.cjs +331 -0
- package/dist/chunk-QJAUUYZU.cjs.map +1 -0
- package/dist/chunk-TLR7A64G.js +103 -0
- package/dist/chunk-TLR7A64G.js.map +1 -0
- package/dist/{chunk-MVKTV3FT.cjs → chunk-TQQZGNOI.cjs} +2 -2
- package/dist/chunk-TQQZGNOI.cjs.map +1 -0
- package/dist/chunk-UOFYS6M3.js +219 -0
- package/dist/chunk-UOFYS6M3.js.map +1 -0
- package/dist/chunk-UXMQI6B7.js +2406 -0
- package/dist/chunk-UXMQI6B7.js.map +1 -0
- package/dist/chunk-WN75ORDT.js +571 -0
- package/dist/chunk-WN75ORDT.js.map +1 -0
- package/dist/chunk-Y55PYKXH.cjs +595 -0
- package/dist/chunk-Y55PYKXH.cjs.map +1 -0
- package/dist/chunk-YEZBTYCP.cjs +77 -0
- package/dist/chunk-YEZBTYCP.cjs.map +1 -0
- package/dist/chunk-ZQOIYCGA.cjs +1126 -0
- package/dist/chunk-ZQOIYCGA.cjs.map +1 -0
- package/dist/chunk-ZY3TSHMJ.cjs +2665 -0
- package/dist/chunk-ZY3TSHMJ.cjs.map +1 -0
- package/dist/client-DkVBHMWb.d.cts +2613 -0
- package/dist/client-V4AF6Bz9.d.ts +2613 -0
- package/dist/common/pda/index.cjs +145 -0
- package/dist/common/pda/index.cjs.map +1 -0
- package/dist/common/pda/index.d.cts +1250 -0
- package/dist/common/pda/index.d.ts +1250 -0
- package/dist/common/pda/index.js +8 -0
- package/dist/common/pda/index.js.map +1 -0
- package/dist/constants/index.cjs +38 -164
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +8 -425
- package/dist/constants/index.d.ts +8 -425
- package/dist/constants/index.js +15 -124
- package/dist/constants/index.js.map +1 -1
- package/dist/crypto/index.cjs +583 -0
- package/dist/crypto/index.cjs.map +1 -0
- package/dist/crypto/index.d.cts +6731 -0
- package/dist/crypto/index.d.ts +6731 -0
- package/dist/crypto/index.js +14 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/{cryptography-BTGC72u-.d.ts → cryptography-BFSJcvi6.d.ts} +3 -2465
- package/dist/{cryptography-BTGC72u-.d.cts → cryptography-D6tPDh-Y.d.cts} +3 -2465
- package/dist/errors/index.cjs +64 -54
- package/dist/errors/index.d.cts +7 -797
- package/dist/errors/index.d.ts +7 -797
- package/dist/errors/index.js +3 -1
- package/dist/errors-B9EoPeWV.d.cts +593 -0
- package/dist/errors-B9EoPeWV.d.ts +593 -0
- package/dist/errors-DAIrstEL.d.cts +300 -0
- package/dist/errors-DPNMfyh0.d.ts +300 -0
- package/dist/index-BG0yjL7C.d.cts +6006 -0
- package/dist/index-ByynoyBO.d.ts +6006 -0
- package/dist/index.cjs +5133 -16116
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1031 -7685
- package/dist/index.d.ts +1031 -7685
- package/dist/index.js +3228 -14905
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.cts +14 -6
- package/dist/interfaces/index.d.ts +14 -6
- package/dist/interfaces-43cReBcS.d.cts +3346 -0
- package/dist/interfaces-B8xKNl_6.d.ts +997 -0
- package/dist/interfaces-D2NO6kDD.d.cts +997 -0
- package/dist/interfaces-z_xYJlgV.d.ts +3346 -0
- package/dist/math/index.cjs +115 -0
- package/dist/math/index.cjs.map +1 -0
- package/dist/math/index.d.cts +1327 -0
- package/dist/math/index.d.ts +1327 -0
- package/dist/math/index.js +10 -0
- package/dist/math/index.js.map +1 -0
- package/dist/networks-RMd3abPE.d.ts +44 -0
- package/dist/networks-yAoO8peQ.d.cts +44 -0
- package/dist/relayer-NRRMSMNB.js +4 -0
- package/dist/relayer-NRRMSMNB.js.map +1 -0
- package/dist/relayer-RJHEIXJG.cjs +21 -0
- package/dist/relayer-RJHEIXJG.cjs.map +1 -0
- package/dist/solana/index.cjs +56 -0
- package/dist/solana/index.cjs.map +1 -0
- package/dist/solana/index.d.cts +105 -0
- package/dist/solana/index.d.ts +105 -0
- package/dist/solana/index.js +7 -0
- package/dist/solana/index.js.map +1 -0
- package/dist/{index-CLj_zWSD.d.ts → temporal-BbRaEPoO.d.ts} +1 -1
- package/dist/{index-CX6_pIRS.d.cts → temporal-oUj7iCaq.d.cts} +1 -1
- package/dist/transaction-forwarder-5mAMTjw6.d.ts +1155 -0
- package/dist/transaction-forwarder-C6gMUG7a.d.cts +1155 -0
- package/dist/types/index.cjs +232 -231
- package/dist/types/index.d.cts +15 -1485
- package/dist/types/index.d.ts +15 -1485
- package/dist/types/index.js +2 -1
- package/dist/types-BohhvPth.d.cts +87 -0
- package/dist/types-CW0oTT0j.d.ts +87 -0
- package/dist/types-C_V_CaKK.d.cts +2468 -0
- package/dist/types-C_V_CaKK.d.ts +2468 -0
- package/dist/types-Ca7frykr.d.ts +793 -0
- package/dist/types-CuKeoI19.d.cts +1296 -0
- package/dist/types-CxfTIpN9.d.ts +1052 -0
- package/dist/{types-n-sHFcgr.d.ts → types-D1jDUjfN.d.ts} +2 -2
- package/dist/types-DKEDUlH9.d.ts +1296 -0
- package/dist/types-EKuIfxTz.d.cts +1052 -0
- package/dist/{types-BBuELtY8.d.cts → types-IMGYmlv-.d.cts} +2 -2
- package/dist/types-PwNLi_2k.d.cts +793 -0
- package/dist/utils/index.cjs +823 -525
- package/dist/utils/index.d.cts +1711 -4021
- package/dist/utils/index.d.ts +1711 -4021
- package/dist/utils/index.js +9 -3
- package/dist/{versions-D9PqsEvj.d.cts → versions-BRlR36EA.d.cts} +1 -0
- package/dist/{versions-D9PqsEvj.d.ts → versions-BRlR36EA.d.ts} +1 -0
- package/package.json +79 -18
- package/dist/chunk-2Q75CQQJ.js.map +0 -1
- package/dist/chunk-BM7N6N7E.js.map +0 -1
- package/dist/chunk-GXKSUB2U.cjs +0 -4416
- package/dist/chunk-GXKSUB2U.cjs.map +0 -1
- package/dist/chunk-HOEXDXRC.cjs.map +0 -1
- package/dist/chunk-MDFSBU5W.cjs.map +0 -1
- package/dist/chunk-MQY7HDIA.js +0 -600
- package/dist/chunk-MQY7HDIA.js.map +0 -1
- package/dist/chunk-MVKTV3FT.cjs.map +0 -1
- package/dist/chunk-PG2J6V6Y.js +0 -4094
- package/dist/chunk-PG2J6V6Y.js.map +0 -1
- package/dist/chunk-VEGLTTYQ.cjs +0 -621
- package/dist/chunk-VEGLTTYQ.cjs.map +0 -1
- package/dist/chunk-WVHQ46DD.js +0 -758
- package/dist/chunk-WVHQ46DD.js.map +0 -1
- package/dist/index-B9pDY73x.d.ts +0 -12933
- package/dist/index-D33yo0qB.d.cts +0 -12933
- package/dist/networks-C-orpSFW.d.ts +0 -65
- package/dist/networks-FxYERGD1.d.cts +0 -65
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common/converters/cryptography.ts","../src/common/converters/unsigned-integers.ts","../src/common/converters/signed-integers.ts","../src/common/converters/sign-conversions.ts","../src/common/converters/number-conversions.ts","../src/common/math-utils.ts","../src/common/arcium.ts","../src/common/addresses.ts","../src/common/temporal/temporal.ts","../src/common/token/token.ts","../src/common/type-helpers.ts"],"names":["U128_MAX","address"],"mappings":";;;;;;;;;;AAiJO,SAAS,+BAA+B,KAAA,EAAgC;AAC7E,EAAA,UAAA,CAAW,KAAK,CAAA;AAChB,EAAA,IAAI,SAAS,iBAAA,EAAmB;AAC9B,IAAA,MAAM,IAAI,gBAAgB,CAAA,+BAAA,CAAA,EAAmC;AAAA,MAC3D,WAAA,EAAa,KAAA;AAAA,MACb,UAAA,EAAY,MAAA;AAAA,MACZ,UAAA,EAAY,mBAAA;AAAA,MACZ,MAAA,EAAQ,CAAA,gBAAA,EAAmB,MAAA,CAAO,iBAAiB,CAAC,CAAA;AAAA,KACrD,CAAA;AAAA,EACH;AACA,EAAA,uBAAA,CAAwB,KAAK,CAAA;AAC7B,EAAA,OAAO,KAAA;AACT;AAZgB,MAAA,CAAA,8BAAA,EAAA,gCAAA,CAAA;AAwCT,SAAS,+BAA+B,KAAA,EAAgC;AAC7E,EAAA,uBAAA,CAAwB,KAAK,CAAA;AAC7B,EAAA,UAAA,CAAW,KAAK,CAAA;AAChB,EAAA,OAAO,KAAA;AACT;AAJgB,MAAA,CAAA,8BAAA,EAAA,gCAAA,CAAA;AAoCT,SAAS,oCAAoC,KAAA,EAAqC;AACvF,EAAA,UAAA,CAAW,KAAK,CAAA;AAChB,EAAA,IAAI,SAAS,sBAAA,EAAwB;AACnC,IAAA,MAAM,IAAI,gBAAgB,CAAA,oCAAA,CAAA,EAAwC;AAAA,MAChE,WAAA,EAAa,KAAA;AAAA,MACb,UAAA,EAAY,MAAA;AAAA,MACZ,UAAA,EAAY,wBAAA;AAAA,MACZ,MAAA,EAAQ;AAAA,KACT,CAAA;AAAA,EACH;AACA,EAAA,4BAAA,CAA6B,KAAK,CAAA;AAClC,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7B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,0CAAA,EAA6C,OAAO,KAAK,CAAA,CAAE,CAAA;AAAA,EAC7E;AACA,EAAA,IAAI,QAAQ,EAAA,EAAI;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,qDAAA,EAAwD,MAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EACzF;AACA,EAAA,OAAO,KAAA;AACT;AARgB,MAAA,CAAA,yBAAA,EAAA,2BAAA,CAAA;AAoET,SAAS,SAAA,CAAU,KAAA,EAAmB,KAAA,EAAe,IAAA,GAAO,OAAA,EAAiB;AAClF,EAAA,IAAI,KAAA,GAAQ,CAAA,IAAK,KAAA,IAAS,KAAA,CAAM,MAAA,EAAQ;AACtC,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,EAAG,IAAI,CAAA,QAAA,EAAW,MAAA,CAAO,KAAK,CAAC,CAAA,wCAAA,EAA2C,MAAA,CAAO,KAAA,CAAM,MAAM,CAAC,CAAA;AAAA,KAChG;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;AAfgB,MAAA,CAAA,SAAA,EAAA,WAAA,CAAA","file":"chunk-UXMQI6B7.js","sourcesContent":["/**\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 type U128LeBytes,\n type U128BeBytes,\n type U256LeBytes,\n type U256BeBytes,\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 type MasterViewingKey,\n type YearlyViewingKey,\n type MonthlyViewingKey,\n type DailyViewingKey,\n type MintViewingKey,\n assertMasterViewingKey,\n assertYearlyViewingKey,\n assertMonthlyViewingKey,\n assertDailyViewingKey,\n assertMintViewingKey,\n} from \"../../types/cryptography\";\n\nimport { ConversionError } from \"./errors\";\nimport {\n encodeU256ToU256LeBytes,\n encodeU256ToU256BeBytes,\n decodeU256LeBytesToU256,\n decodeU256BeBytesToU256,\n encodeU128ToU128LeBytes,\n encodeU128ToU128BeBytes,\n decodeU128LeBytesToU128,\n decodeU128BeBytesToU128,\n} from \"./byte-encoding\";\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/* =============================================================================\n * FIELD ELEMENT ↔ BYTES DIRECT CONVERSIONS\n * ============================================================================= */\n\n/** Encodes a {@link Bn254FieldElement} to little-endian bytes. @since 2.0.0 @public */\nexport function encodeBn254FieldElementToLeBytes(value: Bn254FieldElement): U256LeBytes {\n return encodeU256ToU256LeBytes(convertBn254FieldElementToU256(value));\n}\n\n/** Encodes a {@link Bn254FieldElement} to big-endian bytes. @since 2.0.0 @public */\nexport function encodeBn254FieldElementToBeBytes(value: Bn254FieldElement): U256BeBytes {\n return encodeU256ToU256BeBytes(convertBn254FieldElementToU256(value));\n}\n\n/** Decodes little-endian bytes to a {@link Bn254FieldElement}. @since 2.0.0 @public */\nexport function decodeLeBytesToBn254FieldElement(bytes: U256LeBytes): Bn254FieldElement {\n return convertU256ToBn254FieldElement(decodeU256LeBytesToU256(bytes));\n}\n\n/** Decodes big-endian bytes to a {@link Bn254FieldElement}. @since 2.0.0 @public */\nexport function decodeBeBytesToBn254FieldElement(bytes: U256BeBytes): Bn254FieldElement {\n return convertU256ToBn254FieldElement(decodeU256BeBytesToU256(bytes));\n}\n\n/** Encodes a {@link Curve25519FieldElement} to little-endian bytes. @since 2.0.0 @public */\nexport function encodeCurve25519FieldElementToLeBytes(value: Curve25519FieldElement): U256LeBytes {\n return encodeU256ToU256LeBytes(convertCurve25519FieldElementToU256(value));\n}\n\n/** Encodes a {@link Curve25519FieldElement} to big-endian bytes. @since 2.0.0 @public */\nexport function encodeCurve25519FieldElementToBeBytes(value: Curve25519FieldElement): U256BeBytes {\n return encodeU256ToU256BeBytes(convertCurve25519FieldElementToU256(value));\n}\n\n/** Decodes little-endian bytes to a {@link Curve25519FieldElement}. @since 2.0.0 @public */\nexport function decodeLeBytesToCurve25519FieldElement(bytes: U256LeBytes): Curve25519FieldElement {\n return convertU256ToCurve25519FieldElement(decodeU256LeBytesToU256(bytes));\n}\n\n/** Decodes big-endian bytes to a {@link Curve25519FieldElement}. @since 2.0.0 @public */\nexport function decodeBeBytesToCurve25519FieldElement(bytes: U256BeBytes): Curve25519FieldElement {\n return convertU256ToCurve25519FieldElement(decodeU256BeBytesToU256(bytes));\n}\n\n/* =============================================================================\n * RC ENCRYPTION NONCE ↔ BYTES DIRECT CONVERSIONS\n * ============================================================================= */\n\n/** Encodes an {@link RcEncryptionNonce} to little-endian bytes. @since 2.0.0 @public */\nexport function encodeRcEncryptionNonceToLeBytes(value: RcEncryptionNonce): U128LeBytes {\n return encodeU128ToU128LeBytes(convertRcEncryptionNonceToU128(value));\n}\n\n/** Encodes an {@link RcEncryptionNonce} to big-endian bytes. @since 2.0.0 @public */\nexport function encodeRcEncryptionNonceToBeBytes(value: RcEncryptionNonce): U128BeBytes {\n return encodeU128ToU128BeBytes(convertRcEncryptionNonceToU128(value));\n}\n\n/** Decodes little-endian bytes to an {@link RcEncryptionNonce}. @since 2.0.0 @public */\nexport function decodeLeBytesToRcEncryptionNonce(bytes: U128LeBytes): RcEncryptionNonce {\n return convertU128ToRcEncryptionNonce(decodeU128LeBytesToU128(bytes));\n}\n\n/** Decodes big-endian bytes to an {@link RcEncryptionNonce}. @since 2.0.0 @public */\nexport function decodeBeBytesToRcEncryptionNonce(bytes: U128BeBytes): RcEncryptionNonce {\n return convertU128ToRcEncryptionNonce(decodeU128BeBytesToU128(bytes));\n}\n\n/* =============================================================================\n * POSEIDON / RESCUE ↔ U256 SHORTCUT CONVERSIONS\n * ============================================================================= */\n\n/** Converts a {@link PoseidonHash} directly to {@link U256}. @since 2.0.0 @public */\nexport function convertPoseidonHashToU256(value: PoseidonHash): U256 {\n return convertBn254FieldElementToU256(convertPoseidonHashToBn254FieldElement(value));\n}\n\n/** Converts a {@link U256} directly to {@link PoseidonHash}. @since 2.0.0 @public */\nexport function convertU256ToPoseidonHash(value: U256): PoseidonHash {\n return convertBn254FieldElementToPoseidonHash(convertU256ToBn254FieldElement(value));\n}\n\n/** Converts a {@link PoseidonPlaintext} directly to {@link U256}. @since 2.0.0 @public */\nexport function convertPoseidonPlaintextToU256(value: PoseidonPlaintext): U256 {\n return convertBn254FieldElementToU256(convertPoseidonPlaintextToBn254FieldElement(value));\n}\n\n/** Converts a {@link U256} directly to {@link PoseidonPlaintext}. @since 2.0.0 @public */\nexport function convertU256ToPoseidonPlaintext(value: U256): PoseidonPlaintext {\n return convertBn254FieldElementToPoseidonPlaintext(convertU256ToBn254FieldElement(value));\n}\n\n/** Converts a {@link PoseidonKey} directly to {@link U256}. @since 2.0.0 @public */\nexport function convertPoseidonKeyToU256(value: PoseidonKey): U256 {\n return convertBn254FieldElementToU256(convertPoseidonKeyToBn254FieldElement(value));\n}\n\n/** Converts a {@link U256} directly to {@link PoseidonKey}. @since 2.0.0 @public */\nexport function convertU256ToPoseidonKey(value: U256): PoseidonKey {\n return convertBn254FieldElementToPoseidonKey(convertU256ToBn254FieldElement(value));\n}\n\n/** Converts a {@link PoseidonCiphertext} directly to {@link U256}. @since 2.0.0 @public */\nexport function convertPoseidonCiphertextToU256(value: PoseidonCiphertext): U256 {\n return convertBn254FieldElementToU256(convertPoseidonCiphertextToBn254FieldElement(value));\n}\n\n/** Converts a {@link U256} directly to {@link PoseidonCiphertext}. @since 2.0.0 @public */\nexport function convertU256ToPoseidonCiphertext(value: U256): PoseidonCiphertext {\n return convertBn254FieldElementToPoseidonCiphertext(convertU256ToBn254FieldElement(value));\n}\n\n/** Converts an {@link RcPlaintext} directly to {@link U256}. @since 2.0.0 @public */\nexport function convertRcPlaintextToU256(value: RcPlaintext): U256 {\n return convertCurve25519FieldElementToU256(convertRcPlaintextToCurve25519FieldElement(value));\n}\n\n/** Converts a {@link U256} directly to {@link RcPlaintext}. @since 2.0.0 @public */\nexport function convertU256ToRcPlaintext(value: U256): RcPlaintext {\n return convertCurve25519FieldElementToRcPlaintext(convertU256ToCurve25519FieldElement(value));\n}\n\n/** Converts an {@link RcCiphertext} directly to {@link U256}. @since 2.0.0 @public */\nexport function convertRcCiphertextToU256(value: RcCiphertext): U256 {\n return convertCurve25519FieldElementToU256(convertRcCiphertextToCurve25519FieldElement(value));\n}\n\n/** Converts a {@link U256} directly to {@link RcCiphertext}. @since 2.0.0 @public */\nexport function convertU256ToRcCiphertext(value: U256): RcCiphertext {\n return convertCurve25519FieldElementToRcCiphertext(convertU256ToCurve25519FieldElement(value));\n}\n\n/** Converts an {@link RcKey} directly to {@link U256}. @since 2.0.0 @public */\nexport function convertRcKeyToU256(value: RcKey): U256 {\n return convertCurve25519FieldElementToU256(convertRcKeyToCurve25519FieldElement(value));\n}\n\n/** Converts a {@link U256} directly to {@link RcKey}. @since 2.0.0 @public */\nexport function convertU256ToRcKey(value: U256): RcKey {\n return convertCurve25519FieldElementToRcKey(convertU256ToCurve25519FieldElement(value));\n}\n\n/** Converts an {@link RcCounter} directly to {@link U256}. @since 2.0.0 @public */\nexport function convertRcCounterToU256(value: RcCounter): U256 {\n return convertCurve25519FieldElementToU256(convertRcCounterToCurve25519FieldElement(value));\n}\n\n/** Converts a {@link U256} directly to {@link RcCounter}. @since 2.0.0 @public */\nexport function convertU256ToRcCounter(value: U256): RcCounter {\n return convertCurve25519FieldElementToRcCounter(convertU256ToCurve25519FieldElement(value));\n}\n\n/* =============================================================================\n * VIEWING KEY CONSTRUCTORS FROM BN254 FIELD ELEMENT\n * ============================================================================= */\n\n/** Converts a {@link Bn254FieldElement} to a {@link MasterViewingKey}. @since 2.0.0 @public */\nexport function convertBn254FieldElementToMasterViewingKey(value: Bn254FieldElement): MasterViewingKey {\n assertBn254FieldElement(value);\n assertMasterViewingKey(value);\n return value;\n}\n\n/** Converts a {@link Bn254FieldElement} to a {@link YearlyViewingKey}. @since 2.0.0 @public */\nexport function convertBn254FieldElementToYearlyViewingKey(value: Bn254FieldElement): YearlyViewingKey {\n assertBn254FieldElement(value);\n assertYearlyViewingKey(value);\n return value;\n}\n\n/** Converts a {@link Bn254FieldElement} to a {@link MonthlyViewingKey}. @since 2.0.0 @public */\nexport function convertBn254FieldElementToMonthlyViewingKey(value: Bn254FieldElement): MonthlyViewingKey {\n assertBn254FieldElement(value);\n assertMonthlyViewingKey(value);\n return value;\n}\n\n/** Converts a {@link Bn254FieldElement} to a {@link DailyViewingKey}. @since 2.0.0 @public */\nexport function convertBn254FieldElementToDailyViewingKey(value: Bn254FieldElement): DailyViewingKey {\n assertBn254FieldElement(value);\n assertDailyViewingKey(value);\n return value;\n}\n\n/** Converts a {@link Bn254FieldElement} to a {@link MintViewingKey}. @since 2.0.0 @public */\nexport function convertBn254FieldElementToMintViewingKey(value: Bn254FieldElement): MintViewingKey {\n assertBn254FieldElement(value);\n assertMintViewingKey(value);\n return value;\n}\n","/**\n * Unsigned Integer Conversions\n *\n * Widening (always safe) and narrowing (range-checked) conversions between\n * unsigned branded integer types U8 through U1024.\n *\n * @module common/converters/unsigned-integers\n * @since 2.0.0\n */\n\nimport {\n type U8, type U16, type U32, type U64, type U128, type U256, type U512, type U1024,\n U8_MAX, U16_MAX, U32_MAX, U64_MAX, U128_MAX, U256_MAX, U512_MAX,\n assertU8, assertU16, assertU32, assertU64, assertU128, assertU256, assertU512, assertU1024,\n} from \"../types\";\n\nimport { ConversionError } from \"./errors\";\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 Conversions\n *\n * Widening (always safe) and narrowing (range-checked) conversions between\n * signed branded integer types I8 through I1024.\n *\n * @module common/converters/signed-integers\n * @since 2.0.0\n */\n\nimport {\n type I8, type I16, type I32, type I64, type I128, type I256, type I512, type I1024,\n I8_MIN, I8_MAX, I16_MIN, I16_MAX, I32_MIN, I32_MAX, I64_MIN, I64_MAX,\n I128_MIN, I128_MAX, I256_MIN, I256_MAX, I512_MIN, I512_MAX, I1024_MAX,\n assertI8, assertI16, assertI32, assertI64, assertI128, assertI256, assertI512, assertI1024,\n} from \"../types\";\n\nimport { ConversionError } from \"./errors\";\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/* =============================================================================\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 * Sign Conversions\n *\n * Conversions between signed (I{N}) and unsigned (U{N}) branded integers\n * of the same width. Validates that values are representable in the target sign.\n *\n * @module common/converters/sign-conversions\n * @since 2.0.0\n */\n\nimport {\n type U8, type U16, type U32, type U64, type U128, type U256, type U512, type U1024,\n type I8, type I16, type I32, type I64, type I128, type I256, type I512, type I1024,\n U8_MAX, U16_MAX, U32_MAX, U64_MAX, U128_MAX, U256_MAX, U512_MAX,\n I8_MAX, I16_MAX, I32_MAX, I64_MAX, I128_MAX, I256_MAX, I512_MAX, I1024_MAX,\n assertU8, assertU16, assertU32, assertU64, assertU128, assertU256, assertU512, assertU1024,\n assertI8, assertI16, assertI32, assertI64, assertI128, assertI256, assertI512, assertI1024,\n} from \"../types\";\n\nimport { ConversionError } from \"./errors\";\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/* =============================================================================\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 * Number ↔ Branded Integer Conversions\n *\n * Provides bidirectional conversions between JavaScript `number` (IEEE 754\n * double-precision, safe integer range ≤ 2^53-1) and the SDK's branded integer\n * types (U8–U1024, I8–I1024).\n *\n * ## Safety\n *\n * - **number → U{N}**: Validates that the input is a non-negative safe integer\n * within the target type's range.\n * - **U{N} → number**: Validates that the branded bigint value fits within\n * `Number.MAX_SAFE_INTEGER` (2^53-1). Throws if precision would be lost.\n * - **number → I{N}**: Validates that the input is a safe integer within the\n * target signed range.\n * - **I{N} → number**: Validates that the branded bigint value fits within\n * `Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`.\n *\n * @module common/converters/number-conversions\n * @since 2.0.0\n */\n\nimport {\n type U8, type U16, type U32, type U64, type U128, type U256, type U512, type U1024,\n type I8, type I16, type I32, type I64, type I128, type I256, type I512, type I1024,\n U8_MAX, U16_MAX, U32_MAX, U64_MAX, U128_MAX, U256_MAX,\n I8_MIN, I8_MAX, I16_MIN, I16_MAX, I32_MIN, I32_MAX, I64_MIN, I64_MAX,\n assertU8, assertU16, assertU32, assertU64, assertU128, assertU256, assertU512, assertU1024,\n assertI8, assertI16, assertI32, assertI64, assertI128, assertI256, assertI512, assertI1024,\n} from \"../types\";\n\nimport { ConversionError, assertNumberInRange } from \"./errors\";\n\nconst MAX_SAFE = Number.MAX_SAFE_INTEGER;\nconst MIN_SAFE = Number.MIN_SAFE_INTEGER;\nconst MAX_SAFE_BIGINT = BigInt(MAX_SAFE);\nconst MIN_SAFE_BIGINT = BigInt(MIN_SAFE);\n\n/* =============================================================================\n * number → UNSIGNED\n * ============================================================================= */\n\n/**\n * Converts a JavaScript `number` to a {@link U8}.\n *\n * @param value - A non-negative safe integer in range [0, 255].\n * @returns The value branded as {@link U8}.\n * @throws {ConversionError} If not a safe integer or out of range.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToU8(value: number): U8 {\n assertNumberInRange(value, 0, Number(U8_MAX), \"U8\");\n const result = BigInt(value);\n assertU8(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to a {@link U16}.\n *\n * @param value - A non-negative safe integer in range [0, 65535].\n * @returns The value branded as {@link U16}.\n * @throws {ConversionError} If not a safe integer or out of range.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToU16(value: number): U16 {\n assertNumberInRange(value, 0, Number(U16_MAX), \"U16\");\n const result = BigInt(value);\n assertU16(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to a {@link U32}.\n *\n * @param value - A non-negative safe integer in range [0, 4294967295].\n * @returns The value branded as {@link U32}.\n * @throws {ConversionError} If not a safe integer or out of range.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToU32(value: number): U32 {\n assertNumberInRange(value, 0, Number(U32_MAX), \"U32\");\n const result = BigInt(value);\n assertU32(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to a {@link U64}.\n *\n * @remarks\n * The input must be a safe integer (≤ 2^53-1). For values larger than\n * `Number.MAX_SAFE_INTEGER`, construct a `U64` directly from a `bigint` literal.\n *\n * @param value - A non-negative safe integer.\n * @returns The value branded as {@link U64}.\n * @throws {ConversionError} If not a safe integer or negative.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToU64(value: number): U64 {\n assertNumberInRange(value, 0, MAX_SAFE, \"U64\");\n const result = BigInt(value);\n assertU64(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to a {@link U128}.\n *\n * @param value - A non-negative safe integer.\n * @returns The value branded as {@link U128}.\n * @throws {ConversionError} If not a safe integer or negative.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToU128(value: number): U128 {\n assertNumberInRange(value, 0, MAX_SAFE, \"U128\");\n const result = BigInt(value);\n assertU128(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to a {@link U256}.\n *\n * @param value - A non-negative safe integer.\n * @returns The value branded as {@link U256}.\n * @throws {ConversionError} If not a safe integer or negative.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToU256(value: number): U256 {\n assertNumberInRange(value, 0, MAX_SAFE, \"U256\");\n const result = BigInt(value);\n assertU256(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to a {@link U512}.\n *\n * @param value - A non-negative safe integer.\n * @returns The value branded as {@link U512}.\n * @throws {ConversionError} If not a safe integer or negative.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToU512(value: number): U512 {\n assertNumberInRange(value, 0, MAX_SAFE, \"U512\");\n const result = BigInt(value);\n assertU512(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to a {@link U1024}.\n *\n * @param value - A non-negative safe integer.\n * @returns The value branded as {@link U1024}.\n * @throws {ConversionError} If not a safe integer or negative.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToU1024(value: number): U1024 {\n assertNumberInRange(value, 0, MAX_SAFE, \"U1024\");\n const result = BigInt(value);\n assertU1024(result);\n return result;\n}\n\n/* =============================================================================\n * UNSIGNED → number\n * ============================================================================= */\n\n/**\n * Converts a {@link U8} to a JavaScript `number`. Always safe (max 255).\n *\n * @param value - The branded U8 value.\n * @returns The numeric value.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertU8ToNumber(value: U8): number {\n return Number(value);\n}\n\n/**\n * Converts a {@link U16} to a JavaScript `number`. Always safe (max 65535).\n *\n * @param value - The branded U16 value.\n * @returns The numeric value.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertU16ToNumber(value: U16): number {\n return Number(value);\n}\n\n/**\n * Converts a {@link U32} to a JavaScript `number`. Always safe (max ~4.3 billion).\n *\n * @param value - The branded U32 value.\n * @returns The numeric value.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertU32ToNumber(value: U32): number {\n return Number(value);\n}\n\n/**\n * Converts a {@link U64} to a JavaScript `number`.\n *\n * @remarks\n * Throws if the value exceeds `Number.MAX_SAFE_INTEGER` (2^53-1), since\n * JavaScript `number` cannot represent larger integers without precision loss.\n *\n * @param value - The branded U64 value.\n * @returns The numeric value.\n * @throws {ConversionError} If value > `Number.MAX_SAFE_INTEGER`.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertU64ToNumber(value: U64): number {\n if ((value as bigint) > MAX_SAFE_BIGINT) {\n throw new ConversionError(\n `U64 value ${String(value)} exceeds Number.MAX_SAFE_INTEGER`,\n { sourceValue: value, sourceType: \"U64\", targetType: \"number\", reason: \"Value exceeds 2^53-1\" },\n );\n }\n return Number(value);\n}\n\n/**\n * Converts a {@link U128} to a JavaScript `number`.\n *\n * @param value - The branded U128 value.\n * @returns The numeric value.\n * @throws {ConversionError} If value > `Number.MAX_SAFE_INTEGER`.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertU128ToNumber(value: U128): number {\n if ((value as bigint) > MAX_SAFE_BIGINT) {\n throw new ConversionError(\n `U128 value ${String(value)} exceeds Number.MAX_SAFE_INTEGER`,\n { sourceValue: value, sourceType: \"U128\", targetType: \"number\", reason: \"Value exceeds 2^53-1\" },\n );\n }\n return Number(value);\n}\n\n/**\n * Converts a {@link U256} to a JavaScript `number`.\n *\n * @param value - The branded U256 value.\n * @returns The numeric value.\n * @throws {ConversionError} If value > `Number.MAX_SAFE_INTEGER`.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertU256ToNumber(value: U256): number {\n if ((value as bigint) > MAX_SAFE_BIGINT) {\n throw new ConversionError(\n `U256 value ${String(value)} exceeds Number.MAX_SAFE_INTEGER`,\n { sourceValue: value, sourceType: \"U256\", targetType: \"number\", reason: \"Value exceeds 2^53-1\" },\n );\n }\n return Number(value);\n}\n\n/**\n * Converts a {@link U512} to a JavaScript `number`.\n *\n * @param value - The branded U512 value.\n * @returns The numeric value.\n * @throws {ConversionError} If value > `Number.MAX_SAFE_INTEGER`.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertU512ToNumber(value: U512): number {\n if ((value as bigint) > MAX_SAFE_BIGINT) {\n throw new ConversionError(\n `U512 value ${String(value)} exceeds Number.MAX_SAFE_INTEGER`,\n { sourceValue: value, sourceType: \"U512\", targetType: \"number\", reason: \"Value exceeds 2^53-1\" },\n );\n }\n return Number(value);\n}\n\n/**\n * Converts a {@link U1024} to a JavaScript `number`.\n *\n * @param value - The branded U1024 value.\n * @returns The numeric value.\n * @throws {ConversionError} If value > `Number.MAX_SAFE_INTEGER`.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertU1024ToNumber(value: U1024): number {\n if ((value as bigint) > MAX_SAFE_BIGINT) {\n throw new ConversionError(\n `U1024 value ${String(value)} exceeds Number.MAX_SAFE_INTEGER`,\n { sourceValue: value, sourceType: \"U1024\", targetType: \"number\", reason: \"Value exceeds 2^53-1\" },\n );\n }\n return Number(value);\n}\n\n/* =============================================================================\n * number → SIGNED\n * ============================================================================= */\n\n/**\n * Converts a JavaScript `number` to an {@link I8}.\n *\n * @param value - A safe integer in range [-128, 127].\n * @returns The value branded as {@link I8}.\n * @throws {ConversionError} If not a safe integer or out of range.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToI8(value: number): I8 {\n assertNumberInRange(value, Number(I8_MIN), Number(I8_MAX), \"I8\");\n const result = BigInt(value);\n assertI8(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to an {@link I16}.\n *\n * @param value - A safe integer in range [-32768, 32767].\n * @returns The value branded as {@link I16}.\n * @throws {ConversionError} If not a safe integer or out of range.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToI16(value: number): I16 {\n assertNumberInRange(value, Number(I16_MIN), Number(I16_MAX), \"I16\");\n const result = BigInt(value);\n assertI16(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to an {@link I32}.\n *\n * @param value - A safe integer in range [-2147483648, 2147483647].\n * @returns The value branded as {@link I32}.\n * @throws {ConversionError} If not a safe integer or out of range.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToI32(value: number): I32 {\n assertNumberInRange(value, Number(I32_MIN), Number(I32_MAX), \"I32\");\n const result = BigInt(value);\n assertI32(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to an {@link I64}.\n *\n * @remarks\n * The safe integer range [-(2^53-1), 2^53-1] is a subset of I64's range.\n *\n * @param value - A safe integer.\n * @returns The value branded as {@link I64}.\n * @throws {ConversionError} If not a safe integer.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToI64(value: number): I64 {\n assertNumberInRange(value, MIN_SAFE, MAX_SAFE, \"I64\");\n const result = BigInt(value);\n assertI64(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to an {@link I128}.\n *\n * @param value - A safe integer.\n * @returns The value branded as {@link I128}.\n * @throws {ConversionError} If not a safe integer.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToI128(value: number): I128 {\n assertNumberInRange(value, MIN_SAFE, MAX_SAFE, \"I128\");\n const result = BigInt(value);\n assertI128(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to an {@link I256}.\n *\n * @param value - A safe integer.\n * @returns The value branded as {@link I256}.\n * @throws {ConversionError} If not a safe integer.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToI256(value: number): I256 {\n assertNumberInRange(value, MIN_SAFE, MAX_SAFE, \"I256\");\n const result = BigInt(value);\n assertI256(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to an {@link I512}.\n *\n * @param value - A safe integer.\n * @returns The value branded as {@link I512}.\n * @throws {ConversionError} If not a safe integer.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToI512(value: number): I512 {\n assertNumberInRange(value, MIN_SAFE, MAX_SAFE, \"I512\");\n const result = BigInt(value);\n assertI512(result);\n return result;\n}\n\n/**\n * Converts a JavaScript `number` to an {@link I1024}.\n *\n * @param value - A safe integer.\n * @returns The value branded as {@link I1024}.\n * @throws {ConversionError} If not a safe integer.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertNumberToI1024(value: number): I1024 {\n assertNumberInRange(value, MIN_SAFE, MAX_SAFE, \"I1024\");\n const result = BigInt(value);\n assertI1024(result);\n return result;\n}\n\n/* =============================================================================\n * SIGNED → number\n * ============================================================================= */\n\n/**\n * Converts an {@link I8} to a JavaScript `number`. Always safe (range [-128, 127]).\n *\n * @param value - The branded I8 value.\n * @returns The numeric value.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertI8ToNumber(value: I8): number {\n return Number(value);\n}\n\n/**\n * Converts an {@link I16} to a JavaScript `number`. Always safe (range [-32768, 32767]).\n *\n * @param value - The branded I16 value.\n * @returns The numeric value.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertI16ToNumber(value: I16): number {\n return Number(value);\n}\n\n/**\n * Converts an {@link I32} to a JavaScript `number`. Always safe.\n *\n * @param value - The branded I32 value.\n * @returns The numeric value.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertI32ToNumber(value: I32): number {\n return Number(value);\n}\n\n/**\n * Converts an {@link I64} to a JavaScript `number`.\n *\n * @param value - The branded I64 value.\n * @returns The numeric value.\n * @throws {ConversionError} If value is outside safe integer range.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertI64ToNumber(value: I64): number {\n const v = value as bigint;\n if (v > MAX_SAFE_BIGINT || v < MIN_SAFE_BIGINT) {\n throw new ConversionError(\n `I64 value ${String(value)} exceeds safe integer range`,\n { sourceValue: value, sourceType: \"I64\", targetType: \"number\", reason: \"Value outside [-(2^53-1), 2^53-1]\" },\n );\n }\n return Number(value);\n}\n\n/**\n * Converts an {@link I128} to a JavaScript `number`.\n *\n * @param value - The branded I128 value.\n * @returns The numeric value.\n * @throws {ConversionError} If value is outside safe integer range.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertI128ToNumber(value: I128): number {\n const v = value as bigint;\n if (v > MAX_SAFE_BIGINT || v < MIN_SAFE_BIGINT) {\n throw new ConversionError(\n `I128 value ${String(value)} exceeds safe integer range`,\n { sourceValue: value, sourceType: \"I128\", targetType: \"number\", reason: \"Value outside [-(2^53-1), 2^53-1]\" },\n );\n }\n return Number(value);\n}\n\n/**\n * Converts an {@link I256} to a JavaScript `number`.\n *\n * @param value - The branded I256 value.\n * @returns The numeric value.\n * @throws {ConversionError} If value is outside safe integer range.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertI256ToNumber(value: I256): number {\n const v = value as bigint;\n if (v > MAX_SAFE_BIGINT || v < MIN_SAFE_BIGINT) {\n throw new ConversionError(\n `I256 value ${String(value)} exceeds safe integer range`,\n { sourceValue: value, sourceType: \"I256\", targetType: \"number\", reason: \"Value outside [-(2^53-1), 2^53-1]\" },\n );\n }\n return Number(value);\n}\n\n/**\n * Converts an {@link I512} to a JavaScript `number`.\n *\n * @param value - The branded I512 value.\n * @returns The numeric value.\n * @throws {ConversionError} If value is outside safe integer range.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertI512ToNumber(value: I512): number {\n const v = value as bigint;\n if (v > MAX_SAFE_BIGINT || v < MIN_SAFE_BIGINT) {\n throw new ConversionError(\n `I512 value ${String(value)} exceeds safe integer range`,\n { sourceValue: value, sourceType: \"I512\", targetType: \"number\", reason: \"Value outside [-(2^53-1), 2^53-1]\" },\n );\n }\n return Number(value);\n}\n\n/**\n * Converts an {@link I1024} to a JavaScript `number`.\n *\n * @param value - The branded I1024 value.\n * @returns The numeric value.\n * @throws {ConversionError} If value is outside safe integer range.\n *\n * @since 2.0.0\n * @public\n */\nexport function convertI1024ToNumber(value: I1024): number {\n const v = value as bigint;\n if (v > MAX_SAFE_BIGINT || v < MIN_SAFE_BIGINT) {\n throw new ConversionError(\n `I1024 value ${String(value)} exceeds safe integer range`,\n { sourceValue: value, sourceType: \"I1024\", targetType: \"number\", reason: \"Value outside [-(2^53-1), 2^53-1]\" },\n );\n }\n return Number(value);\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 * @since 2.0.0\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 * @since 2.0.0\n * @module utils/cryptography/arcium\n */\n\nimport type { MaybeEncodedAccount } from \"@solana/kit\";\nimport { decodeMXEAccount } from \"@umbra-privacy/arcium-codama\";\n\nimport { assertRcEncryptionNonce, type RcEncryptionNonce, type U64 } from \"../types\";\nimport { generateRandomU128, generateRandomU64 } from \"./math-utils\";\nimport { UmbraError } from \"./errors\";\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 `EncryptedUserAccount`. 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 generateComputationOffset} 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 { generateComputationOffset } from \"@umbra-privacy/sdk\";\n *\n * // Generate a unique offset for each MPC computation\n * const computationOffset = generateComputationOffset();\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 generateComputationOffset(): U64 {\n return generateRandomU64();\n}\n\n/**\n * Extracts the Arcium cluster offset from a fetched MXE account.\n *\n * The cluster offset is stored in the `cluster` field of the on-chain MXE\n * account as an `Option<u32>`. This function decodes the account data and\n * returns the cluster offset, or throws if the account does not exist or\n * the cluster has not been set.\n *\n * @param mxeAccount - The raw encoded account data from an RPC fetch.\n * @returns The cluster offset as a number (u32).\n *\n * @throws {UmbraError} if the MXE account does not exist on-chain.\n * @throws {UmbraError} if the MXE account's `cluster` field is `None`.\n *\n * @example\n * ```typescript\n * const accountMap = await accountInfoProvider([mxeAccountAddress, ...otherAddresses]);\n * const clusterOffset = extractClusterOffsetFromMxeAccount(accountMap.get(mxeAccountAddress)!);\n * ```\n *\n * @public\n */\nexport function extractClusterOffsetFromMxeAccount(\n mxeAccount: MaybeEncodedAccount,\n): number {\n if (!mxeAccount.exists) {\n throw new UmbraError(\n \"MXE account not found on-chain. Cannot determine cluster offset.\",\n );\n }\n const decoded = decodeMXEAccount(mxeAccount);\n const cluster = decoded.data.cluster;\n if (cluster.__option === \"None\") {\n throw new UmbraError(\n \"MXE account has no cluster set. The Arcium cluster may not be initialized.\",\n );\n }\n return cluster.value;\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 * @since 2.0.0\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 * 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 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 = createU64(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 five sections:\n * 1. **Mathematics** — `createU32`, `createU64`, `createU128`, `createU256`\n * 2. **Field elements** — `createBn254FieldElement`, `createCurve25519FieldElement`, `createPoseidonKey`\n * 3. **Rescue Cipher** — `createRcPlaintext`, `createRcCiphertext`, `createRcKey`, `createRcEncryptionNonce`\n * 4. **Limbs** — `createBase85Limb`\n * 5. **Protocol types** — `createOptionalData32`, `createMicroLamportsPerAcu`\n * 6. **Array indexing** — `getByteAt`\n *\n * @packageDocumentation\n * @since 2.0.0\n * @module common/type-helpers\n */\n\nimport {\n // Mathematics types and assertions\n type U32,\n type U64,\n type U128,\n type U256,\n assertU32,\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 type OptionalData32,\n assertBn254FieldElement,\n assertPoseidonKey,\n assertCurve25519FieldElement,\n assertRcPlaintext,\n assertRcCiphertext,\n assertRcKey,\n assertRcEncryptionNonce,\n assertBase85Limb,\n assertOptionalData32,\n} from \"../types\";\n\nimport type { MicroLamportsPerAcu } from \"../types/arcium\";\n\n/* =============================================================================\n * MATHEMATICS TYPE HELPERS\n * ============================================================================= */\n\n/**\n * Validates a `bigint` as a 32-bit unsigned integer and returns it branded as `U32`.\n *\n * @remarks\n * Delegates to `assertU32` from `../types`. The assertion verifies that `value` is a\n * `bigint` in the closed range `[0, 2^32 - 1]` (i.e. `[0, 4294967295]`). If the value\n * is out of range or is not a `bigint`, a `MathematicsAssertionError` is thrown.\n *\n * `U32` values appear in the Umbra SDK as mixer tree indices, insertion indices, and\n * other slot or offset fields that fit within a 32-bit unsigned range. When feeding\n * user-supplied values (e.g. from a CLI argument or JSON payload) into SDK functions\n * that expect `U32`, always call `createU32(BigInt(value))` rather than passing a\n * raw `number` or relying on implicit coercion.\n *\n * @param value - The raw `bigint` to validate and brand.\n * @returns The same `bigint` value, branded as {@link U32}.\n * @throws `MathematicsAssertionError` if `value` is not a `bigint` or exceeds `2^32 - 1`.\n *\n * @example\n * ```typescript\n * import { createU32 } from \"@umbra-privacy/sdk\";\n *\n * const treeIndex = createU32(0n);\n * const startIndex = createU32(100n);\n *\n * // Convert from a JS number first (e.g. from user input or Zod-validated schema):\n * const userInputIndex = 42;\n * const safeIndex = createU32(BigInt(userInputIndex));\n *\n * // Throws for out-of-range values:\n * createU32(-1n); // MathematicsAssertionError\n * createU32(2n ** 32n); // MathematicsAssertionError\n * ```\n *\n * @see {@link assertU32} for the underlying assertion.\n * @see {@link createU64} for the 64-bit variant.\n * @see {@link createU128} for the 128-bit variant.\n * @public\n */\nexport function createU32(value: bigint): U32 {\n assertU32(value);\n return value;\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 { createU64 } from \"@umbra-privacy/sdk\";\n *\n * const raw = 1_000_000n;\n * const amount: U64 = createU64(raw, \"amount\");\n *\n * // Throws for negative or oversized values:\n * createU64(-1n); // MathematicsAssertionError\n * createU64(2n ** 64n); // MathematicsAssertionError\n * ```\n *\n * @see {@link assertU64} for the underlying assertion.\n * @see {@link createU128} for 128-bit variant.\n * @see {@link createU256} for 256-bit variant.\n * @public\n */\nexport function createU64(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 * `CLAIM_INTO_EXISTING_NETWORK_BALANCE_V11_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 { createU128 } from \"@umbra-privacy/sdk\";\n *\n * const seed = createU128(340282366920938463463374607431768211455n, \"instructionSeed\");\n * // seed is now typed as U128 and safe to pass to PDA derivation helpers.\n *\n * // Throws for oversized values:\n * createU128(2n ** 128n); // MathematicsAssertionError\n * ```\n *\n * @see {@link assertU128} for the underlying assertion.\n * @see {@link createU64} for the 64-bit variant.\n * @see {@link createU256} for the 256-bit variant.\n * @public\n */\nexport function createU128(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 { createU256 } from \"@umbra-privacy/sdk\";\n *\n * const scalar = createU256(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 createU64} for the 64-bit variant.\n * @see {@link createU128} for the 128-bit variant.\n * @public\n */\nexport function createU256(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 { createBn254FieldElement } from \"@umbra-privacy/sdk\";\n *\n * const publicInput = createBn254FieldElement(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 * createBn254FieldElement(BN254_FIELD_PRIME); // CryptographyAssertionError (not strictly less than)\n * ```\n *\n * @see {@link assertBn254FieldElement} for the underlying assertion.\n * @see {@link createCurve25519FieldElement} for the Curve25519 variant.\n * @see {@link createPoseidonKey} for Poseidon key validation.\n * @public\n */\nexport function createBn254FieldElement(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 { createCurve25519FieldElement } from \"@umbra-privacy/sdk\";\n *\n * const privKey = createCurve25519FieldElement(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 createBn254FieldElement} for the BN254 variant.\n * @public\n */\nexport function createCurve25519FieldElement(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 { createPoseidonKey } from \"@umbra-privacy/sdk\";\n *\n * const key = createPoseidonKey(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 createBn254FieldElement} for the parent field element helper.\n * @public\n */\nexport function createPoseidonKey(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 { createRcPlaintext } from \"@umbra-privacy/sdk\";\n *\n * const balance = createRcPlaintext(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 createRcCiphertext} for the ciphertext variant.\n * @see {@link createRcKey} for the key variant.\n * @public\n */\nexport function createRcPlaintext(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 `EncryptedTokenAccount` 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 { createRcCiphertext } from \"@umbra-privacy/sdk\";\n *\n * const ct = createRcCiphertext(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 createRcPlaintext} for the plaintext variant.\n * @see {@link createRcEncryptionNonce} for the nonce variant.\n * @public\n */\nexport function createRcCiphertext(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 * `EncryptedTokenAccount`.\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 { createRcKey } from \"@umbra-privacy/sdk\";\n *\n * const sessionKey = createRcKey(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 createRcPlaintext} for the plaintext variant.\n * @see {@link createRcCiphertext} for the ciphertext variant.\n * @public\n */\nexport function createRcKey(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 { createRcEncryptionNonce } from \"@umbra-privacy/sdk\";\n *\n * const nonce = createRcEncryptionNonce(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 createRcKey} for the key variant.\n * @see {@link EncryptedUserAccount.generationIndex} for the source of nonce values.\n * @public\n */\nexport function createRcEncryptionNonce(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 { createBase85Limb } from \"@umbra-privacy/sdk\";\n *\n * const limb0 = createBase85Limb(value & ((1n << 85n) - 1n), \"limb0\");\n * const limb1 = createBase85Limb((value >> 85n) & ((1n << 85n) - 1n), \"limb1\");\n * const limb2 = createBase85Limb(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 createBase85Limb(value: bigint, name?: string): Base85Limb {\n assertBase85Limb(value, name);\n return value;\n}\n\n/* =============================================================================\n * PROTOCOL TYPE HELPERS\n * ============================================================================= */\n\n/**\n * Validates a `Uint8Array` as a 32-byte optional data payload and returns it branded\n * as `OptionalData32`.\n *\n * @remarks\n * Delegates to `assertOptionalData32` from `../types`. The assertion verifies that\n * `value` is a `Uint8Array` with exactly 32 bytes. This type is used as the\n * `optionalData` field in several service option objects (`PublicBalanceToEncryptedBalanceDirectDepositorOptions`,\n * `CreateUtxoOptions`, `EncryptedBalanceToPublicBalanceDirectWithdrawerOptions`, etc.) and is stored\n * on-chain as an opaque 32-byte blob.\n *\n * The content of `OptionalData32` is protocol-defined. At this time the bytes are\n * not interpreted by the Umbra program, but future protocol upgrades may assign\n * semantics to specific byte positions.\n *\n * @param value - The raw `Uint8Array` to validate and brand. Must be exactly 32 bytes.\n * @param name - Optional variable name to include in the error message for easier debugging.\n * @returns The same `Uint8Array`, branded as {@link OptionalData32}.\n * @throws If `value` is not a `Uint8Array` or is not exactly 32 bytes.\n *\n * @example\n * ```typescript\n * import { createOptionalData32 } from \"@umbra-privacy/sdk\";\n *\n * // Pass 32 zero bytes (no optional data):\n * const noData = createOptionalData32(new Uint8Array(32));\n *\n * // Pass a custom 32-byte payload:\n * const payload = new Uint8Array(32);\n * payload[0] = 0x01;\n * const optionalData = createOptionalData32(payload, \"depositOptionalData\");\n * ```\n *\n * @see {@link assertOptionalData32} for the underlying assertion.\n * @public\n */\nexport function createOptionalData32(value: Uint8Array, name?: string): OptionalData32 {\n assertOptionalData32(value, name);\n return value;\n}\n\n/**\n * Validates a `bigint` as a micro-lamports-per-ACU priority fee and returns it branded\n * as `MicroLamportsPerAcu`.\n *\n * @remarks\n * `MicroLamportsPerAcu` is the price a user is willing to pay per Arcium Computation\n * Unit (ACU). It maps directly to the `priorityFees` field in Umbra on-chain\n * instructions. A value of `0n` indicates no priority fee.\n *\n * The value must be a non-negative `bigint`. There is no protocol-enforced maximum,\n * but excessively large values will increase transaction cost proportionally. When\n * passed as the optional `microLamportsPerAcu` field in service option objects,\n * omitting the field defaults to `0n` (no priority fee).\n *\n * @param value - The raw `bigint` to validate and brand. Must be `>= 0n`.\n * @returns The same `bigint` value, branded as {@link MicroLamportsPerAcu}.\n * @throws `Error` if `value` is not a `bigint` or is negative.\n *\n * @example\n * ```typescript\n * import { createMicroLamportsPerAcu } from \"@umbra-privacy/sdk\";\n *\n * // No priority fee:\n * const noFee = createMicroLamportsPerAcu(0n);\n *\n * // 1000 micro-lamports per ACU:\n * const fee = createMicroLamportsPerAcu(1000n);\n *\n * // Use in a deposit call:\n * await deposit(mint, amount, { microLamportsPerAcu: fee });\n * ```\n *\n * @public\n */\nexport function createMicroLamportsPerAcu(value: bigint): MicroLamportsPerAcu {\n if (typeof value !== \"bigint\") {\n throw new Error(`MicroLamportsPerAcu: Expected bigint, got ${typeof value}`);\n }\n if (value < 0n) {\n throw new Error(`MicroLamportsPerAcu: Value must be non-negative, got ${String(value)}`);\n }\n return value as MicroLamportsPerAcu;\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 \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"]}
|