@helium/crypto
Version:
Cryptography utilities including mnemonics, keypairs and base58-check encoding
23 lines • 944 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const address_1 = require("@helium/address");
class KeySignature {
constructor(index, signature) {
this.index = index;
this.signature = signature;
}
static new(addresses, address, signature) {
if (address.keyType === address_1.KeyTypes.MULTISIG_KEY_TYPE) {
throw new Error('invalid keytype for multisig KeySignature');
}
return new KeySignature(address_1.utils.sortAddresses(addresses).findIndex((addr) => addr.publicKey === address.publicKey), signature);
}
static fromMap(addresses, signatureMap) {
return Array.from(signatureMap).map((value) => KeySignature.new(addresses, value[0], value[1]));
}
get bin() {
return new Uint8Array([this.index, this.signature.length, ...this.signature]);
}
}
exports.default = KeySignature;
//# sourceMappingURL=KeySignature.js.map