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

Refactor SMPC protocol implementation #876

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

iliailia
Copy link
Collaborator

@iliailia iliailia commented Jan 3, 2025

The main goal of this change is to make an implementation of the SMPC protocol (Aby3Store formerly known as LocalNetAby3NgStoreProtocol) more atomic, lightweight and independent of implementation details not related to the protocol. In particular,

  • shared points are passed through Arc to avoid unnecessary copying;
  • runtime is replaced with a session that abstracts away all the networking details; this fits into the previous assumption that each instance of the protocol should be run within a single session.

In addition, LocalRuntime is simplified by removing unused fields.

@iliailia iliailia requested a review from bgillesp January 3, 2025 10:04
Copy link
Collaborator

@bgillesp bgillesp left a comment

Choose a reason for hiding this comment

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

Looks like a nice refactor! The main thing I see aside from a few naming suggestions is some extra clone calls that aren't necessary now due to a change you made in the SharedIrises::get_vector interface. After small fixes should be good to go!

Comment on lines +70 to +77
struct SharedIrisesBody {
points: Vec<GaloisRingSharedIris>,
}

impl std::fmt::Debug for Aby3NgStorePlayer {
#[derive(Clone)]
pub struct SharedIrises {
body: Arc<RwLock<SharedIrisesBody>>,
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a bit concerned about these struct names causing confusion because there are two different types of sharing involved -- secret shares and Arc references. One possibility that would be more explicit about this distinction would be SharedIrises for the struct with points, and SharedIrisesRef for the Arc<RwLock<_>>-wrapped version. These make it clear at least to me that the first contains actual shared irises, and the second is a reference to the shared irises. Thoughts?

}
}

impl SharedIrises {
pub fn new_with_shared_db(data: Vec<GaloisRingSharedIris>) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this constructor name be changed to just new? The with_shared_db suffix is a bit confusing because every instance of this type represents a shared database, and also again there's this ambiguity of the term "shared" -- secret sharing, Arc sharing, the input data being shared, or the data being shared after being moved, or...? I guess the purpose of the data type is clear enough by itself, so that the extra with_shared_db part of the name looks like a signpost for some complexity that isn't actually there.

@@ -90,33 +112,32 @@ impl Aby3NgStorePlayer {
})
}

pub fn get_vector(&self, vector: &VectorId) -> &GaloisRingPoint {
&self.points[vector.id]
pub fn get_vector(&self, vector: &VectorId) -> GaloisRingSharedIris {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The return type change from an immutable ref to a cloned copy seems fine at the moment (all current uses of the method do a clone on the returned ref afterwards already), but since the clone happens internally, we should remove the extra clones that happen after calling get_vector, e.g. on lines 258, 275, ...

}

/// Implementation of VectorStore based on the ABY3 framework (https://eprint.iacr.org/2018/403.pdf).
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like to fix this warning from building the docs you need to make this an "automatic link" by surrounding the url with angle brackets, as in

/// Implementation of VectorStore based on the ABY3 framework (<https://eprint.iacr.org/2018/403.pdf>).

LocalNetAby3NgStoreProtocol,
GraphMem<LocalNetAby3NgStoreProtocol>,
)>,
Vec<(Aby3Store, GraphMem<Aby3Store>)>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The new type signature is refreshingly concise! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants