Skip to content

feat(tokengen): add zkatsnark public parameters gen/update/print and ValidateForDeployment - #2595

Merged
adecaro merged 3 commits into
feature/zkat-snark-driverfrom
zkatsnark/tokengen
Oct 30, 2026
Merged

adecaro merged 3 commits into
feature/zkat-snark-driverfrom
zkatsnark/tokengen

Conversation

@adecaro

@adecaro adecaro commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds operator tooling for zkatsnark public parameters, and the open-policy deployment check that zkatdlog has. Until now, zkatsnark PPs could only be generated through the NWO integration generator. tokengen could not generate them, update their issuers or auditors, or print them.

This PR is part of the series of zkatsnark-vs-zkatdlog parity PRs against feature/zkat-snark-driver (#2590, #2591, #2592, and others).

Changes

  • PublicParams.ValidateForDeployment (new file pp/deployment.go): mirrors zkatdlog and returns an open-policy-mode error when IssuerIdentities is empty.
  • setup.GeneratePublicParams (new file setup/generate.go): a shared builder that applies defaults, then overrides, then runs Validate and SetupAll. It comes with ParseProofSystem and ParseCurve. It rejects:
    • MaxBits outside 1..64;
    • a precision greater than MaxBits;
    • a missing idemix key;
    • an unknown proof system or curve.
  • NWO generator refactor. integration/nwo/token/generators/pp/zkatsnarkv1 now uses the shared builder, so the generation logic is no longer duplicated. This is in its own commit.
  • New tokengen pp gen zkatsnark.v1 and tokengen pp update zkatsnark.v1 subcommands:
    • gen takes the proof system (groth16/plonk/plonkfri), curve, MaxBits, precision, idemix key, issuers, auditors and output path. It prints a notice about the chosen proof system's setup trust model, and a warning in open-policy mode, matching the existing drivers.
    • update replaces issuers and auditors, or appends them with deduplication, without regenerating keys. It checks that the input is a zkatsnark.v* PP, and it refuses a PP without circuit keys.
    • printpp now knows the zkatsnark format.
  • Docs: docs/drivers/zkatsnark.md, docs/public_parameters.md, cmd/tokengen/README.md.
  • Base-branch fix. A separate chore commit syncs golang.org/x/net in the zkatsnark go.mod. Without it, the module does not build on the base branch. Other parity branches carry the same commit.

Testing

  • Unit tests:
    • pp/deployment_test.go and setup/generate_test.go;
    • cmd/tokengen/cobra/pp/zkatsnarkv1 gen/update tests, including a zkatdlog PP rejected with the identifier-mismatch error, a keyless PP rejected, append deduplication, and circuit keys preserved;
    • printpp and pp_test.go.
  • TestZKATSNARKGenUpdatePrint: a gexec end-to-end test in cmd/tokengen/main_test.go that runs gen, then update, then print.
  • The tests use the smallest valid parameters. No multi-MB PP testdata is committed.

The plan and the implementation were each reviewed by an independent agent.

Notes

  • CI gap (pre-existing): cmd/tokengen is not in GO_PACKAGES, so the new tokengen tests do not run in CI. They were run locally.
  • Open-policy messages: the zkatdlog and fabtoken gen commands still print their own inline open-policy message instead of calling ValidateForDeployment. Aligning them is left as a follow-up.

🤖 Generated with Claude Code

@adecaro adecaro added this to the ZKAT Snark Driver milestone Oct 30, 2026
@adecaro adecaro added enhancement New feature or request token-driver labels Oct 30, 2026
@adecaro adecaro self-assigned this Oct 30, 2026
adecaro and others added 3 commits October 30, 2026 14:44
…arams

Add PublicParams.ValidateForDeployment, mirroring zkatdlog, which reports
open-policy mode (empty IssuerIdentities). Add setup.GeneratePublicParams
plus ParseProofSystem/ParseCurve helpers so tokengen and the NWO generator
build and set up zkatsnark public parameters the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
…neratePublicParams

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
Add the zkatsnarkv1 tokengen package:
- gen builds fully set-up ZKAT-SNARK public parameters (groth16, plonk or
  plonkfri; bn254 or bls12_381; MaxBits, precision, one or more idemix
  issuer keys, issuers, auditors, extras) via setup.GeneratePublicParams;
- update replaces or appends (deduplicated) issuers and auditors, merges
  extras and optionally overrides the version without re-running setup;
  it rejects non-zkatsnark and keyless inputs;
- both warn when PublicParams.ValidateForDeployment reports open-policy mode.

pp print now also decodes zkatsnark public parameters. Document the
commands and deployment checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
@adecaro
adecaro force-pushed the zkatsnark/tokengen branch from 3e1005c to 429804e Compare October 30, 2026 13:48
@adecaro
adecaro merged commit c710a98 into feature/zkat-snark-driver Oct 30, 2026
350 of 351 checks passed
@adecaro
adecaro deleted the zkatsnark/tokengen branch October 30, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request token-driver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant