general: revert #1665

This commit is contained in:
Rajeh Taher
2025-10-03 18:14:30 +03:00
parent 55f09e8c84
commit 334977f983
29 changed files with 51841 additions and 3500 deletions
@@ -1,7 +1,13 @@
import { proto } from '../../../WAProto/index.js'
import { decodeAndHydrate } from '../../Utils/proto-utils'
import { CiphertextMessage } from './ciphertext-message'
interface SenderKeyDistributionMessageStructure {
id: number
iteration: number
chainKey: Uint8Array
signingKey: Uint8Array
}
export class SenderKeyDistributionMessage extends CiphertextMessage {
private readonly id: number
private readonly iteration: number
@@ -21,7 +27,9 @@ export class SenderKeyDistributionMessage extends CiphertextMessage {
if (serialized) {
try {
const message = serialized.slice(1)
const distributionMessage = decodeAndHydrate(proto.SenderKeyDistributionMessage, message)
const distributionMessage = proto.SenderKeyDistributionMessage.decode(
message
).toJSON() as SenderKeyDistributionMessageStructure
this.serialized = serialized
this.id = distributionMessage.id
+7 -2
View File
@@ -1,8 +1,13 @@
import { calculateSignature, verifySignature } from 'libsignal/src/curve'
import { proto } from '../../../WAProto/index.js'
import { decodeAndHydrate } from '../../Utils/proto-utils'
import { CiphertextMessage } from './ciphertext-message'
interface SenderKeyMessageStructure {
id: number
iteration: number
ciphertext: Buffer
}
export class SenderKeyMessage extends CiphertextMessage {
private readonly SIGNATURE_LENGTH = 64
private readonly messageVersion: number
@@ -25,7 +30,7 @@ export class SenderKeyMessage extends CiphertextMessage {
const version = serialized[0]!
const message = serialized.slice(1, serialized.length - this.SIGNATURE_LENGTH)
const signature = serialized.slice(-1 * this.SIGNATURE_LENGTH)
const senderKeyMessage = decodeAndHydrate(proto.SenderKeyMessage, message)
const senderKeyMessage = proto.SenderKeyMessage.decode(message).toJSON() as SenderKeyMessageStructure
this.serialized = serialized
this.messageVersion = (version & 0xff) >> 4