diff --git a/go.mod b/go.mod index 320f878367134628c5f1697219e1341cc02d594a..9caa51bf96e05a4f661ab3150dcdc47e885acfae 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/spf13/viper v1.7.1 gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 gitlab.com/elixxir/comms v0.0.4-0.20201116233755-b476dea10095 - gitlab.com/elixxir/crypto v0.0.5-0.20201110193609-6b5e881867b4 + gitlab.com/elixxir/crypto v0.0.5-0.20201118204646-9b23991834c6 gitlab.com/elixxir/ekv v0.1.3 gitlab.com/elixxir/primitives v0.0.3-0.20201116174806-97f190989704 gitlab.com/xx_network/comms v0.0.4-0.20201110022115-4a6171cad07d diff --git a/go.sum b/go.sum index fdfcad50117713c867743bfe80c2e7f83b3a8c7d..e29eb17e519edc1e3d7201d9815aad8500a42421 100644 --- a/go.sum +++ b/go.sum @@ -260,6 +260,8 @@ gitlab.com/elixxir/crypto v0.0.3 h1:znCt/x2bL4y8czTPaaFkwzdgSgW3BJc/1+dxyf1jqVw= gitlab.com/elixxir/crypto v0.0.3/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp07WQmhA= gitlab.com/elixxir/crypto v0.0.5-0.20201110193609-6b5e881867b4 h1:1a1zZDuqZ56qU1EPgpc+Sqny1YFl0kAKJgQbsVc0WJQ= gitlab.com/elixxir/crypto v0.0.5-0.20201110193609-6b5e881867b4/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp07WQmhA= +gitlab.com/elixxir/crypto v0.0.5-0.20201118204646-9b23991834c6 h1:HEJHC6gyVMdCZ1PSJkFDScHnsrWAMF+PFxyL2zpNrgU= +gitlab.com/elixxir/crypto v0.0.5-0.20201118204646-9b23991834c6/go.mod h1:BqvmtLM4eW+3NNOVK7U3COnnxqhJZxdCv4yziCuYhlA= gitlab.com/elixxir/ekv v0.1.3 h1:OE+LBMIhjGUMwc6hHJzYvEPNJQV7t1vMnJyIgxUMUo8= gitlab.com/elixxir/ekv v0.1.3/go.mod h1:e6WPUt97taFZe5PFLPb1Dupk7tqmDCTQu1kkstqJvw4= gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg= diff --git a/ud/addFact.go b/ud/addFact.go index 28bf676b2ade2a8718a280a4a3bd93a8997ee3ef..1d7372eac09958a9ae24486188fd9dcb0436736f 100644 --- a/ud/addFact.go +++ b/ud/addFact.go @@ -3,6 +3,7 @@ package ud import ( "crypto/rand" pb "gitlab.com/elixxir/comms/mixmessages" + "gitlab.com/elixxir/crypto/factID" "gitlab.com/elixxir/crypto/hash" "gitlab.com/elixxir/primitives/fact" "gitlab.com/xx_network/comms/connect" @@ -17,24 +18,29 @@ func (m *Manager) SendRegisterFact(fact fact.Fact) (*pb.FactRegisterResponse, er return m.addFact(fact, m.comms) } -func (m *Manager) addFact(fact fact.Fact, aFC addFactComms) (*pb.FactRegisterResponse, error) { - // Construct the message to send - // Convert our Fact to a mixmessages Fact for sending - mmFact := pb.Fact{ - Fact: fact.Fact, - FactType: uint32(fact.T), +func (m *Manager) addFact(inFact fact.Fact, aFC addFactComms) (*pb.FactRegisterResponse, error) { + // Create a primitives Fact so we can hash it + f, err := fact.NewFact(inFact.T, inFact.Fact) + if err != nil { + return &pb.FactRegisterResponse{}, err } - // Sign our fact for putting into the request - fsig, err := rsa.Sign(rand.Reader, m.privKey, hash.CMixHash, mmFact.Digest(), nil) + // Create a hash of our fact + fhash := factID.Fingerprint(f) + + // Sign our inFact for putting into the request + fsig, err := rsa.Sign(rand.Reader, m.privKey, hash.CMixHash, fhash, nil) if err != nil { return &pb.FactRegisterResponse{}, err } // Create our Fact Removal Request message data remFactMsg := pb.FactRegisterRequest{ - UID: m.host.GetId().Marshal(), - Fact: &mmFact, + UID: m.host.GetId().Marshal(), + Fact: &pb.Fact{ + Fact: inFact.Fact, + FactType: uint32(inFact.T), + }, FactSig: fsig, }