diff --git a/groupChat/makeGroup_test.go b/groupChat/makeGroup_test.go index 6c38cae0fcd61d2c21e750c050c713d55b6edd77..b8a30199ad53555ca42295cae77d20c74314a859 100644 --- a/groupChat/makeGroup_test.go +++ b/groupChat/makeGroup_test.go @@ -21,6 +21,8 @@ import ( "strconv" "strings" "testing" + util "gitlab.com/elixxir/client/storage/utility" + "github.com/cloudflare/circl/dh/sidh" ) // Tests that Manager.MakeGroup adds a group and returns the expected status. @@ -290,14 +292,30 @@ func addPartners(m *Manager, t *testing.T) ([]*id.ID, group.Membership, uid := id.NewIdFromUInt(uint64(i), id.User, t) dhKey := m.store.E2e().GetGroup().NewInt(int64(i + 42)) + myVariant := sidh.KeyVariantSidhA + prng := rand.New(rand.NewSource(int64(i+42))) + mySIDHPrivKey := util.NewSIDHPrivateKey(myVariant) + mySIDHPubKey := util.NewSIDHPublicKey(myVariant) + mySIDHPrivKey.Generate(prng) + mySIDHPrivKey.GeneratePublicKey(mySIDHPubKey) + + theirVariant := sidh.KeyVariant(sidh.KeyVariantSidhB) + theirSIDHPrivKey := util.NewSIDHPrivateKey(theirVariant) + theirSIDHPubKey := util.NewSIDHPublicKey(theirVariant) + theirSIDHPrivKey.Generate(prng) + theirSIDHPrivKey.GeneratePublicKey(theirSIDHPubKey) + // Add to lists memberIDs[i] = uid members = append(members, group.Member{ID: uid, DhKey: dhKey}) - dkl.Add(dhKey, group.Member{ID: uid, DhKey: dhKey}, m.store.E2e().GetGroup()) + dkl.Add(dhKey, group.Member{ID: uid, DhKey: dhKey}, + m.store.E2e().GetGroup()) // Add partner err := m.store.E2e().AddPartner(uid, dhKey, dhKey, - params.GetDefaultE2ESessionParams(), params.GetDefaultE2ESessionParams()) + theirSIDHPubKey, mySIDHPrivKey, + params.GetDefaultE2ESessionParams(), + params.GetDefaultE2ESessionParams()) if err != nil { t.Errorf("Failed to add partner %d: %+v", i, err) } diff --git a/groupChat/receiveRequest_test.go b/groupChat/receiveRequest_test.go index eda6c9e50315ba284d83ee8cc80a6b9d6bc51f17..760e7685ecbdd8dd14a424836563736fe6a4047b 100644 --- a/groupChat/receiveRequest_test.go +++ b/groupChat/receiveRequest_test.go @@ -18,6 +18,8 @@ import ( "strings" "testing" "time" + util "gitlab.com/elixxir/client/storage/utility" + "github.com/cloudflare/circl/dh/sidh" ) // Tests that the correct group is received from the request. @@ -48,10 +50,24 @@ func TestManager_receiveRequest(t *testing.T) { MessageType: message.GroupCreationRequest, } + myVariant := sidh.KeyVariantSidhA + mySIDHPrivKey := util.NewSIDHPrivateKey(myVariant) + mySIDHPubKey := util.NewSIDHPublicKey(myVariant) + mySIDHPrivKey.Generate(prng) + mySIDHPrivKey.GeneratePublicKey(mySIDHPubKey) + + theirVariant := sidh.KeyVariant(sidh.KeyVariantSidhB) + theirSIDHPrivKey := util.NewSIDHPrivateKey(theirVariant) + theirSIDHPubKey := util.NewSIDHPublicKey(theirVariant) + theirSIDHPrivKey.Generate(prng) + theirSIDHPrivKey.GeneratePublicKey(theirSIDHPubKey) + + _ = m.store.E2e().AddPartner( g.Members[0].ID, g.Members[0].DhKey, m.store.E2e().GetGroup().NewInt(2), + theirSIDHPubKey, mySIDHPrivKey, params.GetDefaultE2ESessionParams(), params.GetDefaultE2ESessionParams(), ) @@ -161,11 +177,26 @@ func TestManager_receiveRequest_SendMessageTypeError(t *testing.T) { // Unit test of readRequest. func TestManager_readRequest(t *testing.T) { - m, g := newTestManager(rand.New(rand.NewSource(42)), t) + prng := rand.New(rand.NewSource(42)) + m, g := newTestManager(prng, t) + + myVariant := sidh.KeyVariantSidhA + mySIDHPrivKey := util.NewSIDHPrivateKey(myVariant) + mySIDHPubKey := util.NewSIDHPublicKey(myVariant) + mySIDHPrivKey.Generate(prng) + mySIDHPrivKey.GeneratePublicKey(mySIDHPubKey) + + theirVariant := sidh.KeyVariant(sidh.KeyVariantSidhB) + theirSIDHPrivKey := util.NewSIDHPrivateKey(theirVariant) + theirSIDHPubKey := util.NewSIDHPublicKey(theirVariant) + theirSIDHPrivKey.Generate(prng) + theirSIDHPrivKey.GeneratePublicKey(theirSIDHPubKey) + _ = m.store.E2e().AddPartner( g.Members[0].ID, g.Members[0].DhKey, m.store.E2e().GetGroup().NewInt(2), + theirSIDHPubKey, mySIDHPrivKey, params.GetDefaultE2ESessionParams(), params.GetDefaultE2ESessionParams(), )