Skip to content
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

Merged
merged 19 commits into from
Feb 20, 2024
Merged

Conversation

al8n
Copy link
Contributor

@al8n al8n commented Jan 31, 2024

Port fisheryates.py and poisson.py to Rust.

@al8n al8n added the mixnet label Jan 31, 2024
@al8n al8n added this to the Mixnet milestone Jan 31, 2024
@al8n al8n self-assigned this Jan 31, 2024
Cargo.toml Outdated Show resolved Hide resolved
mixnet-utils/src/lib.rs Outdated Show resolved Hide resolved
mixnet/Cargo.toml Outdated Show resolved Hide resolved
mixnet/src/utils.rs Outdated Show resolved Hide resolved
Base automatically changed from mixnet-v1-skeleton to mixnet-v1 January 31, 2024 08:25
mixnet/src/utils.rs Outdated Show resolved Hide resolved
mixnet/src/utils.rs Outdated Show resolved Hide resolved
mixnet/src/utils.rs Outdated Show resolved Hide resolved
///
/// 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 {
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Contributor

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.)

Copy link
Contributor

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?

Copy link
Contributor

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

@youngjoon-lee youngjoon-lee changed the title Add random utils for mixnet Add Poisson interval function for Mixnet Feb 20, 2024
@youngjoon-lee youngjoon-lee merged commit a660948 into mixnet-v1 Feb 20, 2024
7 checks passed
@youngjoon-lee youngjoon-lee deleted the mixnet-utils branch February 20, 2024 11:43
youngjoon-lee added a commit that referenced this pull request Mar 12, 2024
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants