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

Introduce Horner evaluation ops #1656

Merged
merged 12 commits into from
Feb 24, 2025
Merged

Introduce Horner evaluation ops #1656

merged 12 commits into from
Feb 24, 2025

Conversation

Al-Kindi-0
Copy link
Collaborator

Closes #1600

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 nits & questions


![rcomb_base](../../assets/design/stack/crypto_ops/RCOMBBASE.png)
![horner_eval_base](../../assets/design/stack/crypto_ops/HORNERBASE.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

This file doesn't exist yet right? I still see RCOMBASE.png but no HORNERBASE.png

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 them now

Comment on lines +264 to +279
#rcomb_base
push.0 drop
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming you'll update this after we merge #1658?

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 am now working, in a separate PR against this branch, on updating Falcon and it should be done today. I think it is better if we hold off on merging this one until then.

@@ -68,7 +68,7 @@ impl AuxTraceBuilder {

debug_assert_eq!(*t_chip.last().unwrap(), E::ONE);
// TODO: Fix and re-enable after testing with miden-base
// debug_assert_eq!(*b_chip.last().unwrap(), E::ONE);
debug_assert_eq!(*b_chip.last().unwrap(), E::ONE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean miden-base tests now pass? Was the bug only with the RCOMBBASE instruction then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All tests passed with the above line uncommented for RCOMBBASE and I uncommented that line to test for the correctness of the implementation for HORNER* ops.
I will put the comment back as I haven't tested with miden-base

The effect on the rest of the stack is:
* **No change.**

> TODO: add detailed constraint descriptions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we doing this in this PR?

Copy link
Collaborator Author

@Al-Kindi-0 Al-Kindi-0 Feb 11, 2025

Choose a reason for hiding this comment

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

#1660
I am thinking this might be implemented directly in AirScript

Copy link
Contributor

Choose a reason for hiding this comment

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

Then I would remove this TODO from the docs, as they tend to stick around, and it makes for cleaner docs not to have any in there

@Al-Kindi-0 Al-Kindi-0 force-pushed the al-introduce-horner-eval-ops branch from 86cddd7 to 3c6f139 Compare February 11, 2025 13:02
Copy link
Contributor

@bobbinth bobbinth 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! Thank you! I left some a couple of questions and a few small comments inline.

alphas,
row,
eval_point_ptr,
[eval_point_0, eval_point_1, ZERO, ZERO],
Copy link
Contributor

@plafer plafer Feb 13, 2025

Choose a reason for hiding this comment

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

An insight gained from #1664 is that the RCOMBBASE request would fail to match the response by the memory chiplet when the positions 2 and 3 here are not ZERO, ZERO. This happened specifically in the falcon signature code. I didn't investigate more, but my assumption is that memory was reused (probably with the use of procedure locals), and that there are leftover garbage values in those positions.

Hence the fix is to fully read the memory word in the helper registers and include it in the bus message. This learning applies generally too: when we read a word, we must read it entirely and include it all in the bus message, since the "zeroed-out memory" assumption doesn't always hold.

Ideally, we'd add a test also to check that when there are non-zero values in positions 2 & 3, that the bus doesn't fail.

EDIT: Upon closer examination, I don't believe the values in memory from the miden-base are garbage. Since this code is changing with #1661, I will stop investigating; we can see if somehow the problem was fixed when switching to horner base eval.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, thinking more, the larger problem in miden-base seems more to be that the data in the advice provider is wrong, such that the pipe doesn't insert 0s where there should be some.

Regardless, it's probably safer to fully read the word anyway instead of assuming the memory was zero'd in those positions.

Copy link
Contributor

@bobbinth bobbinth 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! Sorry for such a delayed review! I left one comment inline about potentially changing how we describe things in the doc comments - the code itself looks fine.

Also, I think we need to merge the latest next into this branch as the file structure for the auxiliary trace generation has changed a bit.

@Al-Kindi-0 Al-Kindi-0 force-pushed the al-introduce-horner-eval-ops branch from cec1812 to 6fcd075 Compare February 24, 2025 08:27
@Al-Kindi-0 Al-Kindi-0 force-pushed the al-introduce-horner-eval-ops branch from 6fcd075 to 3402f34 Compare February 24, 2025 08:44
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

All looks good! Thank you!

@Al-Kindi-0
Copy link
Collaborator Author

All looks good! Thank you!

Thank you! I think this is good to merge.

@bobbinth bobbinth merged commit 552a51f into next Feb 24, 2025
9 checks passed
@bobbinth bobbinth deleted the al-introduce-horner-eval-ops branch February 24, 2025 08:58
@bobbinth
Copy link
Contributor

I merged this, but now that I think of it, this probably broke the Falcon signature verification (at least until #1661 is merged).

@Al-Kindi-0
Copy link
Collaborator Author

Al-Kindi-0 commented Feb 24, 2025

Indeed!
I am working on #1661 now, should be done quickly but it will break miden-base. Should we un-merge?

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.

3 participants