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

Randomizing x coordinate in shamir split #2621

Merged
merged 4 commits into from
Apr 28, 2017
Merged

Randomizing x coordinate in shamir split #2621

merged 4 commits into from
Apr 28, 2017

Conversation

chrishoffman
Copy link
Contributor

Fixes #2608

shamir/shamir.go Outdated
@@ -166,13 +167,16 @@ func Split(secret []byte, parts, threshold int) ([][]byte, error) {
return nil, fmt.Errorf("cannot split an empty secret")
}

// Generate random list of x coordinates
xCoordinates := mathrand.Perm(255)
Copy link
Member

Choose a reason for hiding this comment

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

I did not know about rand.Perm -- neat!

@jefferai
Copy link
Member

LGTM. Adding @armon for an extra look since he handled the original code.

@jefferai jefferai requested a review from armon April 20, 2017 11:54
@chrishoffman
Copy link
Contributor Author

Good catch. It was an efficiency change but I also forgot the original intent of the change. Back to 255.

@armon
Copy link
Member

armon commented Apr 20, 2017

My only concern is using math/rand instead of crypto/rand. Otherwise looks good!

@chrishoffman
Copy link
Contributor Author

@armon I don't think we need a cryptographically secure random x coordinate. All we are doing is shuffling the x coordinates so we don't leak any information about how many shares we might be issuing. The original issue #2608 does a good job explaining the issue.

@armon
Copy link
Member

armon commented Apr 20, 2017

@chrishoffman If the permutation you get back is always consistently ordered, it makes it easy to map backwards to the actual lower bound. At the least, math/rand should be randomly seeded on start.

@chrishoffman
Copy link
Contributor Author

chrishoffman commented Apr 20, 2017

Thanks @armon for bringing this to my attention. It looks like I made a bad assumption about automatic seeding in math/rand. I added a seed.

Copy link
Member

@vishalnayak vishalnayak left a comment

Choose a reason for hiding this comment

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

LGTM! Nicely done.

@jefferai jefferai added this to the 0.7.1 milestone Apr 27, 2017
@chrishoffman chrishoffman merged commit b4602fc into master Apr 28, 2017
@chrishoffman chrishoffman deleted the issue-2608 branch August 9, 2017 15:29
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