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

rlp + tests #1

Merged
merged 8 commits into from
Nov 21, 2023
Merged

rlp + tests #1

merged 8 commits into from
Nov 21, 2023

Conversation

nikkolasg
Copy link
Collaborator

This code and associated test comes mostly from the previous codebase from recursive-batch-proof repo. It's a light version of the RLP stuff.
There is still a bunch of warnings because some functions do get used in other modules so currently not really used.

builder.split_le(x, n)
}

pub fn bits_to_num<F: RichField + Extendable<D>, const D: usize>(
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to do the same thing as the le_sum gadget in plonky2/src/gadgets/split_base.rs

res
}

pub fn less_than<F: RichField + Extendable<D>, const D: usize>(
Copy link
Contributor

Choose a reason for hiding this comment

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

These comparison operators could probably be rewritten using the range_check gadget

x: Target,
shift: usize,
) -> Target {
// nikko: Is this legit ? an IF depending on the witness seems
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems fishy to me as well. I'm not familiar enough with Plonky2 to know what happens behind the scenes in the circuit for the true/false cases. Perhaps right_shift adds a single row with a trivial permutation in both cases, which could be OK (depending on the circuit config?). But even if it's OK I think it should be rewritten to remove the if statement. Such things don't belong in circuits!

Copy link
Contributor

@lopeetall lopeetall left a comment

Choose a reason for hiding this comment

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

I think there are several opportunities to rewrite self-rolled functions using built-in plonky2 gadgets which are (hopefully) well-optimized, well-tested, and well-documented. We can compare the constraint counts of circuits using the self-rolled versions to using the built-ins to see if there is an improvement or not. Those optimizations can wait though...this code looks correct to me and will make a good base on which to iterate on. Good work!

@nikkolasg
Copy link
Collaborator Author

Sounds good, I've created an issue for it https://github.com/Lagrange-Labs/mapreduce-plonky2/issues/4

@nikkolasg nikkolasg merged commit aa7e829 into main Nov 21, 2023
3 checks passed
@nikkolasg nikkolasg deleted the feat/rlp branch November 21, 2023 21:33
nikkolasg added a commit that referenced this pull request Sep 20, 2024
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