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

Add PCS types and basic setup flow using SRS #28

Merged
merged 34 commits into from
Mar 14, 2024
Merged

Add PCS types and basic setup flow using SRS #28

merged 34 commits into from
Mar 14, 2024

Conversation

tess-eract
Copy link
Contributor

@tess-eract tess-eract commented Dec 23, 2023

This adds some basic support for generating public parameters from a SRS for a polynomial commitment scheme.

@tess-eract tess-eract changed the base branch from main to dorebell-setup-patch January 4, 2024 22:38
@tess-eract tess-eract linked an issue Jan 4, 2024 that may be closed by this pull request
4 tasks
govereau pushed a commit that referenced this pull request Jan 5, 2024
* cleanup secondary circuit code

* rework relaxed nimfs

* fix circuits

* run bench build in the same profile

* reduce the number of bits to 127
@tess-eract tess-eract marked this pull request as ready for review January 5, 2024 20:48
@tess-eract tess-eract changed the base branch from dorebell-setup-patch to main January 5, 2024 20:50
@tess-eract tess-eract requested a review from govereau January 5, 2024 20:50
@govereau
Copy link
Contributor

govereau commented Jan 9, 2024

This looks good. However, I think the last patch (merge of main) is not right. Did you want to rebase the two commits not in main onto main?

govereau pushed a commit that referenced this pull request Jan 9, 2024
* cleanup secondary circuit code

* rework relaxed nimfs

* fix circuits

* run bench build in the same profile

* reduce the number of bits to 127
@tess-eract tess-eract marked this pull request as draft January 30, 2024 01:18
@tess-eract tess-eract marked this pull request as ready for review January 30, 2024 01:27
@tess-eract tess-eract marked this pull request as draft January 31, 2024 19:00
@tess-eract tess-eract marked this pull request as ready for review February 2, 2024 02:07
.gitignore Outdated
Comment on lines 7 to 9

# public parameter files
*.zst
Copy link
Contributor

Choose a reason for hiding this comment

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

This is supposed to used cache folder. If postponed for later, newline missing

prover/src/pp.rs Outdated
{
let f = File::open(file)?;
let mut dec = Decoder::new(&f)?;
let pp = PP::<SP>::deserialize_compressed(&mut dec)?;
let pp = PP::<C, SP>::deserialize_compressed_unchecked(&mut dec)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it wouldn't make a difference anymore due to the arkworks update: is
this not true?

SC: StepCircuit<F1> + Sync,
SP: SetupParams<G1, G2, C1, C2, RO, SC> + Sync,
SP: SetupParams<G1, G2, C, C2, RO, SC> + Sync,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should keep C1 C2 notation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

C1 is a type alias for Pedersen: here, we want C to be generic so it works
for PVC as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't notice it because of wildcard imports unfortunately

Copy link

vercel bot commented Mar 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nexus-docs ❌ Failed (Inspect) Mar 8, 2024 6:52pm

SC: StepCircuit<F1> + Sync,
SP: SetupParams<G1, G2, C1, C2, RO, SC> + Sync,
SP: SetupParams<G1, G2, C, C2, RO, SC> + Sync,
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't notice it because of wildcard imports unfortunately

Comment on lines +26 to +43
pub fn gen_test_srs(num_vars: usize) -> Result<SRS, ProofError> {
let mut rng = test_rng();
PC::setup(num_vars, b"test_srs", &mut rng).map_err(|_| ProofError::SRSSamplingError)
}

pub fn save_srs(srs: SRS, file: &str) -> Result<(), ProofError> {
let f = File::create(file)?;
let mut enc = Encoder::new(&f, 0)?;
srs.serialize_compressed(&mut enc)?;
enc.finish()?;
f.sync_all()?;
Ok(())
}

pub fn gen_test_srs_to_file(poly_length: usize, file: &str) -> Result<(), ProofError> {
let srs = gen_test_srs(poly_length)?;
save_srs(srs, file)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

same story

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these aren't tests; the compression-cli PR will introduce a CLI command to call into these. the word test is in the name to emphasize that an SRS generated this way is insecure and not to be used in production.

* testing proof deserialization

* proofs save and verify

* removed cargo.lock

* todo: merge dorebell onto this

* fixed merge mistakes

* reads proof and compresses. key not yet saved to file

* added back cargo.lock

* moved the compression cli into prover crate

* formatting

* remove whitespace

* added com option to prove

* updated local prove

* todo:save key and proof to file

* derive CanonicalSerialize+CanonicalDeserialize for Spartan types

* add options to save and load spartan key from file

* save compressed proof to file, implement arkworks serialization

* clippy

* remove SRS generation from CI

* ignore spartan_encode_test

* integrate compression cli with recent version of nexus-tools

* add cli function to sample test SRS

* forgot to add new files

* small compression UI fixes

* add spartan setup command to main 'cargo nexus'

* bump number of SRS vars to 27

* minor fix

* review fixes

* another round of review fixes

* read pp and srs from default cache locations if unspecified during compression

* add helper function to get minimum srs size for a given k

---------

Co-authored-by: Dan Dore <dorebell@gmail.com>
danielmarinq and others added 5 commits March 8, 2024 10:02
* Initial CCS implementation.

* Remove direct construction interfaces so that everything goes through R1CS.

* Trim more, Fold multipliers together, and inline satisfaction checking.

* Fix formatting.

* Precompute products.

* Remove direct CCS construction.

* Add mle helpers.

* Start to integrate polynomial commitments.

* Shading closer to polynomial commitments.

* Initial stab at relating various polynomial types and traits.

* Finish utility functions.

* Fix endianness and ranges and get tests passing.

* Fix formatting.

* Realized there's a better way to invoke the partially fixed polynomial.

* Update interfaces and some additional reworking.

* Resolve clippy.

* Unify shapes.

* Product renaming

Co-authored-by: Dan Dore <dorebell@gmail.com>

* Revert "Unify shapes."

This reverts commit 3463e43.

* Move to polynomial/poly commitment implementations from Spartan repo.

* Move to unified matrix-based model.

* Fix tests.

* Fix fmt.

* Remove files accidently restored during rebase.

* Move to using polynomial commitment exlcusively.

* Fix formatting.

---------

Co-authored-by: Dan Dore <dorebell@gmail.com>
* Update README.md

* Update README.md

* Create .all-contributorsrc
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
* Delete .all-contributorsrc

* Update README.md
@tess-eract tess-eract merged commit 6045c59 into main Mar 14, 2024
5 of 6 checks passed
@tess-eract tess-eract deleted the dorebell-SRS branch March 14, 2024 11:47
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.

6 participants