diff --git a/api/auth.go b/api/auth.go index 50ac3131b93a6da5feba080fbbdc24846fe78a72..dfd97b120139aa6c9719f950560e2f273e9a29b4 100644 --- a/api/auth.go +++ b/api/auth.go @@ -8,18 +8,12 @@ package api import ( - "encoding/binary" "gitlab.com/elixxir/client/e2e/ratchet/partner" - "math/rand" - "github.com/cloudflare/circl/dh/sidh" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/auth" - "gitlab.com/elixxir/client/e2e/ratchet/partner/session" - util "gitlab.com/elixxir/client/storage/utility" "gitlab.com/elixxir/crypto/contact" - "gitlab.com/elixxir/primitives/fact" "gitlab.com/xx_network/primitives/id" ) @@ -106,66 +100,6 @@ func (c *Client) HasAuthenticatedChannel(partner *id.ID) bool { return m != nil && err == nil } -// Create an insecure e2e relationship with a precanned user -func (c *Client) MakePrecannedAuthenticatedChannel(precannedID uint) ( - contact.Contact, error) { - - precan := c.MakePrecannedContact(precannedID) - - myID := binary.BigEndian.Uint64(c.GetUser().GetContact().ID[:]) - // Pick a variant based on if their ID is bigger than mine. - myVariant := sidh.KeyVariantSidhA - theirVariant := sidh.KeyVariant(sidh.KeyVariantSidhB) - if myID > uint64(precannedID) { - myVariant = sidh.KeyVariantSidhB - theirVariant = sidh.KeyVariantSidhA - } - prng1 := rand.New(rand.NewSource(int64(precannedID))) - theirSIDHPrivKey := util.NewSIDHPrivateKey(theirVariant) - theirSIDHPubKey := util.NewSIDHPublicKey(theirVariant) - theirSIDHPrivKey.Generate(prng1) - theirSIDHPrivKey.GeneratePublicKey(theirSIDHPubKey) - - prng2 := rand.New(rand.NewSource(int64(myID))) - mySIDHPrivKey := util.NewSIDHPrivateKey(myVariant) - mySIDHPubKey := util.NewSIDHPublicKey(myVariant) - mySIDHPrivKey.Generate(prng2) - mySIDHPrivKey.GeneratePublicKey(mySIDHPubKey) - - // add the precanned user as a e2e contact - // FIXME: these params need to be threaded through... - sesParam := session.GetDefaultParams() - _, err := c.e2e.AddPartner(precan.ID, precan.DhPubKey, - c.e2e.GetHistoricalDHPrivkey(), theirSIDHPubKey, - mySIDHPrivKey, sesParam, sesParam) - - // check garbled messages in case any messages arrived before creating - // the channel - c.network.CheckInProgressMessages() - - return precan, err -} - -// Create an insecure e2e contact object for a precanned user -func (c *Client) MakePrecannedContact(precannedID uint) contact.Contact { - - e2eGrp := c.storage.GetE2EGroup() - - precanned := createPrecannedUser(precannedID, c.rng.GetStream(), - c.storage.GetCmixGroup(), e2eGrp) - - // compute their public e2e key - partnerPubKey := e2eGrp.ExpG(precanned.E2eDhPrivateKey, - e2eGrp.NewInt(1)) - - return contact.Contact{ - ID: precanned.ReceptionID, - DhPubKey: partnerPubKey, - OwnershipProof: nil, - Facts: make([]fact.Fact, 0), - } -} - // GetRelationshipFingerprint returns a unique 15 character fingerprint for an // E2E relationship. An error is returned if no relationship with the partner // is found.