Skip to content

Switched EcdsaPod and MDLPod to work with 29-bit BigInt Chunks#10

Merged
dgulotta merged 6 commits into0xPARC:mainfrom
Weobe:main
Jul 31, 2025
Merged

Switched EcdsaPod and MDLPod to work with 29-bit BigInt Chunks#10
dgulotta merged 6 commits into0xPARC:mainfrom
Weobe:main

Conversation

@Weobe
Copy link
Contributor

@Weobe Weobe commented Jul 22, 2025

Making this change allows us to write a more optimized Custom Gate for nonnative multiplication by getting rid of unnecessary carry operations

@dgulotta dgulotta self-assigned this Jul 22, 2025
@dgulotta
Copy link
Collaborator

Looks good overall! I'll add some comments on individual items.

@dgulotta
Copy link
Collaborator

Our CI automatically checks the code with cargo fmt --check and cargo clippy. It's a good idea to run these locally before pushing. You can probably configure your editor to run cargo fmt automatically whenever you save.

Copy link
Collaborator

@dgulotta dgulotta left a comment

Choose a reason for hiding this comment

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

A few things from plonky2-ecdsa:

https://github.com/Weobe/plonky2-ecdsa/blob/c2f20afcd5722235199dd8fbb88985c8b22c2d9e/src/gadgets/curve_windowed_mul.rs#L156
Extra println

https://github.com/Weobe/plonky2-ecdsa/blob/c2f20afcd5722235199dd8fbb88985c8b22c2d9e/src/gates/mul_nonnative.rs#L276-L329
It looks like this is a test and not something that should be in run_once.

https://github.com/Weobe/plonky2-ecdsa/blob/c2f20afcd5722235199dd8fbb88985c8b22c2d9e/src/gadgets/biguint.rs#L35-L37
The line let i = i.clone(); can be removed if you replace i with *i on the next line. Or you can eliminate the need to write *i by replacing for i in x with for &i in x or for i in x.iter().copied()

It would be good to add a comment about how mul_nonnative works and the assumptions being made, as well as some comments in the curve functions explaining why it's okay to do additions that are not range checked.

It would also be good to run cargo clippy on your plonky2-ecdsa and plonky2_ux repos.

.gitignore Outdated
@@ -1,2 +1,3 @@
/target
Cargo.lock
src/main.rs
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you have a file that's only your system and you don't want to commit it, you can add the path to .git/info/exclude. The .gitignore is for files that many users will have (usually because they are auto generated).

Cargo.toml Outdated
x509-parser = "0.16"
p256 = "0.13.2"
log = "0.4.14"
env_logger = "0.10.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the library use these dependencies now, or were they just for your testing?

use super::*;

#[ignore]
fn get_test_rsa_pod() -> Result<(Box<dyn RecursivePod>, VDSet, Vec<u8>)> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function isn't a test, so I don't think the #[ignore] does anything.

src/mdlpod.rs Outdated
// let recovered_pod = MdlPod::deserialize_data(params, data, vd_set, pod.id())?;
// assert!(pod.equals(recovered_pod.as_ref()));
// Ok(())
// }
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test can be ignored by default since it takes a long time to run, but it shouldn't be commented out.


#[test]
#[ignore]
fn test_rsa_pod_with_mainpod_verify() -> Result<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be at least one RSA test that isn't ignored.

src/mdlpod.rs Outdated
impl MdlVerifyTarget {
fn add_targets(builder: &mut CircuitBuilder<F, D>) -> Self {
let sig = P256VerifyTarget::add_targets(builder, MSO_MAX_BITS_PADDED);
builder.print_gate_counts(0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this is left over from testing.

@dgulotta
Copy link
Collaborator

0xPARC recently forked plonky2, and it looks like your Cargo.toml files need to be updated to use the fork. Currently pod2 is using:

plonky2 = { git = "https://github.com/0xPARC/plonky2.git", rev = "3defd60532c8693cf5e9d2e6a8412c77ca58760f", optional = true }

@dgulotta
Copy link
Collaborator

0xPARC recently forked plonky2, and it looks like your Cargo.toml files need to be updated to use the fork. Currently pod2 is using:

plonky2 = { git = "https://github.com/0xPARC/plonky2.git", rev = "3defd60532c8693cf5e9d2e6a8412c77ca58760f", optional = true }

Hmm, I guess introduction-pods is using an older version of pod2 that isn't using the plonky2 fork yet. So I'm not sure exactly why there is a conflict.

@dgulotta
Copy link
Collaborator

It looks the problem is that ax0/plonky2-u32 was updated to use the plonky2 fork. So I guess introduction-pods and your forks should be updated to use the plonky2 fork, and introduction-pods should also be updated to use the latest pod2 commit.

Sorry you ran into this!

@dgulotta
Copy link
Collaborator

If updating causes too many problems, you could instead revert to using revision a18e790 of ax0/plonky2-u32.

@dgulotta dgulotta self-requested a review July 26, 2025 03:04
Copy link
Collaborator

@dgulotta dgulotta 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 to me.

@dgulotta dgulotta merged commit 6ddfbe2 into 0xPARC:main Jul 31, 2025
5 checks passed
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