"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDeriveFn = createDeriveFn;
const tslib_1 = require("tslib");
const sr25519 = tslib_1.__importStar(require("@pezkuwi/scure-sr25519"));
const util_1 = require("@pezkuwi/util");
function createDeriveFn(derive) {
    return (keypair, chainCode) => {
        if (!(0, util_1.isU8a)(chainCode) || chainCode.length !== 32) {
            throw new Error('Invalid chainCode passed to derive');
        }
        const secretKey = derive(keypair.secretKey, chainCode);
        const publicKey = sr25519.getPublicKey(secretKey);
        return { publicKey, secretKey };
    };
}
