UNPKG

@shard-auth/client

Version:

Next-generation API authentication without secret keys - MPC-based authentication with FROST threshold signatures

37 lines 1.24 kB
"use strict"; /** * 簡略化された署名実装(テスト用) */ Object.defineProperty(exports, "__esModule", { value: true }); exports.initSimpleSignature = initSimpleSignature; exports.setShareForSigning = setShareForSigning; exports.createSimpleSignature = createSimpleSignature; const simple_frost_1 = require("./frost/simple-frost"); // グローバルな署名情報(実際は通信で共有) let currentShares = {}; function initSimpleSignature() { currentShares = {}; } function setShareForSigning(share) { const shareValue = BigInt('0x' + share.share.toString('hex')); if (share.index === 1) { currentShares.share1 = shareValue; } else { currentShares.share2 = shareValue; } } async function createSimpleSignature(message, publicKey) { if (!currentShares.share1 || !currentShares.share2) { throw new Error('Both shares required for signing'); } const { r, s } = await simple_frost_1.SimpleFROST.sign(currentShares.share1, currentShares.share2, message); return { r, s, async verify(msg, pubKey) { return simple_frost_1.SimpleFROST.verify(r, s, msg, pubKey); } }; } //# sourceMappingURL=simple-signature.js.map