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

feat(precompile): add bn254 precompile #384

Merged
merged 20 commits into from
Mar 28, 2024

Conversation

0xkanekiken
Copy link
Contributor

@0xkanekiken 0xkanekiken commented Mar 14, 2024

This PR adds support for the bn254 curve's add and double operations by leveraging the existing weierstrass precompile.

  • Added support for bn254_mul by leveraging bn254_add and bn254_double. One operation of bn254 is taking 3,806,937 vm cycles.

@0xkanekiken 0xkanekiken force-pushed the kaneki-bn254-precompile branch from eff4894 to e977a32 Compare March 18, 2024 13:36
Copy link
Contributor

@puma314 puma314 left a comment

Choose a reason for hiding this comment

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

generally looks pretty good! few minor comments

zkvm/entrypoint/src/syscalls/bn254.rs Show resolved Hide resolved
}

impl Bn254AffinePoint {
pub fn from(x: [u32; 8], y: [u32; 8]) -> Self {
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 reuse code with the other AffinePoint? this seems like a lot of this copy-pasted from another file

Copy link
Contributor Author

@0xkanekiken 0xkanekiken Mar 19, 2024

Choose a reason for hiding this comment

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

core/src/utils/ec/weierstrass/bn254.rs Outdated Show resolved Hide resolved
core/src/utils/ec/weierstrass/bn254.rs Outdated Show resolved Hide resolved
core/src/utils/ec/field.rs Outdated Show resolved Hide resolved
@0xkanekiken 0xkanekiken marked this pull request as ready for review March 19, 2024 09:22
Signed-off-by: 0xkanekiken <[email protected]>
@0xkanekiken
Copy link
Contributor Author

Just an update on the VM cycles: bn254_mul and secp256k1_mul are taking approximately ~2800 cycles.

@0xkanekiken 0xkanekiken requested a review from puma314 March 19, 2024 12:29
book/writing-programs/precompiles.md Outdated Show resolved Hide resolved
zkvm/precompiles/src/utils.rs Outdated Show resolved Hide resolved
tests/secp256k1-mul/Cargo.toml Outdated Show resolved Hide resolved
tests/bn254-mul/Cargo.toml Outdated Show resolved Hide resolved
@0xkanekiken 0xkanekiken requested a review from ctian1 March 25, 2024 13:37
Signed-off-by: 0xkanekiken <[email protected]>
core/src/utils/ec/weierstrass/bn254.rs Outdated Show resolved Hide resolved
Signed-off-by: 0xkanekiken <[email protected]>
Signed-off-by: 0xkanekiken <[email protected]>
Signed-off-by: 0xkanekiken <[email protected]>
Signed-off-by: 0xkanekiken <[email protected]>
Signed-off-by: 0xkanekiken <[email protected]>
@0xkanekiken 0xkanekiken requested a review from puma314 March 28, 2024 02:50
@puma314 puma314 merged commit 0c4c91a into succinctlabs:main Mar 28, 2024
5 checks passed
@0xkanekiken 0xkanekiken deleted the kaneki-bn254-precompile branch March 28, 2024 20:20
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