-
Notifications
You must be signed in to change notification settings - Fork 36
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: avoid superfluous clones in ProverKey
and VerifierKey
for Nova & SuperNova
#285
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
huitseeker
force-pushed
the
killing_params
branch
from
January 29, 2024 21:41
51ff4b3
to
a20f871
Compare
- Major changes in the handling of the Commitment Key object across several files, moving from direct references to using the Arc (Atomic Reference Counting) mechanism for improved thread-safety and efficient sharing of data. - Removed the `Abomonation` trait from several structures, such as `ProverKey` and `VerifierKey`. - Introduced the `SimpleDigestible` trait to VerifierKey in several files, allowing them to be converted into a digestible form for hashing or storage. - Numerous updates in test cases and instances to reflect the shift from direct Commitment Key references to Arc. - Refactoring of the `setup` and `prove` methods in multiple files to handle the Arc type for Commitment Key. - Removal of several `abomonate_with` and `abomonation_skip` attribute annotations. - Enhancement of error details in multiple `assert` statements. - Added "rc" feature to the serde dependency in the Cargo.toml file. - Made comments on minimizing unnecessary data copies and keeping `setup` methods inexpensive.
- Extended functionality in `lib.rs` with new `PublicParams` structure, efficient abomonationwith `FlatPublicParams`, - Updated `mod.rs` for conditional feature `abomonate`, added `AuxParams` struct, and implemented conversions between `AuxParams` and `FlatAuxParams`. - demoed the new use of Abomonation in the minroot example
huitseeker
force-pushed
the
killing_params
branch
from
January 29, 2024 21:53
a20f871
to
78741eb
Compare
- Removed Abomonation dependency from several files.
huitseeker
force-pushed
the
killing_params
branch
from
January 30, 2024 21:46
49f3835
to
3d5e341
Compare
huitseeker
added a commit
to lurk-lab/lurk-beta
that referenced
this pull request
Jan 30, 2024
This adapts to upstream lurk-lang/arecibo#285, which removes the need for separate `ProverKey` and `VerifierKey` instances (the former containing `CommitmentKey` copies) in Public Parameters. - Implemented structural changes in `nova.rs` for improvements in key handling for the prover and verifier keys, which generated as `OnceCell`, - Revamped `disk_cache.rs` with added `Arc` imports, elimination of lifetime parameter `'a` from `DiskCache`, modifications of `read` and `write` functions, and updates in the serialization and deserialization steps. - Altered `public_params` and `supernova_public_params` functions in `mod.rs` to deal more capably with errors and modified various methods and tests to align with the changes in `disk_cache.rs`. - Removed complete `mem_cache.rs` file, which was unsafe, and unused. - Moved initialization of `store` to an earlier point in `fibonacci_prove` function and made minor formatting changes in `fibonacci.rs`.
huitseeker
added a commit
to lurk-lab/lurk-beta
that referenced
this pull request
Jan 30, 2024
This adapts to upstream lurk-lang/arecibo#285, which removes the need for separate `ProverKey` and `VerifierKey` instances (the former containing `CommitmentKey` copies) in Public Parameters. - Implemented structural changes in `nova.rs` for improvements in key handling for the prover and verifier keys, which generated as `OnceCell`, - Revamped `disk_cache.rs` with added `Arc` imports, elimination of lifetime parameter `'a` from `DiskCache`, modifications of `read` and `write` functions, and updates in the serialization and deserialization steps. - Altered `public_params` and `supernova_public_params` functions in `mod.rs` to deal more capably with errors and modified various methods and tests to align with the changes in `disk_cache.rs`. - Removed complete `mem_cache.rs` file, which was unsafe, and unused. - Moved initialization of `store` to an earlier point in `fibonacci_prove` function and made minor formatting changes in `fibonacci.rs`.
winston-h-zhang
approved these changes
Jan 31, 2024
github-merge-queue bot
pushed a commit
to lurk-lab/lurk-beta
that referenced
this pull request
Jan 31, 2024
* refactor: Refactor public parameters handling and caching This adapts to upstream lurk-lang/arecibo#285, which removes the need for separate `ProverKey` and `VerifierKey` instances (the former containing `CommitmentKey` copies) in Public Parameters. - Implemented structural changes in `nova.rs` for improvements in key handling for the prover and verifier keys, which generated as `OnceCell`, - Revamped `disk_cache.rs` with added `Arc` imports, elimination of lifetime parameter `'a` from `DiskCache`, modifications of `read` and `write` functions, and updates in the serialization and deserialization steps. - Altered `public_params` and `supernova_public_params` functions in `mod.rs` to deal more capably with errors and modified various methods and tests to align with the changes in `disk_cache.rs`. - Removed complete `mem_cache.rs` file, which was unsafe, and unused. - Moved initialization of `store` to an earlier point in `fibonacci_prove` function and made minor formatting changes in `fibonacci.rs`. * refactor: Refactor code to remove lifetime on Instance + Abomonation dependency - Removed `Abomonation` trait and `PrimeField` imports from `multiframe.rs`, also simplified the `NonUniformCircuit` access in the same file. - Removed `Abomonation` trait bounds from the `circuit_cache_key` functions in `supernova.rs`. - Refactored `Instance<>` struct in `instance.rs`, removing the usage of `Abomonation` and `PhantomData`, and eliminated need for lifetime declaration `'a`. - Enhanced `open()` method in `instance.rs` to include metadata comparison to prevent instance mismatches. * refactor: Adapt SuperNova parameters and remove superfluous Abomonation bounds - Improved `supernova.rs` by using `OnceCell` to store `ProverKey` and `VerifierKey` and updating related methods, - removed uneeded Abomonation bounds in a few places. * chore: slience clippy * refactor: Refactor PublicParams cache to remove obsolete std::sync::Arc usage - reduced complexity by removing `std::sync::Arc` in `src/public_parameters/disk_cache.rs`. - Modified `read` and `write` functions in `DiskCache` to work directly with `PublicParams`. * chore: remove anymap dependency * chore: point the dependency back to Arecibo's dev
gabriel-barrett
pushed a commit
to gabriel-barrett/arecibo
that referenced
this pull request
Feb 9, 2024
…g#226) * Expose the last outputs and number of steps from RecursiveSNARK (lurk-lang#285) Both of these data are easily accessible, and could be very useful to clients: * Exposing the last outputs allows us to get the current state of the computation on the prover side without wasting energy recomputing it * Exposing the number of steps makes it easier to eventually pass `num_steps` into `CompressedSNARK::verify` * Improve error handling (lurk-lang#286) * When a function already returns a `Result`, propagate errors instead of panicking with `expect` * For `NovaError::SynthesisError`, retain information about the original bellpepper error. Since `NovaError` implements `Clone` but bellpepper's `SynthesisError` does not, we keep the error information as a `String`. This commit only fixes low-hanging fruit in lib.rs, for functions that already return a `Result` and can easily propagate errors just by replacing `expect(...)` with `?`. There are still many `unwrap()` calls in functions returning `Result` in other modules, particularly gadgets. But I don't understand the code well in those parts, and I suspect some of those `unwrap()`s actually can't fail based on invariants of the code, so it makes perfect sense to leave them as is. Co-authored-by: Francois Garillot <francois@lurk-lab.com> --------- Co-authored-by: Jeb Bearer <jeb.bearer@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR removes extra copies of the
CommitmentKey
in theProverKey
andVerifierKey
.Using the results of this PR, we hope to remove the ProverKey and VerifierKey in Lurk's PublicParams, leaving only the nova::PublicParams field there, from which it's cheap to derive the removed fields as needed,
In Detail
This notices that it is fundamentally cheap to derive prover and verifier key from a set of universal public parameters (in nova parlance, the
CommitmentKey
), and takes that into motion:EvaluationEgine
are deterministic and near-free,CompressedSNARK
,Serialize
,Deserialize
andAbomonate
bounds on allProverKey
s,Deserialize
andAbomonate
bounds on allVerifierKey
s,Serialize
bound on theVerifierKey
is momentarily kept in order to compute itsDigestible
instance usingSimpleDigestible
(it's not essential to keep, but a bit involved for this short PR)In More Detail: repairing the
Abomonate
functionalityThis introduces
Arc
inside the fields of thePublicParams
data structures, which is at odds withAbomonate
-ing them in the course of a proof. Since it is highly non trivial (if at all possible) toAbomonate
something under anArc
, we bypass the problem in the following way:FlatPublicParams
, a facade with noArc
, which we know how toAbomonate
TryFrom<PublicParams> for FlatPublicParams
andFrom<FlatPublicParams> for <PublicParams>
,The
TryFrom<PublicParams> for FlatPublicParams
relies onArc::try_unwrap
for each of the two problematic fields, and the only thing we'd have to take care of at runtime is that we haven't left a trailingProverKey
orVerifierKey
in scope before doing the conversion.Then instead of trying to have
Abomonate
on thePublicParams
, what the caching logic does isFlatPublicParams::try_from(nova_public_params)?.encode()
andPublicParams::from(decode::<FlatPublicParams>(bytes).clone())
. We demonstrate that in the minroot example.Note
Lurk is not expected to compile on top of this. Companion PR at lurk-lab/lurk-beta#1085