/**

 * Minimal wallet_crypto stub for Node policy tests (no CDN / ML-DSA).

 */

export function sha3_256(bytes) {

  // Deterministic fake hash for merkle/hash helpers used indirectly — not for crypto parity.

  const out = new Uint8Array(32);

  const data = bytes instanceof Uint8Array ? bytes : new TextEncoder().encode(String(bytes));

  for (let i = 0; i < data.length; i++) out[i % 32] ^= data[i];

  out[0] ^= data.length & 0xff;

  return out;

}



export function bytesToHex(bytes) {

  return Array.from(bytes || [])

    .map((b) => b.toString(16).padStart(2, "0"))

    .join("");

}



export function hexToBytes(hex) {

  const h = String(hex || "");

  const out = new Uint8Array(h.length / 2);

  for (let i = 0; i < out.length; i++) out[i] = parseInt(h.slice(i * 2, i * 2 + 2), 16);

  return out;

}



export function sign(_msg, _sk) {

  return new Uint8Array(64);

}



export function publicKeyToAddress(_pk) {

  return "SRMD1TESTMINER0000000000000000000000";

}



export function isValidSrmdAddress(addr) {

  return typeof addr === "string" && addr.startsWith("SRMD") && addr.length >= 10;

}


