Skip to content
Snippets Groups Projects
Commit ae5df0c3 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

started removign my ID in e2e

parent 4029f414
No related branches found
No related tags found
3 merge requests!510Release,!207WIP: Client Restructure,!203Symmetric broadcast
......@@ -49,7 +49,7 @@ type Handler interface {
// pass nil to this.
//
// If a message matches multiple listeners, all of them will hear the message.
RegisterListener(user *id.ID, messageType catalog.MessageType,
RegisterListener(senderID *id.ID, messageType catalog.MessageType,
newListener receive.Listener) receive.ListenerID
// RegisterFunc Registers a new listener built around the passed function.
......@@ -66,7 +66,7 @@ type Handler interface {
// Do not pass nil to this.
//
// If a message matches multiple listeners, all of them will hear the message.
RegisterFunc(name string, user *id.ID, messageType catalog.MessageType,
RegisterFunc(name string, senderID *id.ID, messageType catalog.MessageType,
newListener receive.ListenerFunc) receive.ListenerID
// RegisterChannel Registers a new listener built around the passed channel.
......@@ -83,7 +83,7 @@ type Handler interface {
// Do not pass nil to this.
//
// If a message matches multiple listeners, all of them will hear the message.
RegisterChannel(name string, user *id.ID, messageType catalog.MessageType,
RegisterChannel(name string, senderID *id.ID, messageType catalog.MessageType,
newListener chan receive.Message) receive.ListenerID
// Unregister removes the listener with the specified ID so it will no longer
......@@ -98,7 +98,7 @@ type Handler interface {
// then pass them in, otherwise, leave myID and myPrivateKey nil
// If temporary is true, an alternate ram kv will be used for storage and
// the relationship will not survive a reset
AddPartner(myID *id.ID, partnerID *id.ID,
AddPartner(partnerID *id.ID,
partnerPubKey, myPrivKey *cyclic.Int, partnerSIDHPubKey *sidh.PublicKey,
mySIDHPrivKey *sidh.PrivateKey, sendParams,
receiveParams session.Params) (*partner.Manager, error)
......@@ -106,16 +106,16 @@ type Handler interface {
// GetPartner returns the partner per its ID, if it exists
// myID is your ID in the relationship, if left blank, it will
// assume to be your defaultID
GetPartner(partnerID *id.ID, myID *id.ID) (*partner.Manager, error)
GetPartner(partnerID *id.ID) (*partner.Manager, error)
// DeletePartner removes the associated contact from the E2E store
// myID is your ID in the relationship, if left blank, it will
// assume to be your defaultID
DeletePartner(partnerId *id.ID, myID *id.ID) error
DeletePartner(partnerId *id.ID) error
// GetAllPartnerIDs returns a list of all partner IDs that the user has
// an E2E relationship with.
GetAllPartnerIDs(myID *id.ID) []*id.ID
GetAllPartnerIDs() []*id.ID
/* === Services ========================================================= */
......@@ -155,12 +155,12 @@ type Handler interface {
// GetGroup returns the cyclic group used for end to end encruption
GetGroup() *cyclic.Group
// GetDefaultHistoricalDHPubkey returns the default user's Historical DH Public Key
GetDefaultHistoricalDHPubkey() *cyclic.Int
// GetHistoricalDHPubkey returns the default user's Historical DH Public Key
GetHistoricalDHPubkey() *cyclic.Int
// GetDefaultHistoricalDHPrivkey returns the default user's Historical DH Private Key
GetDefaultHistoricalDHPrivkey() *cyclic.Int
// GetHistoricalDHPrivkey returns the default user's Historical DH Private Key
GetHistoricalDHPrivkey() *cyclic.Int
// GetDefaultID returns the default IDs
GetDefaultID() *id.ID
// GetReceptionID returns the default IDs
GetReceptionID() *id.ID
}
......@@ -37,9 +37,19 @@ const e2eRekeyParamsKey = "e2eRekeyParams"
const e2eRekeyParamsVer = 0
// Init Creates stores. After calling, use load
// Passes a default ID and public key which is used for relationship with
// partners when no default ID is selected
func Init(kv *versioned.KV, myDefaultID *id.ID, privKey *cyclic.Int,
// Passes a the ID public key which is used for the relationship
// uses the passed ID to modify the kv prefix for a unique storage path
func Init(kv *versioned.KV, myID *id.ID, privKey *cyclic.Int,
grp *cyclic.Group, rekeyParams rekey.Params) error {
kv = kv.Prefix(makeE2ePrefix(myID))
return InitLegacy(kv, myID, privKey, grp, rekeyParams)
}
// InitLegacy Creates stores. After calling, use load
// Passes a the ID public key which is used for the relationship
// Does not modify the kv prefix in any way to maintain backwards compatibility
// before multiple IDs were supported
func InitLegacy(kv *versioned.KV, myID *id.ID, privKey *cyclic.Int,
grp *cyclic.Group, rekeyParams rekey.Params) error {
rekeyParamsData, err := json.Marshal(rekeyParams)
if err != nil {
......@@ -53,13 +63,21 @@ func Init(kv *versioned.KV, myDefaultID *id.ID, privKey *cyclic.Int,
if err != nil {
return errors.WithMessage(err, "Failed to save rekeyParams")
}
return ratchet.New(kv, myDefaultID, privKey, grp)
return ratchet.New(kv, myID, privKey, grp)
}
// Load returns an e2e manager from storage
func Load(kv *versioned.KV, net cmix.Client, myDefaultID *id.ID,
grp *cyclic.Group, rng *fastRNG.StreamGenerator, events event.Manager) (
Handler, error) {
}
// LoadLegacy returns an e2e manager from storage
// Passes a default ID which is used for relationship with
// partners when no default ID is selected
func Load(kv *versioned.KV, net cmix.Client, myDefaultID *id.ID,
// Does not modify the kv prefix in any way to maintain backwards compatibility
// before multiple IDs were supported
func LoadLegacy(kv *versioned.KV, net cmix.Client, myDefaultID *id.ID,
grp *cyclic.Group, rng *fastRNG.StreamGenerator, events event.Manager) (Handler, error) {
//build the manager
......@@ -141,3 +159,7 @@ func (m *manager) EnableUnsafeReception() {
tag: ratchet.E2e,
})
}
func makeE2ePrefix(myid *id.ID) string {
return "e2eStore:" + myid.String()
}
......@@ -11,16 +11,16 @@ func (m *manager) GetGroup() *cyclic.Group {
}
// GetDefaultHistoricalDHPubkey returns the default user's Historical DH Public Key
func (m *manager) GetDefaultHistoricalDHPubkey() *cyclic.Int {
func (m *manager) GetHistoricalDHPubkey() *cyclic.Int {
return m.Ratchet.GetDHPublicKey()
}
// GetDefaultHistoricalDHPrivkey returns the default user's Historical DH Private Key
func (m *manager) GetDefaultHistoricalDHPrivkey() *cyclic.Int {
func (m *manager) GetHistoricalDHPrivkey() *cyclic.Int {
return m.Ratchet.GetDHPrivateKey()
}
// GetDefaultID returns the default IDs
func (m *manager) GetDefaultID() *id.ID {
func (m *manager) GetReceptionID() *id.ID {
return m.myDefaultID
}
......@@ -50,7 +50,7 @@ func NewManager(services cmix.Client, e2e e2e.Handler, receptionId *id.ID,
// Load the group chat storage or create one if one does not exist
gStore, err := gs.NewOrLoadStore(
kv, group.Member{ID: receptionId, DhKey: e2e.GetDefaultHistoricalDHPubkey()})
kv, group.Member{ID: receptionId, DhKey: e2e.GetHistoricalDHPubkey()})
if err != nil {
return nil, errors.Errorf(newGroupStoreErr, err)
}
......
......@@ -274,7 +274,7 @@ func Test_newManager_LoadError(t *testing.T) {
func TestManager_JoinGroup(t *testing.T) {
prng := rand.New(rand.NewSource(42))
m, _ := newTestManagerWithStore(prng, 10, 0, nil, nil, t)
g := newTestGroup(m.grp, m.e2e.GetDefaultHistoricalDHPubkey(), prng, t)
g := newTestGroup(m.grp, m.e2e.GetHistoricalDHPubkey(), prng, t)
err := m.JoinGroup(g)
if err != nil {
......
......@@ -28,8 +28,8 @@ func TestManager_receiveRequest(t *testing.T) {
requestFunc := func(g gs.Group) { requestChan <- g }
m, _ := newTestManagerWithStore(prng, 10, 0, requestFunc, nil, t)
g := newTestGroupWithUser(m.grp,
m.receptionId, m.e2e.GetDefaultHistoricalDHPubkey(),
m.e2e.GetDefaultHistoricalDHPrivkey(), prng, t)
m.receptionId, m.e2e.GetHistoricalDHPubkey(),
m.e2e.GetHistoricalDHPrivkey(), prng, t)
requestMarshaled, err := proto.Marshal(&Request{
Name: g.Name,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment