-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Poisson interval function for Mixnet #575
Conversation
mixnet/src/utils.rs
Outdated
/// | ||
/// The Poisson (exponential) distribution is used because of its memoryless properties, | ||
/// which is known to offer optimal anonymity properties (Nym whitepaper 4.4). | ||
pub fn interval(&mut self, rate_per_min: f64) -> Duration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not generic function instead of a struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid always providing a seed
to the function, I assume that we will invoke this function multiple times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may have to change the randomness source as well. @youngjoon-lee can you confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In our Mixnet specification, we don't strictly specify how randomness source has to be set for Poisson.
Poisson distribution is used for both the interval of packet emissions (by msg senders) and the packet delays (by mix nodes). As long as all of them follow a Poisson distribution with the same "rate parameter" (aka. lambda) for a long time, the effect of mixing can be maintained as calculated in the spec. From my understanding, the randomness source is not very important as long as the same rate parameter is used across the network. Implementers (including us) can decide on the strategy whether they'll change the source periodically. It's okay even if each node uses different randomness source.
Similarly, Nym implementation uses OsRng
: reference1 and reference2. (they're still discussing which Rng is better, though).
So, in our implementation, I think we can go with the struct because we're not gonna change the Rng until we find any better strategy.
(Nym implementation has a generic function instead :) But I think both is okay.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@al8n @danielSanchezQ This PR has stayed opened for too long.
I just added a final commit 80e68d2, which just defines a generic function instead of struct. While implementing mixnet logic, I've found we actually don't need seed
(as I noted at the comment above). Let's go with the simplest structure, as Nym does: https://github.com/nymtech/nym/blob/release/v1.1.22/common/nymsphinx/src/utils/mod.rs. I think we don't need to make things complicated before knowing what we really need.
@danielSanchezQ Could you pls lift the change required
sign in this PR, so I can merge this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, renamed utils.rs
to poisson.rs
: 88da71e
* base * Remove mixnet client from libp2p network backend (#572) * Mixnet v1: Remove all mixnet legacies: mixnet crate, mixnode binary, tests, and docker (#573) * Mixnet v1: Skeleton (#570) * Use QUIC for libp2p (#580) * Add Poisson interval function for Mixnet (#575) * Mixnet network backend skeleton (#586) * Libp2p stream read/write (#587) * Emitting packets from mixclient using libp2p stream (#588) * Handle outputs from mixnode using libp2p stream/gossipsub (#589) * Refactor poisson (#590) * Mix client Poisson emission (#591) * Mix node packet handling (#592) * Mix Packet / Fragment logic (#593) * Move FisherYates to `nomos-utils` (#594) * Mixnet topology (#595) * Mix client/node unit tests (#596) * change multiaddr from tcp to udp with quic-v1 (#607) --------- Co-authored-by: Al Liu <scygliu1@gmail.com>
Port fisheryates.py and poisson.py to Rust.