@@ -223,6 +223,7 @@ func (proc *Processor) decodeMutations(
223223 Hex ("index_mac" , indexMAC ).
224224 Hex ("value_mac" , valueMAC ).
225225 Strs ("index" , index ).
226+ Stringer ("operation" , mutation .GetOperation ()).
226227 Msg ("DEBUG: mutation metadata" )
227228 if mutation .GetOperation () == waServerSync .SyncdMutation_REMOVE {
228229 out .RemoveMAC (indexMAC )
@@ -396,6 +397,7 @@ func (proc *Processor) evilHackForLIDMutation(
396397 newIndexMAC = concatAndHMAC (sha256 .New , keys .Index , indexBytes )
397398 currentKeyID := mutation .GetRecord ().GetKeyID ().GetID ()
398399 triedIndexMACs := map [string ]string {hex .EncodeToString (currentKeyID ): hex .EncodeToString (newIndexMAC )}
400+ moreMetadata := map [int ]map [string ]any {}
399401 for i := mutationNum - 1 ; i >= 0 ; i -- {
400402 newKeyID := prevMutations [i ].GetRecord ().GetKeyID ().GetID ()
401403 if ! bytes .Equal (currentKeyID , newKeyID ) {
@@ -407,14 +409,24 @@ func (proc *Processor) evilHackForLIDMutation(
407409 newIndexMAC = concatAndHMAC (sha256 .New , keys .Index , indexBytes )
408410 triedIndexMACs [hex .EncodeToString (currentKeyID )] = hex .EncodeToString (newIndexMAC )
409411 }
412+ moreMetadata [i ] = map [string ]any {
413+ "expected_mac" : hex .EncodeToString (newIndexMAC ),
414+ "mac_at_idx" : hex .EncodeToString (prevMutations [i ].GetRecord ().GetIndex ().GetBlob ()),
415+ "key_id" : hex .EncodeToString (newKeyID ),
416+ }
410417 if bytes .Equal (prevMutations [i ].GetRecord ().GetIndex ().GetBlob (), newIndexMAC ) {
418+ moreMetadata [i ]["equal" ] = true
419+ moreMetadata [i ]["op_is_set" ] = prevMutations [i ].GetOperation () == waServerSync .SyncdMutation_SET
411420 if prevMutations [i ].GetOperation () == waServerSync .SyncdMutation_SET {
412421 value := prevMutations [i ].GetRecord ().GetValue ().GetBlob ()
413422 newValueMAC = value [len (value )- 32 :]
423+ break
414424 } else {
415425 // Found a REMOVE operation, no previous value
416426 return nil , nil , nil
417427 }
428+ } else {
429+ moreMetadata [i ]["equal" ] = false
418430 }
419431 }
420432 if newValueMAC == nil && checkDatabase {
@@ -444,6 +456,7 @@ func (proc *Processor) evilHackForLIDMutation(
444456 Hex ("old_index_mac" , oldIndexMAC ).
445457 Strs ("new_index" , newIndex ).
446458 Any ("new_index_macs_attempted" , triedIndexMACs ).
459+ Any ("more_metadata" , moreMetadata ).
447460 Msg ("DEBUG: No PN value MAC found for LID mutation" )
448461 } else {
449462 zerolog .Ctx (ctx ).Debug ().
0 commit comments