diff --git a/auth/confirm.go b/auth/confirm.go index 72928f04927ab8ccd8a50e06096eeab480a57775..05c1bc136ac567749d1115b7e13d1c7091da1a6b 100644 --- a/auth/confirm.go +++ b/auth/confirm.go @@ -15,7 +15,6 @@ import ( "gitlab.com/elixxir/client/auth/store" "gitlab.com/elixxir/client/cmix" "gitlab.com/elixxir/client/cmix/message" - "gitlab.com/elixxir/client/e2e/ratchet/partner/session" "gitlab.com/elixxir/client/event" util "gitlab.com/elixxir/client/storage/utility" "gitlab.com/elixxir/crypto/contact" @@ -110,7 +109,7 @@ func (s *state) confirm(partner contact.Contact, serviceTag string) ( // into critical messages does not occur // create local relationship - p := session.GetDefaultParams() + p := s.sessionParams _, err := s.e2e.AddPartner(partner.ID, partner.DhPubKey, dhPriv, rr.GetTheirSidHPubKeyA(), sidhPriv, p, p) if err != nil { diff --git a/auth/receivedConfirm.go b/auth/receivedConfirm.go index bf25d5661743e226f2d7cb2024cff457365ab20c..ad30186d15c911dbc739495ccf58df4bdcf05818 100644 --- a/auth/receivedConfirm.go +++ b/auth/receivedConfirm.go @@ -9,7 +9,6 @@ import ( "gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/message" "gitlab.com/elixxir/client/cmix/rounds" - "gitlab.com/elixxir/client/e2e/ratchet/partner/session" "gitlab.com/elixxir/crypto/contact" cAuth "gitlab.com/elixxir/crypto/e2e/auth" "gitlab.com/elixxir/primitives/fact" @@ -90,7 +89,7 @@ func (rcs *receivedConfirmService) Process(msg format.Message, } // add the partner - p := session.GetDefaultParams() + p := authState.sessionParams _, err = authState.e2e.AddPartner(rcs.GetPartner(), partnerPubKey, rcs.GetMyPrivKey(), partnerSIDHPubKey, rcs.GetMySIDHPrivKey(), p, p) if err != nil { diff --git a/auth/state.go b/auth/state.go index 3b82f15e46049abd5cc8be2367fb4abb45b68e71..f77da163641d59a5be7004c8f52b498e3c2cb6bb 100644 --- a/auth/state.go +++ b/auth/state.go @@ -9,12 +9,14 @@ package auth import ( "encoding/base64" + "github.com/pkg/errors" "gitlab.com/elixxir/client/auth/store" "gitlab.com/elixxir/client/cmix" "gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/message" "gitlab.com/elixxir/client/e2e" + "gitlab.com/elixxir/client/e2e/ratchet/partner/session" "gitlab.com/elixxir/client/event" "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/crypto/fastRNG" @@ -37,6 +39,10 @@ type state struct { params Params + // These are the parameters used when creating/adding session + // partners + sessionParams session.Params + backupTrigger func(reason string) } @@ -56,11 +62,12 @@ type state struct { // with a memory only versioned.KV) as well as a memory only versioned.KV for // NewState and use GetDefaultTemporaryParams() for the parameters func NewState(kv *versioned.KV, net cmix.Client, e2e e2e.Handler, - rng *fastRNG.StreamGenerator, event event.Reporter, params Params, - callbacks Callbacks, backupTrigger func(reason string)) (State, error) { + rng *fastRNG.StreamGenerator, event event.Reporter, authParams Params, + sessParams session.Params, callbacks Callbacks, + backupTrigger func(reason string)) (State, error) { kv = kv.Prefix(makeStorePrefix(e2e.GetReceptionID())) - return NewStateLegacy( - kv, net, e2e, rng, event, params, callbacks, backupTrigger) + return NewStateLegacy(kv, net, e2e, rng, event, authParams, sessParams, + callbacks, backupTrigger) } // NewStateLegacy loads the auth state or creates new auth state if one cannot @@ -68,8 +75,9 @@ func NewState(kv *versioned.KV, net cmix.Client, e2e e2e.Handler, // Does not modify the kv prefix for backwards compatibility. // Otherwise, acts the same as NewState func NewStateLegacy(kv *versioned.KV, net cmix.Client, e2e e2e.Handler, - rng *fastRNG.StreamGenerator, event event.Reporter, params Params, - callbacks Callbacks, backupTrigger func(reason string)) (State, error) { + rng *fastRNG.StreamGenerator, event event.Reporter, authParams Params, + sessParams session.Params, callbacks Callbacks, + backupTrigger func(reason string)) (State, error) { s := &state{ callbacks: callbacks, @@ -78,7 +86,8 @@ func NewStateLegacy(kv *versioned.KV, net cmix.Client, e2e e2e.Handler, e2e: e2e, rng: rng, event: event, - params: params, + params: authParams, + sessionParams: sessParams, backupTrigger: backupTrigger, } @@ -90,13 +99,13 @@ func NewStateLegacy(kv *versioned.KV, net cmix.Client, e2e e2e.Handler, // register services net.AddService(e2e.GetReceptionID(), message.Service{ Identifier: e2e.GetReceptionID()[:], - Tag: params.RequestTag, + Tag: authParams.RequestTag, Metadata: nil, }, &receivedRequestService{s: s, reset: false}) net.AddService(e2e.GetReceptionID(), message.Service{ Identifier: e2e.GetReceptionID()[:], - Tag: params.ResetRequestTag, + Tag: authParams.ResetRequestTag, Metadata: nil, }, &receivedRequestService{s: s, reset: true}) diff --git a/bindings/autheticatedConnection.go b/bindings/autheticatedConnection.go index cc0ef41a8092ad48d45e9c7357c502ed4483e632..837580897b1bb71f8faf9a6d916075731bad527f 100644 --- a/bindings/autheticatedConnection.go +++ b/bindings/autheticatedConnection.go @@ -25,6 +25,8 @@ func (_ *AuthenticatedConnection) IsAuthenticated() bool { // with the server and then authenticate their identity to the server. // accepts a marshalled ReceptionIdentity and contact.Contact object func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact []byte) (*AuthenticatedConnection, error) { + paramsJSON := GetDefaultE2EParams() + cont, err := contact.Unmarshal(recipientContact) if err != nil { return nil, err @@ -35,6 +37,12 @@ func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact []byte) (*A return nil, err } - connection, err := connect.ConnectWithAuthentication(cont, e2eClient.api, connect.GetDefaultParams()) - return authenticatedConnectionTrackerSingleton.make(connection), nil + params, err := parseE2EParams(paramsJSON) + if err != nil { + return nil, err + } + + connection, err := connect.ConnectWithAuthentication(cont, + e2eClient.api, params) + return authenticatedConnectionTrackerSingleton.make(connection), err } diff --git a/bindings/cmix.go b/bindings/cmix.go index 2003f7c2fa876a091325fdd5b1f04a3bc710de98..5c1790738b07c8ca143ee34e24b16b083be88836 100644 --- a/bindings/cmix.go +++ b/bindings/cmix.go @@ -2,6 +2,7 @@ package bindings import ( "fmt" + "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/xxdk" @@ -50,7 +51,13 @@ func NewKeystore(network, storageDir string, password []byte, regCode string) er // starts subprocesses to perform network operations. // TODO: add in custom parameters instead of the default func Login(storageDir string, password []byte) (*Cmix, error) { - client, err := xxdk.LoadCmix(storageDir, password, xxdk.GetDefaultParams()) + paramsJSON := GetDefaultCMixParams() + params, err := parseCMixParams(paramsJSON) + if err != nil { + return nil, err + } + + client, err := xxdk.LoadCmix(storageDir, password, params) if err != nil { return nil, errors.New(fmt.Sprintf("Failed to login: %+v", err)) } diff --git a/bindings/connect.go b/bindings/connect.go index 98f9795398040d1cb372e8c54fb4d273efd84dbc..94d13cba8ec571c07da43b0fd286a06731eb7ee3 100644 --- a/bindings/connect.go +++ b/bindings/connect.go @@ -2,11 +2,10 @@ package bindings import ( "encoding/json" + "gitlab.com/elixxir/client/catalog" "gitlab.com/elixxir/client/connect" - e2e2 "gitlab.com/elixxir/client/e2e" "gitlab.com/elixxir/crypto/contact" - "time" ) // connectionTrackerSingleton is used to track connections so they can be @@ -35,6 +34,7 @@ func (c *Connection) GetId() int { // myIdentity - marshalled ReceptionIdentity object func (c *Cmix) Connect(e2eId int, recipientContact []byte) ( *Connection, error) { + paramsJSON := GetDefaultE2EParams() cont, err := contact.Unmarshal(recipientContact) if err != nil { return nil, err @@ -45,8 +45,11 @@ func (c *Cmix) Connect(e2eId int, recipientContact []byte) ( return nil, err } - p := connect.GetDefaultParams() - p.Timeout = 45 * time.Second + p, err := parseE2EParams(paramsJSON) + if err != nil { + return nil, err + } + connection, err := connect.Connect(cont, e2eClient.api, p) if err != nil { return nil, err @@ -58,8 +61,15 @@ func (c *Cmix) Connect(e2eId int, recipientContact []byte) ( // SendE2E is a wrapper for sending specifically to the Connection's partner.Manager // Returns marshalled E2ESendReport func (c *Connection) SendE2E(mt int, payload []byte) ([]byte, error) { + paramsJSON := GetDefaultE2EParams() + + params, err := parseE2EParams(paramsJSON) + if err != nil { + return nil, err + } + rounds, mid, ts, err := c.connection.SendE2E(catalog.MessageType(mt), payload, - e2e2.GetDefaultParams()) + params.Base) if err != nil { return nil, err diff --git a/bindings/e2e.go b/bindings/e2e.go index bd849f9ad1304b14b6eaa3a20e8177059c82c7d6..b2e9984d5f3759cf90eb4f6d111d37ee91b97a05 100644 --- a/bindings/e2e.go +++ b/bindings/e2e.go @@ -36,6 +36,7 @@ func (e *E2e) GetID() int { // identity should be created via MakeIdentity() and passed in here // If callbacks is left nil, a default auth.Callbacks will be used func LoginE2e(cmixId int, callbacks AuthCallbacks, identity []byte) (*E2e, error) { + paramsJSON := GetDefaultE2EParams() cmix, err := cmixTrackerSingleton.get(cmixId) if err != nil { return nil, err @@ -53,7 +54,12 @@ func LoginE2e(cmixId int, callbacks AuthCallbacks, identity []byte) (*E2e, error authCallbacks = &authCallback{bindingsCbs: callbacks} } - newE2e, err := xxdk.Login(cmix.api, authCallbacks, newIdentity) + params, err := parseE2EParams(paramsJSON) + if err != nil { + return nil, err + } + + newE2e, err := xxdk.Login(cmix.api, authCallbacks, newIdentity, params) if err != nil { return nil, err } @@ -65,6 +71,7 @@ func LoginE2e(cmixId int, callbacks AuthCallbacks, identity []byte) (*E2e, error // identity should be created via MakeIdentity() and passed in here // If callbacks is left nil, a default auth.Callbacks will be used func LoginE2eEphemeral(cmixId int, callbacks AuthCallbacks, identity []byte) (*E2e, error) { + paramsJSON := GetDefaultE2EParams() cmix, err := cmixTrackerSingleton.get(cmixId) if err != nil { return nil, err @@ -82,7 +89,13 @@ func LoginE2eEphemeral(cmixId int, callbacks AuthCallbacks, identity []byte) (*E authCallbacks = &authCallback{bindingsCbs: callbacks} } - newE2e, err := xxdk.LoginEphemeral(cmix.api, authCallbacks, newIdentity) + params, err := parseE2EParams(paramsJSON) + if err != nil { + return nil, err + } + + newE2e, err := xxdk.LoginEphemeral(cmix.api, authCallbacks, + newIdentity, params) if err != nil { return nil, err } @@ -95,6 +108,7 @@ func LoginE2eEphemeral(cmixId int, callbacks AuthCallbacks, identity []byte) (*E // This function is designed to maintain backwards compatibility with previous xx messenger designs // and should not be used for other purposes func LoginE2eLegacy(cmixId int, callbacks AuthCallbacks) (*E2e, error) { + paramsJSON := GetDefaultE2EParams() cmix, err := cmixTrackerSingleton.get(cmixId) if err != nil { return nil, err @@ -107,7 +121,12 @@ func LoginE2eLegacy(cmixId int, callbacks AuthCallbacks) (*E2e, error) { authCallbacks = &authCallback{bindingsCbs: callbacks} } - newE2e, err := xxdk.LoginLegacy(cmix.api, authCallbacks) + params, err := parseE2EParams(paramsJSON) + if err != nil { + return nil, err + } + + newE2e, err := xxdk.LoginLegacy(cmix.api, params, authCallbacks) if err != nil { return nil, err } diff --git a/bindings/e2eHandler.go b/bindings/e2eHandler.go index 043b69ce352fb51653608f56e1dce09af7a62c02..3fe81a225c31f4fef7aade2361943a95f44817ae 100644 --- a/bindings/e2eHandler.go +++ b/bindings/e2eHandler.go @@ -9,6 +9,7 @@ package bindings import ( "encoding/json" "fmt" + "gitlab.com/elixxir/client/catalog" "gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/rounds" @@ -120,7 +121,7 @@ func (e *E2e) RemoveService(tag string) error { // - []byte - the marshalled bytes of the E2ESendReport object. func (e *E2e) SendE2E(messageType int, recipientId, payload, e2eParams []byte) ([]byte, error) { - + // Note that specifically these are the .Base params from xxdk.E2EParams params := e2e.GetDefaultParams() err := params.UnmarshalJSON(e2eParams) if err != nil { diff --git a/bindings/params.go b/bindings/params.go new file mode 100644 index 0000000000000000000000000000000000000000..860c1fbcd1077201c2d285d84af37881fe54e8eb --- /dev/null +++ b/bindings/params.go @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright © 2020 xx network SEZC // +// // +// Use of this source code is governed by a license that can be found in the // +// LICENSE file // +/////////////////////////////////////////////////////////////////////////////// + +// params.go provides functions for getting and setting parameters in bindings. + +package bindings + +import ( + jww "github.com/spf13/jwalterweatherman" + "gitlab.com/elixxir/client/xxdk" +) + +// GetDefaultCMixParams returns a JSON serialized object with all of the +// CMIX parameters and their default values. Call this function and modify +// the json to change CMIX settings. +func GetDefaultCMixParams() []byte { + defaultParams := xxdk.GetDefaultCMixParams() + data, err := defaultParams.Marshal() + if err != nil { + jww.FATAL.Panicf("Unexpected error: %+v", err) + } + return data +} + +// GetDefaultE2EParams returns a JSON serialized object with all of the +// E2E parameters and their default values. Call this function and modify +// the json to change E2E settings. +func GetDefaultE2EParams() []byte { + defaultParams := xxdk.GetDefaultE2EParams() + data, err := defaultParams.Marshal() + if err != nil { + jww.FATAL.Panicf("Unexpected error: %+v", err) + } + return data +} + +func parseCMixParams(data []byte) (xxdk.CMIXParams, error) { + p := &xxdk.CMIXParams{} + err := p.Unmarshal(data) + return *p, err +} + +func parseE2EParams(data []byte) (xxdk.E2EParams, error) { + p := &xxdk.E2EParams{} + err := p.Unmarshal(data) + return *p, err +} diff --git a/bindings/restlike.go b/bindings/restlike.go index c6c31c7ae744e644747a8da6018471fd03b8680e..be0bd004f7bce59111e3c347ceecb7b5eab5bfcf 100644 --- a/bindings/restlike.go +++ b/bindings/restlike.go @@ -8,6 +8,7 @@ package bindings import ( "encoding/json" + "gitlab.com/elixxir/client/e2e" "gitlab.com/elixxir/client/restlike" "gitlab.com/elixxir/client/restlike/connect" @@ -34,6 +35,8 @@ type RestlikeMessage struct { // request - marshalled RestlikeMessage // Returns marshalled result RestlikeMessage func RestlikeRequest(clientID int, connectionID int, request []byte) ([]byte, error) { + paramsJSON := GetDefaultE2EParams() + cl, err := cmixTrackerSingleton.get(clientID) if err != nil { return nil, err @@ -43,6 +46,11 @@ func RestlikeRequest(clientID int, connectionID int, request []byte) ([]byte, er return nil, err } + params, err := parseE2EParams(paramsJSON) + if err != nil { + return nil, err + } + msg := &RestlikeMessage{} err = json.Unmarshal(request, msg) if err != nil { @@ -58,7 +66,7 @@ func RestlikeRequest(clientID int, connectionID int, request []byte) ([]byte, er result, err := c.Request(restlike.Method(msg.Method), restlike.URI(msg.URI), msg.Content, &restlike.Headers{ Headers: msg.Headers, Version: msg.Version, - }, e2e.GetDefaultParams()) + }, params.Base) if err != nil { return nil, err } diff --git a/cmd/broadcast.go b/cmd/broadcast.go index 1b4039dd54afbaca2ed87ae257c5c584fcb52a73..5d98893bd533444b459563bc22c7ed4790a67784 100644 --- a/cmd/broadcast.go +++ b/cmd/broadcast.go @@ -2,6 +2,9 @@ package cmd import ( "fmt" + "os" + "time" + "github.com/spf13/cobra" jww "github.com/spf13/jwalterweatherman" "github.com/spf13/viper" @@ -12,8 +15,6 @@ import ( crypto "gitlab.com/elixxir/crypto/broadcast" "gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/primitives/utils" - "os" - "time" ) // singleCmd is the single-use subcommand that allows for sending and responding @@ -23,7 +24,8 @@ var broadcastCmd = &cobra.Command{ Short: "Send broadcast messages", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - client := initE2e() + cmixParams, e2eParams := initParams() + client := initE2e(cmixParams, e2eParams) // Write user contact to file user := client.GetReceptionIdentity() diff --git a/cmd/callbacks.go b/cmd/callbacks.go index d5d75a321f7e215062738184bbaab954812c29b6..4be99e0d0b6c7521d34cdd4cfa7e9ac90a763dbe 100644 --- a/cmd/callbacks.go +++ b/cmd/callbacks.go @@ -10,6 +10,7 @@ package cmd import ( "fmt" + "github.com/spf13/viper" "gitlab.com/elixxir/client/xxdk" @@ -26,12 +27,14 @@ import ( type authCallbacks struct { autoConfirm bool confCh chan *id.ID + params xxdk.E2EParams } -func makeAuthCallbacks(autoConfirm bool) *authCallbacks { +func makeAuthCallbacks(autoConfirm bool, params xxdk.E2EParams) *authCallbacks { return &authCallbacks{ autoConfirm: autoConfirm, confCh: make(chan *id.ID, 10), + params: params, } } @@ -46,7 +49,7 @@ func (a *authCallbacks) Request(requestor contact.Contact, jww.INFO.Printf("Channel Request: %s", requestor.ID) if viper.GetBool("verify-sends") { // Verify message sends were successful - acceptChannelVerified(client, requestor.ID) + acceptChannelVerified(client, requestor.ID, a.params) } else { acceptChannel(client, requestor.ID) } diff --git a/cmd/fileTransfer.go b/cmd/fileTransfer.go index 468bc50fe270ecc3a9114cc8aedf8627ddcd0f90..eb9b7f34e441b078db012e114b3abc45f00154a3 100644 --- a/cmd/fileTransfer.go +++ b/cmd/fileTransfer.go @@ -9,10 +9,11 @@ package cmd import ( "fmt" - "gitlab.com/elixxir/client/xxdk" "io/ioutil" "time" + "gitlab.com/elixxir/client/xxdk" + "github.com/spf13/cobra" jww "github.com/spf13/jwalterweatherman" "github.com/spf13/viper" @@ -34,9 +35,8 @@ var ftCmd = &cobra.Command{ Short: "Send and receive file for cMix client", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - - // Initialise a new client - client := initE2e() + cmixParams, e2eParams := initParams() + client := initE2e(cmixParams, e2eParams) // Print user's reception ID and save contact file user := client.GetReceptionIdentity() diff --git a/cmd/group.go b/cmd/group.go index 1520d97c648ed47d952636c9f8aba703c04295cd..3045e71b328bc51dc71fd30364398e761c7170b3 100644 --- a/cmd/group.go +++ b/cmd/group.go @@ -12,12 +12,13 @@ package cmd import ( "bufio" "fmt" + "os" + "time" + "gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/rounds" "gitlab.com/elixxir/client/xxdk" "gitlab.com/elixxir/primitives/format" - "os" - "time" "github.com/spf13/cobra" jww "github.com/spf13/jwalterweatherman" @@ -33,8 +34,8 @@ var groupCmd = &cobra.Command{ Short: "Group commands for cMix client", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - - client := initE2e() + cmixParams, e2eParams := initParams() + client := initE2e(cmixParams, e2eParams) // Print user's reception ID user := client.GetReceptionIdentity() diff --git a/cmd/root.go b/cmd/root.go index fa78f7dacb34f9a5f5789634fdb88a665fbcb8fb..049b9fb3a2eb1cfce0be2225119a55c04a5fb415 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -28,7 +28,6 @@ import ( "gitlab.com/elixxir/client/storage/user" "gitlab.com/elixxir/client/backup" - "gitlab.com/elixxir/client/e2e" "gitlab.com/elixxir/client/xxdk" "gitlab.com/elixxir/client/catalog" @@ -197,7 +196,9 @@ var rootCmd = &cobra.Command{ pprof.StartCPUProfile(f) } - client := initE2e() + cmixParams, e2eParams := initParams() + + client := initE2e(cmixParams, e2eParams) jww.INFO.Printf("Client Initialized...") @@ -277,12 +278,12 @@ var rootCmd = &cobra.Command{ // Accept auth request for this recipient authConfirmed := false - paramsE2E := e2e.GetDefaultParams() if viper.GetBool("accept-channel") { // Verify that the confirmation message makes it to the // original sender if viper.GetBool("verify-sends") { - acceptChannelVerified(client, recipientID) + acceptChannelVerified(client, recipientID, + e2eParams) } else { // Accept channel, agnostic of round result acceptChannel(client, recipientID) @@ -306,7 +307,7 @@ var rootCmd = &cobra.Command{ if !unsafe && !authConfirmed && !isPrecanPartner && sendAuthReq { addAuthenticatedChannel(client, recipientID, - recipientContact) + recipientContact, e2eParams) } else if !unsafe && !authConfirmed && isPrecanPartner { addPrecanAuthenticatedChannel(client, recipientID, recipientContact) @@ -315,7 +316,7 @@ var rootCmd = &cobra.Command{ sendAuthReq { jww.WARN.Printf("Resetting negotiated auth channel") resetAuthenticatedChannel(client, recipientID, - recipientContact) + recipientContact, e2eParams) authConfirmed = false } @@ -393,10 +394,6 @@ var rootCmd = &cobra.Command{ payload := []byte(msgBody) recipient := recipientID - if viper.GetBool("splitSends") { - paramsE2E.ExcludedRounds = excludedRounds.NewSet() - } - jww.INFO.Printf("Client Sending messages...") wg := &sync.WaitGroup{} @@ -412,14 +409,14 @@ var rootCmd = &cobra.Command{ // Send messages var roundIDs []id.Round if unsafe { - paramsE2E.CMIXParams.DebugTag = "cmd.Unsafe" + e2eParams.Base.DebugTag = "cmd.Unsafe" roundIDs, _, err = client.GetE2E().SendUnsafe( mt, recipient, payload, - paramsE2E) + e2eParams.Base) } else { - paramsE2E.CMIXParams.DebugTag = "cmd.E2E" + e2eParams.Base.DebugTag = "cmd.E2E" roundIDs, _, _, err = client.GetE2E().SendE2E(mt, - recipient, payload, paramsE2E) + recipient, payload, e2eParams.Base) } if err != nil { jww.FATAL.Panicf("%+v", err) @@ -443,7 +440,7 @@ var rootCmd = &cobra.Command{ } // Monitor rounds for results - err = client.GetCmix().GetRoundResults(paramsE2E.CMIXParams.Timeout, f, roundIDs...) + err = client.GetCmix().GetRoundResults(e2eParams.Base.Timeout, f, roundIDs...) if err != nil { jww.DEBUG.Printf("Could not verify messages were sent successfully, resending messages...") continue @@ -489,10 +486,18 @@ var rootCmd = &cobra.Command{ done = true break case m := <-recvCh: - fmt.Printf("Message received: %s\n", string( - m.Payload)) + strToPrint := string(m.Payload) + if m.MessageType != catalog.XxMessage { + strToPrint = fmt.Sprintf("type is %s", + m.MessageType) + } else { + receiveCnt++ + } + + fmt.Printf("Message received: %s\n", + strToPrint) + // fmt.Printf("%s", m.Timestamp) - receiveCnt++ if receiveCnt == expectedCnt { done = true break @@ -635,8 +640,9 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) { } } - params := initParams() - client, err := xxdk.OpenCmix(storeDir, pass, params) + cmixParams, _ := initParams() + + client, err := xxdk.OpenCmix(storeDir, pass, cmixParams) if err != nil { jww.FATAL.Panicf("%+v", err) } @@ -665,57 +671,62 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) { return client, identity } -func initParams() xxdk.Params { - p := xxdk.GetDefaultParams() - p.Session.MinKeys = uint16(viper.GetUint("e2eMinKeys")) - p.Session.MaxKeys = uint16(viper.GetUint("e2eMaxKeys")) - p.Session.NumRekeys = uint16(viper.GetUint("e2eNumReKeys")) - p.Session.RekeyThreshold = viper.GetFloat64("e2eRekeyThreshold") - p.CMix.Pickup.ForceHistoricalRounds = viper.GetBool( +func initParams() (xxdk.CMIXParams, xxdk.E2EParams) { + e2eParams := xxdk.GetDefaultE2EParams() + e2eParams.Session.MinKeys = uint16(viper.GetUint("e2eMinKeys")) + e2eParams.Session.MaxKeys = uint16(viper.GetUint("e2eMaxKeys")) + e2eParams.Session.NumRekeys = uint16(viper.GetUint("e2eNumReKeys")) + e2eParams.Session.RekeyThreshold = viper.GetFloat64("e2eRekeyThreshold") + + if viper.GetBool("splitSends") { + e2eParams.Base.ExcludedRounds = excludedRounds.NewSet() + } + + cmixParams := xxdk.GetDefaultCMixParams() + cmixParams.Network.Pickup.ForceHistoricalRounds = viper.GetBool( "forceHistoricalRounds") - p.CMix.FastPolling = !viper.GetBool("slowPolling") - p.CMix.Pickup.ForceMessagePickupRetry = viper.GetBool( + cmixParams.Network.FastPolling = !viper.GetBool("slowPolling") + cmixParams.Network.Pickup.ForceMessagePickupRetry = viper.GetBool( "forceMessagePickupRetry") - if p.CMix.Pickup.ForceMessagePickupRetry { + if cmixParams.Network.Pickup.ForceMessagePickupRetry { period := 3 * time.Second jww.INFO.Printf("Setting Uncheck Round Period to %v", period) - p.CMix.Pickup.UncheckRoundPeriod = period + cmixParams.Network.Pickup.UncheckRoundPeriod = period } - p.CMix.VerboseRoundTracking = viper.GetBool( + cmixParams.Network.VerboseRoundTracking = viper.GetBool( "verboseRoundTracking") - return p + return cmixParams, e2eParams } // initE2e returns a fully-formed xxdk.E2e object -func initE2e() *xxdk.E2e { +func initE2e(cmixParams xxdk.CMIXParams, e2eParams xxdk.E2EParams) *xxdk.E2e { _, receptionIdentity := initCmix() pass := parsePassword(viper.GetString("password")) storeDir := viper.GetString("session") jww.DEBUG.Printf("sessionDur: %v", storeDir) - params := initParams() - // load the client - baseClient, err := xxdk.LoadCmix(storeDir, pass, params) + baseClient, err := xxdk.LoadCmix(storeDir, pass, cmixParams) if err != nil { jww.FATAL.Panicf("%+v", err) } authCbs = makeAuthCallbacks( - viper.GetBool("unsafe-channel-creation")) + viper.GetBool("unsafe-channel-creation"), e2eParams) // Force LoginLegacy for precanned senderID var client *xxdk.E2e if isPrecanID(receptionIdentity.ID) { jww.INFO.Printf("Using LoginLegacy for precan sender") - client, err = xxdk.LoginLegacy(baseClient, authCbs) + client, err = xxdk.LoginLegacy(baseClient, e2eParams, authCbs) if err != nil { jww.FATAL.Panicf("%+v", err) } } else { jww.INFO.Printf("Using Login for non-precan sender") - client, err = xxdk.Login(baseClient, authCbs, receptionIdentity) + client, err = xxdk.Login(baseClient, authCbs, receptionIdentity, + e2eParams) if err != nil { jww.FATAL.Panicf("%+v", err) } @@ -804,7 +815,7 @@ func deleteChannel(client *xxdk.E2e, partnerId *id.ID) { } func addAuthenticatedChannel(client *xxdk.E2e, recipientID *id.ID, - recipient contact.Contact) { + recipient contact.Contact, e2eParams xxdk.E2EParams) { var allowed bool if viper.GetBool("unsafe-channel-creation") { msg := "unsafe channel creation enabled\n" @@ -833,7 +844,7 @@ func addAuthenticatedChannel(client *xxdk.E2e, recipientID *id.ID, // Verify that the auth request makes it to the recipient // by monitoring the round result if viper.GetBool("verify-sends") { - requestChannelVerified(client, recipientContact, me) + requestChannelVerified(client, recipientContact, me, e2eParams) } else { // Just call Request, agnostic of round result _, err := client.GetAuth().Request(recipientContact, @@ -850,7 +861,7 @@ func addAuthenticatedChannel(client *xxdk.E2e, recipientID *id.ID, } func resetAuthenticatedChannel(client *xxdk.E2e, recipientID *id.ID, - recipient contact.Contact) { + recipient contact.Contact, e2eParams xxdk.E2EParams) { var allowed bool if viper.GetBool("unsafe-channel-creation") { msg := "unsafe channel creation enabled\n" @@ -877,7 +888,8 @@ func resetAuthenticatedChannel(client *xxdk.E2e, recipientID *id.ID, // Verify that the auth request makes it to the recipient // by monitoring the round result if viper.GetBool("verify-sends") { - resetChannelVerified(client, recipientContact) + resetChannelVerified(client, recipientContact, + e2eParams) } else { _, err := client.GetAuth().Reset(recipientContact) if err != nil { @@ -890,9 +902,9 @@ func resetAuthenticatedChannel(client *xxdk.E2e, recipientID *id.ID, } } -func acceptChannelVerified(client *xxdk.E2e, recipientID *id.ID) { - paramsE2E := e2e.GetDefaultParams() - roundTimeout := paramsE2E.CMIXParams.SendTimeout +func acceptChannelVerified(client *xxdk.E2e, recipientID *id.ID, + params xxdk.E2EParams) { + roundTimeout := params.Base.CMIXParams.SendTimeout done := make(chan struct{}, 1) retryChan := make(chan struct{}, 1) @@ -927,9 +939,9 @@ func acceptChannelVerified(client *xxdk.E2e, recipientID *id.ID) { } func requestChannelVerified(client *xxdk.E2e, - recipientContact, me contact.Contact) { - paramsE2E := e2e.GetDefaultParams() - roundTimeout := paramsE2E.CMIXParams.SendTimeout + recipientContact, me contact.Contact, + params xxdk.E2EParams) { + roundTimeout := params.Base.CMIXParams.SendTimeout retryChan := make(chan struct{}, 1) done := make(chan struct{}, 1) @@ -966,9 +978,9 @@ func requestChannelVerified(client *xxdk.E2e, } } -func resetChannelVerified(client *xxdk.E2e, recipientContact contact.Contact) { - paramsE2E := e2e.GetDefaultParams() - roundTimeout := paramsE2E.CMIXParams.SendTimeout +func resetChannelVerified(client *xxdk.E2e, recipientContact contact.Contact, + params xxdk.E2EParams) { + roundTimeout := params.Base.CMIXParams.SendTimeout retryChan := make(chan struct{}, 1) done := make(chan struct{}, 1) diff --git a/cmd/single.go b/cmd/single.go index ed6939618864287668739abd0e6e258c02ae41f4..406374c939efacb4af6e0e5b55f5cf91581da5c0 100644 --- a/cmd/single.go +++ b/cmd/single.go @@ -33,7 +33,8 @@ var singleCmd = &cobra.Command{ Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - client := initE2e() + cmixParams, e2eParams := initParams() + client := initE2e(cmixParams, e2eParams) // Write user contact to file user := client.GetReceptionIdentity() diff --git a/cmd/ud.go b/cmd/ud.go index 44d159684a40756dcc724c88b1a17b94c7ed9b65..2310b172c2b138026d03b1309dc0d04cc9ff5f80 100644 --- a/cmd/ud.go +++ b/cmd/ud.go @@ -10,13 +10,14 @@ package cmd import ( "fmt" + "strings" + "time" + "gitlab.com/elixxir/client/single" "gitlab.com/elixxir/client/ud" "gitlab.com/elixxir/client/xxmutils" "gitlab.com/elixxir/primitives/fact" "gitlab.com/xx_network/primitives/utils" - "strings" - "time" "github.com/spf13/cobra" jww "github.com/spf13/jwalterweatherman" @@ -33,7 +34,8 @@ var udCmd = &cobra.Command{ Short: "Register for and search users using the xx network user discovery service.", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { - client := initE2e() + cmixParams, e2eParams := initParams() + client := initE2e(cmixParams, e2eParams) // get user and save contact to file user := client.GetReceptionIdentity() diff --git a/cmix.go b/cmix.go deleted file mode 100644 index 69ee456715006686934cd8b27cbc3dccd8a976a1..0000000000000000000000000000000000000000 --- a/cmix.go +++ /dev/null @@ -1,8 +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 main diff --git a/cmix/message/handler.go b/cmix/message/handler.go index 842337d656d146daf2629ce8abf0c35afdfa3ae1..6a5baf55486860b3d14d5d2960acaa861dc18ba0 100644 --- a/cmix/message/handler.go +++ b/cmix/message/handler.go @@ -182,15 +182,14 @@ func (h *handler) handleMessageHelper(ecrMsg format.Message, bundle Bundle) bool services, exists := h.get( identity.Source, ecrMsg.GetSIH(), ecrMsg.GetContents()) - if exists { + // If the id doesn't exist or there are no services for it, then + // we want messages to be reprocessed as garbled. + if exists && len(services) != 0 { for _, t := range services { jww.DEBUG.Printf("handleMessage service found: %s, %s", ecrMsg.Digest(), t) go t.Process(ecrMsg, identity, round) } - if len(services) == 0 { - jww.WARN.Printf("Empty service list for %s", ecrMsg.Digest()) - } return true } diff --git a/cmix/message/handler_test.go b/cmix/message/handler_test.go index b842ce1e4aa367e8c3fbafddd0e0a24da1cbca5b..99dfb9f199d0ea3ced7341e0ae7282e73930feaf 100644 --- a/cmix/message/handler_test.go +++ b/cmix/message/handler_test.go @@ -7,6 +7,9 @@ package message import ( + "testing" + "time" + "gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/rounds" "gitlab.com/elixxir/client/event" @@ -17,8 +20,6 @@ import ( "gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/states" "gitlab.com/xx_network/primitives/id" - "testing" - "time" ) type testProcessor struct { @@ -150,9 +151,16 @@ func Test_handler_handleMessageHelper_Service(t *testing.T) { contents := []byte{4, 4} lazyPreimage := sih.MakePreimage(contents, "test") + + s := Service{ + Identifier: nil, + Tag: "test", + lazyPreimage: &lazyPreimage, + } + ecrMsg := format.NewMessage(2056) ecrMsg.SetContents(contents) - ecrMsg.SetSIH(sih.Hash(lazyPreimage, ecrMsg.GetContents())) + ecrMsg.SetSIH(s.Hash(ecrMsg.GetContents())) testRound := rounds.Round{ Timestamps: make(map[states.Round]time.Time), @@ -166,12 +174,9 @@ func Test_handler_handleMessageHelper_Service(t *testing.T) { RoundInfo: testRound, } - s := Service{ - Identifier: nil, - Tag: "test", - lazyPreimage: &lazyPreimage, - } - m.AddService(testId, s, nil) + processor := &testProcessor{} + + m.AddService(testId, s, processor) result := m.handleMessageHelper(ecrMsg, bundle) if !result { t.Errorf("Expected handleMessage success!") diff --git a/cmix/message/inProgress.go b/cmix/message/inProgress.go index e5e9826a9c0dbba61e28401fac041e530146ade0..83cc22fe27041c352bdfb73545e7113a9e5adb38 100644 --- a/cmix/message/inProgress.go +++ b/cmix/message/inProgress.go @@ -29,6 +29,8 @@ import ( func (h *handler) CheckInProgressMessages() { select { case h.checkInProgress <- struct{}{}: + jww.DEBUG.Print("[Garbled] Sent signal to check garbled " + + "message queue...") default: jww.WARN.Print("Failed to check garbled messages due to full channel.") } @@ -54,16 +56,19 @@ func (h *handler) recheckInProgress() { // Try to decrypt every garbled message, excising those whose counts are too // high for grbldMsg, ri, identity, has := h.inProcess.Next(); has; grbldMsg, ri, identity, has = h.inProcess.Next() { + bundleMsgs := []format.Message{grbldMsg} bundle := Bundle{ Round: id.Round(ri.ID), RoundInfo: rounds.MakeRound(ri), - Messages: []format.Message{grbldMsg}, + Messages: bundleMsgs, Finish: func() {}, Identity: identity, } select { case h.messageReception <- bundle: + jww.INFO.Printf("[GARBLE] Sent %d messages to process", + len(bundleMsgs)) default: jww.WARN.Printf("Failed to send bundle, channel full.") } diff --git a/cmix/params.go b/cmix/params.go index d8aa778b104dadbdfa0e28215e00f0a10f5b6761..73ec67dd10f47bb5969164e8593687cac5cf0e16 100644 --- a/cmix/params.go +++ b/cmix/params.go @@ -222,7 +222,7 @@ type cMixParamsDisk struct { func GetDefaultCMIXParams() CMIXParams { return CMIXParams{ RoundTries: 10, - Timeout: 25 * time.Second, + Timeout: 45 * time.Second, RetryDelay: 1 * time.Second, SendTimeout: 3 * time.Second, DebugTag: DefaultDebugTag, diff --git a/connect/authCallbacks.go b/connect/authCallbacks.go index cdf8b849fdf3b4065d3e19b62ec5191b79fbf48a..227c47500e166155655ce96d0bdc0b9bfbfa2a94 100644 --- a/connect/authCallbacks.go +++ b/connect/authCallbacks.go @@ -27,7 +27,7 @@ type clientAuthCallback struct { // Used for building new Connection objects connectionE2e clientE2e.Handler - connectionParams Params + connectionParams xxdk.E2EParams authState auth.State } @@ -35,7 +35,7 @@ type clientAuthCallback struct { // of an auth.State object. // it will accept requests only if a request callback is passed in func getClientAuthCallback(confirm, request Callback, e2e clientE2e.Handler, - auth auth.State, params Params) *clientAuthCallback { + auth auth.State, params xxdk.E2EParams) *clientAuthCallback { return &clientAuthCallback{ confirmCallback: confirm, requestCallback: request, @@ -94,14 +94,14 @@ type serverAuthCallback struct { cl *ConnectionList // Used for building new Connection objects - connectionParams Params + connectionParams xxdk.E2EParams } // getServerAuthCallback returns a callback interface to be passed into the creation // of a xxdk.E2e object. // it will accept requests only if a request callback is passed in func getServerAuthCallback(confirm, request Callback, cl *ConnectionList, - params Params) *serverAuthCallback { + params xxdk.E2EParams) *serverAuthCallback { return &serverAuthCallback{ confirmCallback: confirm, requestCallback: request, diff --git a/connect/authenticated.go b/connect/authenticated.go index 926cd15435d61883896117c98a5c370860365c27..4376a2ceec13c2588e2dd637ce742cff02a4b033 100644 --- a/connect/authenticated.go +++ b/connect/authenticated.go @@ -8,6 +8,9 @@ package connect import ( + "sync" + "time" + "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/catalog" @@ -19,8 +22,6 @@ import ( "gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/netTime" - "sync" - "time" ) // Constant error messages @@ -52,7 +53,7 @@ type AuthenticatedCallback func(connection AuthenticatedConnection) // connection with the server. Once a connect.Connection has been established // with the server and then authenticate their identity to the server. func ConnectWithAuthentication(recipient contact.Contact, e2eClient *xxdk.E2e, - p Params) (AuthenticatedConnection, error) { + p xxdk.E2EParams) (AuthenticatedConnection, error) { // Track the time since we started to attempt to establish a connection timeStart := netTime.Now() @@ -80,7 +81,7 @@ func ConnectWithAuthentication(recipient contact.Contact, e2eClient *xxdk.E2e, func connectWithAuthentication(conn Connection, timeStart time.Time, recipient contact.Contact, salt []byte, myRsaPrivKey *rsa.PrivateKey, rng *fastRNG.StreamGenerator, - net cmix.Client, p Params) (AuthenticatedConnection, error) { + net cmix.Client, p xxdk.E2EParams) (AuthenticatedConnection, error) { // Construct message to prove your identity to the server payload, err := buildClientAuthRequest(conn.GetPartner(), rng, myRsaPrivKey, salt) @@ -133,7 +134,7 @@ func connectWithAuthentication(conn Connection, timeStart time.Time, }) // Find the remaining time in the timeout since we first sent the message - remainingTime := p.Timeout - netTime.Since(timeStart) + remainingTime := p.Base.Timeout - netTime.Since(timeStart) // Track the result of the round(s) we sent the // identity authentication message on @@ -174,7 +175,9 @@ func connectWithAuthentication(conn Connection, timeStart time.Time, // authenticate themselves. An established AuthenticatedConnection will // be passed via the callback. func StartAuthenticatedServer(identity xxdk.ReceptionIdentity, - cb AuthenticatedCallback, net *xxdk.Cmix, p Params) (*ConnectionServer, error) { + cb AuthenticatedCallback, net *xxdk.Cmix, p xxdk.E2EParams, + clParams ConnectionListParams) ( + *ConnectionServer, error) { // Register the waiter for a connection establishment connCb := Callback(func(connection Connection) { @@ -191,7 +194,7 @@ func StartAuthenticatedServer(identity xxdk.ReceptionIdentity, connection.GetPartner().PartnerId(), err) } }) - return StartServer(identity, connCb, net, p) + return StartServer(identity, connCb, net, p, clParams) } // authenticatedHandler provides an implementation for the diff --git a/connect/authenticated_test.go b/connect/authenticated_test.go index 5a8a3112fbe10e7672fae864d75f995dcb0c1c50..d4f5be3d2875ff0841ce91a6f81c4f5ef846c204 100644 --- a/connect/authenticated_test.go +++ b/connect/authenticated_test.go @@ -8,6 +8,11 @@ package connect import ( + "math/rand" + "testing" + "time" + + "gitlab.com/elixxir/client/xxdk" "gitlab.com/elixxir/crypto/contact" "gitlab.com/elixxir/crypto/diffieHellman" "gitlab.com/elixxir/crypto/fastRNG" @@ -15,9 +20,6 @@ import ( "gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/crypto/xx" "gitlab.com/xx_network/primitives/id" - "math/rand" - "testing" - "time" ) // TestConnectWithAuthentication will test the client/server relationship for @@ -77,8 +79,8 @@ func TestConnectWithAuthentication(t *testing.T) { }) // Initialize params with a shorter timeout to hasten test results - customParams := GetDefaultParams() - customParams.Timeout = 3 * time.Second + customParams := xxdk.GetDefaultE2EParams() + customParams.Base.Timeout = 3 * time.Second // Initialize the server serverHandler := buildAuthConfirmationHandler(serverCb, mockConn) @@ -96,7 +98,7 @@ func TestConnectWithAuthentication(t *testing.T) { } // Wait for the server to establish it's connection via the callback - timeout := time.NewTimer(customParams.Timeout) + timeout := time.NewTimer(customParams.Base.Timeout) select { case <-authConnChan: return diff --git a/connect/connect.go b/connect/connect.go index 0a6b9a7fc8b1d95125bf24ac9d0f9cfff245205e..5e77868c43fb00970483a59b00350a6b5c082999 100644 --- a/connect/connect.go +++ b/connect/connect.go @@ -7,15 +7,13 @@ package connect import ( - "encoding/json" - "gitlab.com/elixxir/client/e2e/rekey" - "gitlab.com/elixxir/client/event" - "gitlab.com/elixxir/client/xxdk" - "gitlab.com/xx_network/primitives/netTime" "io" "sync/atomic" "time" + "gitlab.com/elixxir/client/xxdk" + "gitlab.com/xx_network/primitives/netTime" + "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/auth" @@ -85,51 +83,19 @@ type Connection interface { // new Connection objects as they are established. type Callback func(connection Connection) -// Params for managing Connection objects. -type Params struct { - Auth auth.Params - Rekey rekey.Params - Event event.Reporter `json:"-"` - List ConnectionListParams - Timeout time.Duration -} - -// GetDefaultParams returns a usable set of default Connection parameters. -func GetDefaultParams() Params { - return Params{ - Auth: auth.GetDefaultTemporaryParams(), - Rekey: rekey.GetDefaultEphemeralParams(), - Event: event.NewEventManager(), - List: DefaultConnectionListParams(), - Timeout: connectionTimeout, - } -} - -// GetParameters returns the default Params, or override with given -// parameters, if set. -func GetParameters(params string) (Params, error) { - p := GetDefaultParams() - if len(params) > 0 { - err := json.Unmarshal([]byte(params), &p) - if err != nil { - return Params{}, err - } - } - return p, nil -} - // Connect performs auth key negotiation with the given recipient, // and returns a Connection object for the newly-created partner.Manager // This function is to be used sender-side and will block until the // partner.Manager is confirmed. func Connect(recipient contact.Contact, e2eClient *xxdk.E2e, - p Params) (Connection, error) { + p xxdk.E2EParams) (Connection, error) { // Build callback for E2E negotiation signalChannel := make(chan Connection, 1) cb := func(connection Connection) { signalChannel <- connection } - callback := getClientAuthCallback(cb, nil, e2eClient.GetE2E(), e2eClient.GetAuth(), p) + callback := getClientAuthCallback(cb, nil, e2eClient.GetE2E(), + e2eClient.GetAuth(), p) e2eClient.GetAuth().AddPartnerCallback(recipient.ID, callback) // Perform the auth request @@ -141,7 +107,7 @@ func Connect(recipient contact.Contact, e2eClient *xxdk.E2e, // Block waiting for auth to confirm jww.DEBUG.Printf("Connection waiting for auth request "+ "for %s to be confirmed...", recipient.ID.String()) - timeout := time.NewTimer(p.Timeout) + timeout := time.NewTimer(p.Base.Timeout) defer timeout.Stop() select { case newConnection := <-signalChannel: @@ -168,10 +134,10 @@ func Connect(recipient contact.Contact, e2eClient *xxdk.E2e, // This call does an xxDK.ephemeralLogin under the hood and the connection // server must be the only listener on auth. func StartServer(identity xxdk.ReceptionIdentity, cb Callback, net *xxdk.Cmix, - p Params) (*ConnectionServer, error) { + p xxdk.E2EParams, clParams ConnectionListParams) (*ConnectionServer, error) { // Create connection list and start cleanup thread - cl := NewConnectionList(p.List) + cl := NewConnectionList(clParams) err := net.AddService(cl.CleanupThread) if err != nil { return nil, err @@ -180,7 +146,7 @@ func StartServer(identity xxdk.ReceptionIdentity, cb Callback, net *xxdk.Cmix, // Build callback for E2E negotiation callback := getServerAuthCallback(nil, cb, cl, p) - e2eClient, err := xxdk.LoginEphemeral(net, callback, identity) + e2eClient, err := xxdk.LoginEphemeral(net, callback, identity, p) if err != nil { return nil, err } @@ -200,21 +166,20 @@ type handler struct { auth auth.State partner partner.Manager e2e clientE2e.Handler + params xxdk.E2EParams // Timestamp of last time a message was sent or received (Unix nanoseconds) lastUse *int64 // Indicates if the connection has been closed (0 = open, 1 = closed) closed *uint32 - - params Params } // BuildConnection assembles a Connection object // after an E2E partnership has already been confirmed with the given // partner.Manager. func BuildConnection(partner partner.Manager, e2eHandler clientE2e.Handler, - auth auth.State, p Params) Connection { + auth auth.State, p xxdk.E2EParams) Connection { lastUse := netTime.Now().UnixNano() closed := uint32(0) return &handler{ diff --git a/connect/params_test.go b/connect/params_test.go index 5501ad55153af983a72df2b0ab4d1e8b64358628..98bb5e2953b5ec570639c0601e78924b7e39c6ec 100644 --- a/connect/params_test.go +++ b/connect/params_test.go @@ -11,11 +11,13 @@ import ( "bytes" "encoding/json" "testing" + + "gitlab.com/elixxir/client/xxdk" ) func TestParams_MarshalUnmarshal(t *testing.T) { // Construct a set of params - p := GetDefaultParams() + p := xxdk.GetDefaultE2EParams() // Marshal the params data, err := json.Marshal(&p) @@ -26,7 +28,7 @@ func TestParams_MarshalUnmarshal(t *testing.T) { t.Logf("%s", string(data)) // Unmarshal the params object - received := Params{} + received := xxdk.E2EParams{} err = json.Unmarshal(data, &received) if err != nil { t.Fatalf("Unmarshal error: %v", err) diff --git a/e2e/manager.go b/e2e/manager.go index 6d4102ebba81c19ee4ddce1bb7cf65ad8e3b7ecf..49e288af55a40be86a1d27e73b24524c7077dc7f 100644 --- a/e2e/manager.go +++ b/e2e/manager.go @@ -173,12 +173,13 @@ func (m *manager) StartProcesses() (stoppable.Stoppable, error) { recipient *id.ID, payload []byte, cmixParams cmix.CMIXParams) ( []id.Round, e2e.MessageID, time.Time, error) { + // FIXME: we should have access to the e2e params here... par := GetDefaultParams() par.CMIXParams = cmixParams return m.SendE2E(mt, recipient, payload, par) } rekeyStopper, err := rekey.Start(m.Switchboard, m.Ratchet, - rekeySendFunc, m.net, m.grp, rekey.GetDefaultParams()) + rekeySendFunc, m.net, m.grp, m.rekeyParams) if err != nil { return nil, err } diff --git a/e2e/processor.go b/e2e/processor.go index 1b6620149005c12ad456fc3b3b34ead31890a240..17e2293401209f84783f4855182f607cc8f6bd0e 100644 --- a/e2e/processor.go +++ b/e2e/processor.go @@ -2,6 +2,7 @@ package e2e import ( "fmt" + "gitlab.com/elixxir/client/e2e/ratchet/partner/session" jww "github.com/spf13/jwalterweatherman" @@ -18,6 +19,7 @@ type processor struct { func (p *processor) Process(ecrMsg format.Message, receptionID receptionID.EphemeralIdentity, round rounds.Round) { + jww.TRACE.Printf("[E2E] Process(ecrMsgDigest: %s)", ecrMsg.Digest()) // ensure the key will be marked used before returning defer p.cy.Use() diff --git a/e2e/ratchet/partner/relationship.go b/e2e/ratchet/partner/relationship.go index ff321d04becdce2e4ddeb9f18d520174b40f1b5c..bd6f60ccef05edaaa526a01288b7905f4e351829 100644 --- a/e2e/ratchet/partner/relationship.go +++ b/e2e/ratchet/partner/relationship.go @@ -273,8 +273,8 @@ func (r *relationship) getSessionForSending() *session.Session { for _, s := range sessions { status := s.Status() confirmed := s.IsConfirmed() - jww.TRACE.Printf("[REKEY] Session Status/Confirmed: %v, %v", - status, confirmed) + jww.TRACE.Printf("[REKEY] Session Status/Confirmed: (%v, %s), %v", + status, s.NegotiationStatus(), confirmed) if status == session.Active && confirmed { //always return the first confirmed active, happy path return s diff --git a/e2e/ratchet/partner/session/session.go b/e2e/ratchet/partner/session/session.go index 58d1ca8ac4ca71d2adbc3f0eaf554e1507dfee0c..d0ee6ca19b1e233699ca6d7869e7e88420046b19 100644 --- a/e2e/ratchet/partner/session/session.go +++ b/e2e/ratchet/partner/session/session.go @@ -11,6 +11,11 @@ import ( "encoding/binary" "encoding/json" "fmt" + "math" + "math/big" + "sync" + "testing" + "github.com/cloudflare/circl/dh/sidh" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" @@ -23,10 +28,6 @@ import ( "gitlab.com/xx_network/crypto/randomness" "gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/netTime" - "math" - "math/big" - "sync" - "testing" ) const currentSessionVersion = 0 diff --git a/e2e/receive/switchboard.go b/e2e/receive/switchboard.go index 3bb5e23cfae466cad43a4a2ca665a079caa48413..3f6122df73beeafd49129e1ab0d859e32e3a8ea5 100644 --- a/e2e/receive/switchboard.go +++ b/e2e/receive/switchboard.go @@ -8,11 +8,12 @@ package receive import ( + "sync" + "github.com/golang-collections/collections/set" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/catalog" "gitlab.com/xx_network/primitives/id" - "sync" ) type Switchboard struct { @@ -142,6 +143,9 @@ func (sw *Switchboard) Speak(item Message) { // well as those that do not care about certain criteria matches := sw.matchListeners(item) + jww.TRACE.Printf("[E2E] Switchboard.Speak(SenderID: %s, MsgType: %s)", + item.Sender, item.MessageType) + //Execute hear on all matched listeners in a new goroutine matches.Do(func(i interface{}) { lid := i.(ListenerID) diff --git a/e2e/rekey/confirm.go b/e2e/rekey/confirm.go index b6ae0a6ddaec07fa19dab7b8e86a0d374ad27b50..449aefddbbd2bd3723545ad03c1df5f9424757f9 100644 --- a/e2e/rekey/confirm.go +++ b/e2e/rekey/confirm.go @@ -32,6 +32,9 @@ func startConfirm(ratchet *ratchet.Ratchet, c chan receive.Message, } func handleConfirm(ratchet *ratchet.Ratchet, confirmation receive.Message) { + jww.DEBUG.Printf("[REKEY] handleConfirm(partner: %s)", + confirmation.Sender) + //ensure the message was encrypted properly if !confirmation.Encrypted { jww.ERROR.Printf( diff --git a/e2e/rekey/rekey.go b/e2e/rekey/rekey.go index 8de7ef2daff692cc41914f67c3d8ea7974bb84c9..960df918f20e3aee3e87a77ac4959668fc5db87c 100644 --- a/e2e/rekey/rekey.go +++ b/e2e/rekey/rekey.go @@ -96,6 +96,8 @@ func trigger(instance *commsNetwork.Instance, grp *cyclic.Group, sendE2E E2eSend func negotiate(instance *commsNetwork.Instance, grp *cyclic.Group, sendE2E E2eSender, param Params, sess *session.Session, sendTimeout time.Duration) error { + // Note: All new sending sessions are set to "Sending" status by default + //generate public key pubKey := diffieHellman.GeneratePublicKey(sess.GetMyPrivKey(), grp) diff --git a/e2e/rekey/trigger.go b/e2e/rekey/trigger.go index c44fba7ff728fc81a8cfeeccc46eae85ea3a8974..80d2cd2b62a8a1840e8605aa79bc7d4e501cbb2d 100644 --- a/e2e/rekey/trigger.go +++ b/e2e/rekey/trigger.go @@ -53,6 +53,10 @@ func startTrigger(ratchet *ratchet.Ratchet, sender E2eSender, net cmix.Client, func handleTrigger(ratchet *ratchet.Ratchet, sender E2eSender, net cmix.Client, grp *cyclic.Group, request receive.Message, param Params, stop *stoppable.Single) error { + + jww.DEBUG.Printf("[REKEY] handleTrigger(partner: %s)", + request.Sender) + //ensure the message was encrypted properly if !request.Encrypted { errMsg := fmt.Sprintf(errBadTrigger, request.Sender) @@ -105,9 +109,12 @@ func handleTrigger(ratchet *ratchet.Ratchet, sender E2eSender, } //Send the Confirmation Message - //build the payload + // build the payload, note that for confirmations, we need only send the + // (generated from new keys) session id, which the other side should + // know about already. + // When sending a trigger, the source session id is sent instead payload, err := proto.Marshal(&RekeyConfirm{ - SessionID: sess.GetSource().Marshal(), + SessionID: sess.GetID().Marshal(), }) //If the payload cannot be marshaled, panic @@ -116,7 +123,7 @@ func handleTrigger(ratchet *ratchet.Ratchet, sender E2eSender, "Negotation Confirmation with %s", sess.GetPartner()) } - //send the trigger + //send the trigger confirmation params := cmix.GetDefaultCMIXParams() params.Critical = true //ignore results, the passed sender interface makes it a critical message diff --git a/e2e/sendE2E.go b/e2e/sendE2E.go index 65cf98cdf63105298daebbc8eede2b21dc6e3d17..159f7c8451ca997d3924803f01bb30eb4355d0f1 100644 --- a/e2e/sendE2E.go +++ b/e2e/sendE2E.go @@ -81,7 +81,7 @@ func (m *manager) sendE2E(mt catalog.MessageType, recipient *id.ID, rekeySendFunc := func(mt catalog.MessageType, recipient *id.ID, payload []byte, cmixParams cmix.CMIXParams) ( []id.Round, e2e.MessageID, time.Time, error) { - par := GetDefaultParams() + par := params par.CMIXParams = cmixParams return m.SendE2E(mt, recipient, payload, par) } diff --git a/restlike/connect/server.go b/restlike/connect/server.go index d2a22dad5d3a46dbd63af11dbf5f2eb937a080da..9320d5e5c924f82107567908b62e0babf5959e08 100644 --- a/restlike/connect/server.go +++ b/restlike/connect/server.go @@ -23,7 +23,7 @@ type Server struct { // NewServer builds a RestServer with connect.Connection and // the provided arguments, then registers necessary external services func NewServer(identity xxdk.ReceptionIdentity, net *xxdk.Cmix, - p connect.Params) (*Server, error) { + p xxdk.E2EParams, clParams connect.ConnectionListParams) (*Server, error) { newServer := &Server{ receptionId: identity.ID, endpoints: restlike.NewEndpoints(), @@ -36,7 +36,7 @@ func NewServer(identity xxdk.ReceptionIdentity, net *xxdk.Cmix, } // Build the connection listener - _, err := connect.StartServer(identity, cb, net, p) + _, err := connect.StartServer(identity, cb, net, p, clParams) if err != nil { return nil, err } diff --git a/xxdk/cmix.go b/xxdk/cmix.go index 54aa051cbd8c22b0e7205e7e3c4d06822d5c5c39..fbc08044b3cdb27bc8224cdff2805dff8efd09eb 100644 --- a/xxdk/cmix.go +++ b/xxdk/cmix.go @@ -122,7 +122,7 @@ func NewVanityClient(ndfJSON, storageDir string, password []byte, // NOTE: This is a helper function that, in most applications, should not be used on its own // Consider using LoadCmix instead, which calls this function for you. func OpenCmix(storageDir string, password []byte, - parameters Params) (*Cmix, error) { + parameters CMIXParams) (*Cmix, error) { jww.INFO.Printf("OpenCmix()") rngStreamGen := fastRNG.NewStreamGenerator(12, 1024, @@ -199,7 +199,7 @@ func NewProtoClient_Unsafe(ndfJSON, storageDir string, password []byte, } // LoadCmix initializes a Cmix object from existing storage and starts the network -func LoadCmix(storageDir string, password []byte, parameters Params) (*Cmix, error) { +func LoadCmix(storageDir string, password []byte, parameters CMIXParams) (*Cmix, error) { jww.INFO.Printf("LoadCmix()") c, err := OpenCmix(storageDir, password, parameters) @@ -207,7 +207,7 @@ func LoadCmix(storageDir string, password []byte, parameters Params) (*Cmix, err return nil, err } - c.network, err = cmix.NewClient(parameters.CMix, c.comms, c.storage, + c.network, err = cmix.NewClient(parameters.Network, c.comms, c.storage, c.rng, c.events) if err != nil { return nil, err diff --git a/xxdk/e2e.go b/xxdk/e2e.go index 3cee728a0fb45f87e6413facaf8a24088ebd3fd8..55c83b6f490a25691c4954916a558901816ae661 100644 --- a/xxdk/e2e.go +++ b/xxdk/e2e.go @@ -9,6 +9,8 @@ package xxdk import ( "encoding/binary" "encoding/json" + "time" + "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/auth" @@ -24,7 +26,6 @@ import ( "gitlab.com/elixxir/ekv" "gitlab.com/xx_network/crypto/xx" "gitlab.com/xx_network/primitives/id" - "time" ) // E2e object bundles a ReceptionIdentity with a Cmix @@ -52,21 +53,24 @@ type AuthCallbacks interface { // It bundles a Cmix object with a ReceptionIdentity object // and initializes the auth.State and e2e.Handler objects func Login(client *Cmix, callbacks AuthCallbacks, - identity ReceptionIdentity) (m *E2e, err error) { - return login(client, callbacks, identity, client.GetStorage().GetKV()) + identity ReceptionIdentity, params E2EParams) (m *E2e, err error) { + return login(client, callbacks, identity, client.GetStorage().GetKV(), + params) } // LoginEphemeral creates a new E2e backed by a totally ephemeral versioned.KV func LoginEphemeral(client *Cmix, callbacks AuthCallbacks, - identity ReceptionIdentity) (m *E2e, err error) { - return login(client, callbacks, identity, versioned.NewKV(ekv.MakeMemstore())) + identity ReceptionIdentity, params E2EParams) (m *E2e, err error) { + return login(client, callbacks, identity, + versioned.NewKV(ekv.MakeMemstore()), params) } // LoginLegacy creates a new E2e backed by the xxdk.Cmix persistent versioned.KV // Uses the pre-generated transmission ID used by xxdk.Cmix. // This function is designed to maintain backwards compatibility with previous // xx messenger designs and should not be used for other purposes. -func LoginLegacy(client *Cmix, callbacks AuthCallbacks) (m *E2e, err error) { +func LoginLegacy(client *Cmix, params E2EParams, callbacks AuthCallbacks) ( + m *E2e, err error) { m = &E2e{ Cmix: client, backup: &Container{}, @@ -87,13 +91,15 @@ func LoginLegacy(client *Cmix, callbacks AuthCallbacks) (m *E2e, err error) { } m.auth, err = auth.NewState(client.GetStorage().GetKV(), client.GetCmix(), - m.e2e, client.GetRng(), client.GetEventReporter(), - auth.GetDefaultParams(), MakeAuthCallbacksAdapter(callbacks, m), m.backup.TriggerBackup) + m.e2e, client.GetRng(), client.GetEventReporter(), params.Auth, + params.Session, MakeAuthCallbacksAdapter(callbacks, m), + m.backup.TriggerBackup) if err != nil { return nil, err } - m.e2eIdentity, err = buildReceptionIdentity(userInfo, m.e2e.GetGroup(), m.e2e.GetHistoricalDHPrivkey()) + m.e2eIdentity, err = buildReceptionIdentity(userInfo, m.e2e.GetGroup(), + m.e2e.GetHistoricalDHPrivkey()) return m, err } @@ -101,7 +107,8 @@ func LoginLegacy(client *Cmix, callbacks AuthCallbacks) (m *E2e, err error) { // while replacing the base NDF. This is designed for some specific deployment // procedures and is generally unsafe. func LoginWithNewBaseNDF_UNSAFE(storageDir string, password []byte, - newBaseNdf string, params Params) (*E2e, error) { + newBaseNdf string, e2eParams E2EParams, cmixParams CMIXParams) (*E2e, + error) { jww.INFO.Printf("LoginWithNewBaseNDF_UNSAFE()") def, err := ParseNDF(newBaseNdf) @@ -109,7 +116,7 @@ func LoginWithNewBaseNDF_UNSAFE(storageDir string, password []byte, return nil, err } - c, err := LoadCmix(storageDir, password, params) + c, err := LoadCmix(storageDir, password, cmixParams) if err != nil { return nil, err } @@ -128,7 +135,7 @@ func LoginWithNewBaseNDF_UNSAFE(storageDir string, password []byte, "able to register or track network.") } - return LoginLegacy(c, nil) + return LoginLegacy(c, e2eParams, nil) } // LoginWithProtoClient creates a client object with a protoclient @@ -136,7 +143,7 @@ func LoginWithNewBaseNDF_UNSAFE(storageDir string, password []byte, // some specific deployment procedures and is generally unsafe. func LoginWithProtoClient(storageDir string, password []byte, protoClientJSON []byte, newBaseNdf string, callbacks AuthCallbacks, - params Params) (*E2e, error) { + cmixParams CMIXParams, e2eParams E2EParams) (*E2e, error) { jww.INFO.Printf("LoginWithProtoClient()") def, err := ParseNDF(newBaseNdf) @@ -156,7 +163,7 @@ func LoginWithProtoClient(storageDir string, password []byte, return nil, err } - c, err := LoadCmix(storageDir, password, params) + c, err := LoadCmix(storageDir, password, cmixParams) if err != nil { return nil, err } @@ -171,12 +178,12 @@ func LoginWithProtoClient(storageDir string, password []byte, userInfo := user.NewUserFromProto(protoUser) receptionIdentity, err := buildReceptionIdentity(userInfo, c.GetStorage().GetE2EGroup(), protoUser.E2eDhPrivateKey) - return Login(c, callbacks, receptionIdentity) + return Login(c, callbacks, receptionIdentity, e2eParams) } // login creates a new xxdk.E2e backed by the given versioned.KV -func login(client *Cmix, callbacks AuthCallbacks, - identity ReceptionIdentity, kv *versioned.KV) (m *E2e, err error) { +func login(client *Cmix, callbacks AuthCallbacks, identity ReceptionIdentity, + kv *versioned.KV, params E2EParams) (m *E2e, err error) { // Verify the passed-in ReceptionIdentity matches its properties privatePem, err := identity.GetRSAPrivatePem() @@ -211,7 +218,7 @@ func login(client *Cmix, callbacks AuthCallbacks, //initialize the e2e storage jww.INFO.Printf("Initializing new e2e.Handler for %s", identity.ID.String()) err = e2e.Init(kv, identity.ID, dhPrivKey, e2eGrp, - rekey.GetDefaultParams()) + params.Rekey) if err != nil { return nil, err } @@ -234,7 +241,8 @@ func login(client *Cmix, callbacks AuthCallbacks, m.auth, err = auth.NewState(kv, client.GetCmix(), m.e2e, client.GetRng(), client.GetEventReporter(), - auth.GetDefaultTemporaryParams(), MakeAuthCallbacksAdapter(callbacks, m), m.backup.TriggerBackup) + params.Auth, params.Session, + MakeAuthCallbacksAdapter(callbacks, m), m.backup.TriggerBackup) if err != nil { return nil, err } @@ -415,6 +423,13 @@ type authCallbacksAdapter struct { e2e *E2e } +func MakeAuthCB(e2e *E2e, cbs AuthCallbacks) auth.Callbacks { + return &authCallbacksAdapter{ + ac: cbs, + e2e: e2e, + } +} + func (aca *authCallbacksAdapter) Request(partner contact.Contact, receptionID receptionID.EphemeralIdentity, round rounds.Round) { aca.ac.Request(partner, receptionID, round, aca.e2e) diff --git a/xxdk/params.go b/xxdk/params.go index c5768a2a0512560367f9e0cb5ad3d7f9221ab3c9..10621cade01944cfdb640405d007ac4823fe851d 100644 --- a/xxdk/params.go +++ b/xxdk/params.go @@ -7,33 +7,83 @@ package xxdk +// params.go define the high level parameters structures (which embed E2E and +// CMIX params respectively) that are passed down into the core xxdk modules. + import ( "encoding/json" + + "gitlab.com/elixxir/client/auth" "gitlab.com/elixxir/client/cmix" + "gitlab.com/elixxir/client/e2e" "gitlab.com/elixxir/client/e2e/ratchet/partner/session" + "gitlab.com/elixxir/client/e2e/rekey" ) -type Params struct { - CMix cmix.Params - Session session.Params +// CMIXParams contains the parameters for Network tracking and for +// specific CMIX messaging settings. +// +// FIXME: this breakdown could be cleaner and is an unfortunate side effect of +// several refactors of the codebase. +type CMIXParams struct { + Network cmix.Params + CMIX cmix.CMIXParams +} + +// E2EParams holds all the settings for e2e and it's various submodules. +// +// NOTE: "Base" wraps cmix.CMIXParams to control message send params, +// so xxdk library users should copy the desired settings to both. +// FIXME: this should not wrap a copy of cmix.CMIXParams. +type E2EParams struct { + Session session.Params + Base e2e.Params + Rekey rekey.Params + EphemeralRekey rekey.Params + Auth auth.Params } -func GetDefaultParams() Params { - return Params{ - CMix: cmix.GetDefaultParams(), - Session: session.GetDefaultParams(), +//////////////////////////////////////// +// -- CMix Params Helper Functions -- // +//////////////////////////////////////// + +func GetDefaultCMixParams() CMIXParams { + return CMIXParams{ + Network: cmix.GetDefaultParams(), + CMIX: cmix.GetDefaultCMIXParams(), } } -// GetParameters returns the default Params, or override with given -// parameters, if set. -func GetParameters(params string) (Params, error) { - p := GetDefaultParams() - if len(params) > 0 { - err := json.Unmarshal([]byte(params), &p) - if err != nil { - return Params{}, err - } +// Unmarshal fills an empty object with the deserialized contents of jsonData +func (p *CMIXParams) Unmarshal(jsonData []byte) error { + return json.Unmarshal(jsonData, p) +} + +// Marshal creates json data of the object +func (p *CMIXParams) Marshal() ([]byte, error) { + return json.Marshal(p) +} + +//////////////////////////////////////// +// -- E2E Params Helper Functions -- // +//////////////////////////////////////// + +func GetDefaultE2EParams() E2EParams { + return E2EParams{ + Session: session.GetDefaultParams(), + Base: e2e.GetDefaultParams(), + Rekey: rekey.GetDefaultParams(), + EphemeralRekey: rekey.GetDefaultEphemeralParams(), + Auth: auth.GetDefaultParams(), } - return p, nil +} + +// Unmarshal fills an empty object with the deserialized contents of jsonData +func (p *E2EParams) Unmarshal(jsonData []byte) error { + return json.Unmarshal(jsonData, p) +} + +// Marshal creates json data of the object +func (p *E2EParams) Marshal() ([]byte, error) { + return json.Marshal(p) } diff --git a/xxdk/params_test.go b/xxdk/params_test.go index 13868e1fb03e192a9a94cc916960d4121a871b08..47853d6f2a79ac12d8a5a66845030872130404cc 100644 --- a/xxdk/params_test.go +++ b/xxdk/params_test.go @@ -17,7 +17,7 @@ import ( // unmarshaling the Params object. func TestParams_MarshalUnmarshal(t *testing.T) { // Construct a set of params - p := GetDefaultParams() + p := GetDefaultCMixParams() // Marshal the params data, err := json.Marshal(&p) @@ -28,7 +28,7 @@ func TestParams_MarshalUnmarshal(t *testing.T) { t.Logf("%s", string(data)) // Unmarshal the params object - received := Params{} + received := CMIXParams{} err = json.Unmarshal(data, &received) if err != nil { t.Fatalf("Unmarshal error: %v", err) diff --git a/xxdk/utils_test.go b/xxdk/utils_test.go index e537fc3b9f7863f5ee051d03c61dc4dd0fc60937..cb88fc20c36269b469fc533625b1a6ce2120372a 100644 --- a/xxdk/utils_test.go +++ b/xxdk/utils_test.go @@ -45,7 +45,7 @@ func newTestingClient(face interface{}) (*Cmix, error) { "Could not construct a mock client: %v", err) } - c, err := OpenCmix(storageDir, password, GetDefaultParams()) + c, err := OpenCmix(storageDir, password, GetDefaultCMixParams()) if err != nil { return nil, errors.Errorf("Could not open a mock client: %v", err)