{"version":3,"file":"index.cjs","sources":["../../../../src/utils/checkAddressOnCurve/index.ts"],"sourcesContent":["import { Address, ReadonlyUint8Array } from \"@solana/kit\";\r\n\r\nimport { addressCodec } from \"../../codecs\";\r\nimport { _pointIsOnCurve } from \"./ed25519\";\r\n\r\nfunction byteToHex(byte: number): string {\r\n  const hexString = byte.toString(16);\r\n  if (hexString.length === 1) {\r\n    return `0${hexString}`;\r\n  } else {\r\n    return hexString;\r\n  }\r\n}\r\n\r\nfunction decompressPointBytes(bytes: ReadonlyUint8Array): bigint {\r\n  const hexString = bytes.reduce(\r\n    (acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~0x80 : byte)}${acc}`,\r\n    \"\"\r\n  );\r\n  const integerLiteralString = `0x${hexString}`;\r\n\r\n  return BigInt(integerLiteralString);\r\n}\r\n\r\nexport function checkAddressOnCurve(address: Address): boolean {\r\n  const bytes = addressCodec.encode(address);\r\n  if (bytes.byteLength !== 32) {\r\n    return false;\r\n  }\r\n  const y = decompressPointBytes(bytes);\r\n\r\n  return _pointIsOnCurve(y, bytes[31]);\r\n}\r\n"],"names":["address","bytes","addressCodec","encode","byteLength","y","hexString","reduce","acc","byte","ii","toString","length","byteToHex","BigInt","decompressPointBytes","_pointIsOnCurve"],"mappings":"sGAwBM,SAA8BA,GAClC,MAAMC,EAAQC,EAAAA,aAAaC,OAAOH,GAClC,GAAyB,KAArBC,EAAMG,WACR,OAAO,EAET,MAAMC,EAfR,SAA8BJ,GAC5B,MAAMK,EAAYL,EAAMM,QACtB,CAACC,EAAKC,EAAMC,IAAO,GAXvB,SAAmBD,GACjB,MAAMH,EAAYG,EAAKE,SAAS,IAChC,OAAyB,IAArBL,EAAUM,OACL,IAAIN,IAEJA,CAEX,CAI0BO,CAAiB,KAAPH,OAAYD,EAAeA,KAAQD,KACnE,IAIF,OAAOM,OAFsB,KAAKR,IAGpC,CAOYS,CAAqBd,GAE/B,OAAOe,kBAAgBX,EAAGJ,EAAM,IAClC"}