WXL
3 天以前 4d9da000fbe74d344e0e4580b138e79d4ad98ede
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseSigner = void 0;
class BaseSigner {
    _auth;
    _config;
    constructor(auth, config) {
        this._auth = auth;
        this._config = config;
    }
    get auth() {
        return this._auth;
    }
    get config() {
        return this._config;
    }
    get publicKey() {
        return this.auth.getPublicKey(this.config.publicKey.isCompressed);
    }
    get publicKeyHash() {
        return this.config.publicKey.hash(this.publicKey);
    }
    setAuth(auth) {
        this._auth = auth;
    }
    setConfig(config) {
        this._config = config;
    }
    signArbitrary(message) {
        const signature = this.auth.sign(this.config.message.hash(message));
        return this.config.signature.toCompact(signature, this.auth.algo);
    }
    verifyArbitrary(message, signature) {
        if (!this.auth.verify) {
            throw new Error("verify method is not implemented yet");
        }
        return this.auth.verify(this.config.message.hash(message), this.config.signature.fromCompact(signature, this.auth.algo));
    }
}
exports.BaseSigner = BaseSigner;
//# sourceMappingURL=base-signer.js.map