Skip to content
Snippets Groups Projects
Commit c86790e5 authored by Josh Brooks's avatar Josh Brooks
Browse files

Propagate key residue for receiver

parent b83ad5f4
No related branches found
No related tags found
2 merge requests!510Release,!344Xx 4084/send e2e residue
......@@ -80,7 +80,7 @@ func (p *Partitioner) Partition(recipient *id.ID, mt catalog.MessageType,
func (p *Partitioner) HandlePartition(sender *id.ID,
contents []byte, relationshipFingerprint []byte,
residue e2eCrypto.KeyResidue) (receive.Message, bool) {
residue e2eCrypto.KeyResidue) (receive.Message, e2eCrypto.KeyResidue, bool) {
if isFirst(contents) {
// If it is the first message in a set, then handle it as so
......
......@@ -54,7 +54,7 @@ func (s *Store) AddFirst(partner *id.ID, mt catalog.MessageType,
messageID uint64, partNum, numParts uint8, senderTimestamp,
storageTimestamp time.Time, part []byte, relationshipFingerprint []byte,
residue e2e.KeyResidue) (
receive.Message, bool) {
receive.Message, e2e.KeyResidue, bool) {
mpm := s.load(partner, messageID)
mpm.AddFirst(mt, partNum, numParts, senderTimestamp, storageTimestamp, part)
......@@ -64,34 +64,39 @@ func (s *Store) AddFirst(partner *id.ID, mt catalog.MessageType,
s.mux.Lock()
defer s.mux.Unlock()
keyRes := e2e.KeyResidue{}
if !ok {
s.activeParts[mpm] = true
s.saveActiveParts()
} else {
keyRes = mpm.KeyResidue
mpID := getMultiPartID(mpm.Sender, mpm.MessageID)
delete(s.multiParts, mpID)
}
return msg, ok
return msg, keyRes, ok
}
func (s *Store) Add(partner *id.ID, messageID uint64, partNum uint8,
part []byte, relationshipFingerprint []byte) (receive.Message, bool) {
part []byte, relationshipFingerprint []byte) (
receive.Message, e2e.KeyResidue, bool) {
mpm := s.load(partner, messageID)
mpm.Add(partNum, part)
msg, ok := mpm.IsComplete(relationshipFingerprint)
keyRes := e2e.KeyResidue{}
if !ok {
s.activeParts[mpm] = true
s.saveActiveParts()
} else {
keyRes = mpm.KeyResidue
mpID := getMultiPartID(mpm.Sender, mpm.MessageID)
delete(s.multiParts, mpID)
}
return msg, ok
return msg, keyRes, ok
}
// prune clears old messages on it's stored timestamp.
......
......@@ -8,6 +8,7 @@
package parse
import (
"gitlab.com/elixxir/crypto/e2e"
"testing"
"gitlab.com/elixxir/client/catalog"
......@@ -72,10 +73,11 @@ func TestPartitioner_HandlePartition(t *testing.T) {
p := NewPartitioner(versioned.NewKV(ekv.MakeMemstore()), len(ipsumTestStr))
m := newMessagePart(1107, 1, []byte(ipsumTestStr), len(ipsumTestStr)+headerLen)
_, _ = p.HandlePartition(
_, _, _ = p.HandlePartition(
&id.DummyUser,
m.bytes(),
[]byte{'t', 'e', 's', 't', 'i', 'n', 'g', 's', 't', 'r', 'i', 'n', 'g'},
e2e.KeyResidue{},
)
}
......@@ -85,9 +87,10 @@ func TestPartitioner_HandleFirstPartition(t *testing.T) {
m := newFirstMessagePart(
catalog.XxMessage, 1107, 1, netTime.Now(), []byte(ipsumTestStr), len([]byte(ipsumTestStr))+firstHeaderLen)
_, _ = p.HandlePartition(
_, _, _ = p.HandlePartition(
&id.DummyUser,
m.bytes(),
[]byte{'t', 'e', 's', 't', 'i', 'n', 'g', 's', 't', 'r', 'i', 'n', 'g'},
e2e.KeyResidue{},
)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment