-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Signed-digit multi-comb for ecmult_gen #546
Changes from 1 commit
75d9e97
09ca146
e8beef9
183a7ff
e848342
4c8ff9b
9156619
91179c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,13 +225,14 @@ static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context *ctx, secp25 | |
bit_pos = comb_off; | ||
for (block = 0; block < COMB_BLOCKS; ++block) { | ||
#if COMB_GROUPED | ||
bits = (recoded[bit_pos >> 5] >> (bit_pos & 0x1F)) & ((1 << COMB_TEETH) - 1); | ||
bit_pos += COMB_SPACING * COMB_TEETH; | ||
bits = recoded[bit_pos >> 5] >> (bit_pos & 0x1F); | ||
bit_pos += COMB_TEETH; | ||
#else | ||
bits = 0; | ||
for (tooth = 0; tooth < COMB_TEETH; ++tooth) { | ||
bit = (recoded[bit_pos >> 5] >> (bit_pos & 0x1F)) & 1; | ||
bits |= bit << tooth; | ||
bit = recoded[bit_pos >> 5] >> (bit_pos & 0x1F); | ||
bits &= ~(1 << tooth); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this bit-clearing line isn't actually needed, because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that ‘bit’ may now contain junk (or noise) bits beyond bit 0. Iterations after the first therefore need to clear the target bit (and we try to leave noise in the high bits). The change is in response to [1], which I think @gmaxwell mentioned on IRC a while back. [1] https://www.usenix.org/system/files/conference/usenixsecurity18/sec18-alam.pdf There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! I understand, I was misreading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the variable is named |
||
bits ^= bit << tooth; | ||
bit_pos += COMB_SPACING; | ||
} | ||
#endif | ||
|
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 this be done as part of a cmov ladder, like the old algorithm, to avoid cache-timing attacks?
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.
This line is reading a window from the scalar. IIUC, the cmov ladder you mean is the _ge_storage_cmov loop at lines 255-257.
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.
Oh, yes! I missed that - you do indeed have a cmov ladder at the point where the secret data is actually used. Thanks.