1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const identities_1 = require("../identities");
|
4 | const managers_1 = require("../managers");
|
5 | const hash_1 = require("./hash");
|
6 | const hash_algorithms_1 = require("./hash-algorithms");
|
7 | class 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 | }
|
34 | exports.Message = Message;
|
35 |
|
\ | No newline at end of file |