Skip to content
Snippets Groups Projects
Commit f9e20595 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

fix precan gen

parent 44ad6c69
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"crypto" "crypto"
"crypto/rand" "crypto/rand"
"crypto/sha256" "crypto/sha256"
"encoding/binary"
"fmt" "fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
...@@ -23,6 +22,7 @@ import ( ...@@ -23,6 +22,7 @@ import (
"gitlab.com/xx_network/comms/messages" "gitlab.com/xx_network/comms/messages"
"gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"strconv"
"time" "time"
) )
...@@ -97,12 +97,13 @@ func registerWithNode(comms RegisterNodeCommsInterface, ngw network.NodeGateway, ...@@ -97,12 +97,13 @@ func registerWithNode(comms RegisterNodeCommsInterface, ngw network.NodeGateway,
var transmissionKey *cyclic.Int var transmissionKey *cyclic.Int
// TODO: should move this to a precanned user initialization // TODO: should move this to a precanned user initialization
if uci.IsPrecanned() { if uci.IsPrecanned() {
userNum := binary.BigEndian.Uint64(uci.GetUserID().Bytes()) userNum := int(uci.GetUserID().Bytes()[7])
h := sha256.New() h := sha256.New()
h.Reset() h.Reset()
h.Write([]byte(string(40000 + userNum))) h.Write([]byte(strconv.Itoa(int(4000 + userNum))))
transmissionKey = store.GetGroup().NewIntFromBytes(h.Sum(nil)) transmissionKey = store.GetGroup().NewIntFromBytes(h.Sum(nil))
jww.INFO.Printf("transmissionKey: %v", transmissionKey.Bytes())
} else { } else {
// Initialise blake2b hash for transmission keys and sha256 for reception // Initialise blake2b hash for transmission keys and sha256 for reception
// keys // keys
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment