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

Ns/versionize zk #1482

Merged
merged 9 commits into from
Sep 30, 2024
Merged

Ns/versionize zk #1482

merged 9 commits into from
Sep 30, 2024

Conversation

nsarlin-zama
Copy link
Contributor

@nsarlin-zama nsarlin-zama commented Aug 19, 2024

closes: please link all relevant issues

PR content/description

Versionize the ProvenCompactCiphertextList.

Arkworks serialization

For this I changed a bit the way the serialization of arkworks data is handled.
Arkworks use a custom serialization framework (not serde). The reason they state for this is that they want to be able to compress the elliptic curve data during serialization.

However, their serialization scheme is "code oriented" (whereas serde is more "data oriented" because the code serialization is generated automatically based only on type definitions). It means that for backward compatibility we need to check not only the types but also the serialization functions, where subtle breaking changes can occur.

This PR changes this by defining serializable counterparts to arkworks types. These types then simply derive "serialize/deserialize" so they can be easily versioned.
The compression is still optionally supported. the "SerializableAffine" type is defined as an enum:

pub enum SerializableAffine<F> {
    Infinity,
    Compressed { x: F, take_largest_y: bool },
    Uncompressed { x: F, y: F },
}

The "compression" happens when this type is created from arkwork's Affine type. Using an enum is easier for versioning than the bitflags system used by arkworks, and is directly compatible with serde.

To handle compression, I added a trait Compressible. Now to serialize a compressed version we do:

bincode::serialize(&public_params.compress());

The dependency to ark_serialize has been removed.

pke/pke_v2

Both have been versioned in this PR, a commit has been added to use pke_v2. It can be removed if needed.

Verify

The Verify option of ark_serialize is currently not supported, which is a regression. I think it should be moved to the conformance API for uniformization.

Check-list:

  • Adds a test the data repo for ProvenCompactCiphertextList
  • Enable the zk in tfhe-lints
  • Docs have been added / updated (for bug fixes / features)
  • Chose between zk v1 or v2
  • Relevant issues are marked as resolved/closed, related issues are linked in the description
  • Check for breaking changes (including serialization changes) and add them to commit message following the conventional commit specification

@cla-bot cla-bot bot added the cla-signed label Aug 19, 2024
@IceTDrinker IceTDrinker force-pushed the sk/feat/zk-pke-v2 branch 2 times, most recently from a8944a8 to 6c68ae8 Compare September 6, 2024 09:37
Base automatically changed from sk/feat/zk-pke-v2 to main September 6, 2024 12:25
@nsarlin-zama nsarlin-zama force-pushed the ns/versionize_zk branch 4 times, most recently from e4f0564 to 1d78ad8 Compare September 9, 2024 12:11
@nsarlin-zama nsarlin-zama marked this pull request as ready for review September 9, 2024 12:41
@nsarlin-zama nsarlin-zama force-pushed the ns/versionize_zk branch 4 times, most recently from 132ca0e to 50322d0 Compare September 10, 2024 10:24
@nsarlin-zama nsarlin-zama added the data_PR This is a PR that needs to fetch new data for backward compat tests label Sep 10, 2024
@nsarlin-zama nsarlin-zama force-pushed the ns/versionize_zk branch 2 times, most recently from d7f9f46 to f955b3f Compare September 12, 2024 14:28
@nsarlin-zama nsarlin-zama changed the base branch from main to am/chore/zk-v2-manage-upper-bound-params September 12, 2024 14:31
Base automatically changed from am/chore/zk-v2-manage-upper-bound-params to main September 13, 2024 08:24
@nsarlin-zama nsarlin-zama mentioned this pull request Sep 18, 2024
4 tasks
@nsarlin-zama nsarlin-zama force-pushed the ns/versionize_zk branch 7 times, most recently from b967bec to c96e301 Compare September 24, 2024 16:28
Base automatically changed from am/feat/zk-v1-padding to main September 27, 2024 14:57
@zama-bot zama-bot removed the approved label Sep 27, 2024
@zama-bot zama-bot removed the approved label Sep 30, 2024
@nsarlin-zama nsarlin-zama merged commit 8256e76 into main Sep 30, 2024
81 of 86 checks passed
@nsarlin-zama nsarlin-zama deleted the ns/versionize_zk branch September 30, 2024 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cla-signed data_PR This is a PR that needs to fetch new data for backward compat tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants