Repository navigation
feat!: move to pcreds with Jali 0.3.0 and application contexts - #5
Conversation
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>
b890110 to
5f49301
Compare
There was a problem hiding this comment.
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
- 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 intoI, and A's own enrolment then gotAlreadyIssuedfor the whole period. The removedbound_ids/IdentifierReboundcheck used to cover this. Nowenrolment_ssidlives invtc.rs, andissue_vetter_rootrebuilds it for the submitting member and no longer takes anssidparameter (API change). Test:a_root_request_is_bound_to_the_member_that_submits_it. - Unbounded attestations per request (
Vtc::submit).Policy::threshold(usize::MAX)makeswith_max_attestationsunusable, so an applicant could make the VTC run a pairing check per junk attestation. AddedMAX_ATTESTATIONS = 64, checked before any verification, with a newProtoError::TooManyAttestations. Test:a_request_over_the_attestation_limit_is_refused_before_verification. - Token lost on a failed refresh (
VetterEngine::attest).attestspent the token beforeattest_in_context, so thereleaseinrefresh's error branch did nothing.attestnow signs first and spends only on success (split intosignandrecord). - Ineligible statements burned their token (
Vtc::submit).record_spendran 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. ApplicantEngine::replacedropped the old attestation before checking the new one. It now checks first (the checks are factored intocheck). Test:a_failed_replacement_keeps_the_old_attestation.rotateaccepted a live period name, which gave twoPeriods with one name. It now returnsProtoError::PeriodExists. Test:rotate_refuses_a_live_period_name.- Plain copy of
uskinEnrolment. Removed.withdrawusesUser::expose_key(), so the per-period key is only held where it is wiped on drop. - CI comment. The self dev-dependency comment in
ci.ymlnow listsjaliandlatticetoo.
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.
| transcript.append_u64(b"count", attestations.len() as u64); | ||
| for attestation in attestations { | ||
| transcript.append_serializable(b"att", attestation)?; | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
147f124 to
023b13d
Compare
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:
pcredsreplacespcsandcredpcredsis the protocolΠ_PCredsof the paper's revised version, generic over itsbuilding blocks (
pcreds::Backend). The modulespcsandcredare removed.Σ-PSandΣ-BBSwithTag_DDHandTag_DYover BLS12-381. Thesigma protocols follow
draft-irtf-cfrg-sigma-protocols-04anddraft-irtf-cfrg-fiat-shamir-04(SHAKE128 duplex sponge), with the drafts' vectors inkat/ietf/.lattice):Σ-vSISon an NTRU trapdoor withTag_LWR,proved with Jali 0.3.0 and
ntru-trapdoor0.1.1, both fromcrates.io and pinned exactly. Its proofs are straight-line extractable by default (Katsumata's
transform). The feature
lattice-plainselects plain Fiat–Shamir, and the two builds refuseeach other's parameters and proofs.
lattice-extractablestays as an alias.rust-version = "1.95.0", MIT, no default features,#![forbid(unsafe_code)].Application contexts (for OpenVTC, not in the paper)
attest_in_context(.., app):π_attbound toappcheck_attestation_in_context(hvk, id_q, att, app)request_credential_in_context(.., att_apps, ssid, app):π_issbound to each attestation's context, in order, and to the request's ownappevaluate_request_in_context(helper, request, ssid, att_apps, app)unchanged. An empty context is not the same as none.
its attestations carry.
docs/design-notes.md("Contexts") anddocs/encodings.md, and tested intests/application_context.rs(6 tests,Σ-PSandΣ-BBS).The demo on
pcredsdemo/README.md("Changes forpcreds") has the details. In short:pcredshas no class labels, and identifiers andtags 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, theepoch rotation of §4.3.
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.
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.
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.
Σ-PSkey per label. TheΣ-PSofpcredssigns one scalar, the serial,so the label is in the key (the per-month token keys of §5.1).
pcredscredential request underssid = challenge, bound to everystatement's metadata and to the proof context. The VTC evaluates it (
N'') and never answersit 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
unverifiedand simply does not count. Before, one invalid attestation failed the whole proof.requirements::evaluate. Mutation check: eachof eight VTC defences was disabled in turn, and each time the test that covers it failed.
CI
--all-features(the extractable lattice build) and with the plain set.--all-features --all-targetsand with--features lattice-plain.-D warnings, and docs.rs getsserde, jali, lattice.latticejob runsquick_end_to_end_k1andproofs_are_in_the_mode_of_the_buildinrelease, in both modes, with the same pinned actions.
CI.
Lockfile
jali0.3.0 andntru-trapdoor0.1.1, with Jali's dependenciesaes0.9.4,cipher0.5.2,
crypto-primes0.7.2,ctr0.10.1 andinout0.2.6.crypto-bigint0.7.5 → 0.7.11 andctutils0.4.2 → 0.4.8.
vta-sdk =0.56.1) and the rest of its tree are unchanged.Kept from
mainCargo.toml: the MSRV comment, the author note (now naming base commit 5d11dc4),repository, publishing (nopublish = 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,LICENSEandpublish.ymlare untouched.docs/openvtc-integration.mdcomes from the research repository, corrected where its text iswrong 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
predicate-credential-system = "0.1", sovti-vetting-pcs, whichuses the class labels of
pcs, stays on 0.1.x until it is ported. That port is the same onethe demo went through here.
post-quantumbranch (two commits onmain, no PR), which added alattice instantiation to the old API. It can be deleted once this merges.
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:
cargo fmt --all -- --check--all-featuresand the plain set,-D warningscargo test --all-features --all-targetscargo test --features lattice-plaincargo build --no-default-featurescargo doc, both lattice modes,-D warningscargo check --all-featurescargo package --locked--allow-dirty, as the tree was not committed yet)latticejob, four tests in releasecargo test -p pcs-vetting-prototype --release(not in CI)The 24 ignored tests are the heavy lattice suites, which run by hand (README, "Building and
testing").
🤖 Generated with Claude Code