diff options
author | George Kadianakis <desnacked@riseup.net> | 2018-11-27 01:56:23 +0200 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2019-01-02 15:25:55 +0200 |
commit | 2ccf3268375cd46e8c948e94ba58e0d2f03fe722 (patch) | |
tree | a6a820abe9af9a65f7648c2fae8a36ff0d81d607 /src/core | |
parent | 8ad497bb578b13c66489843905764a60545e6388 (diff) | |
download | tor-2ccf3268375cd46e8c948e94ba58e0d2f03fe722.tar.gz tor-2ccf3268375cd46e8c948e94ba58e0d2f03fe722.zip |
Implement and test probability distributions used by WTF-PAD.
This project introduces the prob_distr.c subsystem which implements all the
probability distributions that WTF-PAD needs. It also adds unittests for all of
them.
Code and tests courtesy of Riastradh.
Co-authored-by: Taylor R Campbell <campbell+tor@mumble.net>
Co-authored-by: Mike Perry <mikeperry-git@torproject.org>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/or/circuitpadding.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/or/circuitpadding.c b/src/core/or/circuitpadding.c index 6cfbf4ba56..a9d927619d 100644 --- a/src/core/or/circuitpadding.c +++ b/src/core/or/circuitpadding.c @@ -516,10 +516,10 @@ circpad_distribution_sample(circpad_distribution_t dist) * param1 is Alpha, param2 is Beta */ return dist.param1 * pow(p/(1.0-p), 1.0/dist.param2); case CIRCPAD_DIST_GEOMETRIC: - p = crypto_rand_double(); - /* https://github.com/distributions-io/geometric-quantile/ - * param1 is 'p' (success probability) */ - return ceil(tor_mathlog(1.0-p)/tor_mathlog(1.0-dist.param1)); + { + /* param1 is 'p' (success probability) */ + return geometric_sample(dist.param1); + } case CIRCPAD_DIST_WEIBULL: p = crypto_rand_double(); /* https://en.wikipedia.org/wiki/Weibull_distribution \ |