diff --git a/e2e/rekey/confirm_test.go b/e2e/rekey/confirm_test.go index c916e9c241fadca4fc533f01cd159f3edee868f8..aa4c9eade9134c6c5645e6cd80984ba270415205 100644 --- a/e2e/rekey/confirm_test.go +++ b/e2e/rekey/confirm_test.go @@ -26,7 +26,7 @@ import ( "testing" ) -// Smoke test for handleTrigger +// Smoke test for handleConfirm func TestHandleConfirm(t *testing.T) { grp := getGroup() rng := fastRNG.NewStreamGenerator(1000, 10, csprng.NewSystemRNG) diff --git a/e2e/rekey/exchange_test.go b/e2e/rekey/exchange_test.go index 06c0d060dd2b09c56bb82d807dc8271e9f7210e8..fbe92114074e46d4253ea8ac8add0d7d421bbf5f 100644 --- a/e2e/rekey/exchange_test.go +++ b/e2e/rekey/exchange_test.go @@ -15,16 +15,12 @@ import ( "gitlab.com/elixxir/client/e2e/ratchet" "gitlab.com/elixxir/client/e2e/ratchet/partner/session" "gitlab.com/elixxir/client/e2e/receive" - "gitlab.com/elixxir/client/network" - "gitlab.com/elixxir/client/storage" util "gitlab.com/elixxir/client/storage/utility" "gitlab.com/elixxir/client/storage/versioned" - "gitlab.com/elixxir/comms/client" dh "gitlab.com/elixxir/crypto/diffieHellman" "gitlab.com/elixxir/crypto/fastRNG" "gitlab.com/elixxir/ekv" "gitlab.com/xx_network/crypto/csprng" - "gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/netTime" "math/rand" @@ -32,7 +28,6 @@ import ( "time" ) -var exchangeAliceId, exchangeBobId *id.ID var r *ratchet.Ratchet var myID, bobID *id.ID var aliceSwitchboard = receive.New() @@ -107,33 +102,11 @@ func TestFullExchange(t *testing.T) { // Start the listeners for alice and bob rekeyParams := GetDefaultParams() rekeyParams.RoundTimeout = 1 * time.Second - aliceRSAKey, err := rsa.GenerateKey(csprng.NewSystemRNG(), 256) - bobRSAKey, err := rsa.GenerateKey(csprng.NewSystemRNG(), 256) - aliceComms, err := client.NewClientComms(myID, rsa.CreatePublicKeyPem(aliceRSAKey.GetPublic()), rsa.CreatePrivateKeyPem(aliceRSAKey), nil) - if err != nil { - t.Errorf("Failed to start alice comms: %+v", err) - } - fmt.Println("hi") - aliceManager, err := network.NewManager(network.GetDefaultParams(), aliceComms, storage.InitTestingSession(t), getNDF(t), rng, nil) - if err != nil { - t.Errorf("Failed to start alice manager: %+v", err) - } - fmt.Println("hello") - bobComms, err := client.NewClientComms(myID, rsa.CreatePublicKeyPem(bobRSAKey.GetPublic()), rsa.CreatePrivateKeyPem(bobRSAKey), nil) - if err != nil { - t.Errorf("Failed to start bob comms: %+v", err) - } - fmt.Println("hey") - bobManager, err := network.NewManager(network.GetDefaultParams(), bobComms, storage.InitTestingSession(t), getNDF(t), rng, nil) - if err != nil { - t.Errorf("Failed to start bob manager: %+v", err) - } - fmt.Println("0") - _, err = Start(aliceSwitchboard, r, testSendE2E, aliceManager, grp, rekeyParams) + _, err = Start(aliceSwitchboard, r, testSendE2E, &mockNetManager{}, grp, rekeyParams) if err != nil { t.Errorf("Failed to Start alice: %+v", err) } - _, err = Start(bobSwitchboard, r, testSendE2E, bobManager, grp, rekeyParams) + _, err = Start(bobSwitchboard, r, testSendE2E, &mockNetManager{}, grp, rekeyParams) if err != nil { t.Errorf("Failed to Start bob: %+v", err) } @@ -152,13 +125,13 @@ func TestFullExchange(t *testing.T) { triggerMsg := receive.Message{ Payload: rekeyTrigger, MessageType: catalog.KeyExchangeTrigger, - Sender: exchangeBobId, + Sender: bobID, Timestamp: netTime.Now(), Encrypted: true, } // get Alice's manager for reception from Bob - receivedManager, err := r.GetPartner(exchangeBobId, myID) + receivedManager, err := r.GetPartner(bobID, myID) if err != nil { t.Errorf("Failed to get bob's manager: %v", err) } diff --git a/e2e/rekey/trigger_test.go b/e2e/rekey/trigger_test.go index 310eae6f16cd43d20f7cc8e45cf7d9e0bb3e8b4a..22f8fad7a6a37af54a1ba0becbc9d0aaacb15034 100644 --- a/e2e/rekey/trigger_test.go +++ b/e2e/rekey/trigger_test.go @@ -7,113 +7,148 @@ package rekey +import ( + "github.com/cloudflare/circl/dh/sidh" + "github.com/golang/protobuf/proto" + "gitlab.com/elixxir/client/catalog" + "gitlab.com/elixxir/client/e2e/ratchet" + session2 "gitlab.com/elixxir/client/e2e/ratchet/partner/session" + "gitlab.com/elixxir/client/e2e/receive" + "gitlab.com/elixxir/client/stoppable" + util "gitlab.com/elixxir/client/storage/utility" + "gitlab.com/elixxir/client/storage/versioned" + dh "gitlab.com/elixxir/crypto/diffieHellman" + "gitlab.com/elixxir/crypto/fastRNG" + "gitlab.com/elixxir/ekv" + "gitlab.com/xx_network/crypto/csprng" + "gitlab.com/xx_network/primitives/id" + "gitlab.com/xx_network/primitives/netTime" + "math/rand" + "testing" + "time" +) + // Smoke test for handleTrigger -//func TestHandleTrigger(t *testing.T) { -// // Generate alice and bob's session -// aliceSession, aliceManager, err := InitTestingContextGeneric(t) -// if err != nil { -// t.Fatalf("Failed to create alice session: %v", err) -// } -// bobSession, _, err := InitTestingContextGeneric(t) -// if err != nil { -// t.Fatalf("Failed to create bob session: %v", err) -// } -// // Pull the keys for Alice and Bob -// alicePrivKey := aliceSession.E2e().GetDHPrivateKey() -// bobPubKey := bobSession.E2e().GetDHPublicKey() -// -// // Generate bob's new keypair -// newBobPrivKey := dh.GeneratePrivateKey(dh.DefaultPrivateKeyLength, genericGroup, csprng.NewSystemRNG()) -// newBobPubKey := dh.GeneratePublicKey(newBobPrivKey, genericGroup) -// -// aliceVariant := sidh.KeyVariantSidhA -// prng1 := rand.New(rand.NewSource(int64(1))) -// aliceSIDHPrivKey := util.NewSIDHPrivateKey(aliceVariant) -// aliceSIDHPubKey := util.NewSIDHPublicKey(aliceVariant) -// aliceSIDHPrivKey.Generate(prng1) -// aliceSIDHPrivKey.GeneratePublicKey(aliceSIDHPubKey) -// -// bobVariant := sidh.KeyVariant(sidh.KeyVariantSidhB) -// prng2 := rand.New(rand.NewSource(int64(2))) -// bobSIDHPrivKey := util.NewSIDHPrivateKey(bobVariant) -// bobSIDHPubKey := util.NewSIDHPublicKey(bobVariant) -// bobSIDHPrivKey.Generate(prng2) -// bobSIDHPrivKey.GeneratePublicKey(bobSIDHPubKey) -// -// newBobSIDHPrivKey := util.NewSIDHPrivateKey(bobVariant) -// newBobSIDHPubKey := util.NewSIDHPublicKey(bobVariant) -// newBobSIDHPrivKey.Generate(prng2) -// newBobSIDHPrivKey.GeneratePublicKey(newBobSIDHPubKey) -// newBobSIDHPubKeyBytes := make([]byte, newBobSIDHPubKey.Size()+1) -// newBobSIDHPubKeyBytes[0] = byte(bobVariant) -// newBobSIDHPubKey.Export(newBobSIDHPubKeyBytes[1:]) -// -// // Maintain an ID for bob -// bobID := id.NewIdFromBytes([]byte("test"), t) -// -// // Add bob as a partner -// aliceSession.E2e().AddPartner(bobID, bobSession.E2e().GetDHPublicKey(), -// alicePrivKey, bobSIDHPubKey, aliceSIDHPrivKey, -// params.GetDefaultE2ESessionParams(), -// params.GetDefaultE2ESessionParams()) -// -// // Generate a session ID, bypassing some business logic here -// oldSessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup, -// aliceSIDHPrivKey, bobSIDHPubKey) -// -// // Generate the message -// rekey, _ := proto.Marshal(&RekeyTrigger{ -// SessionID: oldSessionID.Marshal(), -// PublicKey: newBobPubKey.Bytes(), -// SidhPublicKey: newBobSIDHPubKeyBytes, -// }) -// -// receiveMsg := message.Receive{ -// Payload: rekey, -// MessageType: message.NoType, -// Sender: bobID, -// Timestamp: netTime.Now(), -// Encryption: message.E2E, -// } -// -// // Handle the trigger and check for an error -// rekeyParams := params.GetDefaultRekey() -// stop := stoppable.NewSingle("stoppable") -// rekeyParams.RoundTimeout = 0 * time.Second -// err = handleTrigger(aliceSession, aliceManager, receiveMsg, rekeyParams, stop) -// if err != nil { -// t.Errorf("Handle trigger error: %v", err) -// } -// -// // get Alice's manager for reception from Bob -// receivedManager, err := aliceSession.E2e().GetPartner(bobID) -// if err != nil { -// t.Errorf("Failed to get bob's manager: %v", err) -// } -// -// // Generate the new session ID based off of Bob's new keys -// baseKey := session2.GenerateE2ESessionBaseKey(alicePrivKey, newBobPubKey, -// genericGroup, aliceSIDHPrivKey, newBobSIDHPubKey) -// newSessionID := session2.GetSessionIDFromBaseKeyForTesting(baseKey, t) -// -// // Check that this new session ID is now in the manager -// newSession := receivedManager.GetReceiveSession(newSessionID) -// if newSession == nil { -// t.Errorf("Did not get expected session") -// } -// -// // Generate a keypair alice will not recognize -// unknownPrivateKey := dh.GeneratePrivateKey(dh.DefaultPrivateKeyLength, genericGroup, csprng.NewSystemRNG()) -// unknownPubliceKey := dh.GeneratePublicKey(unknownPrivateKey, genericGroup) -// -// // Generate a new session ID based off of these unrecognized keys -// badSessionID := session2.GetSessionIDFromBaseKeyForTesting(unknownPubliceKey, t) -// -// // Check that this session with unrecognized keys is not valid -// badSession := receivedManager.GetReceiveSession(badSessionID) -// if badSession != nil { -// t.Errorf("Alice found a session from an unknown keypair. "+ -// "\nSession: %v", badSession) -// } -// -//} +func TestHandleTrigger(t *testing.T) { + grp := getGroup() + rng := fastRNG.NewStreamGenerator(1000, 10, csprng.NewSystemRNG) + // Generate alice and bob's session + // Pull the keys for Alice and Bob + bobPrivKey := dh.GeneratePrivateKey(dh.DefaultPrivateKeyLength, + grp, rng.GetStream()) + bobPubKey := dh.GeneratePublicKey(bobPrivKey, grp) + alicePrivKey := dh.GeneratePrivateKey(dh.DefaultPrivateKeyLength, grp, rng.GetStream()) + alicePubKey := dh.GeneratePublicKey(alicePrivKey, grp) + + // Generate bob's new keypair + newBobPrivKey := dh.GeneratePrivateKey(dh.DefaultPrivateKeyLength, grp, csprng.NewSystemRNG()) + newBobPubKey := dh.GeneratePublicKey(newBobPrivKey, grp) + + aliceVariant := sidh.KeyVariantSidhA + prng1 := rand.New(rand.NewSource(int64(1))) + aliceSIDHPrivKey := util.NewSIDHPrivateKey(aliceVariant) + aliceSIDHPubKey := util.NewSIDHPublicKey(aliceVariant) + aliceSIDHPrivKey.Generate(prng1) + aliceSIDHPrivKey.GeneratePublicKey(aliceSIDHPubKey) + + bobVariant := sidh.KeyVariant(sidh.KeyVariantSidhB) + prng2 := rand.New(rand.NewSource(int64(2))) + bobSIDHPrivKey := util.NewSIDHPrivateKey(bobVariant) + bobSIDHPubKey := util.NewSIDHPublicKey(bobVariant) + bobSIDHPrivKey.Generate(prng2) + bobSIDHPrivKey.GeneratePublicKey(bobSIDHPubKey) + + newBobSIDHPrivKey := util.NewSIDHPrivateKey(bobVariant) + newBobSIDHPubKey := util.NewSIDHPublicKey(bobVariant) + newBobSIDHPrivKey.Generate(prng2) + newBobSIDHPrivKey.GeneratePublicKey(newBobSIDHPubKey) + newBobSIDHPubKeyBytes := make([]byte, newBobSIDHPubKey.Size()+1) + newBobSIDHPubKeyBytes[0] = byte(bobVariant) + newBobSIDHPubKey.Export(newBobSIDHPubKeyBytes[1:]) + + // Maintain an ID for bob + bobID = id.NewIdFromBytes([]byte("test"), t) + myID = id.NewIdFromString("zezima", id.User, t) + kv := versioned.NewKV(ekv.Memstore{}) + + err := ratchet.New(kv, myID, alicePrivKey, grp) + if err != nil { + t.Errorf("Failed to create ratchet: %+v", err) + } + r, err = ratchet.Load(kv, myID, grp, mockCyHandler{}, mockServiceHandler{}, rng) + if err != nil { + t.Errorf("Failed to load ratchet: %+v", err) + } + + // Add bob as a partner + sendParams := session2.GetDefaultE2ESessionParams() + receiveParams := session2.GetDefaultE2ESessionParams() + _, err = r.AddPartner(myID, bobID, bobPubKey, alicePrivKey, bobSIDHPubKey, aliceSIDHPrivKey, sendParams, receiveParams, false) + if err != nil { + t.Errorf("Failed to add partner to ratchet: %+v", err) + } + _, err = r.AddPartner(bobID, myID, alicePubKey, bobPrivKey, aliceSIDHPubKey, bobSIDHPrivKey, sendParams, receiveParams, false) + if err != nil { + t.Errorf("Failed to add partner to ratchet: %+v", err) + } + // Generate a session ID, bypassing some business logic here + oldSessionID := GeneratePartnerID(alicePrivKey, bobPubKey, grp, + aliceSIDHPrivKey, bobSIDHPubKey) + + // Generate the message + rekey, _ := proto.Marshal(&RekeyTrigger{ + SessionID: oldSessionID.Marshal(), + PublicKey: newBobPubKey.Bytes(), + SidhPublicKey: newBobSIDHPubKeyBytes, + }) + + receiveMsg := receive.Message{ + Payload: rekey, + MessageType: catalog.NoType, + Sender: bobID, + Timestamp: netTime.Now(), + Encrypted: true, + } + + // Handle the trigger and check for an error + rekeyParams := GetDefaultParams() + stop := stoppable.NewSingle("stoppable") + rekeyParams.RoundTimeout = 0 * time.Second + err = handleTrigger(r, testSendE2E, &mockNetManager{}, grp, receiveMsg, rekeyParams, stop) + if err != nil { + t.Errorf("Handle trigger error: %v", err) + } + + // get Alice's manager for reception from Bob + + receivedManager, err := r.GetPartner(bobID, myID) + if err != nil { + t.Errorf("Failed to get bob's manager: %v", err) + } + + // Generate the new session ID based off of Bob's new keys + baseKey := session2.GenerateE2ESessionBaseKey(alicePrivKey, newBobPubKey, + grp, aliceSIDHPrivKey, newBobSIDHPubKey) + newSessionID := session2.GetSessionIDFromBaseKeyForTesting(baseKey, t) + + // Check that this new session ID is now in the manager + newSession := receivedManager.GetReceiveSession(newSessionID) + if newSession == nil { + t.Errorf("Did not get expected session") + } + + // Generate a keypair alice will not recognize + unknownPrivateKey := dh.GeneratePrivateKey(dh.DefaultPrivateKeyLength, grp, csprng.NewSystemRNG()) + unknownPubliceKey := dh.GeneratePublicKey(unknownPrivateKey, grp) + + // Generate a new session ID based off of these unrecognized keys + badSessionID := session2.GetSessionIDFromBaseKeyForTesting(unknownPubliceKey, t) + + // Check that this session with unrecognized keys is not valid + badSession := receivedManager.GetReceiveSession(badSessionID) + if badSession != nil { + t.Errorf("Alice found a session from an unknown keypair. "+ + "\nSession: %v", badSession) + } + +} diff --git a/e2e/rekey/utils_test.go b/e2e/rekey/utils_test.go index e8c8ae2941515af6b1181029ef992531341ad419..2acffacd239a087bde4dcf7271f73b41cb97ed6f 100644 --- a/e2e/rekey/utils_test.go +++ b/e2e/rekey/utils_test.go @@ -14,13 +14,20 @@ import ( session2 "gitlab.com/elixxir/client/e2e/ratchet/partner/session" "gitlab.com/elixxir/client/e2e/receive" "gitlab.com/elixxir/client/network" + "gitlab.com/elixxir/client/network/gateway" + "gitlab.com/elixxir/client/network/historical" "gitlab.com/elixxir/client/network/message" + "gitlab.com/elixxir/client/stoppable" util "gitlab.com/elixxir/client/storage/utility" + network2 "gitlab.com/elixxir/comms/network" "gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/e2e" "gitlab.com/elixxir/crypto/hash" + "gitlab.com/elixxir/primitives/format" + "gitlab.com/xx_network/comms/connect" "gitlab.com/xx_network/crypto/large" "gitlab.com/xx_network/primitives/id" + "gitlab.com/xx_network/primitives/id/ephemeral" "gitlab.com/xx_network/primitives/ndf" "gitlab.com/xx_network/primitives/netTime" "gitlab.com/xx_network/primitives/region" @@ -84,7 +91,7 @@ func testSendE2E(mt catalog.MessageType, recipient *id.ID, payload []byte, cmixP confirmMessage := receive.Message{ Payload: messagePayload, MessageType: catalog.KeyExchangeConfirm, - Sender: exchangeAliceId, + Sender: myID, Timestamp: netTime.Now(), Encrypted: true, } @@ -94,71 +101,8 @@ func testSendE2E(mt catalog.MessageType, recipient *id.ID, payload []byte, cmixP return rounds, e2e.MessageID{}, time.Time{}, nil } -// Intended for alice to send to bob. Trigger's Bob's confirmation, chaining the operation -// together -//func (t *testNetworkManagerFullExchange) SendE2E(message.Send, params.E2E, *stoppable.Single) ( -// []id.Round, cE2e.MessageID, time.Time, error) { -// -// rounds := []id.Round{id.Round(0), id.Round(1), id.Round(2)} -// alicePrivKey := aliceSession.E2e().GetDHPrivateKey() -// bobPubKey := bobSession.E2e().GetDHPublicKey() -// -// aliceVariant := sidh.KeyVariantSidhA -// prng1 := rand.New(rand.NewSource(int64(1))) -// aliceSIDHPrivKey := util.NewSIDHPrivateKey(aliceVariant) -// aliceSIDHPubKey := util.NewSIDHPublicKey(aliceVariant) -// aliceSIDHPrivKey.Generate(prng1) -// aliceSIDHPrivKey.GeneratePublicKey(aliceSIDHPubKey) -// -// bobVariant := sidh.KeyVariant(sidh.KeyVariantSidhB) -// prng2 := rand.New(rand.NewSource(int64(2))) -// bobSIDHPrivKey := util.NewSIDHPrivateKey(bobVariant) -// bobSIDHPubKey := util.NewSIDHPublicKey(bobVariant) -// bobSIDHPrivKey.Generate(prng2) -// bobSIDHPrivKey.GeneratePublicKey(bobSIDHPubKey) -// -// sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup, -// aliceSIDHPrivKey, bobSIDHPubKey) -// -// rekeyConfirm, _ := proto.Marshal(&RekeyConfirm{ -// SessionID: sessionID.Marshal(), -// }) -// payload := make([]byte, 0) -// payload = append(payload, rekeyConfirm...) -// -// confirmMessage := message.Receive{ -// Payload: payload, -// MessageType: message.KeyExchangeConfirm, -// Sender: exchangeAliceId, -// Timestamp: netTime.Now(), -// Encryption: message.E2E, -// } -// -// bobSwitchboard.Speak(confirmMessage) -// -// return rounds, cE2e.MessageID{}, time.Time{}, nil -//} - var pub = "-----BEGIN CERTIFICATE-----\n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\n-----END CERTIFICATE-----\n" -//var genericGroup = cyclic.NewGroup( -// large.NewIntFromString("9DB6FB5951B66BB6FE1E140F1D2CE5502374161FD6538DF1648218642F0B5C48"+ -// "C8F7A41AADFA187324B87674FA1822B00F1ECF8136943D7C55757264E5A1A44F"+ -// "FE012E9936E00C1D3E9310B01C7D179805D3058B2A9F4BB6F9716BFE6117C6B5"+ -// "B3CC4D9BE341104AD4A80AD6C94E005F4B993E14F091EB51743BF33050C38DE2"+ -// "35567E1B34C3D6A5C0CEAA1A0F368213C3D19843D0B4B09DCB9FC72D39C8DE41"+ -// "F1BF14D4BB4563CA28371621CAD3324B6A2D392145BEBFAC748805236F5CA2FE"+ -// "92B871CD8F9C36D3292B5509CA8CAA77A2ADFC7BFD77DDA6F71125A7456FEA15"+ -// "3E433256A2261C6A06ED3693797E7995FAD5AABBCFBE3EDA2741E375404AE25B", 16), -// large.NewIntFromString("5C7FF6B06F8F143FE8288433493E4769C4D988ACE5BE25A0E24809670716C613"+ -// "D7B0CEE6932F8FAA7C44D2CB24523DA53FBE4F6EC3595892D1AA58C4328A06C4"+ -// "6A15662E7EAA703A1DECF8BBB2D05DBE2EB956C142A338661D10461C0D135472"+ -// "085057F3494309FFA73C611F78B32ADBB5740C361C9F35BE90997DB2014E2EF5"+ -// "AA61782F52ABEB8BD6432C4DD097BC5423B285DAFB60DC364E8161F4A2A35ACA"+ -// "3A10B1C4D203CC76A470A33AFDCBDD92959859ABD8B56E1725252D78EAC66E71"+ -// "BA9AE3F1DD2487199874393CD4D832186800654760E1E34C09E4D155179F9EC0"+ -// "DC4473F996BDCE6EED1CABED8B6F116F7AD9CF505DF0F998E34AB27514B0FFE7", 16)) - func getNDF(t *testing.T) *ndf.NetworkDefinition { return &ndf.NetworkDefinition{ E2E: ndf.Group{ @@ -258,3 +202,119 @@ func (m mockServiceHandler) DeleteService(clientID *id.ID, toDelete message.Serv processor message.Processor) { return } + +type mockNetManager struct{} + +func (m *mockNetManager) Follow(report network.ClientErrorReport) (stoppable.Stoppable, error) { + return nil, nil +} + +func (m *mockNetManager) GetMaxMessageLength() int { + return 0 +} + +func (m *mockNetManager) SendCMIX(recipient *id.ID, fingerprint format.Fingerprint, + service message.Service, payload, mac []byte, cmixParams network.CMIXParams) ( + id.Round, ephemeral.Id, error) { + return id.Round(0), ephemeral.Id{}, nil +} + +func (m *mockNetManager) SendManyCMIX(messages []network.TargetedCmixMessage, p network.CMIXParams) ( + id.Round, []ephemeral.Id, error) { + return id.Round(0), nil, nil +} + +func (m *mockNetManager) AddIdentity(id *id.ID, validUntil time.Time, persistent bool) {} + +func (m *mockNetManager) RemoveIdentity(id *id.ID) {} + +func (m *mockNetManager) AddFingerprint(identity *id.ID, fingerprint format.Fingerprint, + mp message.Processor) error { + return nil +} + +func (m *mockNetManager) DeleteFingerprint(identity *id.ID, fingerprint format.Fingerprint) {} + +func (m *mockNetManager) DeleteClientFingerprints(identity *id.ID) {} + +func (m *mockNetManager) AddService(clientID *id.ID, newService message.Service, + response message.Processor) { +} + +func (m *mockNetManager) DeleteService(clientID *id.ID, toDelete message.Service, + processor message.Processor) { +} + +func (m *mockNetManager) DeleteClientService(clientID *id.ID) {} + +func (m *mockNetManager) TrackServices(tracker message.ServicesTracker) {} + +func (m *mockNetManager) CheckInProgressMessages() {} + +func (m *mockNetManager) IsHealthy() bool { + return true +} + +func (m *mockNetManager) WasHealthy() bool { + return true +} + +func (m *mockNetManager) AddHealthCallback(f func(bool)) uint64 { + return 0 +} + +func (m *mockNetManager) RemoveHealthCallback(uint64) {} + +func (m *mockNetManager) HasNode(nid *id.ID) bool { + return true +} + +func (m *mockNetManager) NumRegisteredNodes() int { + return 0 +} + +func (m *mockNetManager) TriggerNodeRegistration(nid *id.ID) {} + +func (m *mockNetManager) GetRoundResults(timeout time.Duration, roundCallback network.RoundEventCallback, + roundList ...id.Round) error { + return nil +} + +func (m *mockNetManager) LookupHistoricalRound( + rid id.Round, callback historical.RoundResultCallback) error { + return nil +} + +func (m *mockNetManager) SendToAny(sendFunc func(host *connect.Host) (interface{}, error), + stop *stoppable.Single) (interface{}, error) { + return nil, nil +} + +func (m *mockNetManager) SendToPreferred(targets []*id.ID, sendFunc gateway.SendToPreferredFunc, + stop *stoppable.Single, timeout time.Duration) (interface{}, error) { + return nil, nil +} + +func (m *mockNetManager) SetGatewayFilter(f gateway.Filter) {} + +func (m *mockNetManager) GetHostParams() connect.HostParams { + return connect.GetDefaultHostParams() +} + +func (m *mockNetManager) GetAddressSpace() uint8 { + return 0 +} + +func (m *mockNetManager) RegisterAddressSpaceNotification(tag string) (chan uint8, error) { + return make(chan uint8), nil +} + +func (m *mockNetManager) UnregisterAddressSpaceNotification(tag string) {} + +func (m *mockNetManager) GetInstance() *network2.Instance { + return nil +} + +func (m *mockNetManager) GetVerboseRounds() string { + return "" +}