public-key.ts (493B)
1 import { secp256k1 } from '@noble/curves/secp256k1'; 2 3 // Admission matches the pinned Radroots x-only public-key type. This module 4 // validates public data only; it never generates keys, signs or derives secrets. 5 export function canonicalPublicKey(value: unknown): string | undefined { 6 if (typeof value !== 'string' || !/^[0-9a-f]{64}$/.test(value)) 7 return undefined; 8 try { 9 secp256k1.ProjectivePoint.fromHex('02' + value); 10 return value; 11 } catch { 12 return undefined; 13 } 14 }