From 9c54675d28f65ff52d6dc3316e82f4bbe46999f5 Mon Sep 17 00:00:00 2001
From: joshemb <josh@elixxir.io>
Date: Mon, 22 Aug 2022 11:18:50 -0700
Subject: [PATCH] Add key residue to partioner

---
 e2e/parse/partition.go                  | 6 ++++--
 e2e/parse/partition/multiPartMessage.go | 2 ++
 e2e/parse/partition/store.go            | 6 ++++--
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/e2e/parse/partition.go b/e2e/parse/partition.go
index da7628381..4850cafd7 100644
--- a/e2e/parse/partition.go
+++ b/e2e/parse/partition.go
@@ -8,6 +8,7 @@
 package parse
 
 import (
+	e2eCrypto "gitlab.com/elixxir/crypto/e2e"
 	"time"
 
 	"github.com/pkg/errors"
@@ -78,7 +79,8 @@ func (p *Partitioner) Partition(recipient *id.ID, mt catalog.MessageType,
 }
 
 func (p *Partitioner) HandlePartition(sender *id.ID,
-	contents []byte, relationshipFingerprint []byte) (receive.Message, bool) {
+	contents []byte, relationshipFingerprint []byte,
+	residue e2eCrypto.KeyResidue) (receive.Message, bool) {
 
 	if isFirst(contents) {
 		// If it is the first message in a set, then handle it as so
@@ -92,7 +94,7 @@ func (p *Partitioner) HandlePartition(sender *id.ID,
 		storageTimestamp := netTime.Now()
 		return p.partition.AddFirst(sender, fm.getType(), messageID,
 			fm.getPart(), fm.getNumParts(), fm.getTimestamp(), storageTimestamp,
-			fm.getSizedContents(), relationshipFingerprint)
+			fm.getSizedContents(), relationshipFingerprint, residue)
 	} else {
 		// If it is a subsequent message part, handle it as so
 		mp := messagePartFromBytes(contents)
diff --git a/e2e/parse/partition/multiPartMessage.go b/e2e/parse/partition/multiPartMessage.go
index d067248d2..f7fd42085 100644
--- a/e2e/parse/partition/multiPartMessage.go
+++ b/e2e/parse/partition/multiPartMessage.go
@@ -41,6 +41,8 @@ type multiPartMessage struct {
 	StorageTimestamp time.Time
 	MessageType      catalog.MessageType
 
+	KeyResidue e2e.KeyResidue
+
 	parts [][]byte
 	kv    *versioned.KV
 	mux   sync.Mutex
diff --git a/e2e/parse/partition/store.go b/e2e/parse/partition/store.go
index 7774e3187..0f128c482 100644
--- a/e2e/parse/partition/store.go
+++ b/e2e/parse/partition/store.go
@@ -14,6 +14,7 @@ import (
 	"gitlab.com/elixxir/client/catalog"
 	"gitlab.com/elixxir/client/e2e/receive"
 	"gitlab.com/elixxir/client/storage/versioned"
+	"gitlab.com/elixxir/crypto/e2e"
 	"gitlab.com/xx_network/primitives/id"
 	"gitlab.com/xx_network/primitives/netTime"
 	"golang.org/x/crypto/blake2b"
@@ -51,12 +52,13 @@ func NewOrLoad(kv *versioned.KV) *Store {
 
 func (s *Store) AddFirst(partner *id.ID, mt catalog.MessageType,
 	messageID uint64, partNum, numParts uint8, senderTimestamp,
-	storageTimestamp time.Time, part []byte, relationshipFingerprint []byte) (
+	storageTimestamp time.Time, part []byte, relationshipFingerprint []byte,
+	residue e2e.KeyResidue) (
 	receive.Message, bool) {
 
 	mpm := s.load(partner, messageID)
-
 	mpm.AddFirst(mt, partNum, numParts, senderTimestamp, storageTimestamp, part)
+	mpm.KeyResidue = residue
 	msg, ok := mpm.IsComplete(relationshipFingerprint)
 
 	s.mux.Lock()
-- 
GitLab