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

Mixnet PoC: Draft design #288

Closed
wants to merge 5 commits into from
Closed

Mixnet PoC: Draft design #288

wants to merge 5 commits into from

Conversation

youngjoon-lee
Copy link
Contributor

@youngjoon-lee youngjoon-lee commented Aug 3, 2023

This PR isn't meant to be merged to the master. Code quality is not good and is not tested.
This is just for proposing the design of Mixnet integration and starting discussions from it.
If we agree on this design, we can merge this PR to the mixnet branch.

For more contexts, please see #273.

This PR is proposing integrating MIxnet only for the first hop of gossipsub (actually before starting gossipsub).
Each Nomos node just throws a message to Mixnet instead of broadcasting it through gossipsub. A message goes through Mixnet, and the last mixnode in the route broadcasts the message via gossipsub.

This PR doesn't cover:

  • how to construct/manage the mixnet topology (mixnode address, and so on).: d55a293
  • how to send some kinds of message to a specific recipient without using gossipsub.

@youngjoon-lee youngjoon-lee self-assigned this Aug 3, 2023
@youngjoon-lee youngjoon-lee mentioned this pull request Aug 3, 2023
pub addr: SocketAddr,
// TODO: add pubkeys
// TODO: find better ways to handle topology
pub topology: Vec<SocketAddr>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having this static (or shared) topology, we may be able to leverage libp2p peer discovery. Mixnodes advertise their IP address and their public key (or libp2p peer_id) to other mixnodes. Then, each mixnode can pick 3 mixnodes randomly in order to build a Sphinx packet.
With this approach, the effect of mixing packets wouldn’t be high until a mixnode get enough advertisements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The important point here would be decoupling the libp2p::PeerId with nomos::NodeId, so that anyone cannot derive nomos::NodeId that is probably associated with stakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just talked with @danielSanchezQ about trying this DHT idea. I'll put a super simple prototype on top of this PR soon, so that we can continue discussions from it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just implemented a naive approach of managing the topology: d55a293. This doesn't actually use DHT. Instead, each node broadcasts their external IP address and their public key via gossipsub, so that receiving nodes can update the mixnet topology that they hold in their memory.
Here, the public key should be different from the public key associated with nomos::NodeId.

Comment on lines 151 to 153
Command::Broadcast { topic, message } => {
match swarm.broadcast(&topic, message) {
Ok(id) => {
tracing::debug!("broadcasted message with id: {id} tp topic: {topic}");
}
Err(e) => {
tracing::error!("failed to broadcast message to topic: {topic} {e:?}");
}
}
let msg = MixnetMessage { topic, message };
log_error!(mixnet_relay.send(MixnetMsg::Send(msg.as_bytes())).await);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you guys think about this strategy, using mixnet only for the first hop of gossipsub? This is one of strategies that we discussed. Although we haven't verified this strategy in detail, I'm getting an impression that this will probably meet our privacy requirements, as Lighthouse guys said.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and for now is probably the easiest approach. So I think is the path to go.

- [Libp2p](./src/backends/libp2p.rs)


## Mixnet integration
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a README to describe the approach of Mixnet PoC. I would say this design/implementation isn't optimal. It's probably a starting point that we can improve.

@youngjoon-lee youngjoon-lee changed the title WIP: Draft design of Mixnet integration Mixnet PoC: Draft design Aug 9, 2023
@youngjoon-lee
Copy link
Contributor Author

As this PR has lots of outdated discussions, I’ll open a new PR based on the design written in Notion: https://www.notion.so/Mixnet-Architecture-613f53cf11a245098c50af6b191d31d2

@youngjoon-lee youngjoon-lee deleted the mixnode branch September 1, 2023 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants