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

Improve Falcon DSA verification procedure #1623

Open
wants to merge 4 commits into
base: next
Choose a base branch
from

Conversation

Al-Kindi-0
Copy link
Collaborator

Reduces the cycle count of the Falcon DSA signature verification procedure. This brings the total cycle count to less than 71000 cycles.
Once/if horner_eval_base is implemented, we can bring down this to hopefully 61000 cycles by removing the need for the powers_of_tau and set_to_zero procedures.

Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

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

Looks good! Left a few nits

///
/// Outputs:
/// Operand stack: [a1, a0, ...]
/// Advice stack: [q0, q1, r, ...]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Advice stack: [q0, q1, r, ...]
/// Advice stack: [q1, q0, r, ...]

Based on the implementation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we want that adv_push.1 pushes q0 first and when we call again adv_push.1 it pushes q1.

padw
dup.12
dup.12 add.1281
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make 1281 a constant to ease readability (even if it's documented in the docstring)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added

Comment on lines 626 to 641
padw
dup.4 add.1 swap.5
dup.4
mem_loadw

repeat.4
exec.norm_sq
movdn.4
end

exec.norm_sq
swap
exec.norm_sq
add
swap
exec.norm_sq
add
swap
exec.norm_sq
add
swap
add.1
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add comments that tracks what happens on the stack in this block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, added comments to help track what's happening

Comment on lines 88 to 91
let v = rand::thread_rng().gen_range(0..Felt::MODULUS);
let (v_lo, v_hi) = (v as u32, v >> 32);
let w = rand::thread_rng().gen_range(0..J);
let u = rand::thread_rng().gen_range(0..J);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should move away from using randomly-generated values in unit tests; if we randomly fall on a failing value, we won't be able to reproduce. Broadly speaking, unit tests should test specific hardcoded values, while prop tests should do the "sweeping" (as you're doing below)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, with proptest, the above is redundant as is. Changed it now to be deterministic

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.

2 participants