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

p256 acceleration #10

Open
wants to merge 21 commits into
base: release-p256/v0.13.2
Choose a base branch
from
Open

Conversation

austinabell
Copy link

@austinabell austinabell commented Dec 12, 2024

Currently accelerates the muls and is ~8-9x speedup, but there is a lot of slop due to the unaccelerated conversion from projective to affine. Also unfortunate that this implementation has BE representation internally, so some unfortunate copies again as with k256.

TODO:

  • Accelerate proj -> affine -> proj
  • Reduce conversion logic
    • Unfortunate this is so generic, and there might be some extra copies that can't be guaranteed to be optimized away
  • Explore different bit widths acceleration (out of scope for this)
    • Currently just errors in compile time with this (which I think is correct, shouldn't accidentally be using this for other crates in this repo
  • Add acceleration for other code paths other than just mul (not sure where/how it might be used)
  • Check const time signature gen (or panic on usage in zkvm) documented non const time
  • Update version to 1.2.1 when released (requires Add modular arithmetic precompiles risc0#2653 to be included)

@austinabell austinabell changed the title zkvm config to allow tests to run in zkvm [WIP] p256 acceleration Dec 18, 2024
@austinabell austinabell marked this pull request as ready for review January 7, 2025 18:21
@austinabell austinabell changed the title [WIP] p256 acceleration p256 acceleration Jan 7, 2025
@austinabell austinabell requested a review from tzerrell January 7, 2025 18:22
Copy link
Member

@tzerrell tzerrell left a comment

Choose a reason for hiding this comment

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

I'm not convinced we're tracking the identity correctly, especially in various places we make affine/projective conversions and conversions in and out of risc zero types. Can you take a look and either make fixes or help me understand how the identity is being handled?

primeorder/src/risc0.rs Outdated Show resolved Hide resolved
primeorder/src/risc0.rs Show resolved Hide resolved
primeorder/src/risc0.rs Show resolved Hide resolved
primeorder/src/affine.rs Show resolved Hide resolved
primeorder/src/risc0.rs Show resolved Hide resolved
primeorder/src/projective.rs Show resolved Hide resolved
Copy link
Member

@tzerrell tzerrell left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, they look good!

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