general: revert #1665
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user