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

fixed user generation, was creating e2e keys in wrong groups

added the deffintion of message IDs
parent 18199c80
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,7 @@ func createNewUser(rng csprng.Source, cmix, e2e *cyclic.Group) user.User { ...@@ -62,7 +62,7 @@ func createNewUser(rng csprng.Source, cmix, e2e *cyclic.Group) user.User {
RSA: rsaKey, RSA: rsaKey,
Precanned: false, Precanned: false,
CmixDhPrivateKey: cmix.NewIntFromBytes(cMixKeyBytes), CmixDhPrivateKey: cmix.NewIntFromBytes(cMixKeyBytes),
E2eDhPrivateKey: cmix.NewIntFromBytes(e2eKeyBytes), E2eDhPrivateKey: e2e.NewIntFromBytes(e2eKeyBytes),
} }
} }
...@@ -89,6 +89,6 @@ func createPrecannedUser(precannedID uint, rng csprng.Source, cmix, e2e *cyclic. ...@@ -89,6 +89,6 @@ func createPrecannedUser(precannedID uint, rng csprng.Source, cmix, e2e *cyclic.
ID: userID.DeepCopy(), ID: userID.DeepCopy(),
Salt: salt, Salt: salt,
Precanned: false, Precanned: false,
E2eDhPrivateKey: cmix.NewIntFromBytes(e2eKeyBytes), E2eDhPrivateKey: e2e.NewIntFromBytes(e2eKeyBytes),
} }
} }
package message
import (
"encoding/binary"
"gitlab.com/elixxir/crypto/hash"
"gitlab.com/xx_network/primitives/id"
jww "github.com/spf13/jwalterweatherman"
)
const messageIDLen = 32
type ID [messageIDLen]byte
func NewID(sender, receiver *id.ID, connectionSalt []byte,
internalMessageID uint64) ID {
h, err := hash.NewCMixHash()
if err != nil {
jww.FATAL.Panicf("Failed to get hash for message ID creation")
}
h.Write(sender.Bytes())
h.Write(receiver.Bytes())
intMidBytes := make([]byte, 8)
binary.BigEndian.PutUint64(intMidBytes, internalMessageID)
h.Write(intMidBytes)
h.Write(connectionSalt)
midBytes := h.Sum(nil)
mid := ID{}
copy(mid[:], midBytes)
return mid
}
...@@ -11,4 +11,7 @@ type Receive struct { ...@@ -11,4 +11,7 @@ type Receive struct {
Sender *id.ID Sender *id.ID
Timestamp time.Time Timestamp time.Time
Encryption EncryptionType Encryption EncryptionType
Id ID
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment