Repository navigation
Conversation
…l sharing their hash byte The channel hash is one byte, so private channels collide with named ones. Grouping by the byte alone put every undecryptable 0x76 packet under #coredrive: on a live instance 5203 of the 6568 messages shown for it came from another channel. Undecrypted packets now share one bucket per byte, decrypted packets go to the bucket of their own name.
n30nex
left a comment
There was a problem hiding this comment.
Source review at ad9486e4, plus an actual-JS decoration probe: encrypted rows receive a saved local channel name and “My Channels” grouping when the hash byte matches a stored key. Without that key, they read “Encrypted”. analytics.js is unchanged, so this predates the PR; please qualify the description and cover both configurations in browser validation.
The combined code/test commit also lacks the recorded RED→GREEN checkpoints required by docs/agents/TDD.md. I have not run this PR's Go suite or browser checks.
…ypted channel left Red: with a saved #coredrive key, the undecrypted bucket on byte 0x76 (traffic the server's #coredrive key did not open) is shown as a second #coredrive row under My Channels.
…pted channel left When the server decrypted a channel on a hash byte, the undecrypted bucket on that byte holds packets that channel's key did not open. A locally saved key with the same name no longer moves that bucket under My Channels with the channel's name; it stays Encrypted (0xNN). A local key for a channel the server did not decrypt still names the bucket.
|
Review feedback addressed (commits Thanks @n30nex, both points held.
Not done: a browser check of the new frontend code, because the fixture has no byte collision between a decrypted and an undecrypted channel. |
…hex8> Red: a key added as hex or by QR is stored as psk:<hex8> with the name only as a label, so the name comparison misses it and the undecrypted bucket on its byte is still shown under My Channels (#coredrive with and without a label, and the Public key). A second local key on the same byte must still name the bucket when the server's key was saved last. The checks run the real channel-decrypt.js and send hash as a string, like the server. buildHashKeyMap is exposed for the test.
… not by name buildHashKeyMap now takes the channel rows and ChannelDecrypt, derives the keys of the channels the server decrypted on the bytes a stored key lands on (#hashtag names, plus the fixed Public key), and leaves out a stored key equal to one of them on the same byte. A key added as hex or by QR (psk:<hex8>) is caught the same way as one saved by name. With two stored keys on one byte, the one the server holds no longer pushes out the other. The name comparison in decorateAnalyticsChannels from be45276 goes, it is covered by this. Not covered: a channel an operator configured in channelKeys under a private name. The client cannot know that key, so a local copy keeps naming the bucket; a test pins that.
|
Follow-up to my last comment (commits The name comparison from
Still not done: a browser check of the new frontend code (no byte collision in the fixture). |
zfouts
left a comment
There was a problem hiding this comment.
Reviewed at ee0f1ffc. Requesting changes, but the fix is about two lines.
The split works for the usual case, and the frontend's key-by-key comparison in buildHashKeyMap is careful and well tested. CI is green, and master hasn't touched computeAnalyticsChannels since your base.
Blocking: a decrypted packet with an empty message renames the undecrypted bucket (cmd/server/store.go, the encrypted := / chKey / placeholder-upgrade lines)
decryptChannelMessagecuts the text at the first NUL (cmd/ingestor/decoder.go:518). Whenplaintext[5] == 0the result isText="",Sender="",Channel="#coredrive",decryptionStatus:"decrypted". That happens for a real empty message, and for about 1 in 256 of the 2-byte-MAC false positives.- On the server,
encryptedis then true, sochKey = hashand the packet joins the shared undecrypted bucket for that byte. - The "upgrade bucket name" branch then renames that bucket from
ch118to#coredrive, and it stays encrypted. decorateAnalyticsChannelsthen shows it under Network as a second#coredriverow with the other channel's thousands of messages. That's the misread this PR is meant to remove. It's also the "1 packet in 14 days carries a channel name without text or sender" in the description.
Suggested fix: key on the name instead of on whether the text is empty:
chKey := hash
if !isPlaceholderName(name) {
chKey = hash + "\x00" + name
}Then remove the rename-on-upgrade branch, since the placeholder bucket never needs a name. Alternatively, use encrypted := decoded.Text == "" && decoded.Sender == "" && !ingestorDecrypted. Either way, please add a Go test: 3 undecrypted packets plus 1 makeGrpTxWithStatus(118, "#coredrive", "", "", "decrypted") on the same byte, and assert that the ch118 bucket keeps its placeholder name and a count of 3.
Notes, none blocking:
- The frontend change still hasn't been checked in a browser, as the description says. A live instance with a saved
#coredrivekey would show it quickly. PUBLIC_CHANNEL_KEYinpublic/analytics.jscopies the ingestor'sbuiltinChannelKeys(). A comment pointing tocmd/ingestor/main.gowould help keep them in sync.- Both of the earlier review's points are addressed: the local-key comparison now goes by key, and the red-to-green record is in place.
…ed bucket A packet the ingestor decrypted can carry no text and no sender: the message was empty, or the 2-byte MAC matched by chance and the text stopped at its first NUL. computeAnalyticsChannels took that as undecrypted, put it in the shared bucket of its hash byte and renamed the bucket to the packet's channel, so the undecrypted packets were shown again as that channel's messages. The bucket is now chosen by name: packets without a channel name share the bucket of their byte, which keeps its placeholder name, and a named packet goes to its own. A packet the ingestor marked decrypted is never counted as encrypted. The rename branch and isPlaceholderName, its only user, are gone.
Packets stored before the ingestor normalised the channel casing carry "public". buildHashKeyMap compared the server's names with "Public" only, so with the Public key saved locally the undecrypted 0x11 bucket was named "Public" under My Channels, next to the decrypted "public" row. Found in a browser check against the E2E fixture, which has such rows.
|
Review feedback addressed (commits
Server suite and |
zfouts
left a comment
There was a problem hiding this comment.
Re-reviewed at 81f672e9. Approving. Thanks for the quick turnaround.
d5fd7cf2: choosing the bucket byname != "ch"+hashand adding&& !ingestorDecryptedtoencryptedtogether fix the case: an empty decrypted message now lands in its own channel's bucket as a decrypted row. Comparing with"ch"+hashrather thanisPlaceholderNameis the better choice, because it also covers the?and hex-hash names. With the rename branch gone, a bucket's name can no longer change after it is created.TestComputeAnalyticsChannels_EmptyDecryptedKeepsUndecryptedBucketpins it: 3 packets inch118, encrypted, and 1 in#coredrive, decrypted.81f672e9: good catch on the fixture's lowercasepublicrows. The case-insensitive compare is the right fix, and it comes with a test.PUBLIC_CHANNEL_KEYnow points tobuiltinChannelKeys().- CI is green on
81f672e9, and the PR merges cleanly.
About the two ESLint errors: they come from the branch's older base (a0b4e6cf). On master those calls are already CSApi.fetch (e.g. public/analytics.js:538), and this PR doesn't touch those lines, so they disappear on merge.
What changes for operators
Analytics > Channels showed a named channel with far more messages than it had. The channel hash on the wire is one byte, so many channels share each value.
computeAnalyticsChannelsgrouped by that byte alone (the #978 fix,cmd/server/store.go), so every packet the ingestor could not decrypt was counted under the decrypted channel with the same byte.Measured on a live instance (14 days,
transmissionstable):#coredrive(0x76)#bemesh(0x63)Public(0x11)An operator read the 6568 as "#coredrive carries almost as much traffic as Public and #bemesh together" and asked for the feature to be switched off.
The change
Encrypted (0xNN)through the existingdecorateAnalyticsChannelspath.decryptionStatustrust from Analytics → Channels: default "Public" channel (0x11) shown as opaque "Encrypted (0x11)" despite known/configured key #1729 are unchanged: a rejected name still falls into the undecrypted bucket.What this undoes from #978
#978 also merged "encrypted" and "decrypted" rows of the same byte, on the premise that one byte is one channel. Decryption happens once per transmission in the ingestor, so an undecrypted packet next to a decrypted channel with the same byte is a packet that channel's key did not open.
TestComputeAnalyticsChannels_MergesEncryptedAndDecryptedasserted the merge; it is replaced byTestComputeAnalyticsChannels_UndecryptedNotCountedAsNamedChannel. The exception is history ingested before a key was added: those packets now show as their ownEncryptedrow instead of being counted under the name.A packet the ingestor decrypted can carry no text and no sender (an empty message, or a 2-byte MAC that matched by chance); the live DB had 1 in 14 days (of 38758 GRP_TXT). It goes to its own channel's bucket as a decrypted row, and the bucket of undecrypted packets keeps its placeholder name.
Locally saved channel keys (
public/analytics.js)decorateAnalyticsChannelsgives anEncryptedrow the name of a channel key the visitor saved in the browser when the hash byte matches, and moves it under My Channels. That predates this PR. With the split it showed up as a duplicate: on a live instance with a#coredrivekey saved, the 3349 undecrypted packets on byte 0x76 appeared as a second#coredriverow under My Channels, next to the 1632 the server decrypted under Network. Without the key they readEncrypted (0x76).Fixed in
buildHashKeyMap, compared by key rather than by name: for the bytes a locally saved key lands on, the page derives the keys of the channels the server decrypted there (#hashtagnames derive from the name,Publichas a fixed key). A local key equal to one of those on the same byte no longer names the bucket, so it staysEncrypted (0xNN): those are packets that key did not open. This catches the key however it was saved: by name, as hex, or by QR (stored aspsk:<hex8>with the name only as a label). A local key the server does not hold still names the bucket, also when another decrypted channel shares the byte, and with two local keys on one byte the one the server holds no longer pushes out the other.Not covered: a channel an operator configured in
channelKeysunder a private (non-#) name. The page cannot know that key, so a local copy of it still names the bucket, as before this PR. A test pins that.Tests
Go (
cmd/server/channel_analytics_test.go):TestComputeAnalyticsChannels_UndecryptedNotCountedAsNamedChannel: 2 decrypted + 3 undecrypted on byte 129 give two rows, 2 and 3 messages.TestComputeAnalyticsChannels_DecryptedChannelsSharingHashStaySeparate:PublicandClubboth on byte 17, both decrypted, give two rows.The Go fix and its tests are one commit (
ad9486e4). The red step, run afterwards: the tests fromad9486e4on top of the basea0b4e6cfcode fail on an assertion, not a build error:With
store.gofromad9486e4, all 5TestComputeAnalyticsChannels*tests pass.cd cmd/server && go vet . && go test .: ok (65.6 s).Frontend (
tests/unit/test-analytics-channels-integration.js), red then green as separate commits, running the realchannel-decrypt.jswithhashas a string like the server sends:c0ccdb64/be452765: a first, name-based version (2 failed, 25 passed, then 27 passed). It missed keys saved aspsk:<hex8>.1cadc3e8replaces those cases: key saved as#coredrive, aspsk:<hex8>with and without a label, the Public key, a private key next to another decrypted channel, upper-case hex, a second local key on the same byte. On that commit: 4 failed, 27 passed.ee0f1ffc: 35 passed (adds the reverse save order, the per-byte comparison and the private-name limit). The other unit suites that loadanalytics.jspass as well.Not done
#test, and the Public key) leaves the undecrypted bucket on its byte under Encrypted; a private key on a byte the server cannot open names that bucket under My Channels. The Public case needed81f672e9: the fixture's rows are namedpublic, from before the ingestor normalised the casing.#/channels?ch=<byte>, as the split rows did before bug: analytics channels page shows duplicate entries (encrypted/decrypted split + rainbow-table collisions) #978. I did not change the channels page.activeChannelsgoes up by the number of bytes that have both kinds of traffic.