diff --git a/connect/authenticated.go b/connect/authenticated.go index f5a54833a21aeba421b78cd9b27e5f5df5085cb2..89311eff3ee33dd957b790c06a98e3de7bd745b9 100644 --- a/connect/authenticated.go +++ b/connect/authenticated.go @@ -15,7 +15,6 @@ import ( clientE2e "gitlab.com/elixxir/client/e2e" "gitlab.com/elixxir/client/xxdk" "gitlab.com/elixxir/crypto/contact" - "gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/fastRNG" "gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/primitives/id" @@ -170,10 +169,8 @@ func connectWithAuthentication(conn Connection, timeStart time.Time, // will handle authenticated requests and verify the client's attempt to // authenticate themselves. An established AuthenticatedConnection will // be passed via the callback. -func StartAuthenticatedServer(cb AuthenticatedCallback, - myId *id.ID, privKey *cyclic.Int, - rng *fastRNG.StreamGenerator, grp *cyclic.Group, net cmix.Client, - p Params) error { +func StartAuthenticatedServer(identity xxdk.ReceptionIdentity, + cb AuthenticatedCallback, net *xxdk.Cmix, p Params) (*xxdk.E2e, error) { // Register the waiter for a connection establishment connCb := Callback(func(connection Connection) { @@ -184,8 +181,7 @@ func StartAuthenticatedServer(cb AuthenticatedCallback, connection.RegisterListener(catalog.ConnectionAuthenticationRequest, buildAuthConfirmationHandler(cb, connection)) }) - return StartServer(connCb, myId, privKey, rng, grp, - net, p) + return StartServer(identity, connCb, net, p) } // authenticatedHandler provides an implementation for the diff --git a/connect/connect.go b/connect/connect.go index 6ebb2b7c4893d3cc0891cd43ad73c8e36b3f8498..e7d4d14c5c8b1cdee3da162226ba8f7c59313e31 100644 --- a/connect/connect.go +++ b/connect/connect.go @@ -8,12 +8,7 @@ package connect import ( "encoding/json" - "gitlab.com/elixxir/client/cmix" - "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/client/xxdk" - "gitlab.com/elixxir/crypto/cyclic" - "gitlab.com/elixxir/crypto/fastRNG" - "gitlab.com/elixxir/ekv" "io" "time" @@ -157,34 +152,28 @@ func Connect(recipient contact.Contact, e2eClient *xxdk.E2e, } } -// StartServer assembles a Connection object on the reception-side -// and feeds it into the given Callback whenever an incoming request -// for an E2E partnership with a partner.Manager is confirmed. -func StartServer(cb Callback, myId *id.ID, privKey *cyclic.Int, - rng *fastRNG.StreamGenerator, grp *cyclic.Group, net cmix.Client, - p Params) error { +// StartServer assembles a Connection object on the reception-side and feeds it +// into the given Callback whenever an incoming request for an E2E partnership +// with a partner.Manager is confirmed. +// +// It is recommended that this be called before StartNetworkFollower to ensure +// no requests are missed. +// 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) (*xxdk.E2e, error) { - // Build an ephemeral KV - kv := versioned.NewKV(ekv.MakeMemstore()) + // Build callback for E2E negotiation + callback := getAuthCallback(nil, cb, nil, nil, p) - // Build E2e handler - err := clientE2e.Init(kv, myId, privKey, grp, p.Rekey) - if err != nil { - return err - } - e2eHandler, err := clientE2e.Load(kv, net, myId, grp, rng, p.Event) + client, err := xxdk.LoginEphemeral(net, callback, identity) if err != nil { - return err + return nil, err } - // Build callback for E2E negotiation - callback := getAuthCallback(nil, cb, e2eHandler, nil, p) - - // Build auth object for E2E negotiation - authState, err := auth.NewState(kv, net, e2eHandler, - rng, p.Event, p.Auth, callback, nil) - callback.authState = authState - return err + callback.connectionE2e = client.GetE2E() + callback.authState = client.GetAuth() + return client, nil } // handler provides an implementation for the Connection interface. diff --git a/restlike/connect/server.go b/restlike/connect/server.go index 977edb7f212781b43f683f2c0f850d00d829344b..d2a22dad5d3a46dbd63af11dbf5f2eb937a080da 100644 --- a/restlike/connect/server.go +++ b/restlike/connect/server.go @@ -8,11 +8,9 @@ package connect import ( "gitlab.com/elixxir/client/catalog" - "gitlab.com/elixxir/client/cmix" "gitlab.com/elixxir/client/connect" "gitlab.com/elixxir/client/restlike" - "gitlab.com/elixxir/crypto/cyclic" - "gitlab.com/elixxir/crypto/fastRNG" + "gitlab.com/elixxir/client/xxdk" "gitlab.com/xx_network/primitives/id" ) @@ -24,10 +22,10 @@ type Server struct { // NewServer builds a RestServer with connect.Connection and // the provided arguments, then registers necessary external services -func NewServer(receptionId *id.ID, privKey *cyclic.Int, - rng *fastRNG.StreamGenerator, grp *cyclic.Group, net cmix.Client, p connect.Params) (*Server, error) { +func NewServer(identity xxdk.ReceptionIdentity, net *xxdk.Cmix, + p connect.Params) (*Server, error) { newServer := &Server{ - receptionId: receptionId, + receptionId: identity.ID, endpoints: restlike.NewEndpoints(), } @@ -38,7 +36,7 @@ func NewServer(receptionId *id.ID, privKey *cyclic.Int, } // Build the connection listener - err := connect.StartServer(cb, receptionId, privKey, rng, grp, net, p) + _, err := connect.StartServer(identity, cb, net, p) if err != nil { return nil, err }