rep_hist_format_hs_stats() rounds once to the bin size, then adds noise which has been rounded to the nearest integer. This isn't ideal, because it makes the least significant bits of the noise meaningless.
See my branch bug23414 for a fix to this, and the additions to add_laplace_noise() that are required to make it safe. They're part of legacy/trac#23416 (moved), and there is no changes file for them yet.
This needs another fix: if we treat signal INT_MIN and INT_MAX as if they are infinite (saturating arithmetic), then the security guarantees are much easier to reason about. And the explanations are shorter, too :-)
Also, the code would be simpler, and the explanations shorter, if we added the noise when we reset the counter. I opened legacy/trac#23501 (moved) for this.
I made a new branch at bug23414-v4, and split off some unrelated changes into legacy/trac#23523 (moved).
It needs a working round_int64_to_next_multiple_of(), which also needs to be backported to 0.2.8 and later. There is a possible fix in legacy/trac#19130 (moved) (which we closed by deleting the buggy function).
See my branches bug23414-029 and bug23414-028, which are security-low because the current code leaks the low bits of the noise. (And it biases the result upwards by an average of the bin size divided by 2, because it rounds first, then adds noise.)
bug23414-028 has the following changes:
the context is different due to legacy/trac#19130 (moved) going into 0.2.9 (but we replace the code from 0.2.8 and 0.2.9 with the same code)
there's no BUG macro in 0.2.8
the existing unit tests for round_int64_to_next_multiple_of() were based on the old implementation, which had the same upwards bias as the 0.2.9 implementation, due to the rounding function itself, rather than the order of operations
Trac: Actualpoints: N/Ato 1.0 Status: needs_revision to needs_review
Oops, the original tests were right: the only thing worse than a consistent bias is one that is inconsistent (it changes when the noised signal is negative).
Good news is that round_int64_to_next_multiple_of() becomes a two-liner:
I don't think I'll have time to fix round_int64_to_next_multiple_of until the end of the week. So if anyone else wants to do it, please feel free to grab this ticket. (Or split it off into its own ticket.)
The good news is that we probably don't need to care about extreme values or binning, because properly implemented noise has known limits, and doesn't need binning.
These needs_revision, tickets, tagged with 034-removed-*, are no longer in-scope for 0.3.4. We can reconsider any of them, if somebody does the necessary revision.
Trac: Milestone: Tor: 0.3.4.x-final to Tor: unspecified