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

Hashed provable type #1377

Merged
merged 10 commits into from
Feb 1, 2024
Merged

Hashed provable type #1377

merged 10 commits into from
Feb 1, 2024

Conversation

mitschabaude
Copy link
Member

@mitschabaude mitschabaude commented Jan 18, 2024

bindings: o1-labs/o1js-bindings#238

This follows up on #1376 with a variant of the same idea: Instead of representing a value by its packed field elements, we now represent it by its hash.

The benefit is that a hash is (potentially) even smaller than packed field elements -- it's a single field element. So, this can achieve a better improvement to constraint count as Packed, in the same situations.

The downside is that the overhead of hashing is much higher than that of packing, so there might be scenarios where either technique is better.

We use Hashed instead of Packed in ECDSA, which achieves a tiny improvement in combination with changing one of the default parameters for point caching (it's slightly worse with the original parameters, which were the optimal ones before, so we see that there's a trade-off. Also, packing seems still better for constant points, but I don't think it's worth adding the complexity of using different representation depending on whether the point is constant)

This also directly exposes the low-level tool underneath - Poseidon.hashPacked<T>(), to improve the Poseidon.hash(value.toFields()) pattern found in many code bases

Base automatically changed from feature/packed-provable to main February 1, 2024 09:05
@mitschabaude mitschabaude marked this pull request as ready for review February 1, 2024 09:16
@mitschabaude mitschabaude requested a review from a team as a code owner February 1, 2024 09:16
@@ -416,10 +416,10 @@ function multiScalarMul(

// pack points to make array access more efficient
Copy link
Member

Choose a reason for hiding this comment

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

it's a hashed point now!
// hashed points to make array access more efficient

@mitschabaude mitschabaude merged commit d99fceb into main Feb 1, 2024
11 checks passed
@mitschabaude mitschabaude deleted the feature/hashed-provable branch February 1, 2024 11:46
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.

None yet

2 participants