"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.SenderKeyDistributionMessage = void 0;var _index = require("../../../WAProto/index.js"); var _ciphertextMessage = require("./ciphertext-message.js"); class SenderKeyDistributionMessage extends _ciphertextMessage.CiphertextMessage { constructor(id, iteration, chainKey, signatureKey, serialized) { super(); if (serialized) { try { const message = serialized.slice(1); const distributionMessage = _index.proto.SenderKeyDistributionMessage.decode(message).toJSON(); this.serialized = serialized; this.id = distributionMessage.id; this.iteration = distributionMessage.iteration; this.chainKey = typeof distributionMessage.chainKey === 'string' ? Buffer.from(distributionMessage.chainKey, 'base64') : distributionMessage.chainKey; this.signatureKey = typeof distributionMessage.signingKey === 'string' ? Buffer.from(distributionMessage.signingKey, 'base64') : distributionMessage.signingKey; } catch (e) { throw new Error(String(e)); } } else { const version = this.intsToByteHighAndLow(this.CURRENT_VERSION, this.CURRENT_VERSION); this.id = id; this.iteration = iteration; this.chainKey = chainKey; this.signatureKey = signatureKey; const message = _index.proto.SenderKeyDistributionMessage.encode(_index.proto.SenderKeyDistributionMessage.create({ id, iteration, chainKey, signingKey: this.signatureKey })).finish(); this.serialized = Buffer.concat([Buffer.from([version]), message]); } } intsToByteHighAndLow(highValue, lowValue) { return ((highValue << 4 | lowValue) & 0xff) % 256; } serialize() { return this.serialized; } getType() { return this.SENDERKEY_DISTRIBUTION_TYPE; } getIteration() { return this.iteration; } getChainKey() { return this.chainKey; } getSignatureKey() { return this.signatureKey; } getId() { return this.id; } }exports.SenderKeyDistributionMessage = SenderKeyDistributionMessage; /* v9-9b27432ff7f37547 */