diff --git a/api/authenticatedChannel.go b/api/authenticatedChannel.go index 9d26304009a4be8bc55471edca3c66da1f9ef5ec..f800efe28e2b3c74712e9c0960ac52db4e7dbadf 100644 --- a/api/authenticatedChannel.go +++ b/api/authenticatedChannel.go @@ -13,7 +13,6 @@ import ( "gitlab.com/elixxir/client/auth" "gitlab.com/elixxir/client/interfaces" "gitlab.com/elixxir/client/interfaces/contact" - "gitlab.com/elixxir/client/storage/e2e" "gitlab.com/elixxir/primitives/fact" "gitlab.com/xx_network/primitives/id" ) @@ -94,7 +93,7 @@ func (c *Client) MakePrecannedAuthenticatedChannel(precannedID uint) (contact.Co precan := c.MakePrecannedContact(precannedID) // add the precanned user as a e2e contact - sesParam := e2e.GetDefaultSessionParams() + sesParam := c.parameters.E2EParams err := c.storage.E2e().AddPartner(precan.ID, precan.DhPubKey, c.storage.E2e().GetDHPrivateKey(), sesParam, sesParam) diff --git a/api/client.go b/api/client.go index 776eec62d319c141c33ad949c7bf256eb58c01ab..17649e531331557dc0fb4d53c53eef3953c752b6 100644 --- a/api/client.go +++ b/api/client.go @@ -242,7 +242,9 @@ func Login(storageDir string, password []byte, parameters params.Network) (*Clie } //initilize the auth tracker - c.auth = auth.NewManager(c.switchboard, c.storage, c.network) + authE2EParams := parameters.E2EParams + c.auth = auth.NewManager(c.switchboard, c.storage, c.network, + authE2EParams) return c, nil } diff --git a/auth/callback.go b/auth/callback.go index a5ccef9fdd6a57aea045baf05c3bb0e980072c33..adc0852018afa952b9bec77c5d392a438683184f 100644 --- a/auth/callback.go +++ b/auth/callback.go @@ -14,7 +14,6 @@ import ( "gitlab.com/elixxir/client/interfaces/contact" "gitlab.com/elixxir/client/stoppable" "gitlab.com/elixxir/client/storage/auth" - "gitlab.com/elixxir/client/storage/e2e" "gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/diffieHellman" cAuth "gitlab.com/elixxir/crypto/e2e/auth" @@ -251,7 +250,7 @@ func (m *Manager) doConfirm(sr *auth.SentRequest, grp *cyclic.Group, // fixme: channel can get into a bricked state if the first save occurs and // the second does not - p := e2e.GetDefaultSessionParams() + p := m.params if err := m.storage.E2e().AddPartner(sr.GetPartner(), partnerPubKey, sr.GetMyPrivKey(), p, p); err != nil { return errors.Errorf("Failed to create channel with partner (%s) "+ diff --git a/auth/confirm.go b/auth/confirm.go index a58306c2da8dce6017c96af1d10888652f67ea73..d6c0485941edd82ac5fc95a5492c822b6c0ed6c4 100644 --- a/auth/confirm.go +++ b/auth/confirm.go @@ -15,7 +15,6 @@ import ( "gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/interfaces/utility" "gitlab.com/elixxir/client/storage" - "gitlab.com/elixxir/client/storage/e2e" ds "gitlab.com/elixxir/comms/network/dataStructures" "gitlab.com/elixxir/crypto/diffieHellman" cAuth "gitlab.com/elixxir/crypto/e2e/auth" @@ -106,7 +105,7 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader, // messages does not occur //create local relationship - p := e2e.GetDefaultSessionParams() + p := net.GetE2EParams() if err := storage.E2e().AddPartner(partner.ID, partner.DhPubKey, newPrivKey, p, p); err != nil { storage.Auth().Fail(partner.ID) diff --git a/auth/manager.go b/auth/manager.go index b5803d69feb7ae67073e351b1c7fd24c3ac5b597..83857a0d8324141fd59b38151c92d6ca42e0d905 100644 --- a/auth/manager.go +++ b/auth/manager.go @@ -10,6 +10,7 @@ package auth import ( "gitlab.com/elixxir/client/interfaces" "gitlab.com/elixxir/client/interfaces/message" + "gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/switchboard" "gitlab.com/xx_network/primitives/id" @@ -23,16 +24,18 @@ type Manager struct { storage *storage.Session net interfaces.NetworkManager + params params.E2ESessionParams } func NewManager(sw interfaces.Switchboard, storage *storage.Session, - net interfaces.NetworkManager) *Manager { + net interfaces.NetworkManager, e2eParams params.E2ESessionParams) *Manager { m := &Manager{ requestCallbacks: newCallbackMap(), confirmCallbacks: newCallbackMap(), rawMessages: make(chan message.Receive, 1000), storage: storage, net: net, + params: e2eParams, } sw.RegisterChannel("Auth", switchboard.AnyUser(), message.Raw, m.rawMessages) @@ -89,3 +92,7 @@ func (m *Manager) AddSpecificConfirmCallback(id *id.ID, cb interfaces.ConfirmCal func (m *Manager) RemoveSpecificConfirmCallback(id *id.ID) { m.confirmCallbacks.RemoveSpecific(id) } + +func (m *Manager) GetE2EParams() params.E2ESessionParams { + return m.params +} diff --git a/interfaces/networkManager.go b/interfaces/networkManager.go index 541dc5b147d64440b3507ec28f72f735086cd37b..b7cbd7383a51294373e9bbaa0928b96dfd2b079a 100644 --- a/interfaces/networkManager.go +++ b/interfaces/networkManager.go @@ -25,6 +25,7 @@ type NetworkManager interface { GetHealthTracker() HealthTracker Follow() (stoppable.Stoppable, error) CheckGarbledMessages() + GetE2EParams() params.E2ESessionParams } //for use in key exchange which needs to be callable inside of network diff --git a/interfaces/params/E2E.go b/interfaces/params/E2E.go index 7a2e38428cfcf7c60604ad4445ec80e9ba680145..cb328ed014e2df988a9b6ff779ee4e6ce91cc040 100644 --- a/interfaces/params/E2E.go +++ b/interfaces/params/E2E.go @@ -10,6 +10,7 @@ package params import ( "encoding/json" "fmt" + "gitlab.com/elixxir/crypto/e2e" ) type E2E struct { @@ -55,3 +56,42 @@ func (st SendType) String() string { return fmt.Sprintf("Unknown SendType %v", uint8(st)) } } + +// Network E2E Params + +// DEFAULT KEY GENERATION PARAMETERS +// Hardcoded limits for keys +// With 16 receiving states we can hold +// 16*64=1024 dirty bits for receiving keys +// With that limit, and setting maxKeys to 800, +// we need a Threshold of 224, and a scalar +// smaller than 1.28 to ensure we never generate +// more than 1024 keys +// With 1 receiving states for ReKeys we can hold +// 64 Rekeys +const ( + minKeys uint16 = 500 + maxKeys uint16 = 800 + ttlScalar float64 = 1.2 // generate 20% extra keys + threshold uint16 = 224 + numReKeys uint16 = 64 +) + +type E2ESessionParams struct { + MinKeys uint16 + MaxKeys uint16 + NumRekeys uint16 + e2e.TTLParams +} + +func GetDefaultE2ESessionParams() E2ESessionParams { + return E2ESessionParams{ + MinKeys: minKeys, + MaxKeys: maxKeys, + NumRekeys: numReKeys, + TTLParams: e2e.TTLParams{ + TTLScalar: ttlScalar, + MinNumKeys: threshold, + }, + } +} diff --git a/interfaces/params/E2E_test.go b/interfaces/params/E2E_test.go index f7d90c4eece73233d37e3941879ccff7bf640f57..a62d3046683aae560e899e6988c23332ff56897c 100644 --- a/interfaces/params/E2E_test.go +++ b/interfaces/params/E2E_test.go @@ -66,3 +66,23 @@ func TestGetE2EParameters_Default(t *testing.T) { t.Errorf("Parameters failed to change! Got %d, Expected %d", q.RoundTries, p.RoundTries) } } + +// Test that the GetDefaultParams function returns the right default data +func Test_GetDefaultParams(t *testing.T) { + p := GetDefaultE2ESessionParams() + if p.MinKeys != minKeys { + t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.MinKeys, minKeys) + } + if p.MaxKeys != maxKeys { + t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.MaxKeys, maxKeys) + } + if p.NumRekeys != numReKeys { + t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.NumRekeys, numReKeys) + } + if p.TTLScalar != ttlScalar { + t.Errorf("MinKeys mismatch\r\tGot: %v\r\tExpected: %v", p.TTLScalar, ttlScalar) + } + if p.MinNumKeys != threshold { + t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.MinNumKeys, threshold) + } +} diff --git a/interfaces/params/network.go b/interfaces/params/network.go index 75e7aa4e4dd04d8a8a9d33f253d95eac8ae44e67..f3de8ea10ee17e5408c2b72d335e8b2ea884e428 100644 --- a/interfaces/params/network.go +++ b/interfaces/params/network.go @@ -25,6 +25,8 @@ type Network struct { Rounds Messages Rekey + + E2EParams E2ESessionParams } func GetDefaultNetwork() Network { @@ -33,6 +35,7 @@ func GetDefaultNetwork() Network { MaxCheckedRounds: 500, RegNodesBufferLen: 500, NetworkHealthTimeout: 30 * time.Second, + E2EParams: GetDefaultE2ESessionParams(), } n.Rounds = GetDefaultRounds() n.Messages = GetDefaultMessage() diff --git a/keyExchange/confirm_test.go b/keyExchange/confirm_test.go index 188a58686d72ba9ae8d306002f6229173b017db6..b2e619c684c0985ded4887178113ade1d489af1d 100644 --- a/keyExchange/confirm_test.go +++ b/keyExchange/confirm_test.go @@ -10,6 +10,7 @@ package keyExchange import ( "github.com/golang/protobuf/proto" "gitlab.com/elixxir/client/interfaces/message" + "gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/storage/e2e" "gitlab.com/xx_network/primitives/id" "testing" @@ -31,7 +32,8 @@ func TestHandleConfirm(t *testing.T) { // Add bob as a partner aliceSession.E2e().AddPartner(bobID, bobPubKey, alicePrivKey, - e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) + params.GetDefaultE2ESessionParams(), + params.GetDefaultE2ESessionParams()) // Generate a session ID, bypassing some business logic here sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup) diff --git a/keyExchange/exchange_test.go b/keyExchange/exchange_test.go index 40265bc30389f6c81bc91c188af9978f4e44c743..2c1729995c28d528c19ffe88a92ae425d2b57e0d 100644 --- a/keyExchange/exchange_test.go +++ b/keyExchange/exchange_test.go @@ -49,9 +49,11 @@ func TestFullExchange(t *testing.T) { // Add Alice and Bob as partners aliceSession.E2e().AddPartner(exchangeBobId, bobPubKey, alicePrivKey, - e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) + params.GetDefaultE2ESessionParams(), + params.GetDefaultE2ESessionParams()) bobSession.E2e().AddPartner(exchangeAliceId, alicePubKey, bobPrivKey, - e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) + params.GetDefaultE2ESessionParams(), + params.GetDefaultE2ESessionParams()) // Start the listeners for alice and bob rekeyParams := params.GetDefaultRekey() diff --git a/keyExchange/rekey.go b/keyExchange/rekey.go index 8391f2653ebca789d875f4f79044ac67af91cacd..389caaad38eb711d5ced93bfb4cd1f16bdc7e0ea 100644 --- a/keyExchange/rekey.go +++ b/keyExchange/rekey.go @@ -49,7 +49,7 @@ func trigger(instance *network.Instance, sendE2E interfaces.SendE2E, fmt.Printf("in new session triggered\n") //create the session, pass a nil private key to generate a new one negotiatingSession = manager.NewSendSession(nil, - e2e.GetDefaultSessionParams()) + session.GetE2EParams()) //move the state of the triggering session forward session.SetNegotiationStatus(e2e.NewSessionCreated) fmt.Printf("after setting session: %v\n", negotiatingSession.NegotiationStatus()) diff --git a/keyExchange/trigger.go b/keyExchange/trigger.go index 5019dc05f936b85bea9a9f2d19bb436f8f199032..cd77c5e4d1be1286b9c488b8b378c1ac2c0a0ada 100644 --- a/keyExchange/trigger.go +++ b/keyExchange/trigger.go @@ -81,7 +81,7 @@ func handleTrigger(sess *storage.Session, net interfaces.NetworkManager, //create the new session session, duplicate := partner.NewReceiveSession(PartnerPublicKey, - e2e.GetDefaultSessionParams(), oldSession) + params.GetDefaultE2ESessionParams(), oldSession) // new session being nil means the session was a duplicate. This is possible // in edge cases where the partner crashes during operation. The session // creation in this case ignores the new session, but the confirmation diff --git a/keyExchange/trigger_test.go b/keyExchange/trigger_test.go index 60c7b4c65e4137ffab880498030b68ca845f1ccf..c69e09562bd10bbe998855c33f3c765b7f0ed085 100644 --- a/keyExchange/trigger_test.go +++ b/keyExchange/trigger_test.go @@ -38,8 +38,8 @@ func TestHandleTrigger(t *testing.T) { // Add bob as a partner aliceSession.E2e().AddPartner(bobID, bobSession.E2e().GetDHPublicKey(), - alicePrivKey, e2e.GetDefaultSessionParams(), - e2e.GetDefaultSessionParams()) + alicePrivKey, params.GetDefaultE2ESessionParams(), + params.GetDefaultE2ESessionParams()) // Generate a session ID, bypassing some business logic here oldSessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup) diff --git a/keyExchange/utils_test.go b/keyExchange/utils_test.go index 4fc72a604e50891d56c748a9c84272b7e7c1b2aa..927cdf958a7bb6983afdcdc79d6b6b4939347071 100644 --- a/keyExchange/utils_test.go +++ b/keyExchange/utils_test.go @@ -98,6 +98,10 @@ func (t *testNetworkManagerGeneric) GetStoppable() stoppable.Stoppable { return &stoppable.Multi{} } +func (t *testNetworkManagerGeneric) GetE2EParams() params.E2ESessionParams { + return params.GetDefaultE2ESessionParams() +} + func InitTestingContextGeneric(i interface{}) (*storage.Session, interfaces.NetworkManager) { switch i.(type) { case *testing.T: @@ -147,6 +151,10 @@ func (t *testNetworkManagerFullExchange) CheckGarbledMessages() { return } +func (t *testNetworkManagerFullExchange) GetE2EParams() params.E2ESessionParams { + return params.GetDefaultE2ESessionParams() +} + // Intended for alice to send to bob. Trigger's Bob's confirmation, chaining the operation // together func (t *testNetworkManagerFullExchange) SendE2E(m message.Send, p params.E2E) ( diff --git a/network/manager.go b/network/manager.go index fff66d50055f45ad80cbe27c9dd6b0542d7141bf..51e10f29d51985f88304be71ee63a5166e38ed98 100644 --- a/network/manager.go +++ b/network/manager.go @@ -46,7 +46,8 @@ type manager struct { message *message.Manager //atomic denotes if the network is running - running *uint32 + running *uint32 + e2eParams params.E2ESessionParams } // NewManager builds a new reception manager object using inputted key fields @@ -154,3 +155,7 @@ func (m *manager) GetInstance() *network.Instance { func (m *manager) CheckGarbledMessages() { m.message.CheckGarbledMessages() } + +func (m *manager) GetE2EParams() params.E2ESessionParams { + return m.e2eParams +} diff --git a/network/message/garbled_test.go b/network/message/garbled_test.go index b59fded2594341bb41003f7e6ad84b899320464b..aa6517a55f21bab2b9d1522f3b80f3da8ebc4aa2 100644 --- a/network/message/garbled_test.go +++ b/network/message/garbled_test.go @@ -7,7 +7,6 @@ import ( "gitlab.com/elixxir/client/network/internal" "gitlab.com/elixxir/client/network/message/parse" "gitlab.com/elixxir/client/storage" - "gitlab.com/elixxir/client/storage/e2e" "gitlab.com/elixxir/client/switchboard" "gitlab.com/elixxir/comms/client" "gitlab.com/elixxir/crypto/fastRNG" @@ -65,13 +64,18 @@ func TestManager_CheckGarbledMessages(t *testing.T) { }, nil) e2ekv := i.Session.E2e() - err = e2ekv.AddPartner(sess2.GetUser().ID, sess2.E2e().GetDHPublicKey(), e2ekv.GetDHPrivateKey(), e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) + err = e2ekv.AddPartner(sess2.GetUser().ID, sess2.E2e().GetDHPublicKey(), e2ekv.GetDHPrivateKey(), + params.GetDefaultE2ESessionParams(), + params.GetDefaultE2ESessionParams()) if err != nil { t.Errorf("Failed to add e2e partner: %+v", err) t.FailNow() } - err = sess2.E2e().AddPartner(sess1.GetUser().ID, sess1.E2e().GetDHPublicKey(), sess2.E2e().GetDHPrivateKey(), e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) + err = sess2.E2e().AddPartner(sess1.GetUser().ID, + sess1.E2e().GetDHPublicKey(), sess2.E2e().GetDHPrivateKey(), + params.GetDefaultE2ESessionParams(), + params.GetDefaultE2ESessionParams()) if err != nil { t.Errorf("Failed to add e2e partner: %+v", err) t.FailNow() diff --git a/storage/e2e/manager.go b/storage/e2e/manager.go index 5ca2dd58ef76b97aa98ee2afc8806eb0fc2f93dd..8faa45a08c635cfe357843be69ceca34f8af8eb2 100644 --- a/storage/e2e/manager.go +++ b/storage/e2e/manager.go @@ -38,7 +38,8 @@ type Manager struct { // newManager creates the relationship and its first Send and Receive sessions. func newManager(ctx *context, kv *versioned.KV, partnerID *id.ID, myPrivKey, - partnerPubKey *cyclic.Int, sendParams, receiveParams SessionParams) *Manager { + partnerPubKey *cyclic.Int, + sendParams, receiveParams params.E2ESessionParams) *Manager { kv = kv.Prefix(fmt.Sprintf(managerPrefix, partnerID)) @@ -112,7 +113,7 @@ func loadManager(ctx *context, kv *versioned.KV, partnerID *id.ID) (*Manager, er // session already exists, then it will not be overwritten and the extant // session will be returned with the bool set to true denoting a duplicate. This // allows for support of duplicate key exchange triggering. -func (m *Manager) NewReceiveSession(partnerPubKey *cyclic.Int, params SessionParams, +func (m *Manager) NewReceiveSession(partnerPubKey *cyclic.Int, e2eParams params.E2ESessionParams, source *Session) (*Session, bool) { // Check if the session already exists @@ -125,7 +126,7 @@ func (m *Manager) NewReceiveSession(partnerPubKey *cyclic.Int, params SessionPar // Add the session to the buffer session := m.receive.AddSession(source.myPrivKey, partnerPubKey, baseKey, - source.GetID(), params) + source.GetID(), e2eParams) return session, false } @@ -133,13 +134,13 @@ func (m *Manager) NewReceiveSession(partnerPubKey *cyclic.Int, params SessionPar // NewSendSession creates a new Receive session using the latest public key // received from the partner and a new private key for the user. Passing in a // private key is optional. A private key will be generated if none is passed. -func (m *Manager) NewSendSession(myPrivKey *cyclic.Int, params SessionParams) *Session { +func (m *Manager) NewSendSession(myPrivKey *cyclic.Int, e2eParams params.E2ESessionParams) *Session { // Find the latest public key from the other party sourceSession := m.receive.getNewestRekeyableSession() // Add the session to the Send session buffer and return return m.send.AddSession(myPrivKey, sourceSession.partnerPubKey, nil, - sourceSession.GetID(), params) + sourceSession.GetID(), e2eParams) } // GetKeyForSending gets the correct session to Send with depending on the type diff --git a/storage/e2e/manager_test.go b/storage/e2e/manager_test.go index ad58f483bf0cc3efb326a783438a2a14959d184e..58b0ca6bb6c5b846abc994b8c5f43e90819be664 100644 --- a/storage/e2e/manager_test.go +++ b/storage/e2e/manager_test.go @@ -33,12 +33,15 @@ func Test_newManager(t *testing.T) { originPartnerPubKey: s.partnerPubKey, originMyPrivKey: s.myPrivKey, } - expectedM.send = NewRelationship(expectedM, Send, GetDefaultSessionParams()) - expectedM.receive = NewRelationship(expectedM, Receive, GetDefaultSessionParams()) + expectedM.send = NewRelationship(expectedM, Send, + params.GetDefaultE2ESessionParams()) + expectedM.receive = NewRelationship(expectedM, Receive, + params.GetDefaultE2ESessionParams()) // Create new relationship - m := newManager(ctx, kv, partnerID, s.myPrivKey, s.partnerPubKey, s.params, - s.params) + m := newManager(ctx, kv, partnerID, s.myPrivKey, s.partnerPubKey, + s.e2eParams, + s.e2eParams) // Check if the new relationship matches the expected if !managersEqual(expectedM, m, t) { @@ -71,7 +74,7 @@ func TestManager_NewReceiveSession(t *testing.T) { m, _ := newTestManager(t) s, _ := makeTestSession() - se, exists := m.NewReceiveSession(s.partnerPubKey, s.params, s) + se, exists := m.NewReceiveSession(s.partnerPubKey, s.e2eParams, s) if exists { t.Errorf("NewReceiveSession() did not return the correct value."+ "\n\texpected: %v\n\treceived: %v", false, exists) @@ -83,7 +86,7 @@ func TestManager_NewReceiveSession(t *testing.T) { m.partner, se.GetPartner(), s.GetID(), se.GetID()) } - se, exists = m.NewReceiveSession(s.partnerPubKey, s.params, s) + se, exists = m.NewReceiveSession(s.partnerPubKey, s.e2eParams, s) if !exists { t.Errorf("NewReceiveSession() did not return the correct value."+ "\n\texpected: %v\n\treceived: %v", true, exists) @@ -102,14 +105,14 @@ func TestManager_NewSendSession(t *testing.T) { m, _ := newTestManager(t) s, _ := makeTestSession() - se := m.NewSendSession(s.myPrivKey, s.params) + se := m.NewSendSession(s.myPrivKey, s.e2eParams) if !m.partner.Cmp(se.GetPartner()) { t.Errorf("NewSendSession() did not return the correct session."+ "\n\texpected partner: %v\n\treceived partner: %v", m.partner, se.GetPartner()) } - se = m.NewSendSession(s.partnerPubKey, s.params) + se = m.NewSendSession(s.partnerPubKey, s.e2eParams) if !m.partner.Cmp(se.GetPartner()) { t.Errorf("NewSendSession() did not return the correct session."+ "\n\texpected partner: %v\n\treceived partner: %v", @@ -238,8 +241,9 @@ func newTestManager(t *testing.T) (*Manager, *versioned.KV) { prng.Uint64(), prng.Uint64()}, id.User, t) // Create new relationship - m := newManager(ctx, kv, partnerID, s.myPrivKey, s.partnerPubKey, s.params, - s.params) + m := newManager(ctx, kv, partnerID, s.myPrivKey, s.partnerPubKey, + s.e2eParams, + s.e2eParams) return m, kv } diff --git a/storage/e2e/params.go b/storage/e2e/params.go deleted file mode 100644 index f06484a3d8ccc2fd4a207f1abd10a6042f417283..0000000000000000000000000000000000000000 --- a/storage/e2e/params.go +++ /dev/null @@ -1,47 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package e2e - -import "gitlab.com/elixxir/crypto/e2e" - -// DEFAULT KEY GENERATION PARAMETERS -// Hardcoded limits for keys -// With 16 receiving states we can hold -// 16*64=1024 dirty bits for receiving keys -// With that limit, and setting maxKeys to 800, -// we need a Threshold of 224, and a scalar -// smaller than 1.28 to ensure we never generate -// more than 1024 keys -// With 1 receiving states for ReKeys we can hold -// 64 Rekeys -const ( - minKeys uint16 = 500 - maxKeys uint16 = 800 - ttlScalar float64 = 1.2 // generate 20% extra keys - threshold uint16 = 224 - numReKeys uint16 = 64 -) - -type SessionParams struct { - MinKeys uint16 - MaxKeys uint16 - NumRekeys uint16 - e2e.TTLParams -} - -func GetDefaultSessionParams() SessionParams { - return SessionParams{ - MinKeys: minKeys, - MaxKeys: maxKeys, - NumRekeys: numReKeys, - TTLParams: e2e.TTLParams{ - TTLScalar: ttlScalar, - MinNumKeys: threshold, - }, - } -} diff --git a/storage/e2e/params_test.go b/storage/e2e/params_test.go deleted file mode 100644 index bf92604d3d42368910a53d25f732f8041a1e25d5..0000000000000000000000000000000000000000 --- a/storage/e2e/params_test.go +++ /dev/null @@ -1,32 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package e2e - -// Testing file for the params.go functions - -import "testing" - -// Test that the GetDefaultParams function returns the right default data -func Test_GetDefaultParams(t *testing.T) { - p := GetDefaultSessionParams() - if p.MinKeys != minKeys { - t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.MinKeys, minKeys) - } - if p.MaxKeys != maxKeys { - t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.MaxKeys, maxKeys) - } - if p.NumRekeys != numReKeys { - t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.NumRekeys, numReKeys) - } - if p.TTLScalar != ttlScalar { - t.Errorf("MinKeys mismatch\r\tGot: %v\r\tExpected: %v", p.TTLScalar, ttlScalar) - } - if p.MinNumKeys != threshold { - t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.MinNumKeys, threshold) - } -} diff --git a/storage/e2e/relationship.go b/storage/e2e/relationship.go index 77effe1661faacafae281fb4b011d1fe8e2367d6..167abcdaff6044361a1bd5ef0b9039074f7fe47e 100644 --- a/storage/e2e/relationship.go +++ b/storage/e2e/relationship.go @@ -11,6 +11,7 @@ import ( "encoding/json" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/crypto/cyclic" "sync" @@ -39,7 +40,7 @@ type relationship struct { } func NewRelationship(manager *Manager, t RelationshipType, - initialParams SessionParams) *relationship { + initialParams params.E2ESessionParams) *relationship { kv := manager.kv.Prefix(t.prefix()) @@ -167,12 +168,12 @@ func (r *relationship) unmarshal(b []byte) error { } func (r *relationship) AddSession(myPrivKey, partnerPubKey, baseKey *cyclic.Int, - trigger SessionID, params SessionParams) *Session { + trigger SessionID, e2eParams params.E2ESessionParams) *Session { r.mux.Lock() defer r.mux.Unlock() s := newSession(r, r.t, myPrivKey, partnerPubKey, baseKey, trigger, - r.fingerprint, params) + r.fingerprint, e2eParams) r.addSession(s) if err := r.save(); err != nil { diff --git a/storage/e2e/relationship_test.go b/storage/e2e/relationship_test.go index 5c5f262079ecadf7a53b374b9e8b930470229667..fe8b67d0d91063f1fd89751cd499c93469297887 100644 --- a/storage/e2e/relationship_test.go +++ b/storage/e2e/relationship_test.go @@ -9,6 +9,7 @@ package e2e import ( "bytes" + "gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/ekv" "gitlab.com/xx_network/primitives/id" @@ -19,7 +20,7 @@ import ( // Subtest: unmarshal/marshal with one session in the buff func TestRelationship_MarshalUnmarshal(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) // Serialization should include session slice only serialized, err := sb.marshal() @@ -49,7 +50,7 @@ func TestRelationship_MarshalUnmarshal(t *testing.T) { // Shows that Relationship returns an equivalent session buff to the one that was saved func TestLoadRelationship(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) err := sb.save() if err != nil { @@ -69,7 +70,7 @@ func TestLoadRelationship(t *testing.T) { // Shows that Relationship returns a valid session buff func TestNewRelationshipBuff(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) if mgr != sb.manager { t.Error("managers should be identical") } @@ -86,7 +87,7 @@ func TestNewRelationshipBuff(t *testing.T) { // Shows that AddSession adds one session to the relationship func TestRelationship_AddSession(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) if len(sb.sessions) != 1 { t.Error("starting session slice length should be 1") } @@ -99,7 +100,7 @@ func TestRelationship_AddSession(t *testing.T) { // should have been created using the same relationship (which is not the case in // this test.) sb.AddSession(session.myPrivKey, session.partnerPubKey, nil, - session.partnerSource, session.params) + session.partnerSource, session.e2eParams) if len(sb.sessions) != 2 { t.Error("ending session slice length should be 2") } @@ -114,7 +115,7 @@ func TestRelationship_AddSession(t *testing.T) { // GetNewest should get the session that was most recently added to the buff func TestRelationship_GetNewest(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) // The newest session should be nil upon session buffer creation nilSession := sb.GetNewest() if nilSession == nil { @@ -124,14 +125,14 @@ func TestRelationship_GetNewest(t *testing.T) { session, _ := makeTestSession() sb.AddSession(session.myPrivKey, session.partnerPubKey, nil, - session.partnerSource, session.params) + session.partnerSource, session.e2eParams) if session.GetID() != sb.GetNewest().GetID() { t.Error("session added should have same ID") } session2, _ := makeTestSession() sb.AddSession(session2.myPrivKey, session2.partnerPubKey, nil, - session2.partnerSource, session2.params) + session2.partnerSource, session.e2eParams) if session2.GetID() != sb.GetNewest().GetID() { t.Error("session added should have same ID") } @@ -141,11 +142,11 @@ func TestRelationship_GetNewest(t *testing.T) { // Shows that Confirm confirms the specified session in the buff func TestRelationship_Confirm(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) session, _ := makeTestSession() sb.AddSession(session.myPrivKey, session.partnerPubKey, nil, - session.partnerSource, session.params) + session.partnerSource, session.e2eParams) sb.sessions[1].negotiationStatus = Sent if sb.sessions[1].IsConfirmed() { @@ -165,7 +166,7 @@ func TestRelationship_Confirm(t *testing.T) { // Shows that the session buff returns an error when the session doesn't exist func TestRelationship_Confirm_Err(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) session, _ := makeTestSession() err := sb.Confirm(session.GetID()) @@ -177,10 +178,10 @@ func TestRelationship_Confirm_Err(t *testing.T) { // Shows that a session can get got by ID from the buff func TestRelationship_GetByID(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) session, _ := makeTestSession() session = sb.AddSession(session.myPrivKey, session.partnerPubKey, nil, - session.partnerSource, session.params) + session.partnerSource, session.e2eParams) session2 := sb.GetByID(session.GetID()) if !reflect.DeepEqual(session, session2) { t.Error("gotten session should be the same") @@ -191,7 +192,7 @@ func TestRelationship_GetByID(t *testing.T) { // returning sessions that are confirmed and past ttl func TestRelationship_GetNewestRekeyableSession(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) sb.sessions[0].negotiationStatus = Unconfirmed // no available rekeyable sessions: nil session2 := sb.getNewestRekeyableSession() @@ -202,7 +203,7 @@ func TestRelationship_GetNewestRekeyableSession(t *testing.T) { // add a rekeyable session: that session session, _ := makeTestSession() sb.AddSession(session.myPrivKey, session.partnerPubKey, session.baseKey, - session.partnerSource, session.params) + session.partnerSource, session.e2eParams) sb.sessions[0].negotiationStatus = Confirmed session3 := sb.getNewestRekeyableSession() @@ -217,7 +218,7 @@ func TestRelationship_GetNewestRekeyableSession(t *testing.T) { additionalSession, _ := makeTestSession() sb.AddSession(additionalSession.myPrivKey, additionalSession.partnerPubKey, additionalSession.partnerPubKey, additionalSession.partnerSource, - additionalSession.params) + additionalSession.e2eParams) sb.sessions[0].negotiationStatus = Confirmed @@ -243,7 +244,7 @@ func TestRelationship_GetNewestRekeyableSession(t *testing.T) { // Shows that GetSessionForSending follows the hierarchy of sessions correctly func TestRelationship_GetSessionForSending(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) sb.sessions = make([]*Session, 0) sb.sessionByID = make(map[SessionID]*Session) @@ -258,7 +259,7 @@ func TestRelationship_GetSessionForSending(t *testing.T) { sb.AddSession(unconfirmedRekey.myPrivKey, unconfirmedRekey.partnerPubKey, unconfirmedRekey.partnerPubKey, unconfirmedRekey.partnerSource, - unconfirmedRekey.params) + unconfirmedRekey.e2eParams) sb.sessions[0].negotiationStatus = Unconfirmed sb.sessions[0].keyState.numAvailable = 600 sending := sb.getSessionForSending() @@ -271,7 +272,7 @@ func TestRelationship_GetSessionForSending(t *testing.T) { sb.AddSession(unconfirmedActive.myPrivKey, unconfirmedActive.partnerPubKey, unconfirmedActive.partnerPubKey, unconfirmedActive.partnerSource, - unconfirmedActive.params) + unconfirmedActive.e2eParams) sb.sessions[0].negotiationStatus = Unconfirmed sb.sessions[0].keyState.numAvailable = 2000 sending = sb.getSessionForSending() @@ -284,7 +285,7 @@ func TestRelationship_GetSessionForSending(t *testing.T) { sb.AddSession(confirmedRekey.myPrivKey, confirmedRekey.partnerPubKey, confirmedRekey.partnerPubKey, confirmedRekey.partnerSource, - confirmedRekey.params) + confirmedRekey.e2eParams) sb.sessions[0].negotiationStatus = Confirmed sb.sessions[0].keyState.numAvailable = 600 sending = sb.getSessionForSending() @@ -296,7 +297,7 @@ func TestRelationship_GetSessionForSending(t *testing.T) { confirmedActive, _ := makeTestSession() sb.AddSession(confirmedActive.myPrivKey, confirmedActive.partnerPubKey, confirmedActive.partnerPubKey, confirmedActive.partnerSource, - confirmedActive.params) + confirmedActive.e2eParams) sb.sessions[0].negotiationStatus = Confirmed sb.sessions[0].keyState.numAvailable = 2000 @@ -309,7 +310,7 @@ func TestRelationship_GetSessionForSending(t *testing.T) { // Shows that GetKeyForRekey returns a key if there's an appropriate session for rekeying func TestSessionBuff_GetKeyForRekey(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) sb.sessions = make([]*Session, 0) sb.sessionByID = make(map[SessionID]*Session) @@ -326,7 +327,7 @@ func TestSessionBuff_GetKeyForRekey(t *testing.T) { session, _ := makeTestSession() sb.AddSession(session.myPrivKey, session.partnerPubKey, session.partnerPubKey, session.partnerSource, - session.params) + session.e2eParams) sb.sessions[0].negotiationStatus = Confirmed key, err = sb.getKeyForRekey() if err != nil { @@ -340,7 +341,7 @@ func TestSessionBuff_GetKeyForRekey(t *testing.T) { // Shows that GetKeyForSending returns a key if there's an appropriate session for sending func TestSessionBuff_GetKeyForSending(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) sb.sessions = make([]*Session, 0) sb.sessionByID = make(map[SessionID]*Session) @@ -357,7 +358,7 @@ func TestSessionBuff_GetKeyForSending(t *testing.T) { session, _ := makeTestSession() sb.AddSession(session.myPrivKey, session.partnerPubKey, session.partnerPubKey, session.partnerSource, - session.params) + session.e2eParams) key, err = sb.getKeyForSending() if err != nil { t.Error(err) @@ -370,14 +371,14 @@ func TestSessionBuff_GetKeyForSending(t *testing.T) { // Shows that TriggerNegotiation sets up for negotiation correctly func TestSessionBuff_TriggerNegotiation(t *testing.T) { mgr := makeTestRelationshipManager(t) - sb := NewRelationship(mgr, Send, GetDefaultSessionParams()) + sb := NewRelationship(mgr, Send, params.GetDefaultE2ESessionParams()) sb.sessions = make([]*Session, 0) sb.sessionByID = make(map[SessionID]*Session) session, _ := makeTestSession() session = sb.AddSession(session.myPrivKey, session.partnerPubKey, session.partnerPubKey, session.partnerSource, - session.params) + session.e2eParams) session.negotiationStatus = Confirmed // The added session isn't ready for rekey so it's not returned here negotiations := sb.TriggerNegotiation() @@ -388,7 +389,7 @@ func TestSessionBuff_TriggerNegotiation(t *testing.T) { // Make only a few keys available to trigger the ttl session2 = sb.AddSession(session2.myPrivKey, session2.partnerPubKey, session2.partnerPubKey, session2.partnerSource, - session2.params) + session2.e2eParams) session2.keyState.numAvailable = 4 session2.negotiationStatus = Confirmed negotiations = sb.TriggerNegotiation() @@ -410,7 +411,7 @@ func TestSessionBuff_TriggerNegotiation(t *testing.T) { session3 = sb.AddSession(session3.myPrivKey, session3.partnerPubKey, session3.partnerPubKey, session3.partnerSource, - session3.params) + session3.e2eParams) session3.negotiationStatus = Unconfirmed // Set session 2 status back to Confirmed to show that more than one session can be returned diff --git a/storage/e2e/session.go b/storage/e2e/session.go index bcea1ff782e45d742dd1a7429e7df4f9a90983f6..f5d37b2d4510307576921dda68422f681e283546 100644 --- a/storage/e2e/session.go +++ b/storage/e2e/session.go @@ -13,6 +13,7 @@ import ( "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/globals" + "gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/crypto/cyclic" dh "gitlab.com/elixxir/crypto/diffieHellman" @@ -34,7 +35,7 @@ type Session struct { //prefixed kv kv *versioned.KV //params - params SessionParams + e2eParams params.E2ESessionParams //type t RelationshipType @@ -70,7 +71,7 @@ type Session struct { // must be exported // Utility struct to write part of session data to disk type SessionDisk struct { - Params SessionParams + E2EParams params.E2ESessionParams //session type Type uint8 @@ -97,7 +98,7 @@ type SessionDisk struct { //Generator which creates all keys and structures func newSession(ship *relationship, t RelationshipType, myPrivKey, partnerPubKey, baseKey *cyclic.Int, trigger SessionID, relationshipFingerprint []byte, - params SessionParams) *Session { + e2eParams params.E2ESessionParams) *Session { confirmation := Unconfirmed if t == Receive { @@ -105,7 +106,7 @@ func newSession(ship *relationship, t RelationshipType, myPrivKey, partnerPubKey } session := &Session{ - params: params, + e2eParams: e2eParams, relationship: ship, t: t, myPrivKey: myPrivKey, @@ -271,7 +272,7 @@ func (s *Session) GetPartner() *id.ID { func (s *Session) marshal() ([]byte, error) { sd := SessionDisk{} - sd.Params = s.params + sd.E2EParams = s.e2eParams sd.Type = uint8(s.t) sd.BaseKey = s.baseKey.Bytes() sd.MyPrivKey = s.myPrivKey.Bytes() @@ -306,7 +307,7 @@ func (s *Session) unmarshal(b []byte) error { grp := s.relationship.manager.ctx.grp - s.params = sd.Params + s.e2eParams = sd.E2EParams s.t = RelationshipType(sd.Type) s.baseKey = grp.NewIntFromBytes(sd.BaseKey) s.myPrivKey = grp.NewIntFromBytes(sd.MyPrivKey) @@ -328,7 +329,7 @@ func (s *Session) unmarshal(b []byte) error { // Pops the first unused key, skipping any which are denoted as used. // will return if the remaining keys are designated as rekeys func (s *Session) PopKey() (*Key, error) { - if s.keyState.GetNumAvailable() <= uint32(s.params.NumRekeys) { + if s.keyState.GetNumAvailable() <= uint32(s.e2eParams.NumRekeys) { return nil, errors.New("no more keys left, remaining reserved " + "for rekey") } @@ -362,7 +363,7 @@ func (s *Session) Status() Status { if numAvailable == 0 { return RekeyEmpty - } else if numAvailable <= uint32(s.params.NumRekeys) { + } else if numAvailable <= uint32(s.e2eParams.NumRekeys) { return Empty // do not need to make a copy of getNumKeys becasue it is static and // only used once @@ -546,13 +547,15 @@ func (s *Session) generate(kv *versioned.KV) *versioned.KV { kv = kv.Prefix(makeSessionPrefix(s.GetID())) + p := s.e2eParams + //generate ttl and keying info keysTTL, numKeys := e2e.GenerateKeyTTL(s.baseKey.GetLargeInt(), - s.params.MinKeys, s.params.MaxKeys, s.params.TTLParams) + p.MinKeys, p.MaxKeys, p.TTLParams) //ensure that enough keys are remaining to rekey - if numKeys-uint32(keysTTL) < uint32(s.params.NumRekeys) { - numKeys = uint32(keysTTL + s.params.NumRekeys) + if numKeys-uint32(keysTTL) < uint32(p.NumRekeys) { + numKeys = uint32(keysTTL + p.NumRekeys) } s.ttl = uint32(keysTTL) @@ -592,3 +595,7 @@ func (s *Session) getUnusedKeys() []*Key { func makeSessionPrefix(sid SessionID) string { return fmt.Sprintf(sessionPrefix, sid) } + +func (s *Session) GetE2EParams() params.E2ESessionParams { + return s.e2eParams +} diff --git a/storage/e2e/session_test.go b/storage/e2e/session_test.go index ec3c51bc9e3d261cdb881f5e05e079e936b36268..91a2d53e67bf4308104c8c7c2d044b18c26fe1ac 100644 --- a/storage/e2e/session_test.go +++ b/storage/e2e/session_test.go @@ -9,6 +9,7 @@ package e2e import ( "errors" + "gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/storage/versioned" dh "gitlab.com/elixxir/crypto/diffieHellman" "gitlab.com/elixxir/crypto/fastRNG" @@ -38,7 +39,7 @@ func TestSession_generate_noPrivateKeyReceive(t *testing.T) { //build the session s := &Session{ partnerPubKey: partnerPubKey, - params: GetDefaultSessionParams(), + e2eParams: params.GetDefaultE2ESessionParams(), relationship: &relationship{ manager: &Manager{ctx: ctx}, }, @@ -99,7 +100,7 @@ func TestSession_generate_PrivateKeySend(t *testing.T) { s := &Session{ myPrivKey: myPrivKey, partnerPubKey: partnerPubKey, - params: GetDefaultSessionParams(), + e2eParams: params.GetDefaultE2ESessionParams(), relationship: &relationship{ manager: &Manager{ctx: ctx}, }, @@ -147,7 +148,7 @@ func TestNewSession(t *testing.T) { // Make a new session with the variables we got from makeTestSession sessionB := newSession(sessionA.relationship, sessionA.t, sessionA.myPrivKey, sessionA.partnerPubKey, sessionA.baseKey, sessionA.GetID(), []byte(""), - sessionA.params) + sessionA.e2eParams) err := cmpSerializedFields(sessionA, sessionB) if err != nil { @@ -252,19 +253,19 @@ func cmpSerializedFields(a *Session, b *Session) error { if a.t != b.t { return errors.New("t differed") } - if a.params.MaxKeys != b.params.MaxKeys { + if a.e2eParams.MaxKeys != b.e2eParams.MaxKeys { return errors.New("maxKeys differed") } - if a.params.MinKeys != b.params.MinKeys { + if a.e2eParams.MinKeys != b.e2eParams.MinKeys { return errors.New("minKeys differed") } - if a.params.NumRekeys != b.params.NumRekeys { + if a.e2eParams.NumRekeys != b.e2eParams.NumRekeys { return errors.New("numRekeys differed") } - if a.params.MinNumKeys != b.params.MinNumKeys { + if a.e2eParams.MinNumKeys != b.e2eParams.MinNumKeys { return errors.New("minNumKeys differed") } - if a.params.TTLScalar != b.params.TTLScalar { + if a.e2eParams.TTLScalar != b.e2eParams.TTLScalar { return errors.New("ttlScalar differed") } if a.baseKey.Cmp(b.baseKey) != 0 { @@ -621,7 +622,7 @@ func makeTestSession() (*Session, *context) { baseKey: baseKey, myPrivKey: myPrivKey, partnerPubKey: partnerPubKey, - params: GetDefaultSessionParams(), + e2eParams: params.GetDefaultE2ESessionParams(), relationship: &relationship{ manager: &Manager{ ctx: ctx, diff --git a/storage/e2e/store.go b/storage/e2e/store.go index 03d0abac178c99410462d84e920cf3c7564b2a06..9144d1bc3d6c986f8e6bce9c11bf79a6dc9b2b63 100644 --- a/storage/e2e/store.go +++ b/storage/e2e/store.go @@ -11,6 +11,7 @@ import ( "encoding/json" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/storage/utility" "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/crypto/cyclic" @@ -154,7 +155,7 @@ func (s *Store) save() error { } func (s *Store) AddPartner(partnerID *id.ID, partnerPubKey, myPrivKey *cyclic.Int, - sendParams, receiveParams SessionParams) error { + sendParams, receiveParams params.E2ESessionParams) error { s.mux.Lock() defer s.mux.Unlock() diff --git a/storage/e2e/store_test.go b/storage/e2e/store_test.go index fccb11fe3a0d5bb2c8f94597d7e4a25e43532b2c..5d4f1c00f49e52ef5299f1752386723a37bbf2fb 100644 --- a/storage/e2e/store_test.go +++ b/storage/e2e/store_test.go @@ -9,6 +9,7 @@ package e2e import ( "bytes" + "gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/diffieHellman" @@ -90,7 +91,7 @@ func TestStore_AddPartner(t *testing.T) { s, _, _ := makeTestStore() partnerID := id.NewIdFromUInt(rand.Uint64(), id.User, t) pubKey := diffieHellman.GeneratePublicKey(s.dhPrivateKey, s.grp) - p := GetDefaultSessionParams() + p := params.GetDefaultE2ESessionParams() expectedManager := newManager(s.context, s.kv, partnerID, s.dhPrivateKey, pubKey, p, p) @@ -112,7 +113,7 @@ func TestStore_GetPartner(t *testing.T) { s, _, _ := makeTestStore() partnerID := id.NewIdFromUInt(rand.Uint64(), id.User, t) pubKey := diffieHellman.GeneratePublicKey(s.dhPrivateKey, s.grp) - p := GetDefaultSessionParams() + p := params.GetDefaultE2ESessionParams() expectedManager := newManager(s.context, s.kv, partnerID, s.dhPrivateKey, pubKey, p, p) s.AddPartner(partnerID, pubKey, s.dhPrivateKey, p, p) diff --git a/storage/utility/e2eMessageBuffer.go b/storage/utility/e2eMessageBuffer.go index 28537e09883c5b1873e4e5131e0b25974d9b88c2..045175c8fd752ef790f4ded0c98d26f1107fdf2b 100644 --- a/storage/utility/e2eMessageBuffer.go +++ b/storage/utility/e2eMessageBuffer.go @@ -16,6 +16,7 @@ import ( "gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/xx_network/primitives/id" + "time" ) diff --git a/ud/lookup_test.go b/ud/lookup_test.go index d732c7004f8f0bdf9f35291006cf08b93ae10b91..fcfebdab93595033e332d7cd3a4fc5ca9944ba39 100644 --- a/ud/lookup_test.go +++ b/ud/lookup_test.go @@ -37,7 +37,7 @@ func TestManager_Lookup(t *testing.T) { udID: &id.UDB, inProgressLookup: map[uint64]chan *LookupResponse{}, net: newTestNetworkManager(t), - registered: &isReg, + registered: &isReg, } // Generate callback function @@ -125,7 +125,7 @@ func TestManager_Lookup_CallbackError(t *testing.T) { udID: &id.UDB, inProgressLookup: map[uint64]chan *LookupResponse{}, net: newTestNetworkManager(t), - registered: &isReg, + registered: &isReg, } // Generate callback function @@ -188,7 +188,7 @@ func TestManager_Lookup_EventChanTimeout(t *testing.T) { udID: &id.UDB, inProgressLookup: map[uint64]chan *LookupResponse{}, net: newTestNetworkManager(t), - registered: &isReg, + registered: &isReg, } // Generate callback function @@ -241,7 +241,7 @@ func TestManager_lookupProcess(t *testing.T) { udID: &id.UDB, inProgressLookup: map[uint64]chan *LookupResponse{}, net: newTestNetworkManager(t), - registered: &isReg, + registered: &isReg, } c := make(chan message.Receive) @@ -297,7 +297,7 @@ func TestManager_lookupProcess_NoLookupResponse(t *testing.T) { udID: &id.UDB, inProgressLookup: map[uint64]chan *LookupResponse{}, net: newTestNetworkManager(t), - registered: &isReg, + registered: &isReg, } c := make(chan message.Receive) @@ -360,6 +360,10 @@ func (t *testNetworkManager) GetInstance() *network.Instance { return t.instance } +func (t *testNetworkManager) GetE2EParams() params.E2ESessionParams { + return params.GetDefaultE2ESessionParams() +} + func (t *testNetworkManager) GetHealthTracker() interfaces.HealthTracker { return nil }