diff --git a/go.mod b/go.mod index 364100667bc4b0c9a455eac2f765e256f551042a..c9dc36787781cd3321b2402c4be09c403bd60ab3 100644 --- a/go.mod +++ b/go.mod @@ -5,23 +5,19 @@ go 1.13 require ( github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang/protobuf v1.4.2 - github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect github.com/magiconair/properties v1.8.4 // indirect github.com/mitchellh/mapstructure v1.3.3 // indirect github.com/pelletier/go-toml v1.8.1 // indirect github.com/pkg/errors v0.9.1 - github.com/smartystreets/assertions v1.0.1 // indirect github.com/spf13/afero v1.4.0 // indirect - github.com/spf13/cast v1.3.1 // indirect github.com/spf13/cobra v1.0.0 github.com/spf13/jwalterweatherman v1.1.0 - github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.7.1 - gitlab.com/elixxir/comms v0.0.0-20200924210331-d7903c023fa6 + gitlab.com/elixxir/comms v0.0.0-20200924225440-76e02f95fb92 gitlab.com/elixxir/crypto v0.0.0-20200921195205-bca0178268ec gitlab.com/elixxir/ekv v0.1.3 gitlab.com/elixxir/primitives v0.0.0-20200915190719-f4586ec93f50 - gitlab.com/xx_network/comms v0.0.0-20200924172734-1124191b69ee + gitlab.com/xx_network/comms v0.0.0-20200924225518-0c867207b1e6 gitlab.com/xx_network/crypto v0.0.0-20200812183430-c77a5281c686 gitlab.com/xx_network/primitives v0.0.0-20200915204206-eb0287ed0031 golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d // indirect diff --git a/go.sum b/go.sum index 4fa2f61b06bad217a57129bbe30eddb99db834c3..cc835da946f25c491687e78561d33e5a867c7c34 100644 --- a/go.sum +++ b/go.sum @@ -257,6 +257,8 @@ github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN github.com/zeebo/blake3 v0.0.4 h1:vtZ4X8B2lKXZFg2Xyg6Wo36mvmnJvc2VQYTtA4RDCkI= github.com/zeebo/blake3 v0.0.4/go.mod h1:YOZo8A49yNqM0X/Y+JmDUZshJWLt1laHsNSn5ny2i34= github.com/zeebo/pcg v0.0.0-20181207190024-3cdc6b625a05/go.mod h1:Gr+78ptB0MwXxm//LBaEvBiaXY7hXJ6KGe2V32X2F6E= +gitlab.com/elixxir/client v1.5.0/go.mod h1:/uVTzYDhKaGgN8LGGh1sSsxbh+BrpVi1X8VToAT3DfA= +gitlab.com/elixxir/comms v0.0.0-20200707210150-b8ebd0951d23/go.mod h1:OsWMZ1O/R9fOkm+PoHnR3rkXfFtipGoPs73FuKuurHY= gitlab.com/elixxir/comms v0.0.0-20200810165153-3039323b5656 h1:A5S3E7EPL95s3+PGhgAiwnMaa7VcWj8/RtBur3lxdOw= gitlab.com/elixxir/comms v0.0.0-20200810165153-3039323b5656/go.mod h1:EeS1z5wXKrnWOvR0dJlVNVv8OzuiGJz7fa6LyUeN6Q0= gitlab.com/elixxir/comms v0.0.0-20200813225502-e879259ca741 h1:yIjgre8xSDpnhJkDzTr1lgR7NC1bPWCk2Sgn8udiS2A= @@ -283,6 +285,7 @@ gitlab.com/elixxir/comms v0.0.0-20200916212207-60e7bd5b0913 h1:p4TLPPaMysV//lOJU gitlab.com/elixxir/comms v0.0.0-20200916212207-60e7bd5b0913/go.mod h1:yBEsOZSPyJQJvDbtlQ5L8ydy1JRgVlRoNgMDy9koQcE= gitlab.com/elixxir/comms v0.0.0-20200917172539-929fc227eb0c h1:go7/RknV7646Ie+nmQXZAa/aJ5wZBn5bpAYRB+tPens= gitlab.com/elixxir/comms v0.0.0-20200917172539-929fc227eb0c/go.mod h1:yBEsOZSPyJQJvDbtlQ5L8ydy1JRgVlRoNgMDy9koQcE= +gitlab.com/elixxir/comms v0.0.0-20200917221445-8a509560122a/go.mod h1:L2Va13j2AbQkpkveOQmNzrQD37uI5NKeBhYH+LWMOx0= gitlab.com/elixxir/comms v0.0.0-20200921200427-5955a0a798b9 h1:skzHNWCMh+T7Cn58/88Mikg2R8KnSWfzLV0w7SnerOs= gitlab.com/elixxir/comms v0.0.0-20200921200427-5955a0a798b9/go.mod h1:uRr8j6yTjCslxZxbRe6k4ixACu9gAeF61JZH36OFFa0= gitlab.com/elixxir/comms v0.0.0-20200922163657-3e723b7170f6 h1:dFgfdATZuiPybonCBh0s4HeLB8Qw3Zm9EoLDRh2Eaaw= @@ -291,8 +294,14 @@ gitlab.com/elixxir/comms v0.0.0-20200924072138-2e2709483d89 h1:PQalM7pnCRzZRKvdz gitlab.com/elixxir/comms v0.0.0-20200924072138-2e2709483d89/go.mod h1:uRr8j6yTjCslxZxbRe6k4ixACu9gAeF61JZH36OFFa0= gitlab.com/elixxir/comms v0.0.0-20200924172854-724244a10032 h1:0RLZM1fBzp7IRrjoCQANQfXMBDr1Hmjbynme564zXG8= gitlab.com/elixxir/comms v0.0.0-20200924172854-724244a10032/go.mod h1:9+Jj7K8HOTgBjPuiP69VtTKTv7GvAK6bWlh4lgMAqrk= +gitlab.com/elixxir/comms v0.0.0-20200924204623-c1ce13fac604 h1:EOvvtQDA/ZGHYH13xcI8WaSCuLeZaEZHGDo4qJvZOQQ= +gitlab.com/elixxir/comms v0.0.0-20200924204623-c1ce13fac604/go.mod h1:3i4o6ie4LFC+EVN68l9tdt9JxJlAd3+pNNnKBFubKSg= gitlab.com/elixxir/comms v0.0.0-20200924210331-d7903c023fa6 h1:ctVsHyiabgRls3esApbBemDwmQ/a0CramEmZt9RCQb8= gitlab.com/elixxir/comms v0.0.0-20200924210331-d7903c023fa6/go.mod h1:9+Jj7K8HOTgBjPuiP69VtTKTv7GvAK6bWlh4lgMAqrk= +gitlab.com/elixxir/comms v0.0.0-20200924225440-76e02f95fb92 h1:KwqVzHpqYg1l1/KG6uRqnl7HBgvrzuknMVCeEvRsbow= +gitlab.com/elixxir/comms v0.0.0-20200924225440-76e02f95fb92/go.mod h1:3i4o6ie4LFC+EVN68l9tdt9JxJlAd3+pNNnKBFubKSg= +gitlab.com/elixxir/crypto v0.0.0-20200707005343-97f868cbd930/go.mod h1:LHBAaEf48a0/AjU118rjoworH0LgXifhAqmNX3ZRvME= +gitlab.com/elixxir/crypto v0.0.0-20200731174640-0503cf80524a/go.mod h1:LHBAaEf48a0/AjU118rjoworH0LgXifhAqmNX3ZRvME= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4 h1:28ftZDeYEko7xptCZzeFWS1Iam95dj46TWFVVlKmw6A= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c= gitlab.com/elixxir/crypto v0.0.0-20200805174804-bdf909f2a16d/go.mod h1:cu6uNoANVLV0J6HyTL6KqVtVyh9SHU1RjJhytYlsbVQ= @@ -334,6 +343,8 @@ gitlab.com/elixxir/ekv v0.1.1 h1:Em3rF8sv+tNbQGXbcpYzAS2blWRAP708JGhYlkN74Kg= gitlab.com/elixxir/ekv v0.1.1/go.mod h1:bXY0kgbV5BHYda4YY5/hiG5bjimGK+R3PYub5yM9C/s= gitlab.com/elixxir/ekv v0.1.3 h1:OE+LBMIhjGUMwc6hHJzYvEPNJQV7t1vMnJyIgxUMUo8= gitlab.com/elixxir/ekv v0.1.3/go.mod h1:e6WPUt97taFZe5PFLPb1Dupk7tqmDCTQu1kkstqJvw4= +gitlab.com/elixxir/primitives v0.0.0-20200706165052-9fe7a4fb99a3/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg= +gitlab.com/elixxir/primitives v0.0.0-20200708185800-a06e961280e6/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg= gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg= gitlab.com/elixxir/primitives v0.0.0-20200804170709-a1896d262cd9/go.mod h1:p0VelQda72OzoUckr1O+vPW0AiFe0nyKQ6gYcmFSuF8= gitlab.com/elixxir/primitives v0.0.0-20200804182913-788f47bded40/go.mod h1:tzdFFvb1ESmuTCOl1z6+yf6oAICDxH2NPUemVgoNLxc= @@ -359,8 +370,13 @@ gitlab.com/xx_network/comms v0.0.0-20200910173932-bd179f5fee4f h1:ExTCqEoro7VuS1 gitlab.com/xx_network/comms v0.0.0-20200910173932-bd179f5fee4f/go.mod h1:+jEkDQKoK51WLl2ZZuxfAZkz6YFbUQ+oZfH0dt2wIF0= gitlab.com/xx_network/comms v0.0.0-20200915154643-d533291041b7 h1:lPx1wpkjNpwLaZ0pyd7/iCcdITjT+eCMmb0HXCVoIkk= gitlab.com/xx_network/comms v0.0.0-20200915154643-d533291041b7/go.mod h1:+jEkDQKoK51WLl2ZZuxfAZkz6YFbUQ+oZfH0dt2wIF0= +gitlab.com/xx_network/comms v0.0.0-20200916172635-6ab807c3c820/go.mod h1:J+GJ6fn71a4xnYVvbcrhtvWSOQIqqhaGcaej5xB3/JY= gitlab.com/xx_network/comms v0.0.0-20200924172734-1124191b69ee h1:dPRaW0OxcoBlWALd5H6VUYnL/ALvT7j14kWJNBi0K7A= gitlab.com/xx_network/comms v0.0.0-20200924172734-1124191b69ee/go.mod h1:jECvMkoYKZFooCudoZxxaf2bo1DzpWP0gCahXHdlqUM= +gitlab.com/xx_network/comms v0.0.0-20200924192723-aa0577a6d899 h1:dGDcAnQm43ihDUaP82XyiwWzLnE+ejJBizycRgx2XCo= +gitlab.com/xx_network/comms v0.0.0-20200924192723-aa0577a6d899/go.mod h1:wDPZABTOhqz+uFM75CzpGplQBRIsCQcS1EYXwker6nw= +gitlab.com/xx_network/comms v0.0.0-20200924225518-0c867207b1e6 h1:8rNFHiwKJvcfN89FAmp4RyfjD/rknp4tNm9sI/Nos0g= +gitlab.com/xx_network/comms v0.0.0-20200924225518-0c867207b1e6/go.mod h1:jECvMkoYKZFooCudoZxxaf2bo1DzpWP0gCahXHdlqUM= gitlab.com/xx_network/crypto v0.0.0-20200805231039-4aa0e350ed0a h1:BlfWGPokU6yU69O+PGGsgc5iA/P9gERbHzYUvjoYbgM= gitlab.com/xx_network/crypto v0.0.0-20200806202113-978fa1984bbf/go.mod h1:i0df/q6dDCBiscgD51fMoS2U2TBrm6LcyN822JmB5Tw= gitlab.com/xx_network/crypto v0.0.0-20200806235322-ede3c15881ce h1:gypNBUl2guESEv4MDgH+miwYqR4jPoWM8dLt2Zs5gIs= @@ -432,6 +448,7 @@ golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -511,6 +528,7 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200514193133-8feb7f20f2a2/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200709005830-7a2ca40e9dc3 h1:JwLN1jVnmIsfE4HkDVe2AblFAbo0Z+4cjteDSOnv6oE= google.golang.org/genproto v0.0.0-20200709005830-7a2ca40e9dc3/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= diff --git a/keyExchange/confirm_test.go b/keyExchange/confirm_test.go index e2eeaf6e2dc6093215753f2ebdf722e9fb9cfd46..020a8b23f07509aaf961ef68bb2fedbd850b6a37 100644 --- a/keyExchange/confirm_test.go +++ b/keyExchange/confirm_test.go @@ -2,7 +2,7 @@ package keyExchange import ( "github.com/golang/protobuf/proto" - "gitlab.com/elixxir/client/context/message" + "gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/storage/e2e" "gitlab.com/xx_network/primitives/id" "testing" @@ -11,16 +11,25 @@ import ( // Smoke test for handleTrigger func TestHandleConfirm(t *testing.T) { + // Generate alice and bob's session + aliceSession, _ := InitTestingContextGeneric(t) + bobSession, _ := InitTestingContextGeneric(t) - aliceContext := InitTestingContextGeneric(t) - bobContext := InitTestingContextGeneric(t) - + // Maintain an ID for bob bobID := id.NewIdFromBytes([]byte("test"), t) - aliceContext.Session.E2e().AddPartner(bobID, bobContext.Session.E2e().GetDHPublicKey(), + // Pull the keys for Alice and Bob + alicePrivKey := aliceSession.E2e().GetDHPrivateKey() + bobPubKey := bobSession.E2e().GetDHPublicKey() + + // Add bob as a partner + aliceSession.E2e().AddPartner(bobID, bobPubKey, e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) - sessionID := GeneratePartnerID(aliceContext, bobContext, genericGroup) + // Generate a session ID, bypassing some business logic here + sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup) + + // Generate the message rekey, _ := proto.Marshal(&RekeyConfirm{ SessionID: sessionID.Marshal(), }) @@ -34,5 +43,7 @@ func TestHandleConfirm(t *testing.T) { Timestamp: time.Now(), Encryption: message.E2E, } - handleConfirm(aliceContext.Session, receiveMsg) + + // Handle the confirmation + handleConfirm(aliceSession, receiveMsg) } diff --git a/keyExchange/exchange_test.go b/keyExchange/exchange_test.go index 9dcca18771e4611561a2f77e84530f2ba9d40506..507bb0c2f46ab7153ef78df63c792ffb5a81d9e6 100644 --- a/keyExchange/exchange_test.go +++ b/keyExchange/exchange_test.go @@ -2,49 +2,55 @@ package keyExchange import ( "github.com/golang/protobuf/proto" - "gitlab.com/elixxir/client/context" - "gitlab.com/elixxir/client/context/message" + "gitlab.com/elixxir/client/interfaces" + "gitlab.com/elixxir/client/interfaces/message" + "gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/storage/e2e" + "gitlab.com/elixxir/client/switchboard" "gitlab.com/xx_network/primitives/id" "testing" "time" ) -var exchangeAliceContext, exchangeBobContext *context.Context var exchangeAliceId, exchangeBobId *id.ID - +var aliceSession, bobSession *storage.Session +var aliceSwitchboard, bobSwitchboard *switchboard.Switchboard +var aliceManager, bobManager interfaces.NetworkManager func TestFullExchange(t *testing.T) { + // Initialzie alice's and bob's session, switchboard and network managers + aliceSession, aliceSwitchboard, aliceManager = InitTestingContextFullExchange(t) + bobSession, bobSwitchboard, bobManager = InitTestingContextFullExchange(t) - exchangeAliceContext = InitTestingContextFullExchange(t) - exchangeBobContext = InitTestingContextFullExchange(t) + // Assign ID's to alice and bob exchangeAliceId = id.NewIdFromBytes([]byte("1234"), t) - exchangeBobId = id.NewIdFromBytes([]byte("test"), t) - exchangeAliceContext.Session.E2e().AddPartner(exchangeBobId, exchangeBobContext.Session.E2e().GetDHPublicKey(), - e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) - exchangeBobContext.Session.E2e().AddPartner(exchangeAliceId, exchangeAliceContext.Session.E2e().GetDHPublicKey(), - e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) + exchangeBobId = id.NewIdFromBytes([]byte("test"), t) + // Pull alice's and bob's keys for later use + alicePrivKey := aliceSession.E2e().GetDHPrivateKey() + alicePubKey := aliceSession.E2e().GetDHPublicKey() + bobPubKey := bobSession.E2e().GetDHPublicKey() - Start(exchangeAliceContext.Switchboard, exchangeAliceContext.Session, - exchangeAliceContext.Manager, nil) - - Start(exchangeBobContext.Switchboard, exchangeBobContext.Session, - exchangeBobContext.Manager, nil) - + // Add Alice and Bob as partners + aliceSession.E2e().AddPartner(exchangeBobId, bobPubKey, + e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) + bobSession.E2e().AddPartner(exchangeAliceId, alicePubKey, + e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) + // Start the listeners for alice and bob + Start(aliceSwitchboard, aliceSession, aliceManager) + Start(bobSwitchboard, bobSession, bobManager) - sessionID := GeneratePartnerID(exchangeAliceContext, exchangeBobContext, genericGroup) + // Generate a session ID, bypassing some business logic here + sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup) - pubKey := exchangeBobContext.Session.E2e().GetDHPrivateKey().Bytes() + // Generate the message rekeyTrigger, _ := proto.Marshal(&RekeyTrigger{ SessionID: sessionID.Marshal(), - PublicKey: pubKey, + PublicKey: bobPubKey.Bytes(), }) payload := make([]byte, 0) - payload = append(payload, rekeyTrigger...) - triggerMsg := message.Receive{ Payload: payload, MessageType: message.KeyExchangeTrigger, @@ -52,11 +58,11 @@ func TestFullExchange(t *testing.T) { Timestamp: time.Now(), Encryption: message.E2E, } - exchangeAliceContext.Switchboard.Speak(triggerMsg) - - - time.Sleep(1*time.Second) + // Speak the message to Bob, triggers the SendE2E in utils_test + aliceSwitchboard.Speak(triggerMsg) + // Allow the test time to work it's goroutines + time.Sleep(1 * time.Second) } diff --git a/keyExchange/trigger_test.go b/keyExchange/trigger_test.go index 2bad56bb240e0a5bb6fdb9b27b90a4c2a917f27a..1c0c5da6e83e1aeac479988256e078eaab7cdb50 100644 --- a/keyExchange/trigger_test.go +++ b/keyExchange/trigger_test.go @@ -1,7 +1,7 @@ package keyExchange import ( - "gitlab.com/elixxir/client/context/message" + "gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/storage/e2e" "gitlab.com/xx_network/primitives/id" "google.golang.org/protobuf/proto" @@ -11,20 +11,28 @@ import ( // Smoke test for handleTrigger func TestHandleTrigger(t *testing.T) { + // Generate alice and bob's session + aliceSession, aliceManager := InitTestingContextGeneric(t) + bobSession, _ := InitTestingContextGeneric(t) - aliceContext := InitTestingContextGeneric(t) - bobContext := InitTestingContextGeneric(t) + // Pull the keys for Alice and Bob + alicePrivKey := aliceSession.E2e().GetDHPrivateKey() + bobPubKey := bobSession.E2e().GetDHPublicKey() + // Maintain an ID for bob bobID := id.NewIdFromBytes([]byte("test"), t) - aliceContext.Session.E2e().AddPartner(bobID, bobContext.Session.E2e().GetDHPublicKey(), + + // Add bob as a partner + aliceSession.E2e().AddPartner(bobID, bobSession.E2e().GetDHPublicKey(), e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) - sessionID := GeneratePartnerID(aliceContext, bobContext, genericGroup) + // Generate a session ID, bypassing some business logic here + sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup) - pubKey := bobContext.Session.E2e().GetDHPrivateKey().Bytes() + // Generate the message rekey, _ := proto.Marshal(&RekeyTrigger{ SessionID: sessionID.Marshal(), - PublicKey: pubKey, + PublicKey: bobPubKey.Bytes(), }) payload := make([]byte, 0) @@ -37,7 +45,9 @@ func TestHandleTrigger(t *testing.T) { Timestamp: time.Now(), Encryption: message.E2E, } - err := handleTrigger(aliceContext.Session, aliceContext.Manager, receiveMsg, nil) + + // Handle the trigger and check for an error + err := handleTrigger(aliceSession, aliceManager, receiveMsg) if err != nil { t.Errorf("Handle trigger error: %v", err) } diff --git a/keyExchange/utils_test.go b/keyExchange/utils_test.go index 18d46335f589eee658e827ffeae1987524ab9320..47fb71b9a9c4329aef8c06bff04539ab2b9e32ef 100644 --- a/keyExchange/utils_test.go +++ b/keyExchange/utils_test.go @@ -2,19 +2,17 @@ package keyExchange import ( "github.com/golang/protobuf/proto" - "gitlab.com/elixxir/client/context" - "gitlab.com/elixxir/client/context/message" - "gitlab.com/elixxir/client/context/params" - "gitlab.com/elixxir/client/context/stoppable" "gitlab.com/elixxir/client/globals" + "gitlab.com/elixxir/client/interfaces" + "gitlab.com/elixxir/client/interfaces/message" + "gitlab.com/elixxir/client/interfaces/params" + "gitlab.com/elixxir/client/stoppable" "gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/storage/e2e" "gitlab.com/elixxir/client/switchboard" "gitlab.com/elixxir/comms/network" - "gitlab.com/elixxir/crypto/csprng" "gitlab.com/elixxir/crypto/cyclic" dh "gitlab.com/elixxir/crypto/diffieHellman" - "gitlab.com/elixxir/crypto/fastRNG" "gitlab.com/elixxir/crypto/hash" "gitlab.com/elixxir/crypto/large" "gitlab.com/elixxir/primitives/format" @@ -26,11 +24,9 @@ import ( ) // Generate partner ID for two people, used for smoke tests -func GeneratePartnerID(aliceContext, bobContext *context.Context, +func GeneratePartnerID(aliceKey, bobKey *cyclic.Int, group *cyclic.Group) e2e.SessionID { - alicePrivKey := aliceContext.Session.E2e().GetDHPrivateKey() - bobPubKey := bobContext.Session.E2e().GetDHPublicKey() - baseKey := dh.GenerateSessionKey(alicePrivKey, bobPubKey, group) + baseKey := dh.GenerateSessionKey(aliceKey, bobKey, group) h, _ := hash.NewCMixHash() h.Write(baseKey.Bytes()) @@ -45,12 +41,23 @@ func GeneratePartnerID(aliceContext, bobContext *context.Context, // Contains a test implementation of the networkManager interface. Used to bypass actual sending // between test clients in testing key exchange type testNetworkManagerGeneric struct { - ctx *context.Context instance *network.Instance } +func (t *testNetworkManagerGeneric) GetHealthTracker() interfaces.HealthTracker { + panic("implement me") +} + +func (t *testNetworkManagerGeneric) Follow() (stoppable.Stoppable, error) { + panic("implement me") +} + +func (t *testNetworkManagerGeneric) CheckGarbledMessages() { + panic("implement me") +} + func (t *testNetworkManagerGeneric) SendE2E(m message.Send, p params.E2E) ([]id.Round, error) { - rounds := []id.Round{id.Round(0),id.Round(1),id.Round(2)} + rounds := []id.Round{id.Round(0), id.Round(1), id.Round(2)} return rounds, nil } @@ -71,14 +78,6 @@ func (t *testNetworkManagerGeneric) GetInstance() *network.Instance { } -func (t *testNetworkManagerGeneric) GetHealthTracker() context.HealthTracker { - return nil -} - -func (t *testNetworkManagerGeneric) SetContext(ctx *context.Context) { - t.ctx = ctx -} - func (t *testNetworkManagerGeneric) RegisterWithPermissioning(string) ([]byte, error) { return nil, nil } @@ -90,8 +89,7 @@ func (t *testNetworkManagerGeneric) GetStoppable() stoppable.Stoppable { return &stoppable.Multi{} } - -func InitTestingContextGeneric(i interface{}) *context.Context { +func InitTestingContextGeneric(i interface{}) (*storage.Session, interfaces.NetworkManager) { switch i.(type) { case *testing.T: break @@ -103,8 +101,6 @@ func InitTestingContextGeneric(i interface{}) *context.Context { globals.Log.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i) } - rng := fastRNG.NewStreamGenerator(7, 3, csprng.NewSystemRNG) - thisSession := storage.InitTestingSession(i) commsManager := connect.NewManagerTesting(i) instanceComms := &connect.ProtoComms{ @@ -114,25 +110,16 @@ func InitTestingContextGeneric(i interface{}) *context.Context { _, err := instanceComms.AddHost(&id.Permissioning, "0.0.0.0:420", []byte(pub), connect.GetDefaultHostParams()) if err != nil { - return nil + return nil, nil } thisInstance, err := network.NewInstanceTesting(instanceComms, def, def, nil, nil, i) if err != nil { - return nil + return nil, nil } thisManager := &testNetworkManagerGeneric{instance: thisInstance} - thisContext := &context.Context{ - Session: thisSession, - Switchboard: nil, - Manager: thisManager, - Rng: rng, - } - - thisManager.SetContext(thisContext) - - return thisContext + return thisSession, thisManager } @@ -140,14 +127,29 @@ func InitTestingContextGeneric(i interface{}) *context.Context { // between test clients in testing key exchange // Separated from Generic to allow for a full stack test that doesn't impact the generic one used in smoke tests type testNetworkManagerFullExchange struct { - ctx *context.Context instance *network.Instance } -// Intended for alice to send to bob +func (t *testNetworkManagerFullExchange) GetHealthTracker() interfaces.HealthTracker { + panic("implement me") +} + +func (t *testNetworkManagerFullExchange) Follow() (stoppable.Stoppable, error) { + panic("implement me") +} + +func (t *testNetworkManagerFullExchange) CheckGarbledMessages() { + panic("implement me") +} + +// 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) ([]id.Round, error) { - rounds := []id.Round{id.Round(0),id.Round(1),id.Round(2)} - sessionID := GeneratePartnerID(exchangeAliceContext, exchangeBobContext, genericGroup) + rounds := []id.Round{id.Round(0), id.Round(1), id.Round(2)} + alicePrivKey := aliceSession.E2e().GetDHPrivateKey() + bobPubKey := bobSession.E2e().GetDHPublicKey() + + sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup) rekeyConfirm, _ := proto.Marshal(&RekeyConfirm{ SessionID: sessionID.Marshal(), @@ -163,7 +165,7 @@ func (t *testNetworkManagerFullExchange) SendE2E(m message.Send, p params.E2E) ( Encryption: message.E2E, } - exchangeBobContext.Switchboard.Speak(confirmMessage) + bobSwitchboard.Speak(confirmMessage) return rounds, nil @@ -185,14 +187,6 @@ func (t *testNetworkManagerFullExchange) GetInstance() *network.Instance { } -func (t *testNetworkManagerFullExchange) GetHealthTracker() context.HealthTracker { - return nil -} - -func (t *testNetworkManagerFullExchange) SetContext(ctx *context.Context) { - t.ctx = ctx -} - func (t *testNetworkManagerFullExchange) RegisterWithPermissioning(string) ([]byte, error) { return nil, nil } @@ -204,8 +198,7 @@ func (t *testNetworkManagerFullExchange) GetStoppable() stoppable.Stoppable { return &stoppable.Multi{} } - -func InitTestingContextFullExchange(i interface{}) *context.Context { +func InitTestingContextFullExchange(i interface{}) (*storage.Session, *switchboard.Switchboard, interfaces.NetworkManager) { switch i.(type) { case *testing.T: break @@ -217,8 +210,6 @@ func InitTestingContextFullExchange(i interface{}) *context.Context { globals.Log.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i) } - rng := fastRNG.NewStreamGenerator(7, 3, csprng.NewSystemRNG) - thisSession := storage.InitTestingSession(i) commsManager := connect.NewManagerTesting(i) instanceComms := &connect.ProtoComms{ @@ -227,40 +218,19 @@ func InitTestingContextFullExchange(i interface{}) *context.Context { _, err := instanceComms.AddHost(&id.Permissioning, "0.0.0.0:420", []byte(pub), connect.GetDefaultHostParams()) if err != nil { - return nil + return nil, nil, nil } thisInstance, err := network.NewInstanceTesting(instanceComms, def, def, nil, nil, i) if err != nil { - return nil + return nil, nil, nil } thisManager := &testNetworkManagerFullExchange{instance: thisInstance} - thisContext := &context.Context{ - Session: thisSession, - Manager: thisManager, - Switchboard:switchboard.New(), - Rng: rng, - } - - thisManager.SetContext(thisContext) - - return thisContext + return thisSession, switchboard.New(), thisManager } -type listener struct { -} - -func (lst *listener) Hear(item message.Receive) { - -} - -func (lst *listener) Name() string { - return "test" -} - - var pub = "-----BEGIN CERTIFICATE-----\nMIIGHTCCBAWgAwIBAgIUOcAn9cpH+hyRH8/UfqtbFDoSxYswDQYJKoZIhvcNAQEL\nBQAwgZIxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTESMBAGA1UEBwwJQ2xhcmVt\nb250MRAwDgYDVQQKDAdFbGl4eGlyMRQwEgYDVQQLDAtEZXZlbG9wbWVudDEZMBcG\nA1UEAwwQZ2F0ZXdheS5jbWl4LnJpcDEfMB0GCSqGSIb3DQEJARYQYWRtaW5AZWxp\neHhpci5pbzAeFw0xOTA4MTYwMDQ4MTNaFw0yMDA4MTUwMDQ4MTNaMI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zAUBgNVHREEDTALgglmb28uY28udWswDQYJKoZIhvcNAQELBQADggIB\nADKz0ST0uS57oC4rT9zWhFqVZkEGh1x1XJ28bYtNUhozS8GmnttV9SnJpq0EBCm/\nr6Ub6+Wmf60b85vCN5WDYdoZqGJEBjGGsFzl4jkYEE1eeMfF17xlNUSdt1qLCE8h\nU0glr32uX4a6nsEkvw1vo1Liuyt+y0cOU/w4lgWwCqyweu3VuwjZqDoD+3DShVzX\n8f1p7nfnXKitrVJt9/uE+AtAk2kDnjBFbRxCfO49EX4Cc5rADUVXMXm0itquGBYp\nMbzSgFmsMp40jREfLYRRzijSZj8tw14c2U9z0svvK9vrLCrx9+CZQt7cONGHpr/C\n/GIrP/qvlg0DoLAtjea73WxjSCbdL3Nc0uNX/ymXVHdQ5husMCZbczc9LYdoT2VP\nD+GhkAuZV9g09COtRX4VP09zRdXiiBvweiq3K78ML7fISsY7kmc8KgVH22vcXvMX\nCgGwbrxi6QbQ80rWjGOzW5OxNFvjhvJ3vlbOT6r9cKZGIPY8IdN/zIyQxHiim0Jz\noavr9CPDdQefu9onizsmjsXFridjG/ctsJxcUEqK7R12zvaTxu/CVYZbYEUFjsCe\nq6ZAACiEJGvGeKbb/mSPvGs2P1kS70/cGp+P5kBCKqrm586FB7BcafHmGFrWhT3E\nLOUYkOV/gADT2hVDCrkPosg7Wb6ND9/mhCVVhf4hLGRh\n-----END CERTIFICATE-----\n" var def = getNDF() var genericGroup = cyclic.NewGroup( @@ -319,5 +289,3 @@ func getNDF() *ndf.NetworkDefinition { }, } } - - diff --git a/storage/session.go b/storage/session.go index 4aeab375ee7489ef28852d56b62e39b633e9e932..884b0e3e8ff81602aa8bbe475b904c74ce46bc1d 100644 --- a/storage/session.go +++ b/storage/session.go @@ -10,7 +10,7 @@ package storage import ( "github.com/pkg/errors" - jww "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/client/globals" "gitlab.com/elixxir/client/storage/cmix" "gitlab.com/elixxir/client/storage/conversation" "gitlab.com/elixxir/client/storage/e2e" @@ -238,7 +238,7 @@ func InitTestingSession(i interface{}) *Session { case *testing.B: break default: - jww.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i) + globals.Log.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i) } privKey, _ := rsa.LoadPrivateKeyFromPem([]byte("-----BEGIN PRIVATE KEY-----\nMIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQC7Dkb6VXFn4cdp\nU0xh6ji0nTDQUyT9DSNW9I3jVwBrWfqMc4ymJuonMZbuqK+cY2l+suS2eugevWZr\ntzujFPBRFp9O14Jl3fFLfvtjZvkrKbUMHDHFehascwzrp3tXNryiRMmCNQV55TfI\nTVCv8CLE0t1ibiyOGM9ZWYB2OjXt59j76lPARYww5qwC46vS6+3Cn2Yt9zkcrGes\nkWEFa2VttHqF910TP+DZk2R5C7koAh6wZYK6NQ4S83YQurdHAT51LKGrbGehFKXq\n6/OAXCU1JLi3kW2PovTb6MZuvxEiRmVAONsOcXKu7zWCmFjuZZwfRt2RhnpcSgzf\nrarmsGM0LZh6JY3MGJ9YdPcVGSz+Vs2E4zWbNW+ZQoqlcGeMKgsIiQ670g0xSjYI\nCqldpt79gaET9PZsoXKEmKUaj6pq1d4qXDk7s63HRQazwVLGBdJQK8qX41eCdR8V\nMKbrCaOkzD5zgnEu0jBBAwdMtcigkMIk1GRv91j7HmqwryOBHryLi6NWBY3tjb4S\no9AppDQB41SH3SwNenAbNO1CXeUqN0hHX6I1bE7OlbjqI7tXdrTllHAJTyVVjenP\nel2ApMXp+LVRdDbKtwBiuM6+n+z0I7YYerxN1gfvpYgcXm4uye8dfwotZj6H2J/u\nSALsU2v9UHBzprdrLSZk2YpozJb+CQIDAQABAoICAARjDFUYpeU6zVNyCauOM7BA\ns4FfQdHReg+zApTfWHosDQ04NIc9CGbM6e5E9IFlb3byORzyevkllf5WuMZVWmF8\nd1YBBeTftKYBn2Gwa42Ql9dl3eD0wQ1gUWBBeEo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5E0xs2l+ABmt30Dtd3iRrQ5BBjnRc4V//sQiwS1aC\nYi5eNYCQ96BSAEo1dxJh5RI/QxF2HEPUuoPM8iXrIJhyg9TEEpbrEJcxeagWk02y\nOMEoUbWbX07OzFVvu+aJaN/GlgiogMQhb6IiNTyMlryFUleF+9OBA8xGHqGWA6nR\nOaRA5ZbdE7g7vxKRV36jT3wvD7W+\n-----END PRIVATE KEY-----\n")) @@ -247,7 +247,7 @@ func InitTestingSession(i interface{}) *Session { s := &Session{kv: kv} u, err := user.NewUser(kv, id.NewIdFromString("zezima", id.User, i), []byte("salt"), privKey, false) if err != nil { - jww.FATAL.Panicf("InitTestingSession failed to create dummy user: %+v", err) + globals.Log.FATAL.Panicf("InitTestingSession failed to create dummy user: %+v", err) } u.SetRegistrationValidationSignature([]byte("sig")) s.user = u @@ -270,7 +270,7 @@ func InitTestingSession(i interface{}) *Session { "DC4473F996BDCE6EED1CABED8B6F116F7AD9CF505DF0F998E34AB27514B0FFE7", 16)) cmix, err := cmix.NewStore(cmixGrp, kv, cmixGrp.NewInt(2)) if err != nil { - jww.FATAL.Panicf("InitTestingSession failed to create dummy cmix session: %+v", err) + globals.Log.FATAL.Panicf("InitTestingSession failed to create dummy cmix session: %+v", err) } s.cmix = cmix