Skip to content
Snippets Groups Projects
Commit 15463994 authored by Jake Taylor's avatar Jake Taylor
Browse files

refactor to use generatepublickey

parent d10a8e57
Branches
Tags
3 merge requests!510Release,!267Make BuildReceptionIdentity public, and make backup restore function return a...,!263Hotfix/refactor cmd
......@@ -12,6 +12,7 @@ import (
session2 "gitlab.com/elixxir/client/e2e/ratchet/partner/session"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/diffieHellman"
"gitlab.com/elixxir/crypto/e2e"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/netTime"
......@@ -20,7 +21,7 @@ import (
func makeRelationshipFingerprint(t session2.RelationshipType, grp *cyclic.Group,
myPrivKey, partnerPubKey *cyclic.Int, me, partner *id.ID) []byte {
myPubKey := grp.ExpG(myPrivKey, grp.NewIntFromUInt(1))
myPubKey := diffieHellman.GeneratePublicKey(myPrivKey, grp)
switch t {
case session2.Send:
......
......@@ -11,6 +11,7 @@ import (
"gitlab.com/elixxir/client/single/message"
"gitlab.com/elixxir/crypto/contact"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/diffieHellman"
"gitlab.com/elixxir/crypto/e2e/auth"
"gitlab.com/elixxir/crypto/e2e/singleUse"
"gitlab.com/xx_network/crypto/csprng"
......@@ -271,7 +272,7 @@ func generateDhKeys(grp *cyclic.Group, dhPubKey *cyclic.Int, rng io.Reader) (
privKey := grp.NewIntFromBytes(privKeyBytes)
// Generate public key and DH key
publicKey = grp.ExpG(privKey, grp.NewInt(1))
publicKey = diffieHellman.GeneratePublicKey(privKey, grp)
dhKey = grp.Exp(dhPubKey, privKey, grp.NewInt(1))
return dhKey, publicKey, nil
......
......@@ -3,6 +3,7 @@ package ud
import (
"github.com/pkg/errors"
pb "gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/crypto/diffieHellman"
"gitlab.com/elixxir/crypto/factID"
"gitlab.com/elixxir/crypto/hash"
"gitlab.com/elixxir/primitives/fact"
......@@ -30,7 +31,7 @@ func (m *Manager) register(username string, rng csprng.Source,
if err != nil {
return err
}
dhKeyPub := grp.ExpG(dhKeyPriv, grp.NewInt(1))
dhKeyPub := diffieHellman.GeneratePublicKey(dhKeyPriv, grp)
// Construct the user registration message
msg := &pb.UDBUserRegistration{
......
......@@ -8,6 +8,7 @@ package xxdk
import (
"encoding/json"
"gitlab.com/elixxir/primitives/fact"
"gitlab.com/elixxir/client/storage/user"
"gitlab.com/elixxir/client/storage/versioned"
......@@ -173,12 +174,11 @@ func (r ReceptionIdentity) GetContact() contact.Contact {
grp, _ := r.GetGroup()
dhKeyPriv, _ := r.GetDHKeyPrivate()
dhPub := grp.ExpG(dhKeyPriv, grp.NewInt(1))
ct := contact.Contact{
ID: r.ID,
DhPubKey: dhPub,
DhPubKey: diffieHellman.GeneratePublicKey(dhKeyPriv, grp),
OwnershipProof: nil,
Facts: nil,
Facts: make([]fact.Fact, 0),
}
return ct
}
......
......@@ -252,7 +252,7 @@ func createNewVanityUser(rng csprng.Source,
}
// createPrecannedUser
func createPrecannedUser(precannedID uint, rng csprng.Source, e2e *cyclic.Group) user.Info {
func createPrecannedUser(precannedID uint, rng csprng.Source, grp *cyclic.Group) user.Info {
// Salt, UID, etc gen
salt := make([]byte, SaltSize)
......@@ -263,13 +263,14 @@ func createPrecannedUser(precannedID uint, rng csprng.Source, e2e *cyclic.Group)
// NOTE: not used... RSA Keygen (4096 bit defaults)
rsaKey, err := rsa.GenerateKey(rng, rsa.DefaultRSABitLen)
if err != nil {
r
jww.FATAL.Panicf(err.Error())
}
prime := e2e.GetPBytes()
prime := grp.GetPBytes()
keyLen := len(prime)
prng := rand.New(rand.NewSource(int64(precannedID)))
dhPrivKey := diffieHellman.GeneratePrivateKey(keyLen, e2e, prng)
dhPrivKey := diffieHellman.GeneratePrivateKey(keyLen, grp, prng)
return user.Info{
TransmissionID: &userID,
TransmissionSalt: salt,
......@@ -277,7 +278,7 @@ func createPrecannedUser(precannedID uint, rng csprng.Source, e2e *cyclic.Group)
ReceptionSalt: salt,
Precanned: true,
E2eDhPrivateKey: dhPrivKey,
E2eDhPublicKey: e2e.ExpG(dhPrivKey, e2e.NewInt(1)),
E2eDhPublicKey: diffieHellman.GeneratePublicKey(dhPrivKey, grp),
TransmissionRSA: rsaKey,
ReceptionRSA: rsaKey,
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment