-
Notifications
You must be signed in to change notification settings - Fork 7
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
ML-DSA: Add rejection sampling functions #195
Conversation
b659790
to
247fe0d
Compare
type Byte = [8] | ||
|
||
/** | ||
* Ring defined as the product of 255 elements in `Z q` used for NTT. |
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.
The array is still 256 for this correct since it is storing X^^0 as well? I get that this only goes up to X^^255 is that what you are implying by this being 255?
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 you're right, that was just a mistake on my part. The definition on page 6 is
// Step 7 - 9. The recursive call here replaces the `while` loop. | ||
a_hat' = case a_hat_j of | ||
Some aj -> [aj] # (sample ctx) | ||
None -> sample ctx |
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.
not sure if it is worth mentioning that the spec just overwrites this part of the "stream" on this case hence why it is safe to just skip writing it
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.
Good call, this was confusing when I came back to it. Added some docs.
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.
LGTM
I'm adding this now so I can write internal properties as I go and have confidence that they're correct.
247fe0d
to
3c3d2e6
Compare
Closes #182.
Adds a few functions for rejection sampling.
I compared some of these to the versions in the IPD. The hash functions are the same. The
CoeffFrom...
functions are the same.RejBoundedPoly
matches. The seed forRejNTTPoly
is a different size and I tried to compare them, but it didn't work. I feel pretty confident about my implementation, though, so I'm willing to wait to see if we get an error at a higher level.