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

Merge branch 'release' into agile/EphemeralReception

# Conflicts:
#	go.mod
#	go.sum
#	network/message/garbled_test.go
#	network/rounds/check.go
#	storage/e2e/session.go
parents df0a696f 50b69bc6
No related branches found
No related tags found
No related merge requests found
Showing with 324 additions and 194 deletions
......@@ -45,6 +45,43 @@ GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -ldflags '-w -s' -o release/clien
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-w -s' -o release/client.darwin64 main.go
```
To get an NDF from a network gateway and the permissioning server, use the `getndf` subcommand. The `getndf` subcommand allows command line users to poll the NDF from both a gateway and the permissioning server without any pre-established client connection. It requires an IP address, port, and ssl certificate. You can download an ssl cert with:
```
openssl s_client -showcerts -connect permissioning.prod.cmix.rip:11420 < /dev/null 2>&1 | openssl x509 -outform PEM > certfile.pem
```
Example usage for Gateways:
```
$ go run main.go getndf --gwhost localhost:8440 --cert ~/integration/keys/cmix.rip.crt | jq . | head
{
"Timestamp": "2021-01-29T01:19:49.227246827Z",
"Gateways": [
{
"Id": "BRM+Iotl6ujIGhjRddZMBdauapS7Z6jL0FJGq7IkUdYB",
"Address": ":8440",
"Tls_certificate": "-----BEGIN CERTIFICATE-----\nMIIDbDCCAlSgAwIBAgIJAOUNtZneIYECMA0GCSqGSIb3DQEBBQUAMGgxCzAJBgNV\nBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRIwEAYDVQQHDAlDbGFyZW1vbnQx\nGzAZBgNVBAoMElByaXZhdGVncml0eSBDb3JwLjETMBEGA1UEAwwKKi5jbWl4LnJp\ncDAeFw0xOTAzMDUxODM1NDNaFw0yOTAzMDIxODM1NDNaMGgxCzAJBgNVBAYTAlVT\nMRMwEQYDVQQIDApDYWxpZm9ybmlhMRIwEAYDVQQHDAlDbGFyZW1vbnQxGzAZBgNV\nBAoMElByaXZhdGVncml0eSBDb3JwLjETMBEGA1UEAwwKKi5jbWl4LnJpcDCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPP0WyVkfZA/CEd2DgKpcudn0oDh\nDwsjmx8LBDWsUgQzyLrFiVigfUmUefknUH3dTJjmiJtGqLsayCnWdqWLHPJYvFfs\nWYW0IGF93UG/4N5UAWO4okC3CYgKSi4ekpfw2zgZq0gmbzTnXcHF9gfmQ7jJUKSE\ntJPSNzXq+PZeJTC9zJAb4Lj8QzH18rDM8DaL2y1ns0Y2Hu0edBFn/OqavBJKb/uA\nm3AEjqeOhC7EQUjVamWlTBPt40+B/6aFJX5BYm2JFkRsGBIyBVL46MvC02MgzTT9\nbJIJfwqmBaTruwemNgzGu7Jk03hqqS1TUEvSI6/x8bVoba3orcKkf9HsDjECAwEA\nAaMZMBcwFQYDVR0RBA4wDIIKKi5jbWl4LnJpcDANBgkqhkiG9w0BAQUFAAOCAQEA\nneUocN4AbcQAC1+b3To8u5UGdaGxhcGyZBlAoenRVdjXK3lTjsMdMWb4QctgNfIf\nU/zuUn2mxTmF/ekP0gCCgtleZr9+DYKU5hlXk8K10uKxGD6EvoiXZzlfeUuotgp2\nqvI3ysOm/hvCfyEkqhfHtbxjV7j7v7eQFPbvNaXbLa0yr4C4vMK/Z09Ui9JrZ/Z4\ncyIkxfC6/rOqAirSdIp09EGiw7GM8guHyggE4IiZrDslT8V3xIl985cbCxSxeW1R\ntgH4rdEXuVe9+31oJhmXOE9ux2jCop9tEJMgWg7HStrJ5plPbb+HmjoX3nBO04E5\n6m52PyzMNV+2N21IPppKwA==\n-----END CERTIFICATE-----\n"
},
{
"Id": "JCBd9mAQb2BW8hc8H9avy1ubcjUAa7MHrPp0dBU/VqQB",
```
Example usage for the Permissioning server:
```
$ go run main.go getndf --permhost localhost:18000 --cert ~/integration/keys/cmix.rip.crt | jq . | head
{
"Timestamp": "2021-01-29T01:19:49.227246827Z",
"Gateways": [
{
"Id": "BRM+Iotl6ujIGhjRddZMBdauapS7Z6jL0FJGq7IkUdYB",
"Address": ":8440",
"Tls_certificate": "-----BEGIN CERTIFICATE-----\nMIIDbDCCAlSgAwIBAgIJAOUNtZneIYECMA0GCSqGSIb3DQEBBQUAMGgxCzAJBgNV\nBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRIwEAYDVQQHDAlDbGFyZW1vbnQx\nGzAZBgNVBAoMElByaXZhdGVncml0eSBDb3JwLjETMBEGA1UEAwwKKi5jbWl4LnJp\ncDAeFw0xOTAzMDUxODM1NDNaFw0yOTAzMDIxODM1NDNaMGgxCzAJBgNVBAYTAlVT\nMRMwEQYDVQQIDApDYWxpZm9ybmlhMRIwEAYDVQQHDAlDbGFyZW1vbnQxGzAZBgNV\nBAoMElByaXZhdGVncml0eSBDb3JwLjETMBEGA1UEAwwKKi5jbWl4LnJpcDCCASIw\nDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPP0WyVkfZA/CEd2DgKpcudn0oDh\nDwsjmx8LBDWsUgQzyLrFiVigfUmUefknUH3dTJjmiJtGqLsayCnWdqWLHPJYvFfs\nWYW0IGF93UG/4N5UAWO4okC3CYgKSi4ekpfw2zgZq0gmbzTnXcHF9gfmQ7jJUKSE\ntJPSNzXq+PZeJTC9zJAb4Lj8QzH18rDM8DaL2y1ns0Y2Hu0edBFn/OqavBJKb/uA\nm3AEjqeOhC7EQUjVamWlTBPt40+B/6aFJX5BYm2JFkRsGBIyBVL46MvC02MgzTT9\nbJIJfwqmBaTruwemNgzGu7Jk03hqqS1TUEvSI6/x8bVoba3orcKkf9HsDjECAwEA\nAaMZMBcwFQYDVR0RBA4wDIIKKi5jbWl4LnJpcDANBgkqhkiG9w0BAQUFAAOCAQEA\nneUocN4AbcQAC1+b3To8u5UGdaGxhcGyZBlAoenRVdjXK3lTjsMdMWb4QctgNfIf\nU/zuUn2mxTmF/ekP0gCCgtleZr9+DYKU5hlXk8K10uKxGD6EvoiXZzlfeUuotgp2\nqvI3ysOm/hvCfyEkqhfHtbxjV7j7v7eQFPbvNaXbLa0yr4C4vMK/Z09Ui9JrZ/Z4\ncyIkxfC6/rOqAirSdIp09EGiw7GM8guHyggE4IiZrDslT8V3xIl985cbCxSxeW1R\ntgH4rdEXuVe9+31oJhmXOE9ux2jCop9tEJMgWg7HStrJ5plPbb+HmjoX3nBO04E5\n6m52PyzMNV+2N21IPppKwA==\n-----END CERTIFICATE-----\n"
},
{
"Id": "JCBd9mAQb2BW8hc8H9avy1ubcjUAa7MHrPp0dBU/VqQB",
```
Basic command line usage, sending unsafe, unencrypted messages to yourself:
```
......@@ -121,6 +158,8 @@ Flags:
-d, --destid string ID to send message to (if below 40, will be
precanned. Use '0x' or 'b64:' for hex and
base64 representations) (default "0")
--forceHistoricalRounds Force all rounds to be sent to historical
round retrieval
-h, --help help for client
-l, --log string Path to the log output path (- is stdout)
(default "-")
......
......@@ -13,7 +13,6 @@ import (
"gitlab.com/elixxir/client/auth"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces/contact"
"gitlab.com/elixxir/client/storage/e2e"
"gitlab.com/elixxir/primitives/fact"
"gitlab.com/xx_network/primitives/id"
)
......@@ -94,7 +93,7 @@ func (c *Client) MakePrecannedAuthenticatedChannel(precannedID uint) (contact.Co
precan := c.MakePrecannedContact(precannedID)
// add the precanned user as a e2e contact
sesParam := e2e.GetDefaultSessionParams()
sesParam := c.parameters.E2EParams
err := c.storage.E2e().AddPartner(precan.ID, precan.DhPubKey,
c.storage.E2e().GetDHPrivateKey(), sesParam, sesParam)
......
......@@ -14,7 +14,6 @@ import (
"gitlab.com/elixxir/client/interfaces/contact"
"gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/client/storage/auth"
"gitlab.com/elixxir/client/storage/e2e"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/diffieHellman"
cAuth "gitlab.com/elixxir/crypto/e2e/auth"
......@@ -251,7 +250,7 @@ func (m *Manager) doConfirm(sr *auth.SentRequest, grp *cyclic.Group,
// fixme: channel can get into a bricked state if the first save occurs and
// the second does not
p := e2e.GetDefaultSessionParams()
p := m.storage.E2e().GetE2ESessionParams()
if err := m.storage.E2e().AddPartner(sr.GetPartner(),
partnerPubKey, sr.GetMyPrivKey(), p, p); err != nil {
return errors.Errorf("Failed to create channel with partner (%s) "+
......
......@@ -15,7 +15,6 @@ import (
"gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/interfaces/utility"
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/storage/e2e"
ds "gitlab.com/elixxir/comms/network/dataStructures"
"gitlab.com/elixxir/crypto/diffieHellman"
cAuth "gitlab.com/elixxir/crypto/e2e/auth"
......@@ -105,7 +104,7 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader,
// messages does not occur
//create local relationship
p := e2e.GetDefaultSessionParams()
p := storage.E2e().GetE2ESessionParams()
if err := storage.E2e().AddPartner(partner.ID, partner.DhPubKey, newPrivKey,
p, p); err != nil {
storage.Auth().Fail(partner.ID)
......
///////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
///////////////////////////////////////////////////////////////////////////////
// Package cmd initializes the CLI and config parsers as well as the logger.
package cmd
import (
"fmt"
"github.com/spf13/cobra"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
// "gitlab.com/elixxir/client/interfaces/contact"
// "gitlab.com/elixxir/client/interfaces/message"
// "gitlab.com/elixxir/client/switchboard"
// "gitlab.com/elixxir/client/ud"
// "gitlab.com/elixxir/primitives/fact"
"gitlab.com/elixxir/comms/client"
"gitlab.com/xx_network/comms/connect"
//"time"
pb "gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/utils"
)
const opensslCertDL = ("openssl s_client -showcerts -connect ip:port < " +
"/dev/null 2>&1 | openssl x509 -outform PEM > certfile.pem")
// getNDFCmd user discovery subcommand, allowing user lookup and registration for
// allowing others to search.
// This basically runs a client for these functions with the UD module enabled.
// Normally, clients don't need it so it is not loaded for the rest of the
// commands.
var getNDFCmd = &cobra.Command{
Use: "getndf",
Short: ("Download the network definition file from the network " +
"and print it."),
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
gwHost := viper.GetString("gwhost")
permHost := viper.GetString("permhost")
certPath := viper.GetString("cert")
// Load the certificate
var cert []byte
if certPath != "" {
cert, _ = utils.ReadFile(certPath)
}
if len(cert) == 0 {
jww.FATAL.Panicf("Could not load a certificate, "+
"provide a certificate file with --cert.\n\n"+
"You can download a cert using openssl:\n\n%s",
opensslCertDL)
}
params := connect.GetDefaultHostParams()
params.AuthEnabled = false
comms, _ := client.NewClientComms(nil, nil, nil, nil)
// Gateway lookup
if gwHost != "" {
host, _ := connect.NewHost(&id.TempGateway, gwHost,
cert, params)
pollMsg := &pb.GatewayPoll{
Partial: &pb.NDFHash{
Hash: nil,
},
LastUpdate: uint64(0),
ClientID: id.DummyUser.Marshal(),
}
resp, err := comms.SendPoll(host, pollMsg)
if err != nil {
jww.FATAL.Panicf("Unable to poll %s for NDF:"+
" %+v",
gwHost, err)
}
fmt.Printf("%s", resp.PartialNDF.Ndf)
return
}
if permHost != "" {
host, _ := connect.NewHost(&id.Permissioning, permHost,
cert, params)
pollMsg := &pb.NDFHash{
Hash: []byte("DummyUserRequest"),
}
resp, err := comms.RequestNdf(host, pollMsg)
if err != nil {
jww.FATAL.Panicf("Unable to ask %s for NDF:"+
" %+v",
permHost, err)
}
fmt.Printf("%s", resp.Ndf)
return
}
fmt.Println("Enter --gwhost or --permhost and --cert please")
},
}
func init() {
getNDFCmd.Flags().StringP("gwhost", "", "",
"Poll this gateway host:port for the NDF")
viper.BindPFlag("gwhost",
getNDFCmd.Flags().Lookup("gwhost"))
getNDFCmd.Flags().StringP("permhost", "", "",
"Poll this permissioning host:port for the NDF")
viper.BindPFlag("permhost",
getNDFCmd.Flags().Lookup("permhost"))
getNDFCmd.Flags().StringP("cert", "", "",
"Check with the TLS certificate at this path")
viper.BindPFlag("cert",
getNDFCmd.Flags().Lookup("cert"))
rootCmd.AddCommand(getNDFCmd)
}
......@@ -212,7 +212,14 @@ func createClient() *api.Client {
}
}
client, err := api.OpenClient(storeDir, []byte(pass), params.GetDefaultNetwork())
netParams := params.GetDefaultNetwork()
netParams.E2EParams.MinKeys = uint16(viper.GetUint("e2eMinKeys"))
netParams.E2EParams.MaxKeys = uint16(viper.GetUint("e2eMaxKeys"))
netParams.E2EParams.NumRekeys = uint16(
viper.GetUint("e2eNumReKeys"))
netParams.ForceHistoricalRounds = viper.GetBool("forceHistoricalRounds")
client, err := api.OpenClient(storeDir, []byte(pass), netParams)
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
......@@ -225,8 +232,15 @@ func initClient() *api.Client {
pass := viper.GetString("password")
storeDir := viper.GetString("session")
netParams := params.GetDefaultNetwork()
netParams.E2EParams.MinKeys = uint16(viper.GetUint("e2eMinKeys"))
netParams.E2EParams.MaxKeys = uint16(viper.GetUint("e2eMaxKeys"))
netParams.E2EParams.NumRekeys = uint16(
viper.GetUint("e2eNumReKeys"))
netParams.ForceHistoricalRounds = viper.GetBool("forceHistoricalRounds")
//load the client
client, err := api.Login(storeDir, []byte(pass), params.GetDefaultNetwork())
client, err := api.Login(storeDir, []byte(pass), netParams)
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
......@@ -613,6 +627,26 @@ func init() {
"Accept the channel request for the corresponding recipient ID")
viper.BindPFlag("accept-channel",
rootCmd.Flags().Lookup("accept-channel"))
rootCmd.Flags().BoolP("forceHistoricalRounds", "", false,
"Force all rounds to be sent to historical round retrieval")
viper.BindPFlag("forceHistoricalRounds",
rootCmd.Flags().Lookup("forceHistoricalRounds"))
// E2E Params
defaultE2EParams := params.GetDefaultE2ESessionParams()
rootCmd.Flags().UintP("e2eMinKeys",
"", uint(defaultE2EParams.MinKeys),
"Minimum number of keys used before requesting rekey")
viper.BindPFlag("MinKeys", rootCmd.Flags().Lookup("e2eMinKeys"))
rootCmd.Flags().UintP("e2eMaxKeys",
"", uint(defaultE2EParams.MaxKeys),
"Max keys used before blocking until a rekey completes")
viper.BindPFlag("e2eMaxKeys", rootCmd.Flags().Lookup("e2eMaxKeys"))
rootCmd.Flags().UintP("e2eNumReKeys",
"", uint(defaultE2EParams.NumRekeys),
"Number of rekeys reserved for rekey operations")
viper.BindPFlag("e2eNumReKeys", rootCmd.Flags().Lookup("e2eNumReKeys"))
}
// initConfig reads in config file and ENV variables if set.
......
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2020-12-30 13:10:27.265664 -0600 CST m=+0.032380471
// 2021-01-28 22:23:27.98267073 +0000 UTC m=+0.009712900
package globals
const GITVERSION = `8185927 Merge branch 'XX-2971/contactCompression' into 'release'`
const GITVERSION = `c38a960 Merge branch 'XX-3071/knownRoundsImpliesBug' into 'release'`
const SEMVER = "1.4.0"
const DEPENDENCIES = `module gitlab.com/elixxir/client
......@@ -14,31 +14,30 @@ require (
github.com/golang/protobuf v1.4.3
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/magiconair/properties v1.8.4 // indirect
github.com/mitchellh/mapstructure v1.3.3 // indirect
github.com/mitchellh/mapstructure v1.4.0 // indirect
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/pkg/errors v0.9.1
github.com/smartystreets/assertions v1.0.1 // indirect
github.com/spf13/afero v1.4.0 // indirect
github.com/spf13/afero v1.5.1 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.0.0
github.com/spf13/cobra v1.1.1
github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.1
gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228
gitlab.com/elixxir/comms v0.0.4-0.20201229200853-c403d72e877c
gitlab.com/elixxir/crypto v0.0.7-0.20201222203132-9b4cc1ae3da6
gitlab.com/elixxir/ekv v0.1.4-0.20201217220111-9c7e8be21577
gitlab.com/elixxir/primitives v0.0.3-0.20201229212305-2ab1e938b1cb
gitlab.com/xx_network/comms v0.0.4-0.20201222193955-56206d700360
gitlab.com/xx_network/crypto v0.0.5-0.20201215233953-36cca1af8b2f
gitlab.com/xx_network/primitives v0.0.4-0.20201229212313-fe33d9809f27
golang.org/x/crypto v0.0.0-20201217014255-9d1352758620
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e // indirect
google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4 // indirect
google.golang.org/grpc v1.33.2 // indirect
gitlab.com/elixxir/comms v0.0.4-0.20210125231706-c782d1f645ea
gitlab.com/elixxir/crypto v0.0.7-0.20210125231257-b52a556be893
gitlab.com/elixxir/ekv v0.1.4
gitlab.com/elixxir/primitives v0.0.3-0.20210126180712-bfbfb725c75a
gitlab.com/xx_network/comms v0.0.4-0.20210121204701-7a1eb0542424
gitlab.com/xx_network/crypto v0.0.5-0.20210121204626-b251b926e4f7
gitlab.com/xx_network/primitives v0.0.4-0.20210121203635-8a771fc14f8a
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
golang.org/x/sys v0.0.0-20210105210732-16f7687f5001 // indirect
google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect
google.golang.org/grpc v1.34.0 // indirect
google.golang.org/protobuf v1.25.0
gopkg.in/ini.v1 v1.61.0 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
)
replace google.golang.org/grpc => github.com/grpc/grpc-go v1.27.1
......
......@@ -3,7 +3,6 @@ module gitlab.com/elixxir/client
go 1.13
require (
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/protobuf v1.4.3
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
......@@ -17,16 +16,14 @@ require (
github.com/spf13/cobra v1.1.1
github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/viper v1.7.1
github.com/ugorji/go v1.1.4 // indirect
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 // indirect
gitlab.com/elixxir/bloomfilter v0.0.0-20210120224144-ac046983a17a
gitlab.com/elixxir/comms v0.0.4-0.20210208181740-1ad1139f7170
gitlab.com/elixxir/crypto v0.0.7-0.20210208181828-64b4b57e23d6
gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228
gitlab.com/elixxir/comms v0.0.4-0.20210202030342-3e0a43736d5b
gitlab.com/elixxir/crypto v0.0.7-0.20210128232700-0d547d16aff5
gitlab.com/elixxir/ekv v0.1.4
gitlab.com/elixxir/primitives v0.0.3-0.20210127201240-6a42ad925e8a
gitlab.com/elixxir/primitives v0.0.3-0.20210126180712-bfbfb725c75a
gitlab.com/xx_network/comms v0.0.4-0.20210121204701-7a1eb0542424
gitlab.com/xx_network/crypto v0.0.5-0.20210121204626-b251b926e4f7
gitlab.com/xx_network/primitives v0.0.4-0.20210208183356-ee1e9ec13f8f
gitlab.com/xx_network/primitives v0.0.4-0.20210121203635-8a771fc14f8a
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
golang.org/x/sys v0.0.0-20210105210732-16f7687f5001 // indirect
......
This diff is collapsed.
......@@ -10,6 +10,7 @@ package params
import (
"encoding/json"
"fmt"
"gitlab.com/elixxir/crypto/e2e"
)
type E2E struct {
......@@ -55,3 +56,43 @@ func (st SendType) String() string {
return fmt.Sprintf("Unknown SendType %v", uint8(st))
}
}
// Network E2E Params
// DEFAULT KEY GENERATION PARAMETERS
// Hardcoded limits for keys
// With 16 receiving states we can hold
// 16*64=1024 dirty bits for receiving keys
// With that limit, and setting maxKeys to 800,
// we need a Threshold of 224, and a scalar
// smaller than 1.28 to ensure we never generate
// more than 1024 keys
// With 1 receiving states for ReKeys we can hold
// 64 Rekeys
const (
minKeys uint16 = 500
maxKeys uint16 = 800
ttlScalar float64 = 1.2 // generate 20% extra keys
threshold uint16 = 224
numReKeys uint16 = 64
)
type E2ESessionParams struct {
MinKeys uint16
MaxKeys uint16
NumRekeys uint16
e2e.TTLParams
}
func GetDefaultE2ESessionParams() E2ESessionParams {
return E2ESessionParams{
MinKeys: minKeys,
MaxKeys: maxKeys,
NumRekeys: numReKeys,
}
}
func (p E2ESessionParams) String() string {
return fmt.Sprintf("Params{ MinKeys: %d, MaxKeys: %d, NumRekeys: %d }",
p.MinKeys, p.MaxKeys, p.NumRekeys)
}
......@@ -66,3 +66,17 @@ func TestGetE2EParameters_Default(t *testing.T) {
t.Errorf("Parameters failed to change! Got %d, Expected %d", q.RoundTries, p.RoundTries)
}
}
// Test that the GetDefaultParams function returns the right default data
func Test_GetDefaultParams(t *testing.T) {
p := GetDefaultE2ESessionParams()
if p.MinKeys != minKeys {
t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.MinKeys, minKeys)
}
if p.MaxKeys != maxKeys {
t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.MaxKeys, maxKeys)
}
if p.NumRekeys != numReKeys {
t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.NumRekeys, numReKeys)
}
}
......@@ -25,6 +25,8 @@ type Network struct {
Rounds
Messages
Rekey
E2EParams E2ESessionParams
}
func GetDefaultNetwork() Network {
......@@ -33,6 +35,7 @@ func GetDefaultNetwork() Network {
MaxCheckedRounds: 500,
RegNodesBufferLen: 500,
NetworkHealthTimeout: 30 * time.Second,
E2EParams: GetDefaultE2ESessionParams(),
}
n.Rounds = GetDefaultRounds()
n.Messages = GetDefaultMessage()
......
......@@ -12,22 +12,25 @@ import (
)
type Rounds struct {
// maximum number of times to attempt to retrieve a round from a gateway
// Maximum number of times to attempt to retrieve a round from a gateway
// before giving up on it
MaxAttemptsCheckingARound uint
// number of historical rounds required to automatically send a historical
// Number of historical rounds required to automatically send a historical
// rounds query
MaxHistoricalRounds uint
// maximum period of time a pending historical round query will wait before
// it si transmitted
// Maximum period of time a pending historical round query will wait before
// it is transmitted
HistoricalRoundsPeriod time.Duration
// number of worker threads for retreiving messages from gateways
// Number of worker threads for retrieving messages from gateways
NumMessageRetrievalWorkers uint
// Length of historical rounds channel buffer
HistoricalRoundsBufferLen uint
// Length of round lookup channel buffer
LookupRoundsBufferLen uint
// Toggles if historical rounds should always be used
ForceHistoricalRounds bool
}
func GetDefaultRounds() Rounds {
......@@ -39,5 +42,6 @@ func GetDefaultRounds() Rounds {
HistoricalRoundsBufferLen: 1000,
LookupRoundsBufferLen: 2000,
ForceHistoricalRounds: false,
}
}
......@@ -10,6 +10,7 @@ package keyExchange
import (
"github.com/golang/protobuf/proto"
"gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/storage/e2e"
"gitlab.com/xx_network/primitives/id"
"testing"
......@@ -31,7 +32,8 @@ func TestHandleConfirm(t *testing.T) {
// Add bob as a partner
aliceSession.E2e().AddPartner(bobID, bobPubKey, alicePrivKey,
e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams())
params.GetDefaultE2ESessionParams(),
params.GetDefaultE2ESessionParams())
// Generate a session ID, bypassing some business logic here
sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup)
......
......@@ -49,9 +49,11 @@ func TestFullExchange(t *testing.T) {
// Add Alice and Bob as partners
aliceSession.E2e().AddPartner(exchangeBobId, bobPubKey, alicePrivKey,
e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams())
params.GetDefaultE2ESessionParams(),
params.GetDefaultE2ESessionParams())
bobSession.E2e().AddPartner(exchangeAliceId, alicePubKey, bobPrivKey,
e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams())
params.GetDefaultE2ESessionParams(),
params.GetDefaultE2ESessionParams())
// Start the listeners for alice and bob
rekeyParams := params.GetDefaultRekey()
......
......@@ -49,7 +49,7 @@ func trigger(instance *network.Instance, sendE2E interfaces.SendE2E,
fmt.Printf("in new session triggered\n")
//create the session, pass a nil private key to generate a new one
negotiatingSession = manager.NewSendSession(nil,
e2e.GetDefaultSessionParams())
sess.E2e().GetE2ESessionParams())
//move the state of the triggering session forward
session.SetNegotiationStatus(e2e.NewSessionCreated)
fmt.Printf("after setting session: %v\n", negotiatingSession.NegotiationStatus())
......
......@@ -81,7 +81,7 @@ func handleTrigger(sess *storage.Session, net interfaces.NetworkManager,
//create the new session
session, duplicate := partner.NewReceiveSession(PartnerPublicKey,
e2e.GetDefaultSessionParams(), oldSession)
sess.E2e().GetE2ESessionParams(), oldSession)
// new session being nil means the session was a duplicate. This is possible
// in edge cases where the partner crashes during operation. The session
// creation in this case ignores the new session, but the confirmation
......
......@@ -38,8 +38,8 @@ func TestHandleTrigger(t *testing.T) {
// Add bob as a partner
aliceSession.E2e().AddPartner(bobID, bobSession.E2e().GetDHPublicKey(),
alicePrivKey, e2e.GetDefaultSessionParams(),
e2e.GetDefaultSessionParams())
alicePrivKey, params.GetDefaultE2ESessionParams(),
params.GetDefaultE2ESessionParams())
// Generate a session ID, bypassing some business logic here
oldSessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup)
......
......@@ -23,10 +23,14 @@ type HostGetter interface {
GetHost(hostId *id.ID) (*connect.Host, bool)
}
// Get the Host of a random gateway in the NDF
func Get(ndf *ndf.NetworkDefinition, hg HostGetter, rng io.Reader) (*connect.Host, error) {
// Get a random gateway
gateways := ndf.Gateways
gwIdx := ReadRangeUint32(0, uint32(len(gateways)), rng)
gwLen := uint32(len(ndf.Gateways))
if gwLen == 0 {
return nil, errors.Errorf("no gateways available")
}
gwIdx := ReadRangeUint32(0, gwLen, rng)
gwID, err := id.Unmarshal(ndf.Nodes[gwIdx].ID)
if err != nil {
return nil, errors.WithMessage(err, "failed to get Gateway")
......@@ -40,6 +44,7 @@ func Get(ndf *ndf.NetworkDefinition, hg HostGetter, rng io.Reader) (*connect.Hos
return gwHost, nil
}
// Get the last gateway Host from the given RoundInfo
func GetLast(hg HostGetter, ri *mixmessages.RoundInfo) (*connect.Host, error) {
roundTop := ri.GetTopology()
lastGw, err := id.Unmarshal(roundTop[len(roundTop)-1])
......
......@@ -63,6 +63,11 @@ func NewManager(session *storage.Session, switchboard *switchboard.Switchboard,
running := uint32(0)
// Note: These are not loaded/stored in E2E Store, but the
// E2E Session Params are a part of the network parameters, so we
// set them here when they are needed on startup
session.E2e().SetE2ESessionParams(params.E2EParams)
//create manager object
m := manager{
param: params,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment