diff --git a/cmd/version.go b/cmd/version.go index e131ee5245f062110c13ad653bb245cdd691a3c2..20be1de684543a5bf04ab7be1272d201e7d11717 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -18,7 +18,7 @@ import ( ) // Change this value to set the version for this build -const currentVersion = "4.3.7" +const currentVersion = "4.3.8" func Version() string { out := fmt.Sprintf("Elixxir Client v%s -- %s\n\n", xxdk.SEMVER, diff --git a/cmix/client.go b/cmix/client.go index 706018eab984f523049bdc9093f5bb7ea79ba0f3..6c3343e4f56b41d83627358968f8375113ac7f55 100644 --- a/cmix/client.go +++ b/cmix/client.go @@ -11,14 +11,15 @@ package cmix // and intra-client state are accessible through the context object. import ( - "gitlab.com/elixxir/client/v4/cmix/attempts" - "gitlab.com/elixxir/client/v4/cmix/clockSkew" - "gitlab.com/xx_network/primitives/netTime" "math" "strconv" "sync/atomic" "time" + "gitlab.com/elixxir/client/v4/cmix/attempts" + "gitlab.com/elixxir/client/v4/cmix/clockSkew" + "gitlab.com/xx_network/primitives/netTime" + "github.com/pkg/errors" "gitlab.com/elixxir/client/v4/cmix/address" "gitlab.com/elixxir/client/v4/cmix/gateway" @@ -241,11 +242,11 @@ func (c *client) initialize(ndfile *ndf.NetworkDefinition) error { // Started Threads are: // - Network Follower (/network/follow.go) // - Historical Round Retrieval (/network/rounds/historical.go) -// - Message Retrieval Worker Group (/network/rounds/retrieve.go) -// - Message Handling Worker Group (/network/message/handle.go) -// - health tracker (/network/health) -// - Garbled Messages (/network/message/inProgress.go) -// - Critical Messages (/network/message/critical.go) +// - Message Retrieval Worker Group (/network/rounds/retrieve.go) +// - Message Handling Worker Group (/network/message/handle.go) +// - health tracker (/network/health) +// - Garbled Messages (/network/message/inProgress.go) +// - Critical Messages (/network/message/critical.go) // - Ephemeral ID tracking (network/address/tracker.go) func (c *client) Follow(report ClientErrorReport) (stoppable.Stoppable, error) { multi := stoppable.NewMulti("networkManager") diff --git a/cmix/cmixMessageBuffer.go b/cmix/cmixMessageBuffer.go index 59fbf7de587ba17c406e3ac745082837e0b1efde..a3590a69ff8062a553ea896221cb352a635fb257 100644 --- a/cmix/cmixMessageBuffer.go +++ b/cmix/cmixMessageBuffer.go @@ -8,7 +8,9 @@ package cmix import ( + "encoding/base64" "encoding/json" + "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/v4/storage/utility" @@ -84,12 +86,19 @@ func (cmh *cmixMessageHandler) DeleteMessage(kv *versioned.KV, key string) error // HashMessage generates a hash of the message. func (cmh *cmixMessageHandler) HashMessage(m interface{}) utility.MessageHash { - h, _ := blake2b.New256(nil) + msg := m.(storedMessage) - h.Write(m.(storedMessage).Marshal()) + h, _ := blake2b.New256(nil) + h.Write(msg.Recipient) + h.Write(msg.Msg) + digest := h.Sum(nil) var messageHash utility.MessageHash - copy(messageHash[:], h.Sum(nil)) + copy(messageHash[:], digest) + + jww.TRACE.Printf("HashMessage Results: %s -> %s", + base64.StdEncoding.EncodeToString(digest), + base64.StdEncoding.EncodeToString(messageHash[:])) return messageHash } @@ -133,7 +142,7 @@ func (cmb *CmixMessageBuffer) Add(msg format.Message, recipient *id.ID, } sm := storedMessage{ - Msg: msg.Marshal(), + Msg: msg.MarshalImmutable(), Recipient: recipient.Marshal(), Params: paramBytes, } @@ -149,7 +158,7 @@ func (cmb *CmixMessageBuffer) AddProcessing(msg format.Message, recipient *id.ID } sm := storedMessage{ - Msg: msg.Marshal(), + Msg: msg.MarshalImmutable(), Recipient: recipient.Marshal(), Params: paramBytes, } @@ -190,7 +199,7 @@ func (cmb *CmixMessageBuffer) Next() (format.Message, *id.ID, CMIXParams, bool) func (cmb *CmixMessageBuffer) Succeeded(msg format.Message, recipient *id.ID) { sm := storedMessage{ - Msg: msg.Marshal(), + Msg: msg.MarshalImmutable(), Recipient: recipient.Marshal(), } @@ -199,7 +208,7 @@ func (cmb *CmixMessageBuffer) Succeeded(msg format.Message, recipient *id.ID) { func (cmb *CmixMessageBuffer) Failed(msg format.Message, recipient *id.ID) { sm := storedMessage{ - Msg: msg.Marshal(), + Msg: msg.MarshalImmutable(), Recipient: recipient.Marshal(), } diff --git a/cmix/critical.go b/cmix/critical.go index 22cd3b8ad664df72682b68f22352744cbc4fc495..c20a36fe4ba1d4464c9487c396dd81aa3efe8946 100644 --- a/cmix/critical.go +++ b/cmix/critical.go @@ -8,9 +8,10 @@ package cmix import ( - "gitlab.com/elixxir/client/v4/cmix/rounds" "time" + "gitlab.com/elixxir/client/v4/cmix/rounds" + jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/v4/cmix/health" "gitlab.com/elixxir/client/v4/stoppable" @@ -88,9 +89,10 @@ func (c *critical) runCriticalMessages(stop *stoppable.Single) { } func (c *critical) handle( - msg format.Message, recipient *id.ID, rid id.Round, rtnErr error) { + msg format.Message, recipient *id.ID, rid id.Round, rtnErr error) bool { if rtnErr != nil { c.Failed(msg, recipient) + return false } else { sendResults := make(chan ds.EventReturn, 1) @@ -110,13 +112,11 @@ func (c *critical) handle( } c.Failed(msg, recipient) - return + return success } - jww.INFO.Printf("Successful resend of critical raw message to %s "+ - "(msgDigest: %s) on round %d", recipient, msg.Digest(), rid) - c.Succeeded(msg, recipient) + return success } } @@ -128,15 +128,20 @@ func (c *critical) evaluate(stop *stoppable.Single) { localRid := recipient.DeepCopy() go func(msg format.Message, recipient *id.ID, params CMIXParams) { params.Stop = stop + params.Critical = false jww.INFO.Printf("Resending critical raw message to %s "+ "(msgDigest: %s)", recipient, msg.Digest()) // Send the message - round, _, err := c.send(msg, recipient, params) + round, _, err := c.send(msg.Copy(), recipient, params) // Pass to the handler - c.handle(msg, recipient, round.ID, err) + if c.handle(msg, recipient, round.ID, err) { + jww.INFO.Printf("Successful resend of "+ + "critical raw message to "+ + "%s (msgDigest: %s) on round %d", + recipient, msg.Digest(), round.ID) + } }(msg, localRid, params) } - } diff --git a/cmix/sendCmix.go b/cmix/sendCmix.go index 1b292cd91544aafcb96910a527109030d7f7aa7b..f1660588aefcb4dfa13d24856d581d74ab41e66e 100644 --- a/cmix/sendCmix.go +++ b/cmix/sendCmix.go @@ -9,11 +9,12 @@ package cmix import ( "fmt" + "strings" + "time" + "gitlab.com/elixxir/client/v4/cmix/attempts" "gitlab.com/elixxir/client/v4/cmix/rounds" "gitlab.com/elixxir/primitives/states" - "strings" - "time" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" @@ -24,7 +25,6 @@ import ( "gitlab.com/elixxir/client/v4/stoppable" pb "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/elixxir/comms/network" - "gitlab.com/elixxir/crypto/cmix" "gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/fastRNG" "gitlab.com/elixxir/primitives/excludedRounds" @@ -42,18 +42,20 @@ import ( // This does not have end-to-end encryption on it and is used exclusively as // a send for higher order cryptographic protocols. Do not use unless // implementing a protocol on top. -// recipient - cMix ID of the recipient. -// fingerprint - Key Fingerprint. 256-bit field to store a 255-bit -// fingerprint, highest order bit must be 0 (panic otherwise). If your -// system does not use key fingerprints, this must be random bits. -// service - Reception Service. The backup way for a client to identify -// messages on receipt via trial hashing and to identify notifications. -// If unused, use message.GetRandomService to fill the field with -// random data. -// payload - Contents of the message. Cannot exceed the payload size for a -// cMix message (panic otherwise). -// mac - 256-bit field to store a 255-bit mac, highest order bit must be 0 -// (panic otherwise). If used, fill with random bits. +// +// recipient - cMix ID of the recipient. +// fingerprint - Key Fingerprint. 256-bit field to store a 255-bit +// fingerprint, highest order bit must be 0 (panic otherwise). If your +// system does not use key fingerprints, this must be random bits. +// service - Reception Service. The backup way for a client to identify +// messages on receipt via trial hashing and to identify notifications. +// If unused, use message.GetRandomService to fill the field with +// random data. +// payload - Contents of the message. Cannot exceed the payload size for a +// cMix message (panic otherwise). +// mac - 256-bit field to store a 255-bit mac, highest order bit must be 0 +// (panic otherwise). If used, fill with random bits. +// // Will return an error if the network is unhealthy or if it fails to send // (along with the reason). Blocks until successful sends or errors. // WARNING: Do not roll your own crypto. @@ -76,9 +78,11 @@ func (c *client) Send(recipient *id.ID, fingerprint format.Fingerprint, // This does not have end-to-end encryption on it and is used exclusively as // a send for higher order cryptographic protocols. Do not use unless // implementing a protocol on top. -// recipient - cMix ID of the recipient. -// assembler - MessageAssembler function, accepting round ID and returning fingerprint -// format.Fingerprint, service message.Service, payload, mac []byte +// +// recipient - cMix ID of the recipient. +// assembler - MessageAssembler function, accepting round ID and returning fingerprint +// format.Fingerprint, service message.Service, payload, mac []byte +// // Will return an error if the network is unhealthy or if it fails to send // (along with the reason). Blocks until successful sends or errors. // WARNING: Do not roll your own crypto. @@ -268,7 +272,7 @@ func sendCmixHelper(sender gateway.Sender, assembler messageAssembler, recipient // Flip leading bits randomly to thwart a tagging attack. // See cmix.SetGroupBits for more info. - cmix.SetGroupBits(msg, grp, stream) + // cmix.SetGroupBits(msg, grp, stream) // Retrieve host and key information from round firstGateway, roundKeys, err := processRound( diff --git a/go.mod b/go.mod index fd5943de3d5c235a3b45e0bbfcb71215dc5d4eb4..3826c9fdab530d07bee28869c9e5985b54a758e9 100644 --- a/go.mod +++ b/go.mod @@ -15,9 +15,9 @@ require ( github.com/stretchr/testify v1.8.0 gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f gitlab.com/elixxir/comms v0.0.4-0.20221110181420-84bca6216fe4 - gitlab.com/elixxir/crypto v0.0.7-0.20221110181326-dd7e5293feb0 + gitlab.com/elixxir/crypto v0.0.7-0.20221114184755-9fecef9a2093 gitlab.com/elixxir/ekv v0.2.1 - gitlab.com/elixxir/primitives v0.0.3-0.20221110181119-e83320a48b13 + gitlab.com/elixxir/primitives v0.0.3-0.20221114231218-cc461261a6af gitlab.com/xx_network/comms v0.0.4-0.20221110181111-4f0694876936 gitlab.com/xx_network/crypto v0.0.5-0.20221110181048-76f0c556fe95 gitlab.com/xx_network/primitives v0.0.4-0.20221110180011-fd6ea3058225 diff --git a/go.sum b/go.sum index 596ea41c2d698b7e9a88be3db73804fc9dc9e7e9..0e16f4709151412f6d35ba89bc9f949466bd6365 100644 --- a/go.sum +++ b/go.sum @@ -483,32 +483,18 @@ github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f h1:yXGvNBqzZwAhDYlSnxPRbgor6JWoOt1Z7s3z1O9JR40= gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k= -gitlab.com/elixxir/comms v0.0.4-0.20221108183306-7c473bca3cd6 h1:9oxGMvOC8UPG5ocBlEjZjKBA2X2P9dpwyd48ywL+Uyk= -gitlab.com/elixxir/comms v0.0.4-0.20221108183306-7c473bca3cd6/go.mod h1:fWr0w/UMT/A7aw+Fw7y9kOOTqE3aYxwo5cl6obrysHM= gitlab.com/elixxir/comms v0.0.4-0.20221110181420-84bca6216fe4 h1:bLRjVCyMVde4n2hTVgoyyIAWrKI4CevpChchkPeb6A0= gitlab.com/elixxir/comms v0.0.4-0.20221110181420-84bca6216fe4/go.mod h1:XhI2/CMng+xcH3mAs+1aPz29PSNu1079XMJ8V+xxihw= -gitlab.com/elixxir/crypto v0.0.7-0.20221108183134-3f4a29c68e97 h1:xZFh1e1vq/j1DF61Bta3Wb4ePcCS+NHyk3ri3VcMOuk= -gitlab.com/elixxir/crypto v0.0.7-0.20221108183134-3f4a29c68e97/go.mod h1:fhS9lyG4zNKC39Hd3YXPo9HYI0WnVz/JDTJw9nwnYHQ= -gitlab.com/elixxir/crypto v0.0.7-0.20221110181326-dd7e5293feb0 h1:IgspAliiN6MGqJX7LZ+1GinCX6bNJw6KlIa+rvEo2+A= -gitlab.com/elixxir/crypto v0.0.7-0.20221110181326-dd7e5293feb0/go.mod h1:IqswRNqsGooEOt2tP1LzeAcBOccVW0aUiJFH5B7UGfg= +gitlab.com/elixxir/crypto v0.0.7-0.20221114184755-9fecef9a2093 h1:lSU2+ANGn60XoMqGZ4qagTwHj7fmUaeGIx6Yza6DYvE= +gitlab.com/elixxir/crypto v0.0.7-0.20221114184755-9fecef9a2093/go.mod h1:oRh3AwveOEvpk9E3kRcMGK8fImcEnN0PY4jr9HDgQE8= gitlab.com/elixxir/ekv v0.2.1 h1:dtwbt6KmAXG2Tik5d60iDz2fLhoFBgWwST03p7T+9Is= gitlab.com/elixxir/ekv v0.2.1/go.mod h1:USLD7xeDnuZEavygdrgzNEwZXeLQJK/w1a+htpN+JEU= -gitlab.com/elixxir/primitives v0.0.3-0.20221108183049-7bdff545bf8e h1:U9aMSBhc2ShJEeCXHNoUPVwrxKAGRhbGZWsbqES8iGA= -gitlab.com/elixxir/primitives v0.0.3-0.20221108183049-7bdff545bf8e/go.mod h1:KeMEPwtmA0zJpetvv5SeyOePIAzsBmQSwJ2nAHYnczw= -gitlab.com/elixxir/primitives v0.0.3-0.20221109183528-7cbb24d14a5b h1:d9FdXv6CB5elYH3cYMcgnRkRGLYm7SPPneSCeQGUsqs= -gitlab.com/elixxir/primitives v0.0.3-0.20221109183528-7cbb24d14a5b/go.mod h1:KeMEPwtmA0zJpetvv5SeyOePIAzsBmQSwJ2nAHYnczw= -gitlab.com/elixxir/primitives v0.0.3-0.20221110181119-e83320a48b13 h1:U3tbClFN5BLYlAoMj+o6VWAs9akbFiJstMGCuk1aB94= -gitlab.com/elixxir/primitives v0.0.3-0.20221110181119-e83320a48b13/go.mod h1:DUnCTXYKgjpro5+6ITySKIf+qzW2vhW40IVHMimdsqw= -gitlab.com/xx_network/comms v0.0.4-0.20221108183032-8732b403e506 h1:QoFyWFGuUquPvam/rHvnUEDdTQ3DzIhxn3x8WTWxXMA= -gitlab.com/xx_network/comms v0.0.4-0.20221108183032-8732b403e506/go.mod h1:/zveWGwSqQbPhPSiGIbS3v78nga8nD5XD1oXr0vD/Zc= +gitlab.com/elixxir/primitives v0.0.3-0.20221114231218-cc461261a6af h1:xcPqknK1ehNb9xwcutTdoR0YgD7DC/ySh9z49tIpSxQ= +gitlab.com/elixxir/primitives v0.0.3-0.20221114231218-cc461261a6af/go.mod h1:DUnCTXYKgjpro5+6ITySKIf+qzW2vhW40IVHMimdsqw= gitlab.com/xx_network/comms v0.0.4-0.20221110181111-4f0694876936 h1:eQQ4zUvGWIzCWdBJ6qlysWUMwrc2tM8GripFqdT1SAs= gitlab.com/xx_network/comms v0.0.4-0.20221110181111-4f0694876936/go.mod h1:+RfHgk75ywMvmucOpPS7rSUlsnbPyBuLsr13tsthUTE= -gitlab.com/xx_network/crypto v0.0.5-0.20221108182939-05998dc093e9 h1:A/gYzA36bQxj6tRczs11JEUsWzaLmTRXN89tlqWEOUc= -gitlab.com/xx_network/crypto v0.0.5-0.20221108182939-05998dc093e9/go.mod h1:0Bk5bSyAqH/GAU4CJ8Wbm24YkMoDVz4JF7585dAMkss= gitlab.com/xx_network/crypto v0.0.5-0.20221110181048-76f0c556fe95 h1:rC6lx6sD6u617Qu0ZndKZQRjXuRkyrI9Q6Y0Ki+dnK4= gitlab.com/xx_network/crypto v0.0.5-0.20221110181048-76f0c556fe95/go.mod h1:acWUBKCpae/XVaQF7J9RnLAlBT13i5r7gnON+mrIxBk= -gitlab.com/xx_network/primitives v0.0.4-0.20221104175439-f0d440beacd9 h1:XE7OBn2gYmfLudiaWOl6LzYblZZqYIsScrSzJqPwymY= -gitlab.com/xx_network/primitives v0.0.4-0.20221104175439-f0d440beacd9/go.mod h1:rP/2IsqIFHapuIB4mstXKItvwoJRQ9Wlms/NGeutHsk= gitlab.com/xx_network/primitives v0.0.4-0.20221110180011-fd6ea3058225 h1:TAn87e6Zt9KwcSnWKyIul5eu8T0RHY9FDubCGs3G0dw= gitlab.com/xx_network/primitives v0.0.4-0.20221110180011-fd6ea3058225/go.mod h1:rP/2IsqIFHapuIB4mstXKItvwoJRQ9Wlms/NGeutHsk= gitlab.com/xx_network/ring v0.0.3-0.20220902183151-a7d3b15bc981 h1:1s0vX9BbkiD0IVXwr3LOaTBcq1wBrWcUWMBK0s8r0Z0= diff --git a/storage/utility/messageBuffer.go b/storage/utility/messageBuffer.go index ce2ae8203c68ebf439724d9e4f08d828ec582abf..501a969c4c5c5429936ed0201e1b29f9632c8f74 100644 --- a/storage/utility/messageBuffer.go +++ b/storage/utility/messageBuffer.go @@ -308,6 +308,12 @@ func (mb *MessageBuffer) Next() (interface{}, bool) { "this may happen on occasion due to replays to increase "+ "reliability: %v", h, err) } + + if m != nil && h != mb.handler.HashMessage(m) { + jww.WARN.Printf("MessageHash mismatch, possible"+ + " deserialization failure: %v != %v", + mb.handler.HashMessage(m), h) + } } return m, m != nil diff --git a/xxdk/version_vars.go b/xxdk/version_vars.go index a207e9f579ddf8cd1fa11ac0470e8897503355cb..8350ae7edde96aaca07cec6ebad2dff7fd596c12 100644 --- a/xxdk/version_vars.go +++ b/xxdk/version_vars.go @@ -1,11 +1,11 @@ // Code generated by go generate; DO NOT EDIT. // This file was generated by robots at -// 2022-11-11 01:37:42.933242774 +0000 UTC m=+0.009422129 +// 2022-11-14 23:15:18.806830082 +0000 UTC m=+0.010342227 package xxdk -const GITVERSION = `f4e3acae Fix version check` -const SEMVER = "4.3.7" +const GITVERSION = `6e5de435 Fix tests but maintain the message hash sanity check in the message buffer deserialization code` +const SEMVER = "4.3.8" const DEPENDENCIES = `module gitlab.com/elixxir/client/v4 go 1.19 @@ -23,9 +23,9 @@ require ( github.com/stretchr/testify v1.8.0 gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f gitlab.com/elixxir/comms v0.0.4-0.20221110181420-84bca6216fe4 - gitlab.com/elixxir/crypto v0.0.7-0.20221110181326-dd7e5293feb0 + gitlab.com/elixxir/crypto v0.0.7-0.20221114184755-9fecef9a2093 gitlab.com/elixxir/ekv v0.2.1 - gitlab.com/elixxir/primitives v0.0.3-0.20221110181119-e83320a48b13 + gitlab.com/elixxir/primitives v0.0.3-0.20221114231218-cc461261a6af gitlab.com/xx_network/comms v0.0.4-0.20221110181111-4f0694876936 gitlab.com/xx_network/crypto v0.0.5-0.20221110181048-76f0c556fe95 gitlab.com/xx_network/primitives v0.0.4-0.20221110180011-fd6ea3058225