"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sr25519Agreement = sr25519Agreement;
const sr25519_1 = require("@pezkuwi/scure-sr25519");
const util_1 = require("@pezkuwi/util");
/**
 * @name sr25519Agreement
 * @description Key agreement between other's public key and self secret key
 */
function sr25519Agreement(secretKey, publicKey) {
    const secretKeyU8a = (0, util_1.u8aToU8a)(secretKey);
    const publicKeyU8a = (0, util_1.u8aToU8a)(publicKey);
    if (publicKeyU8a.length !== 32) {
        throw new Error(`Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
    }
    else if (secretKeyU8a.length !== 64) {
        throw new Error(`Invalid secretKey, received ${secretKeyU8a.length} bytes, expected 64`);
    }
    return (0, sr25519_1.getSharedSecret)(secretKeyU8a, publicKeyU8a);
}
