Skip to content
Snippets Groups Projects
Commit 788439a9 authored by Sydney Anne Erickson's avatar Sydney Anne Erickson :chipmunk:
Browse files

Do the hashing of adding a fact properly

parent c213df42
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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=
......
......@@ -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,
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment