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

Eliminate confusion on party vs participant indices #11

Closed
ggutoski opened this issue Mar 26, 2021 · 4 comments
Closed

Eliminate confusion on party vs participant indices #11

ggutoski opened this issue Mar 26, 2021 · 4 comments
Assignees

Comments

@ggutoski
Copy link
Contributor

Confusion between "party" and "participant" indices is a consistent source of bugs.

  • "party" indices are in 0..share_count from keygen
  • "participant" indices are in 0..participant_count from sign

eg. participant_indices[my_participant_index] == my_secret_key_share.my_index

Suggestion

Use the newtype pattern to wrap usize for party vs participant indices

  • write simple methods to convert between them
  • eg. my_secret_key_share.all_eks can be indexed only by party indices
  • eg. in_r2bcasts can be indexed only by participant indices

You'll probably need a special collection type for each of party, participant index types that's basically a Vec that can be indexed by the index type instead of usize.

@ggutoski
Copy link
Contributor Author

This crate looks promising: typed_index_collections - Rust. The author even lists competing crates---classy!

@ggutoski ggutoski removed the enhancement New feature or request label May 6, 2021
@ggutoski
Copy link
Contributor Author

ggutoski commented Jun 2, 2021

@sdaveas as a first step in refactoring perhaps you can start thinking about this issue. I have a few ideas so let's keep in close contact.

Some rough notes from 2021-04-28:

  • This is close to useful typed_index_collection - Rust. Unfortunately, the index type is tied to the value type. So if I have a collections c,d of type Collection<T> then I could confuse indices for c with those for d.
    • Interesting but not what I want either: vec_map::VecMap - Rust
    • This might be a winner: typed_index_collections - Rust
      • Also checkout self-disclosed similar crates
      • Maybe I can simplify index derivation. Examples want me to make a struct FooId(usize) and derive From<usize> etc. But I can make a generic struct Id<T>(usize,PhantomData<T>) and then implement all the stuff I need to generically over T. Then when I want a new index type I just do
      struct Marker;
      type MyIdx = Id<Marker>;
      let vec : TiVec<MyIdx,T> = // ...

@ggutoski
Copy link
Contributor Author

ggutoski commented Jun 2, 2021

Looking ahead, I'd like our solution to this issue to also do the following:

  1. integrate/replace FillVec
  2. support friendly iterators

For item 2: The vision is as follows. In each protocol round I'd like to have access to two iterators:

  • all iterate over all parties (including myself)
  • other iterate only over other parties (not including myself)

These iterators should have access to all relevant data. eg. as all ranges over all parties 1,...,n, I can do things like all.r1bcast, all.r2bcast, etc. No need for separate iterators for r1bcast, r2bcast, etc. Also, there should be no need for cruft like as_ref, vec_ref, unwrap, etc. All the data should just be there--no Options.

It's not clear to me whether this is a realistic goal. Perhaps any solution would require lots of cruft and mem copy just to prepare the iterator, in which case it might not be worth the effort.

@ggutoski
Copy link
Contributor Author

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

No branches or pull requests

2 participants