Skip to content

feat!: move to pcreds with Jali 0.3.0 and application contexts - #5

Merged
stormer78 merged 3 commits into
mainfrom
feat/pcreds-jali-0.3
Nov 17, 2026
Merged

stormer78 merged 3 commits into
mainfrom
feat/pcreds-jali-0.3

Conversation

@etairi

@etairi etairi commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Brings the crate up to the research implementation at
etairi/predicate-credential-system@5d11dc4
with this repository's adjustments, adds application contexts to its protocol for OpenVTC, and
ports the demo to it. It is breaking (feat!), so release-plz will propose 0.2.0.

138 files changed (+45,637 / −28,032), of which the demo is 10 files (+901 / −520).

The library: pcreds replaces pcs and cred

  • pcreds is the protocol Π_PCreds of the paper's revised version, generic over its
    building blocks (pcreds::Backend). The modules pcs and cred are removed.
  • Pairing instantiations: Σ-PS and Σ-BBS with Tag_DDH and Tag_DY over BLS12-381. The
    sigma protocols follow draft-irtf-cfrg-sigma-protocols-04 and
    draft-irtf-cfrg-fiat-shamir-04 (SHAKE128 duplex sponge), with the drafts' vectors in
    kat/ietf/.
  • Lattice instantiation (feature lattice): Σ-vSIS on an NTRU trapdoor with Tag_LWR,
    proved with Jali 0.3.0 and ntru-trapdoor 0.1.1, both from
    crates.io and pinned exactly. Its proofs are straight-line extractable by default (Katsumata's
    transform). The feature lattice-plain selects plain Fiat–Shamir, and the two builds refuse
    each other's parameters and proofs. lattice-extractable stays as an alias.
  • Unchanged: edition 2024, rust-version = "1.95.0", MIT, no default features,
    #![forbid(unsafe_code)].

Application contexts (for OpenVTC, not in the paper)

Party Binds Checked with
Attester attest_in_context(.., app): π_att bound to app check_attestation_in_context(hvk, id_q, att, app)
Requester request_credential_in_context(.., att_apps, ssid, app): π_iss bound to each attestation's context, in order, and to the request's own app evaluate_request_in_context(helper, request, ssid, att_apps, app)
  • Without contexts, every context is the paper's byte for byte, and the known answers are
    unchanged. An empty context is not the same as none.
  • Verifiers take the context bytes from their own copy of the public data.
  • Tags do not depend on contexts, so one attester counts once for a recipient whatever contexts
    its attestations carry.
  • Documented in docs/design-notes.md ("Contexts") and docs/encodings.md, and tested in
    tests/application_context.rs (6 tests, Σ-PS and Σ-BBS).

The demo on pcreds

demo/README.md ("Changes for pcreds") has the details. In short:

  • Vetter periods become helper keys. pcreds has no class labels, and identifiers and
    tags are functions of the helper key (x_0 = H_id(⟨hvk⟩), x_Q = H_req(⟨pp, hvk, id_Q, j_Q⟩)).
    So the class labels vetter/<period> of design §13 C1 become one helper key per period, the
    epoch rotation of §4.3.
    • Kept: removal stays cryptographic. A removed vetter gets no credential under the next
      period and cannot attest at all once its last period is dropped. The window of two live
      periods stays, and one vetter still counts once per request.
    • Given up: one request can no longer mix periods, which was C1's aim. An application in
      flight completes under its period while that period is live. After the period is dropped,
      the applicant registers again and the vetters refresh their statements without a new
      session, with new tags. Vetters enrol with a fresh key per period (§18.2), so C2's lifelong
      identifier becomes one identifier per member and period.
    • Considered and not taken: one long-lived helper key with the period carried only by the
      token labels. It would keep mixing, but a removed vetter's credential would then stay valid
      for good. Removal would rest on token scarcity alone, and a current vetter could hand tokens
      to a removed one so that it counts as a second, distinct vetter.
  • Tokens use one Σ-PS key per label. The Σ-PS of pcreds signs one scalar, the serial,
    so the label is in the key (the per-month token keys of §5.1).
  • The submission is a pcreds credential request under ssid = challenge, bound to every
    statement's metadata and to the proof context. The VTC evaluates it (N'') and never answers
    it with a credential. Its helpers use a policy no request meets, so every credential under a
    period's key is a root admission (C4). A statement whose attestation does not verify is now
    unverified and simply does not count. Before, one invalid attestation failed the whole proof.
  • Tests: 14 end-to-end tests, with VTI's own requirements::evaluate. Mutation check: each
    of eight VTC defences was disabled in turn, and each time the test that covers it failed.

CI

  • Clippy runs with --all-features (the extractable lattice build) and with the plain set.
  • Tests run with --all-features --all-targets and with --features lattice-plain.
  • Docs build in both lattice modes with -D warnings, and docs.rs gets serde, jali, lattice.
  • A new lattice job runs quick_end_to_end_k1 and proofs_are_in_the_mode_of_the_build in
    release, in both modes, with the same pinned actions.
  • Format, no-default-features, MSRV and package are unchanged. The demo is still not built in
    CI.

Lockfile

  • New: jali 0.3.0 and ntru-trapdoor 0.1.1, with Jali's dependencies aes 0.9.4, cipher
    0.5.2, crypto-primes 0.7.2, ctr 0.10.1 and inout 0.2.6.
  • Upgraded, and shared with the demo's tree: crypto-bigint 0.7.5 → 0.7.11 and ctutils
    0.4.2 → 0.4.8.
  • The demo's pins (vta-sdk =0.56.1) and the rest of its tree are unchanged.

Kept from main

  • Cargo.toml: the MSRV comment, the author note (now naming base commit 5d11dc4),
    repository, publishing (no publish = false) and [workspace] members = ["demo"].
  • README.md: the demo link, and the sentence on the crates.io release by release-plz.
  • release-plz.toml, RELEASING.md, LICENSE and publish.yml are untouched.
  • docs/openvtc-integration.md comes from the research repository, corrected where its text is
    wrong for this one (the crate is published, and attestations can carry an application
    context), and without the research repository's outdated note on the extraction of the
    proofs.

Consumers and related work

  • VTI's workspace depends on predicate-credential-system = "0.1", so vti-vetting-pcs, which
    uses the class labels of pcs, stays on 0.1.x until it is ported. That port is the same one
    the demo went through here.
  • This supersedes the post-quantum branch (two commits on main, no PR), which added a
    lattice instantiation to the old API. It can be deleted once this merges.
  • feat(demo): interactive hidden-vetting walkthrough for a cryptographer audience #4 (interactive walkthrough) changes the same demo files on the old API, so it needs a port to
    this one after this merges.

Verification

Run locally on 2026-11-16 (macOS arm64, rustc 1.100.0, the toolchain 1.95.0 for MSRV), on this
tree before it was committed:

CI step Result
cargo fmt --all -- --check pass
clippy, --all-features and the plain set, -D warnings pass
cargo test --all-features --all-targets 400 passed, 0 failed, 24 ignored
cargo test --features lattice-plain 415 passed (with 15 doc tests), 0 failed, 24 ignored
cargo build --no-default-features pass
cargo doc, both lattice modes, -D warnings pass
MSRV 1.95.0, cargo check --all-features pass
cargo package --locked pass (with --allow-dirty, as the tree was not committed yet)
lattice job, four tests in release 4 passed
cargo test -p pcs-vetting-prototype --release (not in CI) 14 passed

The 24 ignored tests are the heavy lattice suites, which run by hand (README, "Building and
testing").

🤖 Generated with Claude Code

Bring the crate up to the research implementation at
etairi/predicate-credential-system 5d11dc4, adjusted for OpenVTC.

- The protocol is pcreds, the paper's revised Π_PCreds, generic over
  its building blocks. It replaces the modules pcs and cred, which are
  removed. The pairing instantiations are Σ-PS and Σ-BBS with Tag_DDH
  and Tag_DY. The new lattice instantiation (feature lattice) is Σ-vSIS
  with Tag_LWR on Jali 0.3.0 and ntru-trapdoor 0.1.1. Its proofs are
  straight-line extractable by default (Katsumata's transform), and
  the feature lattice-plain selects plain Fiat-Shamir.
- Application contexts for OpenVTC, an implementation note that is
  not in the paper: attestations and credential requests can be bound
  to application bytes (attest_in_context, check_attestation_in_context,
  request_credential_in_context, evaluate_request_in_context). Without
  them the contexts are the paper's byte for byte, and tags never
  depend on them.
- The demo pcs-vetting-prototype runs on pcreds. Vetter periods become
  helper keys, tokens use one Σ-PS key per label, and the VTC evaluates
  the applicant's credential request without answering it.
  demo/README.md says what changed and why.
- CI lints, tests and documents both lattice modes, and a new lattice
  job runs the k = 1 end-to-end test in each.

BREAKING CHANGE: the modules pcs and cred are removed in favour of
pcreds, whose API, proofs and encodings differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Erkan Tairi <erkan.tairi@gmail.com>
@etairi
etairi force-pushed the feat/pcreds-jali-0.3 branch from b890110 to 5f49301 Compare November 17, 2026 02:07
@etairi
etairi requested a review from stormer78 November 17, 2026 02:09

@stormer78 stormer78 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review pass on the pcreds port. I pushed 15ad13b to this branch with fixes for the demo findings below, plus regression tests (cargo test -p pcs-vetting-prototype: 19 pass, clippy clean).

Fixed in 15ad13b

  1. Enrolment replay (demo/src/vtc.rs, issue_vetter_root). The VTC took the root request's ssid from the caller, so member B could submit member A's captured root request: A's id went into I, and A's own enrolment then got AlreadyIssued for the whole period. The removed bound_ids / IdentifierRebound check used to cover this. Now enrolment_ssid lives in vtc.rs, and issue_vetter_root rebuilds it for the submitting member and no longer takes an ssid parameter (API change). Test: a_root_request_is_bound_to_the_member_that_submits_it.
  2. Unbounded attestations per request (Vtc::submit). Policy::threshold(usize::MAX) makes with_max_attestations unusable, so an applicant could make the VTC run a pairing check per junk attestation. Added MAX_ATTESTATIONS = 64, checked before any verification, with a new ProtoError::TooManyAttestations. Test: a_request_over_the_attestation_limit_is_refused_before_verification.
  3. Token lost on a failed refresh (VetterEngine::attest). attest spent the token before attest_in_context, so the release in refresh's error branch did nothing. attest now signs first and spends only on success (split into sign and record).
  4. Ineligible statements burned their token (Vtc::submit). record_spend ran before the expiry and requirements-digest checks. Those checks now run first, and the token is checked and recorded only for an otherwise eligible statement. Test: an_ineligible_statement_does_not_burn_its_token.
  5. ApplicantEngine::replace dropped the old attestation before checking the new one. It now checks first (the checks are factored into check). Test: a_failed_replacement_keeps_the_old_attestation.
  6. rotate accepted a live period name, which gave two Periods with one name. It now returns ProtoError::PeriodExists. Test: rotate_refuses_a_live_period_name.
  7. Plain copy of usk in Enrolment. Removed. withdraw uses User::expose_key(), so the per-period key is only held where it is wiped on drop.
  8. CI comment. The self dev-dependency comment in ci.yml now lists jali and lattice too.

Not changed: the library context encoding, see the inline comment on src/pcreds/context.rs. It is a protocol-level choice, so it is yours to make.

Not covered by this pass: the lattice backend internals (src/pcreds/lattice/*, src/kiprf/lwr.rs) and the src/sigma/* rewrite got little line-by-line reading.

Comment thread src/pcreds/context.rs
transcript.append_u64(b"count", attestations.len() as u64);
for attestation in attestations {
transcript.append_serializable(b"att", attestation)?;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

att_apps = Some(&[]) and att_apps = None produce the same transcript. The loop appends nothing in both cases, and there is no presence marker. The doc above says an empty context is not the same as none, but with zero attestations a π_iss made with the context-free API also verifies under the context API (with att_apps = Some(&[]) and the same app). The app side has the same shape: Some(b"") appends an empty app and so does differ from None, but only because append_bytes frames the length.

Do you want strict separation? One option is a mode byte before the loop, e.g. transcript.append_u64(b"att-apps", att_apps.is_some() as u64) (and the same for app). That changes the digest for every context-free proof, so it is a format change, which is why I didn't make it in the fix commit. If the current behaviour is intended (no attestations means nothing to bind), it may be enough to reword the doc.

@stormer78 stormer78 Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changed in 023b13d. No proofs exist yet, so we made the change now rather than after release, when it would break compatibility.

issuance_context_in now appends an att-apps item (the number of contexts) before the att-app items whenever att_apps is Some, so Some(&[]) is distinct from None even with no attestations. A π_iss proved without application contexts can no longer verify under the context API, which is what the docs already claimed.

I chose a marker that appears only for Some, rather than a 0/1 flag written every time, so that the None encoding stays exactly the paper's. issuance_context and the pinned vectors in tests/serialization.rs (proof_contexts_are_pinned) are unchanged. app already worked this way: Some(b"") appends an empty app item and None appends nothing. Both optional parts now follow the same rule, and the doc says so.

Test: backward_compatible in tests/application_context.rs now also checks the zero-attestation case (None and Some(&[]) for att_apps, crossed with None and Some(b"") for app, all distinct). It fails without the fix. The full library suite (--all-features --all-targets) and clippy pass, as does the demo suite.

Please check that you are happy with this framing before it ships, since it fixes the context-API digests from here on.

- vtc: issue_vetter_root rebuilds the enrolment ssid for the submitting
  member instead of taking it from the caller, so a captured root request
  cannot be replayed by another member to lock its owner out of the period
- vtc: refuse a request with more than MAX_ATTESTATIONS (64) attestations
  before any pairing check (the period policy's k = usize::MAX rules out
  Policy::with_max_attestations)
- vtc: run the requirements-digest and expiry checks before the token
  checks, so an ineligible statement does not burn its token
- vtc: rotate refuses a period name that is already live
- vetter: attest signs before it spends the reserved token, so a failed
  attestation (e.g. in refresh) leaves the token reserved and release()
  returns it, instead of losing it
- vetter: drop the plain usk copy in Enrolment and use User::expose_key,
  so the per-period key is only held where it is wiped on drop
- applicant: replace checks the new attestation before dropping the old one
- ci: the self dev-dependency comment now lists jali and lattice too

Regression tests for the replay, rotate, attestation limit, token-burn and
replace fixes.

Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
issuance_context_in appended nothing for att_apps = Some(&[]), the same as
for None, so with no attestations a π_iss proved without application
contexts verified under the context API with an empty att_apps, against the
documented rule that an empty context is not the same as none.

When att_apps is Some, an item att-apps (the number of contexts) now goes
before the att-app items, so Some is distinct from None whatever it holds.
The None encoding is unchanged, so the paper's contexts and the pinned
regression vectors stay as they were. A test covers the zero-attestation
case and fails without the fix.

Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
@stormer78
stormer78 force-pushed the feat/pcreds-jali-0.3 branch from 147f124 to 023b13d Compare November 17, 2026 17:43
@stormer78
stormer78 merged commit 610bbdc into main Nov 17, 2026
9 checks passed
@stormer78
stormer78 deleted the feat/pcreds-jali-0.3 branch November 17, 2026 22:33
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.

2 participants