UNPKG

1.06 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const bcrypto_1 = require("bcrypto");
4class Hash {
5 static signECDSA(hash, keys) {
6 return bcrypto_1.secp256k1.signatureExport(bcrypto_1.secp256k1.sign(hash, Buffer.from(keys.privateKey, "hex"))).toString("hex");
7 }
8 static verifyECDSA(hash, signature, publicKey) {
9 return bcrypto_1.secp256k1.verify(hash, bcrypto_1.secp256k1.signatureImport(signature instanceof Buffer ? signature : Buffer.from(signature, "hex")), publicKey instanceof Buffer ? publicKey : Buffer.from(publicKey, "hex"));
10 }
11 static signSchnorr(hash, keys) {
12 return bcrypto_1.secp256k1.schnorrSign(hash, Buffer.from(keys.privateKey, "hex")).toString("hex");
13 }
14 static verifySchnorr(hash, signature, publicKey) {
15 return bcrypto_1.secp256k1.schnorrVerify(hash, signature instanceof Buffer ? signature : Buffer.from(signature, "hex"), publicKey instanceof Buffer ? publicKey : Buffer.from(publicKey, "hex"));
16 }
17}
18exports.Hash = Hash;
19//# sourceMappingURL=hash.js.map
\No newline at end of file