diff --git a/bindings/autheticatedConnection.go b/bindings/autheticatedConnection.go index 5e1f78f4e08f813881f01b3695b423a4c1cd2f1e..cc0ef41a8092ad48d45e9c7357c502ed4483e632 100644 --- a/bindings/autheticatedConnection.go +++ b/bindings/autheticatedConnection.go @@ -23,7 +23,7 @@ func (_ *AuthenticatedConnection) IsAuthenticated() bool { // ConnectWithAuthentication is called by the client (i.e. the one establishing // connection with the server). Once a connect.Connection has been established // with the server and then authenticate their identity to the server. -// accepts a marshalled TransmissionIdentity and contact.Contact object +// accepts a marshalled ReceptionIdentity and contact.Contact object func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact []byte) (*AuthenticatedConnection, error) { cont, err := contact.Unmarshal(recipientContact) if err != nil { diff --git a/bindings/connect.go b/bindings/connect.go index 8be9e4881ec5f345fd7d80b932e22d8d693ae19f..42add7b3091bcad9579e6f6d9a5fc2009bc17b04 100644 --- a/bindings/connect.go +++ b/bindings/connect.go @@ -31,7 +31,7 @@ func (c *Connection) GetId() int { // This function is to be used sender-side and will block until the // partner.Manager is confirmed. // recipientContact - marshalled contact.Contact object -// myIdentity - marshalled TransmissionIdentity object +// myIdentity - marshalled ReceptionIdentity object func (c *Cmix) Connect(e2eId int, recipientContact []byte) ( *Connection, error) { cont, err := contact.Unmarshal(recipientContact) diff --git a/bindings/contact.go b/bindings/contact.go index c07b66f8f790eb9ffb4bdf0081aad25c32c8185c..8e24e486141fa9da7f06f61e6ddbb54b353c7924 100644 --- a/bindings/contact.go +++ b/bindings/contact.go @@ -9,8 +9,8 @@ import ( "gitlab.com/xx_network/primitives/id" ) -// TransmissionIdentity struct -// Example marshalled TransmissionIdentity: +// ReceptionIdentity struct +// Example marshalled ReceptionIdentity: // {"ID":"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", // User ID (base64) // // RSA Private key (PEM format) // "RSAPrivatePem":"LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0N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UZNMmN3PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQ==", @@ -19,7 +19,7 @@ import ( // // DH Private key // "DHKeyPrivate":"eyJWYWx1ZSI6NDU2MDgzOTEzMjA0OTIyODA5Njg2MDI3MzQ0MzM3OTA0MzAyODYwMjM2NDk2NDM5NDI4NTcxMTMwNDMzOTQwMzgyMTIyMjY4OTQzNTMyMjIyMzc1MTkzNTEzMjU4MjA4MDA0NTczMDY4MjEwNzg2NDI5NjA1MjA0OTA3MjI2ODI5OTc3NTczMDkxODY0NTY3NDExMDExNjQxNCwiRmluZ2VycHJpbnQiOjE2ODAxNTQxNTExMjMzMDk4MzYzfQ==" // } -type TransmissionIdentity struct { +type ReceptionIdentity struct { ID []byte RSAPrivatePem []byte Salt []byte @@ -30,14 +30,14 @@ type TransmissionIdentity struct { func (c *Cmix) MakeIdentity() ([]byte, error) { s := c.api.GetRng().GetStream() defer s.Close() - ident, err := xxdk.MakeTransmissionIdentity(s, c.api.GetStorage().GetE2EGroup()) + ident, err := xxdk.MakeReceptionIdentity(s, c.api.GetStorage().GetE2EGroup()) dhPrivJson, err := ident.DHKeyPrivate.MarshalJSON() if err != nil { return nil, err } //create the identity object - I := TransmissionIdentity{ + I := ReceptionIdentity{ ID: ident.ID.Marshal(), RSAPrivatePem: rsa.CreatePrivateKeyPem(ident.RSAPrivatePem), Salt: ident.Salt, @@ -47,7 +47,7 @@ func (c *Cmix) MakeIdentity() ([]byte, error) { return json.Marshal(&I) } -// GetContactFromIdentity accepts a marshalled TransmissionIdentity object and returns a marshalled contact.Contact object +// GetContactFromIdentity accepts a marshalled ReceptionIdentity object and returns a marshalled contact.Contact object func (c *Cmix) GetContactFromIdentity(identity []byte) ([]byte, error) { unmarshalledIdentity, err := c.unmarshalIdentity(identity) if err != nil { @@ -68,30 +68,30 @@ func (c *Cmix) GetContactFromIdentity(identity []byte) ([]byte, error) { return ct.Marshal(), nil } -func (c *Cmix) unmarshalIdentity(marshaled []byte) (xxdk.TransmissionIdentity, error) { - newIdentity := xxdk.TransmissionIdentity{} +func (c *Cmix) unmarshalIdentity(marshaled []byte) (xxdk.ReceptionIdentity, error) { + newIdentity := xxdk.ReceptionIdentity{} - // Unmarshal given identity into TransmissionIdentity object - givenIdentity := TransmissionIdentity{} + // Unmarshal given identity into ReceptionIdentity object + givenIdentity := ReceptionIdentity{} err := json.Unmarshal(marshaled, &givenIdentity) if err != nil { - return xxdk.TransmissionIdentity{}, err + return xxdk.ReceptionIdentity{}, err } newIdentity.ID, err = id.Unmarshal(givenIdentity.ID) if err != nil { - return xxdk.TransmissionIdentity{}, err + return xxdk.ReceptionIdentity{}, err } newIdentity.DHKeyPrivate = c.api.GetStorage().GetE2EGroup().NewInt(1) err = newIdentity.DHKeyPrivate.UnmarshalJSON(givenIdentity.DHKeyPrivate) if err != nil { - return xxdk.TransmissionIdentity{}, err + return xxdk.ReceptionIdentity{}, err } newIdentity.RSAPrivatePem, err = rsa.LoadPrivateKeyFromPem(givenIdentity.RSAPrivatePem) if err != nil { - return xxdk.TransmissionIdentity{}, err + return xxdk.ReceptionIdentity{}, err } newIdentity.Salt = givenIdentity.Salt diff --git a/bindings/contact_test.go b/bindings/contact_test.go index 97af0264f4bd9b76c9fe83017ff09477947b7a3d..1d1e0be0f331185480fbf48d87ca7607f2eb7f5b 100644 --- a/bindings/contact_test.go +++ b/bindings/contact_test.go @@ -22,14 +22,14 @@ func TestIdentity_JSON(t *testing.T) { dhpkJson, _ := dhpk.MarshalJSON() op := make([]byte, 64) _, _ = rng.Read(op) - identity := TransmissionIdentity{ + identity := ReceptionIdentity{ ID: uid.Marshal(), RSAPrivatePem: rsa.CreatePrivateKeyPem(pk), Salt: salt, DHKeyPrivate: dhpkJson, } im, _ := json.Marshal(identity) - t.Log("Marshalled TransmissionIdentity object") + t.Log("Marshalled ReceptionIdentity object") t.Log(string(im)) } diff --git a/cmd/root.go b/cmd/root.go index f4f26ef17080c2caded6f8ade4a240658658cd14..66ca4426aa012dbf18666b756675b85547ce6c7a 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1176,7 +1176,7 @@ func init() { viper.BindPFlag("log", rootCmd.PersistentFlags().Lookup("log")) rootCmd.Flags().StringP("regcode", "", "", - "TransmissionIdentity code (optional)") + "ReceptionIdentity code (optional)") viper.BindPFlag("regcode", rootCmd.Flags().Lookup("regcode")) rootCmd.PersistentFlags().StringP("message", "m", "", diff --git a/xxdk/e2e.go b/xxdk/e2e.go index c3536ec8eb316f61bfc49643ab903ee393b1a99b..1dabcf44eb15cd2826c759ca45a7a9dc7ea145d6 100644 --- a/xxdk/e2e.go +++ b/xxdk/e2e.go @@ -25,27 +25,27 @@ import ( "gitlab.com/xx_network/primitives/id" ) -// E2e object bundles a TransmissionIdentity with a Cmix +// E2e object bundles a ReceptionIdentity with a Cmix // and can be used for high level operations such as connections type E2e struct { *Cmix auth auth.State e2e e2e.Handler backup *Container - e2eIdentity TransmissionIdentity + e2eIdentity ReceptionIdentity } // Login creates a new E2e backed by the xxdk.Cmix persistent versioned.KV -// If identity == nil, a new TransmissionIdentity will be generated automagically +// If identity == nil, a new ReceptionIdentity will be generated automagically func Login(client *Cmix, callbacks auth.Callbacks, - identity TransmissionIdentity) (m *E2e, err error) { + identity ReceptionIdentity) (m *E2e, err error) { return login(client, callbacks, identity, client.GetStorage().GetKV()) } // LoginEphemeral creates a new E2e backed by a totally ephemeral versioned.KV -// If identity == nil, a new TransmissionIdentity will be generated automagically +// If identity == nil, a new ReceptionIdentity will be generated automagically func LoginEphemeral(client *Cmix, callbacks auth.Callbacks, - identity TransmissionIdentity) (m *E2e, err error) { + identity ReceptionIdentity) (m *E2e, err error) { return login(client, callbacks, identity, versioned.NewKV(ekv.MakeMemstore())) } @@ -72,7 +72,7 @@ func LoginLegacy(client *Cmix, callbacks auth.Callbacks) (m *E2e, err error) { } u := m.Cmix.GetUser() - m.e2eIdentity = TransmissionIdentity{ + m.e2eIdentity = ReceptionIdentity{ ID: u.TransmissionID, RSAPrivatePem: u.TransmissionRSA, Salt: u.TransmissionSalt, @@ -84,9 +84,9 @@ func LoginLegacy(client *Cmix, callbacks auth.Callbacks) (m *E2e, err error) { // login creates a new e2eApi.E2e backed by the given versioned.KV func login(client *Cmix, callbacks auth.Callbacks, - identity TransmissionIdentity, kv *versioned.KV) (m *E2e, err error) { + identity ReceptionIdentity, kv *versioned.KV) (m *E2e, err error) { - // Verify the passed-in TransmissionIdentity matches its properties + // Verify the passed-in ReceptionIdentity matches its properties generatedId, err := xx.NewID(identity.RSAPrivatePem.GetPublic(), identity.Salt, id.User) if err != nil { return nil, err @@ -209,8 +209,8 @@ func (m *E2e) GetUser() user.Info { return u } -// GetTransmissionIdentity returns a safe copy of the E2e TransmissionIdentity -func (m *E2e) GetTransmissionIdentity() TransmissionIdentity { +// GetTransmissionIdentity returns a safe copy of the E2e ReceptionIdentity +func (m *E2e) GetTransmissionIdentity() ReceptionIdentity { return m.e2eIdentity.DeepCopy() } diff --git a/xxdk/identity.go b/xxdk/identity.go index daef4c673bbf1668ae1a11dc294adfeaaa945e1c..52959db88ced70e0722f18d430397f90e728db6b 100644 --- a/xxdk/identity.go +++ b/xxdk/identity.go @@ -15,20 +15,20 @@ import ( "gitlab.com/xx_network/primitives/id" ) -type TransmissionIdentity struct { +type ReceptionIdentity struct { ID *id.ID RSAPrivatePem *rsa.PrivateKey Salt []byte DHKeyPrivate *cyclic.Int } -// MakeTransmissionIdentity generates a new cryptographic identity for receiving messages -func MakeTransmissionIdentity(rng csprng.Source, grp *cyclic.Group) (TransmissionIdentity, error) { +// MakeReceptionIdentity generates a new cryptographic identity for receiving messages +func MakeReceptionIdentity(rng csprng.Source, grp *cyclic.Group) (ReceptionIdentity, error) { //make RSA Key rsaKey, err := rsa.GenerateKey(rng, rsa.DefaultRSABitLen) if err != nil { - return TransmissionIdentity{}, err + return ReceptionIdentity{}, err } //make salt @@ -44,11 +44,11 @@ func MakeTransmissionIdentity(rng csprng.Source, grp *cyclic.Group) (Transmissio newId, err := xx.NewID(rsaKey.GetPublic(), salt, id.User) if err != nil { - return TransmissionIdentity{}, err + return ReceptionIdentity{}, err } //create the identity object - I := TransmissionIdentity{ + I := ReceptionIdentity{ ID: newId, RSAPrivatePem: rsaKey, Salt: salt, @@ -58,11 +58,11 @@ func MakeTransmissionIdentity(rng csprng.Source, grp *cyclic.Group) (Transmissio return I, nil } -// DeepCopy produces a safe copy of a TransmissionIdentity -func (t TransmissionIdentity) DeepCopy() TransmissionIdentity { +// DeepCopy produces a safe copy of a ReceptionIdentity +func (t ReceptionIdentity) DeepCopy() ReceptionIdentity { saltCopy := make([]byte, len(t.Salt)) copy(saltCopy, t.Salt) - return TransmissionIdentity{ + return ReceptionIdentity{ ID: t.ID.DeepCopy(), RSAPrivatePem: t.RSAPrivatePem, Salt: saltCopy,