-
Notifications
You must be signed in to change notification settings - Fork 168
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
Adds neff shuffling of sequences #457
Conversation
7706572
to
d7e49d7
Compare
d7e49d7
to
5cea1f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly style issues, but one cryptographic issue with the choice of the random number for the shuffle.
examples/neff_shuffle_test.go
Outdated
xs := make([]kyber.Point, sequenceLen) | ||
ys := make([]kyber.Point, sequenceLen) | ||
|
||
for i := 0; i < sequenceLen; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using twice the same iterator i
, please change one.
Here and in other places.
shuffle/shuffle_test.go
Outdated
for i := 0; i < k; i++ { | ||
c[i] = suite.Scalar().Pick(rand) | ||
C[i] = suite.Point().Mul(c[i], nil) | ||
// fmt.Println(" "+C[i].String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debugging strings.
Kudos, SonarCloud Quality Gate passed! |
🔒 Could not start CI tests due to missing safe PR label. Please contact one of the repo maintainers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any error in the crypto, mostly stylistic comments: feel free to integrate them or ignore them if they aren't coherent with the code base.
|
||
// This example illustrates how to use the Neff shuffle protocol with simple, | ||
// single pairs. | ||
func Test_Example_Neff_Shuffle_Simple(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use MixedCaps instead of underscores, but others examples use underscores too, so I guess that's fine. Other examples uses /* ... */
for the example explanation, maybe we want to remain consistent.
cs := make([]kyber.Point, numPairs) | ||
|
||
for i := 0; i < numPairs; i++ { | ||
c := suite.Point().Mul(suite.Scalar().Pick(suite.RandomStream()), nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd assign the point directly to cs[i]
, same for ks[i]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad practice, in my opinion. It makes the code less readable.
|
||
"github.com/stretchr/testify/require" | ||
"go.dedis.ch/kyber/v3" | ||
kproof "go.dedis.ch/kyber/v3/proof" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you use kproof
? I think proof
is fine and later we can use p
instead of proof
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a non crypto guy, I highly appreciate when variables are not only single letters :D
shuffle/sequences.go
Outdated
// | ||
// Variable names are as representative to the paper as possible. Instead of | ||
// representing (variable name with a bar on top), such as (X with a bar on top) | ||
// with Xbar, we represent it with a repeating letter, such as XX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it would be easier to use Xbar
instead of XX
since the paper uses
shuffle/sequences.go
Outdated
|
||
// Fisher–Yates shuffle | ||
for i := k - 1; i > 0; i-- { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove empty line.
shuffle/sequences.go
Outdated
// "Verifiable Mixing (Shuffling) of ElGamal Pairs" by Andrew Neff (April 2004) | ||
// | ||
// The function expects X and Y to be the same dimension, with each row having | ||
// the same length. It also expect X and Y to have at least one element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we don't enforce this at the beginning of the function? Since the cost of the assertion is negligible, I'd add it.
Kudos, SonarCloud Quality Gate passed! |
Based on the work from @lhmerino (https://github.com/dedis/votegral/blob/master/apps/Cothority/votegral/lib/crypto/shuffle.go)