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

refactor: Make tests generic w.r.t. curve/group #40

Merged
merged 4 commits into from
Jul 20, 2023

Conversation

oskarth
Copy link
Collaborator

@oskarth oskarth commented Jul 17, 2023

Addresses #34

Should cover all files

Weird new clippy warning only in CI
src/ccs/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

I'm not in favour of merging this.
It's non-sensical to actually transform the tests into trait-dependant fns and then create new tests that call the old ones passing the type of the generic.

It just adds more code, and no apparent benefit. As whatever passes the tests for pasta, will do for any other cycle.

src/ccs/cccs.rs Show resolved Hide resolved
@arnaucube
Copy link
Collaborator

Regarding generic tests, looks like is also being done in upstream, eg: https://github.com/microsoft/Nova/blob/main/src/nifs.rs#L388

Copy link
Member

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

After discussing privately, seems I agreed to go that way 😅 hahahah

So let's go that way considering that we also have the same format upstream.
Apologies for the noise.

@oskarth oskarth requested a review from arnaucube July 20, 2023 08:53
@oskarth
Copy link
Collaborator Author

oskarth commented Jul 20, 2023

Ready to be merged

@oskarth
Copy link
Collaborator Author

oskarth commented Jul 20, 2023

CI passed before https://github.com/privacy-scaling-explorations/Nova/actions/runs/5577103414 and only comment change, merging now to make it easier for others to rebase

@oskarth oskarth merged commit 9a508b2 into main Jul 20, 2023
1 check passed
@oskarth oskarth deleted the refactor/generic-tests branch July 20, 2023 08:56
hero78119 pushed a commit to hero78119/SuperNova that referenced this pull request Jan 3, 2024
* Add DigestBuilder.

* Make digest and claims private.

* refactor: Refactor DigestBuilder

- Refactored `src/digest.rs` to replace `Vec<u8>` storage with dedicated Write I/O.
- Removed optional `hasher` and introduced dedicated factory method.
- Reworked digest computation and mapping into separate functions.
- Merged build and digest computation to enhance coherence.
- Improved type safety with Result error propagation.

* Propagate DigestBuilder changes.

* Fix tests.

* Correct assertion for OutputSize scale.

* Remove commented.

* Remove dbg!.

* Fixup rebase.

---------

Co-authored-by: porcuquine <porcuquine@users.noreply.github.com>
Co-authored-by: François Garillot <francois@garillot.net>
Ethan-000 pushed a commit to Ethan-000/Nova that referenced this pull request Jun 2, 2024
* Add DigestBuilder.

* Make digest and claims private.

* refactor: Refactor DigestBuilder

- Refactored `src/digest.rs` to replace `Vec<u8>` storage with dedicated Write I/O.
- Removed optional `hasher` and introduced dedicated factory method.
- Reworked digest computation and mapping into separate functions.
- Merged build and digest computation to enhance coherence.
- Improved type safety with Result error propagation.

* Propagate DigestBuilder changes.

* Fix tests.

* Correct assertion for OutputSize scale.

* Remove commented.

* Remove dbg!.

* Fixup rebase.

---------

Co-authored-by: porcuquine <porcuquine@users.noreply.github.com>
Co-authored-by: François Garillot <francois@garillot.net>

feat: add a digest to R1CSShape (privacy-scaling-explorations#49)

* refactor: Refactor Digestible trait

- Removed `to_bytes` method from the `Digestible` trait in `src/digest.rs` file.

* fix: Make bincode serialization in digest.rs more rigorous

- Updated `bincode::serialize_into(byte_sink, self)` with a configurable version to enable "little endian" and "fixint encoding" options.
- Added a comment in `src/digest.rs` about `bincode`'s recursive length-prefixing during serialization.

* refactor: Refactor digest computation using `OnceCell` and `DigestComputer`

This gives up on a generic builder and instead uses an idempotent `OnceCell`
+ a generic digest computer to populate the digest of a structure.

- this shows how to set up digest computation so it doesn't depend on the digest field,
- the digest can't be set twice,
- an erroneous digest can't be inferred from the serialized data.

In Details:

- Overhauled digest functionality in multiple files by replacing `DigestBuilder` with `DigestComputer`, significantly altering the handling of hashes.
- Incorporated `once_cell::sync::OnceCell` and `ff::PrimeField` dependencies to improve performance and simplify code.
- Modified `VerifierKey` and `RunningClaims` structures to include a `OnceCell` for digest, leading to a change in function calls and procedures.
- Simplified `setup_running_claims` by removing error handling and directly returning `RunningClaims` type.
- Adapted test functions according to the changes including the removal of unnecessary unwrapping in certain scenarios.
- Updated Cargo.toml with the new dependency `once_cell` version `1.18.0`.

* refactor: rename pp digest in VerifierKey to pp_digest

* feat: add a digest to R1CSShape

* fix: Small issues

- Introduced a new assertion within the `write_bytes` method of `src/supernova/mod.rs` for validating whether the `claims` are empty
- Improved code comment clarity regarding the creation of a running claim in `src/supernova/mod.rs`.

Co-authored-by: porcuquine <1746729+porcuquine@users.noreply.github.com>
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