Skip to content

[Do not merge until Git dependencies removed] Uncompressed Encoding for Affine Points - #179

Closed
Hanting Zhang (winston-h-zhang) wants to merge 1 commit into
microsoft:mainfrom
lurk-lang:uncompressed
Closed

[Do not merge until Git dependencies removed] Uncompressed Encoding for Affine Points#179
Hanting Zhang (winston-h-zhang) wants to merge 1 commit into
microsoft:mainfrom
lurk-lang:uncompressed

Conversation

@winston-h-zhang

@winston-h-zhang Hanting Zhang (winston-h-zhang) commented Jun 6, 2023

Copy link
Copy Markdown
Contributor

This PR implements a feature (uncompressed_serde) that optimizes the speed of serializing public parameters by using an uncompressed encoding that removes the overhead of computing the second coordinate of points. Note: this PR depends on PRs in pasta_curves and neptune, here: zcash/pasta_curves#73 and lurk-lab/neptune#192. For now, we point at branches on lurk-lab maintained forks.

I compared the performance on the minroot public parameters. Based on some eyeballing benchmarks run on my local machine, deserialization time reduces from 2.7s to 100ms. Downstream in lurk-rs, where the circuit is much bigger -- and serde has become a significant time factor in initializing proving times -- deserialization time on the sha256 example reduces from 120s to 7s. Note, the uncompressed encoding for pasta points are [u8; 64], so this does have the downside of eating twice as much memory compared to the normal/compressed encoding.

The significant improvement in deserialization time makes caching public parameters viable. This would short circuit the need to regenerate costly public parameters each run, improving the develop/iterate experience. This infrastructure currently exists in lurk-rs, and this PR mainly wants to improve its efficiency. Although hopefully, this clarifies a growing need for systematic approach to deal with public parameters in Nova, and leaves future work open to discussion.

As for the feature itself, it is implemented via the UncompressedEncoding trait in group. We only apply the uncompressed serde to CommitmentKey, since the structure stores 90% of the data.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[on MinRoot] deserialization time reduces from 2.7s to 100ms. Downstream in lurk-rs, where the circuit is much bigger [...] deserialization time on the sha256 benchmark reduces from 120s to 7s.

Nice work!

@winston-h-zhang

Hanting Zhang (winston-h-zhang) commented Jun 7, 2023

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="lurk-lab"

@winston-h-zhang

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Lurk Lab"

@CPerezz

Copy link
Copy Markdown
Contributor

This will probably be superset by #198

Also, if we plan to move to halo2curves we already provide this functionallity in our SerdeObject trait. See: https://github.com/privacy-scaling-explorations/halo2curves/blob/main/src/serde.rs

@srinathsetty

Copy link
Copy Markdown
Collaborator

Hi Hanting Zhang (@winston-h-zhang) is this PR still being worked on? I've heard interest in this from several others.

@huitseeker

Copy link
Copy Markdown
Contributor

This is blocked on zcash/pasta_curves#73

@srinathsetty

Copy link
Copy Markdown
Collaborator

Hi CPerezz (@CPerezz)

This will probably be superset by #198

Also, if we plan to move to halo2curves we already provide this functionallity in our SerdeObject trait. See: https://github.com/privacy-scaling-explorations/halo2curves/blob/main/src/serde.rs

What is the best way to use SerdeObject trait to get fast deserialization of field elements? Are there examples of this somewhere to compose this automatically with serde's methods?

@huitseeker

Copy link
Copy Markdown
Contributor

Srinath Setty (@srinathsetty) some answers to these questions might reside in privacy-ethereum/halo2curves#39

@CPerezz

Copy link
Copy Markdown
Contributor

Srinath Setty (@srinathsetty) this is a trait we have for raw/unchecked(and therefore fast) serde. It's not integrated with the regular serde.
The fastest way to serialize/deserialize in terms of CPU time is the raw_checked. As it doesn't imply any tests of correctness of well formation as well as implies that there are no extra ops to perform (no derivation of y coordinate from x or stuff like this.

@srinathsetty

Copy link
Copy Markdown
Collaborator

It seems like this may be a stale PR. Please reopen this if we want to pursue it.

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.

4 participants