// Key tree for the Sia wallet: index i -> ed25519 key via walletd's // KeyFromSeed(root, i), address = standard unlock hash of the public key. // Private keys stay inside this module; sign() is the only way out. module.exports = function makeKeys({ sia }) { class WalletKeys { constructor(root32) { this._root = Uint8Array.from(root32); this._cache = new Map(); } entry(index) { let e = this._cache.get(index); if (!e) { const k = sia.keyFromSeed(this._root, index); e = { index, pub: k.pub, address32: k.address32, address: k.address, _priv: k.priv }; this._cache.set(index, e); } return e; } sign(entry, msg) { return sia.sign(entry._priv, msg); } // Revealed only on explicit user action in Settings. get seedHex() { return sia.toHex(this._root); } wipe() { for (const e of this._cache.values()) e._priv.fill(0); this._cache.clear(); this._root.fill(0); } } return { WalletKeys }; };