UNPKG

1.25 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const identities_1 = require("../identities");
4const managers_1 = require("../managers");
5const hash_1 = require("./hash");
6const hash_algorithms_1 = require("./hash-algorithms");
7class Message {
8 static sign(message, passphrase) {
9 const keys = identities_1.Keys.fromPassphrase(passphrase);
10 return {
11 publicKey: keys.publicKey,
12 signature: hash_1.Hash.signECDSA(this.createHash(message), keys),
13 message,
14 };
15 }
16 static signWithWif(message, wif, network) {
17 if (!network) {
18 network = managers_1.configManager.get("network");
19 }
20 const keys = identities_1.Keys.fromWIF(wif, network);
21 return {
22 publicKey: keys.publicKey,
23 signature: hash_1.Hash.signECDSA(this.createHash(message), keys),
24 message,
25 };
26 }
27 static verify({ message, publicKey, signature }) {
28 return hash_1.Hash.verifyECDSA(this.createHash(message), signature, publicKey);
29 }
30 static createHash(message) {
31 return hash_algorithms_1.HashAlgorithms.sha256(message);
32 }
33}
34exports.Message = Message;
35//# sourceMappingURL=message.js.map
\No newline at end of file