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

[ceremonies/#65] generate random meetup indices #73

Merged
merged 4 commits into from
Nov 10, 2021

Conversation

NicJak
Copy link
Member

@NicJak NicJak commented Oct 17, 2021

the changes in tests can easily be verified by commenting out the performing the random permutation on the indices (ceremonies/src/lib.rs:487)

Copy link
Member

@brenzi brenzi left a comment

Choose a reason for hiding this comment

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

pretty sure this way of doing it won't be compatible with #68. @pifragile can you please comment?

Might be better to store the mapping meetupindex->locationindex separately or derive it directly from a seed as the new assignment does it too. May still be worth merging this for v0.7.0 and then adapting it as part of #68 for v0.8.0?

@pifragile
Copy link
Contributor

@NicJak @brenzi No this wont be compatible, because the way assignments are handled will be fundamentally changed in #68. And just out of curiosity, what is the rationale behind randomizing the meetup locations, when we already randomize the pariticipants? Is it about bootstrappers not always being assigned to the first couple locations?

@brenzi
Copy link
Member

brenzi commented Oct 18, 2021

The set of locations should always be >> set of meetups. So we need to randomize that too

@NicJak
Copy link
Member Author

NicJak commented Oct 18, 2021

Having predictable meetup locations could ease preventive actions towards encointer.

@brenzi
Copy link
Member

brenzi commented Oct 18, 2021

on a public chain all assignments will be public knowledge beforehand anyway. Later, the ceremony pallet will be on a TEE sidechain and this will be solved

@pifragile
Copy link
Contributor

I was just thinking, might there be some nice way to return the locations in a "randomized" order based on some seed input here:

pub fn get_locations(cid: &CommunityIdentifier) -> Vec<Location>{

@brenzi
Copy link
Member

brenzi commented Oct 18, 2021

not sure if a simple getter should involve random. bad for caching i.e. for geo view explorer

@pifragile
Copy link
Contributor

true that makes sense. one could move the functionality to any place actually, was just worried about getting a mess with #68. maybe we could keep this really simple and for locations not do a full random permutation, but just a random offset, because unpredictable locations we already get from the assignment process. just thinking aloud :)

@brenzi
Copy link
Member

brenzi commented Oct 18, 2021

no, needs random because we don't want predictability of where a meetup will take place to make sabotage more difficult.
I suggest to use this PR's logic for now and then adapt it for #68

@pifragile
Copy link
Contributor

i dont understand, a random offset also makes the location unpredictable but takes O(1) and a random permutation takes O(N). i think permutation on locations AND participants is an overkill. what am i missing?

@brenzi
Copy link
Member

brenzi commented Oct 19, 2021

O(n) of a simple index permutation should not worry us.

The difference is: With random offset you only need two samples and you learn that ALL locations in between will hold a meetup.

So a simple offset has inferior sabotage resistance than random permutation

@pifragile
Copy link
Contributor

ok if O(N) does not hurt us if there many locations its better for sure!
still cannot come up with the attack scenario though, let me know sometime :)

@NicJak
Copy link
Member Author

NicJak commented Oct 19, 2021

if O(1) is preferred, we could also use an expensive O(1) + C like a hash. One would have elaborate the impact of a collision and probably do a small performance comparison as to at what n the break-even-point is..

@brenzi
Copy link
Member

brenzi commented Oct 19, 2021

@pifragile you derive an entire assignment from two primes and a seed, right? why not derive the location permutation the same way?

@pifragile
Copy link
Contributor

that would be possible, yes!

ceremonies/src/lib.rs Outdated Show resolved Hide resolved
ceremonies/src/lib.rs Outdated Show resolved Hide resolved
ceremonies/src/tests.rs Show resolved Hide resolved
ceremonies/src/lib.rs Outdated Show resolved Hide resolved
ceremonies/src/tests.rs Show resolved Hide resolved
@NicJak
Copy link
Member Author

NicJak commented Nov 7, 2021

how do we proceed with this change?

@brenzi
Copy link
Member

brenzi commented Nov 7, 2021

we should derive a location permutation client side from the randomness we use for assignments. @NicJak If you see how you could do that from the existing code, please go ahead! Otherwise, @pifragile might be able to help

@brenzi
Copy link
Member

brenzi commented Nov 10, 2021

I'll merge this for the 0.6.x releases, before we'll introduce the new assignment logic in 0.7x #68 #75

@brenzi brenzi merged commit 47282e2 into master Nov 10, 2021
@clangenb clangenb deleted the random_meetup_locations_65 branch November 11, 2021 04:21
NicJak added a commit that referenced this pull request Nov 17, 2021
Copy link
Member

@clangenb clangenb left a comment

Choose a reason for hiding this comment

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

I know this has been merged, but I still wanted to give my two cents here.

In general, this looks good, but I believe, we should be wary about unnecessary collects because these are comparatively expensive, and it's a shame if it's done unnecessarily.

ceremonies/src/tests.rs Show resolved Hide resolved
ceremonies/src/lib.rs Show resolved Hide resolved
pifragile pushed a commit that referenced this pull request Dec 6, 2021
clangenb added a commit that referenced this pull request Dec 11, 2021
* Revert "[ceremonies/#65] generate random meetup indices (#73)"

This reverts commit 47282e2.

* new assignment, lazy issuance, random locations

* [ceremonies/#75] use random coprime for assignment

* [ceremonies] fix no_std compilation and `fn find_coprime_below`

* [ceremonies] print error in `generate_meetup_assignment_params`

* [ceremonies] use checked math operations in `checked_ceil_division`, `assignment_fn`

* [ceremonies] extract most math functions to primitives

* [ceremonies] move `mod_inv` to math module

* [ceremonies] fix randomness in `generate_assignment_function_params` -> introduces failing tests

* [ceremonies] remove unnecessary loc_ix >= 0 comparison for u64 type

* [ceremonies] fix failing tests by fixing `pick_non_zero_u32`

* [ceremonies] minor cleanup

* [ceremonies] add tests for `get_greatest_common_denominator`

* [primitives/random_number_generator] simplify pick_non_zero_u32

* [ceremonies/math] fix-no std compilation; successfully compiles with the node.

* [ceremonies] remove unnecessary result in `generate_all_meetup_assignment_params`

* [ceremonies] add test `generate_meetup_assignment_params_is_random`

Co-authored-by: Nicolas Jakob <jakobnicolas@gmail.com>
Co-authored-by: Christian Langenbacher <clangenb+gh@protonmail.ch>
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.

None yet

4 participants