diff --git a/interfaces/message/receiveMessage.go b/interfaces/message/receiveMessage.go index d11f8880865e8c6db95086c054f554126835b5c2..8771a12bd5790cf114229e6a48f5a6714d08000a 100644 --- a/interfaces/message/receiveMessage.go +++ b/interfaces/message/receiveMessage.go @@ -24,5 +24,5 @@ type Receive struct { RoundId id.Round RoundTimestamp time.Time Timestamp time.Time // Message timestamp of when the user sent - Encryption EncryptionType + Encryption string } diff --git a/interfaces/params/CMIX.go b/interfaces/params/CMIX.go deleted file mode 100644 index 8706165ade26ff43279a325a33fa00b9d306f26a..0000000000000000000000000000000000000000 --- a/interfaces/params/CMIX.go +++ /dev/null @@ -1,16 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package params - -import ( - "encoding/json" - "gitlab.com/elixxir/client/stoppable" - "gitlab.com/elixxir/primitives/excludedRounds" - "gitlab.com/xx_network/primitives/id" - "time" -) diff --git a/interfaces/params/CMIX_test.go b/interfaces/params/CMIX_test.go deleted file mode 100644 index 06d1968bbbd46aeef40e0a5c343c9e863493b5ae..0000000000000000000000000000000000000000 --- a/interfaces/params/CMIX_test.go +++ /dev/null @@ -1,55 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package params - -import ( - "testing" - "time" -) - -func TestGetDefaultCMIX(t *testing.T) { - c := GetDefaultCMIX() - if c.RoundTries != 10 || c.Timeout != 25*time.Second { - t.Errorf("GetDefaultCMIX did not return expected values") - } -} - -// New params path -func TestGetCMIXParameters(t *testing.T) { - p := GetDefaultCMIX() - - expected := p.RoundTries + 1 - p.RoundTries = expected - jsonString, err := p.Marshal() - if err != nil { - t.Errorf("%+v", err) - } - - q, err := GetCMIXParameters(string(jsonString)) - if err != nil { - t.Errorf("%+v", err) - } - - if q.RoundTries != expected { - t.Errorf("Parameters failed to change! Got %d, Expected %d", q.RoundTries, expected) - } -} - -// No new params path -func TestGetCMIXParameters_Default(t *testing.T) { - p := GetDefaultCMIX() - - q, err := GetCMIXParameters("") - if err != nil { - t.Errorf("%+v", err) - } - - if q.RoundTries != p.RoundTries { - t.Errorf("Parameters failed to change! Got %d, Expected %d", q.RoundTries, p.RoundTries) - } -} diff --git a/interfaces/params/E2E.go b/interfaces/params/E2E.go deleted file mode 100644 index f3aed87855d884b9d99f8de68af9bac5a6a2ca1d..0000000000000000000000000000000000000000 --- a/interfaces/params/E2E.go +++ /dev/null @@ -1,102 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package params - -import ( - "encoding/json" - "fmt" -) - -type E2E struct { - Type SendType - RetryCount int - OnlyNotifyOnLastSend bool - CMIX -} - -func GetDefaultE2E() E2E { - return E2E{ - Type: Standard, - CMIX: GetDefaultCMIX(), - OnlyNotifyOnLastSend: true, - RetryCount: 10, - } -} -func (e E2E) Marshal() ([]byte, error) { - return json.Marshal(e) -} - -// Obtain default E2E parameters, or override with given parameters if set -func GetE2EParameters(params string) (E2E, error) { - p := GetDefaultE2E() - if len(params) > 0 { - err := json.Unmarshal([]byte(params), &p) - if err != nil { - return E2E{}, err - } - } - return p, nil -} - -type SendType uint8 - -const ( - Standard SendType = 0 - KeyExchange SendType = 1 -) - -func (st SendType) String() string { - switch st { - case Standard: - return "Standard" - case KeyExchange: - return "KeyExchange" - default: - return fmt.Sprintf("Unknown SendType %v", uint8(st)) - } -} - -// Network E2E Params - -type E2ESessionParams struct { - // using the DH as a seed, both sides generate a number - // of keys to use before they must rekey because - // there are no keys to use. - MinKeys uint16 - MaxKeys uint16 - // the percent of keys before a rekey is attempted. must be <0 - RekeyThreshold float64 - // extra keys generated and reserved for rekey attempts. This - // many keys are not allowed to be used for sending messages - // in order to ensure there are extras for rekeying. - NumRekeys uint16 -} - -// DEFAULT KEY GENERATION PARAMETERS -// Hardcoded limits for keys -// sets the number of keys very high, but with a low rekey threshold. In this case, if the other party is online, you will read -const ( - minKeys uint16 = 1000 - maxKeys uint16 = 2000 - rekeyThrshold float64 = 0.05 - numReKeys uint16 = 16 -) - -func GetDefaultE2ESessionParams() E2ESessionParams { - return E2ESessionParams{ - MinKeys: minKeys, - MaxKeys: maxKeys, - RekeyThreshold: rekeyThrshold, - NumRekeys: numReKeys, - } -} - -func (p E2ESessionParams) String() string { - return fmt.Sprintf("Params{ MinKeys: %d, MaxKeys: %d, NumRekeys: %d }", - p.MinKeys, p.MaxKeys, p.NumRekeys) -} diff --git a/interfaces/params/E2E_test.go b/interfaces/params/E2E_test.go deleted file mode 100644 index aa383c42f4404745dea429c2f93fdd5d98b74415..0000000000000000000000000000000000000000 --- a/interfaces/params/E2E_test.go +++ /dev/null @@ -1,85 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package params - -import "testing" - -func TestGetDefaultE2E(t *testing.T) { - if GetDefaultE2E().Type != Standard { - t.Errorf("GetDefaultE2E did not return Standard") - } - if !GetDefaultE2E().OnlyNotifyOnLastSend { - t.Errorf("GetDefaultE2E did not return OnlyNotifyOnLastSend == true") - } -} - -func TestSendType_String(t *testing.T) { - e := E2E{Type: Standard} - if e.Type.String() != "Standard" { - t.Errorf("Running String on Standard E2E type got %s", e.Type.String()) - } - - e = E2E{Type: KeyExchange} - if e.Type.String() != "KeyExchange" { - t.Errorf("Running String on KeyExchange E2E type got %s", e.Type.String()) - } - - e = E2E{Type: SendType(40)} - if e.Type.String() != "Unknown SendType 40" { - t.Errorf("Running String on unknown E2E type got %s", e.Type.String()) - } -} - -// New params path -func TestGetE2EParameters(t *testing.T) { - p := GetDefaultE2E() - - expected := p.RoundTries + 1 - p.RoundTries = expected - jsonString, err := p.Marshal() - if err != nil { - t.Errorf("%+v", err) - } - - q, err := GetE2EParameters(string(jsonString)) - if err != nil { - t.Errorf("%+v", err) - } - - if q.RoundTries != expected { - t.Errorf("Parameters failed to change! Got %d, Expected %d", q.RoundTries, expected) - } -} - -// No new params path -func TestGetE2EParameters_Default(t *testing.T) { - p := GetDefaultE2E() - - q, err := GetE2EParameters("") - if err != nil { - t.Errorf("%+v", err) - } - - if q.RoundTries != p.RoundTries { - 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) - } -} diff --git a/interfaces/params/historical.go b/interfaces/params/historical.go deleted file mode 100644 index 816ee4f309c9d49e14bb325660b3d27aa344bd2f..0000000000000000000000000000000000000000 --- a/interfaces/params/historical.go +++ /dev/null @@ -1,8 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package params diff --git a/interfaces/params/keyExchange.go b/interfaces/params/keyExchange.go deleted file mode 100644 index c30b49c6168f52fb7ad97098f123bb226486ee11..0000000000000000000000000000000000000000 --- a/interfaces/params/keyExchange.go +++ /dev/null @@ -1,22 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package params - -import ( - "time" -) - -type Rekey struct { - RoundTimeout time.Duration -} - -func GetDefaultRekey() Rekey { - return Rekey{ - RoundTimeout: time.Minute, - } -} diff --git a/interfaces/params/message.go b/interfaces/params/message.go deleted file mode 100644 index 70ef9ad8efbb678a15afdf58bd2cbb6eb72035de..0000000000000000000000000000000000000000 --- a/interfaces/params/message.go +++ /dev/null @@ -1,30 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package params - -import ( - "time" -) - -type Messages struct { - MessageReceptionBuffLen uint - MessageReceptionWorkerPoolSize uint - MaxChecksInProcessMessage uint - InProcessMessageWait time.Duration - RealtimeOnly bool -} - -func GetDefaultMessage() Messages { - return Messages{ - MessageReceptionBuffLen: 500, - MessageReceptionWorkerPoolSize: 4, - MaxChecksInProcessMessage: 10, - InProcessMessageWait: 15 * time.Minute, - RealtimeOnly: false, - } -} diff --git a/interfaces/params/network.go b/interfaces/params/network.go deleted file mode 100644 index 1da0ce56350bf64c6a39999c78d625a00a1f236b..0000000000000000000000000000000000000000 --- a/interfaces/params/network.go +++ /dev/null @@ -1,90 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package params - -import ( - "encoding/json" - "time" -) - -type Network struct { - TrackNetworkPeriod time.Duration - // maximum number of rounds to check in a single iterations network updates - MaxCheckedRounds uint - // Size of the buffer of nodes to register - RegNodesBufferLen uint - // Longest delay between network events for health tracker to denote that - // the network is in a bad state - NetworkHealthTimeout time.Duration - //Number of parallel nodes registration the client is capable of - ParallelNodeRegistrations uint - //How far back in rounds the network should actually check - KnownRoundsThreshold uint - // Determines verbosity of network updates while polling - // If true, client receives a filtered set of updates - // If false, client receives the full list of network updates - FastPolling bool - // Determines if the state of every round processed is tracked in ram. - // This is very memory intensive and is primarily used for debugging - VerboseRoundTracking bool - //disables all attempts to pick up dropped or missed messages - RealtimeOnly bool - // Resends auth requests up the stack if received multiple times - ReplayRequests bool - - Rounds - Messages - Rekey - Historical - - E2EParams E2ESessionParams -} - -func GetDefaultNetwork() Network { - n := Network{ - TrackNetworkPeriod: 100 * time.Millisecond, - MaxCheckedRounds: 500, - RegNodesBufferLen: 1000, - NetworkHealthTimeout: 30 * time.Second, - E2EParams: GetDefaultE2ESessionParams(), - ParallelNodeRegistrations: 20, - KnownRoundsThreshold: 1500, //5 rounds/sec * 60 sec/min * 5 min - FastPolling: true, - BlacklistedNodes: make([]string, 0), - VerboseRoundTracking: false, - RealtimeOnly: false, - ReplayRequests: true, - } - n.Rounds = GetDefaultRounds() - n.Messages = GetDefaultMessage() - n.Rekey = GetDefaultRekey() - return n -} - -func (n Network) Marshal() ([]byte, error) { - return json.Marshal(n) -} - -func (n Network) SetRealtimeOnlyAll() Network { - n.RealtimeOnly = true - n.Rounds.RealtimeOnly = true - n.Messages.RealtimeOnly = true - return n -} - -// Obtain default Network parameters, or override with given parameters if set -func GetNetworkParameters(params string) (Network, error) { - p := GetDefaultNetwork() - if len(params) > 0 { - err := json.Unmarshal([]byte(params), &p) - if err != nil { - return Network{}, err - } - } - return p, nil -} diff --git a/interfaces/params/network_test.go b/interfaces/params/network_test.go deleted file mode 100644 index 3b8b609678f279048a3dcd6ec9b9dc634607e6f7..0000000000000000000000000000000000000000 --- a/interfaces/params/network_test.go +++ /dev/null @@ -1,44 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright © 2021 Privategrity Corporation / -// / -// All rights reserved. / -//////////////////////////////////////////////////////////////////////////////// - -package params - -import "testing" - -// New params path -func TestGetNetworkParameters(t *testing.T) { - p := GetDefaultNetwork() - - expected := p.MaxCheckedRounds + 1 - p.MaxCheckedRounds = expected - jsonString, err := p.Marshal() - if err != nil { - t.Errorf("%+v", err) - } - - q, err := GetNetworkParameters(string(jsonString)) - if err != nil { - t.Errorf("%+v", err) - } - - if q.MaxCheckedRounds != expected { - t.Errorf("Parameters failed to change! Got %d, Expected %d", q.MaxCheckedRounds, expected) - } -} - -// No new params path -func TestGetNetworkParameters_Default(t *testing.T) { - p := GetDefaultNetwork() - - q, err := GetNetworkParameters("") - if err != nil { - t.Errorf("%+v", err) - } - - if q.MaxCheckedRounds != p.MaxCheckedRounds { - t.Errorf("Parameters failed to change! Got %d, Expected %d", q.MaxCheckedRounds, p.MaxCheckedRounds) - } -} diff --git a/interfaces/params/rounds.go b/interfaces/params/rounds.go deleted file mode 100644 index e7f24bffe8308ebdfe1fe8c55406df46e17d9042..0000000000000000000000000000000000000000 --- a/interfaces/params/rounds.go +++ /dev/null @@ -1,53 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package params - -import ( - "time" -) - -type Rounds struct { - // Number of worker threads for retrieving messages from gateways - NumMessageRetrievalWorkers uint - - // Length of round lookup channel buffer - LookupRoundsBufferLen uint - - // Maximum number of times a historical round lookup will be attempted - MaxHistoricalRoundsRetries uint - - // Interval between checking for rounds in UncheckedRoundStore - // due for a message retrieval retry - UncheckRoundPeriod time.Duration - - // Toggles if message pickup retrying mechanism if forced - // by intentionally not looking up messages - ForceMessagePickupRetry bool - - // Duration to wait before sending on a round times out and a new round is - // tried - SendTimeout time.Duration - - //disables all attempts to pick up dropped or missed messages - RealtimeOnly bool - - // Toggles if historical rounds should always be used - ForceHistoricalRounds bool -} - -func GetDefaultRounds() Rounds { - return Rounds{ - NumMessageRetrievalWorkers: 8, - LookupRoundsBufferLen: 2000, - MaxHistoricalRoundsRetries: 3, - UncheckRoundPeriod: 20 * time.Second, - ForceMessagePickupRetry: false, - SendTimeout: 3 * time.Second, - RealtimeOnly: false, - } -} diff --git a/interfaces/params/unsafe.go b/interfaces/params/unsafe.go deleted file mode 100644 index 556559a88a253107ab803521a550c403e5040113..0000000000000000000000000000000000000000 --- a/interfaces/params/unsafe.go +++ /dev/null @@ -1,34 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package params - -import "encoding/json" - -type Unsafe struct { - CMIX -} - -func GetDefaultUnsafe() Unsafe { - return Unsafe{CMIX: GetDefaultCMIX()} -} - -func (u Unsafe) Marshal() ([]byte, error) { - return json.Marshal(u) -} - -// Obtain default Unsafe parameters, or override with given parameters if set -func GetUnsafeParameters(params string) (Unsafe, error) { - p := GetDefaultUnsafe() - if len(params) > 0 { - err := json.Unmarshal([]byte(params), &p) - if err != nil { - return Unsafe{}, err - } - } - return p, nil -} diff --git a/interfaces/params/unsafe_test.go b/interfaces/params/unsafe_test.go deleted file mode 100644 index 49763fdf11e978201d18f29dacdc5f68bd0c2ec7..0000000000000000000000000000000000000000 --- a/interfaces/params/unsafe_test.go +++ /dev/null @@ -1,44 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright © 2021 Privategrity Corporation / -// / -// All rights reserved. / -//////////////////////////////////////////////////////////////////////////////// - -package params - -import "testing" - -// New params path -func TestGetUnsafeParameters(t *testing.T) { - p := GetDefaultUnsafe() - - expected := p.RoundTries + 1 - p.RoundTries = expected - jsonString, err := p.Marshal() - if err != nil { - t.Errorf("%+v", err) - } - - q, err := GetUnsafeParameters(string(jsonString)) - if err != nil { - t.Errorf("%+v", err) - } - - if q.RoundTries != expected { - t.Errorf("Parameters failed to change! Got %d, Expected %d", q.RoundTries, expected) - } -} - -// No new params path -func TestGetUnsafeParameters_Default(t *testing.T) { - p := GetDefaultUnsafe() - - q, err := GetUnsafeParameters("") - if err != nil { - t.Errorf("%+v", err) - } - - if q.RoundTries != p.RoundTries { - t.Errorf("Parameters failed to change! Got %d, Expected %d", q.RoundTries, p.RoundTries) - } -} diff --git a/network/nodes/register.go b/network/nodes/register.go index 3b3d0abb9efcf11523759e6ab1cad95dcdffc112..0a4b1d6702069199251594f66ee7af7ab7c669d6 100644 --- a/network/nodes/register.go +++ b/network/nodes/register.go @@ -15,7 +15,7 @@ import ( jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/network/gateway" "gitlab.com/elixxir/client/stoppable" - "gitlab.com/elixxir/client/storage/user" + "gitlab.com/elixxir/client/storage" pb "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/elixxir/comms/network" "gitlab.com/elixxir/crypto/cyclic" @@ -36,13 +36,8 @@ import ( "time" ) -func registerNodes(r *registrar, stop *stoppable.Single, inProgress, attempts *sync.Map) { - u := r.session.User() - regSignature := u.GetTransmissionRegistrationValidationSignature() - // Timestamp in which user has registered with registration - regTimestamp := u.GetRegistrationTimestamp().UnixNano() - uci := u.GetCryptographicIdentity() - +func registerNodes(r *registrar, s storage.Session, stop *stoppable.Single, + inProgress, attempts *sync.Map) { interval := time.Duration(500) * time.Millisecond t := time.NewTicker(interval) for { @@ -82,8 +77,7 @@ func registerNodes(r *registrar, stop *stoppable.Single, inProgress, attempts *s jww.DEBUG.Printf("Skipping registration with stale nodes %s", nidStr) continue } - err = registerWithNode(r.sender, r.comms, gw, regSignature, - regTimestamp, uci, r, rng, stop) + err = registerWithNode(r.sender, r.comms, gw, s, r, rng, stop) inProgress.Delete(nidStr) if err != nil { jww.ERROR.Printf("Failed to register nodes: %+v", err) @@ -105,9 +99,8 @@ func registerNodes(r *registrar, stop *stoppable.Single, inProgress, attempts *s // registerWithNode serves as a helper for RegisterWithNodes. // It registers a user with a specific in the client's NDF. -func registerWithNode(sender *gateway.Sender, comms RegisterNodeCommsInterface, - ngw network.NodeGateway, regSig []byte, registrationTimestampNano int64, - uci *user.CryptographicIdentity, r *registrar, rng csprng.Source, +func registerWithNode(sender gateway.Sender, comms RegisterNodeCommsInterface, + ngw network.NodeGateway, s storage.Session, r *registrar, rng csprng.Source, stop *stoppable.Single) error { nodeID, err := ngw.Node.GetNodeId() @@ -126,8 +119,8 @@ func registerWithNode(sender *gateway.Sender, comms RegisterNodeCommsInterface, var validUntil uint64 var keyId []byte // TODO: should move this to a precanned user initialization - if uci.IsPrecanned() { - userNum := int(uci.GetTransmissionID().Bytes()[7]) + if s.IsPrecanned() { + userNum := int(s.GetTransmissionID().Bytes()[7]) h := sha256.New() h.Reset() h.Write([]byte(strconv.Itoa(4000 + userNum))) @@ -136,8 +129,8 @@ func registerWithNode(sender *gateway.Sender, comms RegisterNodeCommsInterface, jww.INFO.Printf("transmissionKey: %v", transmissionKey.Bytes()) } else { // Request key from server - transmissionKey, keyId, validUntil, err = requestKey(sender, comms, ngw, - regSig, registrationTimestampNano, uci, r, rng, stop) + transmissionKey, keyId, validUntil, err = requestKey( + sender, comms, ngw, s, r, rng, stop) if err != nil { return errors.Errorf("Failed to request key: %+v", err) @@ -152,9 +145,8 @@ func registerWithNode(sender *gateway.Sender, comms RegisterNodeCommsInterface, return nil } -func requestKey(sender *gateway.Sender, comms RegisterNodeCommsInterface, - ngw network.NodeGateway, regSig []byte, registrationTimestampNano int64, - uci *user.CryptographicIdentity, r *registrar, rng csprng.Source, +func requestKey(sender gateway.Sender, comms RegisterNodeCommsInterface, + ngw network.NodeGateway, s storage.Session, r *registrar, rng csprng.Source, stop *stoppable.Single) (*cyclic.Int, []byte, uint64, error) { grp := r.session.GetCmixGroup() @@ -172,10 +164,10 @@ func requestKey(sender *gateway.Sender, comms RegisterNodeCommsInterface, dhPub := diffieHellman.GeneratePublicKey(dhPriv, grp) // Reconstruct client confirmation message - userPubKeyRSA := rsa.CreatePublicKeyPem(uci.GetTransmissionRSA().GetPublic()) + userPubKeyRSA := rsa.CreatePublicKeyPem(s.GetTransmissionRSA().GetPublic()) confirmation := &pb.ClientRegistrationConfirmation{ RSAPubKey: string(userPubKeyRSA), - Timestamp: registrationTimestampNano, + Timestamp: s.GetRegistrationTimestamp().UnixNano(), } confirmationSerialized, err := proto.Marshal(confirmation) if err != nil { @@ -183,13 +175,14 @@ func requestKey(sender *gateway.Sender, comms RegisterNodeCommsInterface, } keyRequest := &pb.ClientKeyRequest{ - Salt: uci.GetTransmissionSalt(), + Salt: s.GetTransmissionSalt(), ClientTransmissionConfirmation: &pb.SignedRegistrationConfirmation{ - RegistrarSignature: &messages.RSASignature{Signature: regSig}, + RegistrarSignature: &messages.RSASignature{ + Signature: s.GetTransmissionRegistrationValidationSignature()}, ClientRegistrationConfirmation: confirmationSerialized, }, ClientDHPubKey: dhPub.Bytes(), - RegistrationTimestamp: registrationTimestampNano, + RegistrationTimestamp: s.GetRegistrationTimestamp().UnixNano(), RequestTimestamp: netTime.Now().UnixNano(), } @@ -205,7 +198,7 @@ func requestKey(sender *gateway.Sender, comms RegisterNodeCommsInterface, data := h.Sum(nil) // Sign DH pubkey - clientSig, err := rsa.Sign(rng, uci.GetTransmissionRSA(), opts.Hash, + clientSig, err := rsa.Sign(rng, s.GetTransmissionRSA(), opts.Hash, data, opts) if err != nil { return nil, nil, 0, err diff --git a/network/nodes/registrar.go b/network/nodes/registrar.go index 4cb6ba4afb5dfbf91daf160f41610868ec051daa..9c3b8c726da66f27ce222eee3b672d0486bc8e4d 100644 --- a/network/nodes/registrar.go +++ b/network/nodes/registrar.go @@ -104,7 +104,7 @@ func (r *registrar) StartProcesses(numParallel uint) stoppable.Stoppable { for i := uint(0); i < numParallel; i++ { stop := stoppable.NewSingle(fmt.Sprintf("NodeRegistration %d", i)) - go registerNodes(r, stop, inProgress, attempts) + go registerNodes(r, r.session, stop, inProgress, attempts) multi.Add(stop) }