Skip to content

sample_laplace_distribution() should take multiple random inputs

Currently, sample_laplace_distribution() takes a random double as input, and then extracts the following random values:

  • a random sign
  • a random value in (0.0, 1.0]

This reduces the precision of the result. For details, see: https://trac.torproject.org/projects/tor/ticket/23061#comment:32

Instead, the function could take a random boolean sign and p, and the transform becomes:

result = mu - b * (sign ? 1.0 : -1.0)
                * tor_mathlog(1.0 - p);

This would increase the precision by one bit, plus whatever precision is lost in 2.0 * fabs(p - 0.5).

This may have been introduced in dad5eb7e.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information