{"version":3,"file":"onChainBtcPubkey-C_a2L3kL.cjs","sources":["../src/tbv/core/clients/eth/onChainBtcPubkey.ts"],"sourcesContent":["/**\n * The single validator that mints {@link OnChainBtcPubkey}.\n *\n * Extracted from `ViemVaultRegistryReader.getVaultProviderGenesisBtcPubKey` so that\n * RFC-006 operation-key resolution can produce branded keys through exactly\n * the same checks, rather than casting past the brand. Every producer of an\n * `OnChainBtcPubkey` must go through here.\n */\n\nimport * as ecc from \"@bitcoin-js/tiny-secp256k1-asmjs\";\nimport type { Hex } from \"viem\";\n\nimport { hexToUint8Array } from \"../../primitives/utils/bitcoin\";\nimport type { OnChainBtcPubkey } from \"./types\";\n\n/**\n * Validate a registry-returned `bytes32` as an x-only BTC pubkey and mint the\n * brand. Checks length, hex form, and secp256k1 curve membership. Returns\n * 64-char lowercase hex without the `0x` prefix.\n *\n * `label` identifies the read site in error messages (e.g.\n * `getOperationBtcKeyAtEpoch (vp=0x…, epoch=0)`), so a failure names which\n * participant and which getter produced it.\n *\n * A zero hash fails the curve check, so an unregistered operator or an epoch\n * with no bonded key surfaces as an error rather than a silent all-zero key.\n */\nexport function assertOnChainBtcPubkey(\n  value: Hex,\n  label: string,\n): OnChainBtcPubkey {\n  const lowered = value.toLowerCase();\n  if (!/^0x[0-9a-f]{64}$/.test(lowered)) {\n    throw new Error(\n      `${label} returned an unexpected value (length ${lowered.length}, prefix \"${lowered.slice(0, 2)}\")`,\n    );\n  }\n  const stripped = lowered.slice(2);\n  if (!ecc.isXOnlyPoint(hexToUint8Array(stripped))) {\n    throw new Error(\n      `${label} returned a value that is not on the secp256k1 curve`,\n    );\n  }\n  return stripped as OnChainBtcPubkey;\n}\n"],"names":["assertOnChainBtcPubkey","value","label","lowered","stripped","ecc","hexToUint8Array"],"mappings":"+XA2BO,SAASA,EACdC,EACAC,EACkB,CAClB,MAAMC,EAAUF,EAAM,YAAA,EACtB,GAAI,CAAC,mBAAmB,KAAKE,CAAO,EAClC,MAAM,IAAI,MACR,GAAGD,CAAK,yCAAyCC,EAAQ,MAAM,aAAaA,EAAQ,MAAM,EAAG,CAAC,CAAC,IAAA,EAGnG,MAAMC,EAAWD,EAAQ,MAAM,CAAC,EAChC,GAAI,CAACE,EAAI,aAAaC,EAAAA,gBAAgBF,CAAQ,CAAC,EAC7C,MAAM,IAAI,MACR,GAAGF,CAAK,sDAAA,EAGZ,OAAOE,CACT"}