Skip to content

feat(ceremony): telegram/1 ceremony - #170

Open
SupremaLex wants to merge 75 commits into
mainfrom
feat/telegram-ceremony
Open

SupremaLex wants to merge 75 commits into
mainfrom
feat/telegram-ceremony

Conversation

@SupremaLex

@SupremaLex SupremaLex commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

What

The telegram/1 ceremony in @libid/ceremony.

  • Authorization: a code flow with PKCE S256, scope=openid profile, and nonce set to the base64url Authorization Digest. The redirect URI is the Bridge's /auth/callback; the Bridge routes are derived from it.
  • Code swap: Telegram's token endpoint answers no CORS, so the browser posts the code to the Bridge's token route, which swaps it with the private client secret (libID-bridge-rs docs(specs): the EVM Chain Profile that REQ-COMMON-01C asks for #30). Keys come from the Bridge's key-list route. Both requests give up after 15 s with a named error, as does Google's key fetch.
  • ID token rules (Prover): iss, aud equals the configured client id, alg/kid, a nonce that decodes to 32 bytes, the iat window from @libid/contracts (3600 s lifetime, 300 s skew), and preferred_username present. Accounts without a username are refused. A token for another client and one outside the iat window are refused with their own messages, as Google's are; other bad tokens read "Invalid Telegram ID token". The Client checks the nonce against the session's digest through the proof's public inputs.
  • Prover: oidc_telegram circuit inputs (per-claim windows, 57 public fields) and catalog entry. Google and Telegram share one proveOidc, which takes each circuit's assets and SRS size.
  • Circuit pin: the oidc-telegram tarball of libid-circuits v0.9.0, pinned by its manifest.json sha256 4c1ea1fd…143f9 (vk_hash 0x0719c331…cfc8). oidc_telegram has 248,207 gates, so it declares a 2^18-point SRS and its profile fetches that G1 range; the build checks the circuit against it. The vectors are copied from v0.9.0.
  • Contracts: @libid/contracts 0.23.0, which carries PLATFORM_TELEGRAM_KEY and Telegram's proof lifetime and skew.
  • Specs:
    • specs/oauth-bridge.md: a Telegram profile (Bridge-assisted, the secret never in /config, the Bridge sees the identity and stores none, the key list cached at most an hour).
    • specs/platform-ceremonies.md: the Telegram ceremony (REQ-PLAT-64..69, TEST-PLAT-23..24), including RS256 only, how TelegramJwtRoots keeps and drops keys, and a listing rule counted from a key's publication.
    • specs/ceremony-common.md: Telegram binds the digest by the nonce; its PKCE only protects the code at the Bridge swap. The client table gains Telegram (aud, the bot id).
    • specs/libid.md: Telegram's protocol parameters (3600 s, 300 s).
  • Tests: the conformance table gains telegram/1 with the synthetic oidc_telegram vector and its 57 public inputs; browser e2e tables include telegram/1. Identity values in the fixtures are made up.

Boundary

The Bridge owns the swap and the secret; the browser owns the token checks; the circuit owns claim to node; the contracts own the time rule.

Order

The Bridge's Telegram profile (libID-bridge-rs #30, merged) is deployed before this ceremony is enabled. The circuit release and the contracts release it pins are published.

Checks

The branch is merged with main, including main's per-circuit SRS sizing.

Run locally on the merged head:

  • @libid/ceremony vitest: 1242 pass, 1 skipped.
  • tsc (typecheck), biome lint and format, oxlint.
  • build:ccdp-artifacts and test:distribution: 39 pass; 7 skipped that need a served or native SWS (CEREMONY_SWS_URL, CEREMONY_SWS_BINARY). The release-statistics test reads the v0.9.0 tarball and records oidc_telegram at 248,207 gates in 2^18.

Playwright e2e was not run locally; CI runs it.

Not yet tested by anyone: phones and Telegram's in-app browser; the denied, expired and closed-popup paths.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RWH28GG6chGap34Bv6Pmwi

Spec-level tests for the telegram/1 authorization URL, query code return,
Bridge code swap, Bridge JWKS key selection and ID token acceptance.
They import modules that do not exist yet and fail until implemented.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Telegram v1 is OIDC with PKCE. The authorization request carries the
digest as the nonce and the S256 challenge. The browser swaps the code
through the Bridge's token route, since Telegram needs a confidential
client secret, and reads Telegram's keys through the Bridge's JWKS route.

The ID token is accepted only with alg RS256, the fixed issuer, a string
audience equal to the client ID, the ceremony's nonce, iat no more than
5 minutes ahead and no more than 1 hour old, a decimal-string id and a
preferred_username. An account without a username gets an error telling
the user to set one.

The platform is not registered in the catalog yet: registration needs a
prover, a circuit asset and a proof shape, which come with the circuit.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Telegram's token endpoint needs a confidential client secret, so the
browser cannot exchange the code itself. The Bridge gains two routes
where Telegram is configured: a token route that adds HTTP Basic client
authentication and passes Telegram's answer through, and a JWKS route
that relays Telegram's key set with a cache of at most one hour.

The /config Telegram entry carries only the client ID. The route surface,
request-body and security sections now except the Bridge-assisted
profile, and the privacy rule says the Bridge stores and logs none of
the identity it sees. REQ-BRIDGE-07 and TEST-BRIDGE-07 cover the routes.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
…gram/1

telegram/1/url.ts uses pkceAuthorizationUrlBuilder, which gains an
optional nonce field (the digest, length-checked) after `state`; GitHub
and X keep the default and emit the same requests. The JWT-segment JSON
decoder and the kid-selecting key-set fetch move to platforms/oidc.ts;
google/1 and telegram/1 keep their fetchSigningKey signatures as
one-line wrappers.

CRAP (lizard CC, vitest v8 coverage), before -> after:
- telegram buildAuthorizationUrl: 3 -> removed (builder closure 2 -> 3, covered)
- telegram json / google json: 4 / ~4 -> jsonObject 4 (100% stmts)
- telegram fetchSigningKey / google fetchSigningKey: 4 / 4 -> 1 / 1;
  shared fetchSigningKey 4 (covered)
- acceptTelegramIdToken: 19, fully covered, unchanged

Diff: 69 insertions, 93 deletions.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Hand mutation of the telegram/1 diff left survivors where a test ran a
value without reading it: the swap's cache mode, JSON content type and
abort signal; a non-string or oversized token response; an empty kid; a
non-base64url signature; and a payload that is not valid UTF-8.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
PlatformCeremonyVersion gains digestBinding: 'nonce' for Google and
Telegram, 'verifier' for X and GitHub. It states what the Platform
Verifier compares, which pkce no longer does: Telegram sends PKCE only
to protect the code at the Bridge swap. The catalog test now asserts
digestBinding against the prover kind instead of pkce.

pkceAuthorizationUrlBuilder takes { leading, nonce } instead of
positional arguments. The returned builder still takes the digest for
every platform: PlatformCeremonyVersion.buildAuthorizationUrl has one
input shape and the Client passes it uniformly.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
swapCode and fetchSigningKey drop their separate bridge argument and
resolve their paths against redirectUri: the callback is fixed at
/auth/callback on the Bridge origin (oauth-bridge.md), so a second
origin input could only disagree with it.

The return rules and the swap input bound code and redirectUri at 512
bytes, the Bridge's limit. The swap also checks the verifier shape and
the redirect URI before sending anything.

The oidc.ts comment no longer says the key set is reused: the HTTP
cache follows the server, and the Bridge sends no-store.

token.ts keeps its id check; a TODO points to isAccountId/isHandle for
when @libid/contracts carries Telegram.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
…tract

ceremony-common: the binding method is what the Platform Verifier
compares. Telegram joins the table with the nonce method. Its PKCE only
protects the code at the Bridge swap; no verifier compares it, so
REQ-COMMON-15/15A do not apply and REQ-COMMON-02C still holds.

oauth-bridge: the token route's preflight grants content-type; code and
redirectUri are at most 512 bytes; the key route passes a 200 that is
not non-empty JSON through uncached and answers 502 otherwise, as the
Bridge does; TEST-BRIDGE-07 says the same. The Bridge again opens no
notary connection for any profile. The Boundary section and ccdp.md's
role table name the Telegram token relay, its secret, and the identity
the Bridge sees.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
§6a owns the telegram/1 rules that token.ts implements: the
authorization request, the 512-byte code return, the ID token's iss,
string aud, nonce and iat window, observedAt = iat with exp unused
(Telegram's tokens live 30 s), the required preferred_username, and the
id and handle grammar. The circuit and the Platform Verifier own their
checks of those fields. The section is lettered so §7-§10 keep their
numbers and existing references.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
REQ-PLAT-66's field table states the rule the circuit enforces: the
identity table's (not empty, at most 32 bytes, no quote or backslash,
A-Z folded), not Telegram's own 5-32 [A-Za-z0-9_] username alphabet.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
REQ-PLAT-64's upper bound is exclusive, `now < iat + 1 h`, as the shared
freshness check enforces. REQ-PLAT-65 sets observedAt to `iat − 300`
instead of capping `iat` at Block Time (415be94), so a Telegram
observation compares with other profiles' on one scale.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
buildOidcTelegramInputs turns a Telegram RS256 ID token, its signing
modulus and the authorization digest into the oidc-telegram circuit's
inputs: each claim's offset and its window of whole 3-byte payload
groups, the RSA limbs, and the audience hash and identity nodes.

Id and username rules and node tags come from @libid/contracts'
Telegram row through identity.ts. The RSA limb, redc, padding and
claim-offset helpers are exported from oidc_google/inputs.ts and reused;
a shared circuits/rsa.ts would be a cleaner home for them later.
Window widths mirror circuits/oidc-telegram/src/main.nr; the committed
vectors fail if they drift.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
The three Prover tomls are copied from libid-circuits e290104 into
oidc_telegram/vectors/, so the vector cases always run instead of
skipping when no circuits checkout sits beside this repo.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Adds telegram to the conformance table with the synthetic oidc_telegram vector (token and key rebuilt from the circuit's Prover.toml) and a copy of the contracts' real proof and public inputs. stageOidc serves a code flow's ID token from the Bridge swap and expires each fixture at its own retention bound.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
The Prover never holds the Authorization Digest: ProveIdentity carries
none, and the code verifier is a one-way hash of it. ceremony-common
already gives the digest comparison to the Platform Verifier, and the
Client enforces it through validateProof. REQ-PLAT-64 now says the Prover
checks that the nonce is 43 base64url characters encoding 32 bytes, as
Google's does.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Registers telegram/1 in the catalog, the prover table and the asset
table. The prover swaps the code through the Bridge (token-fetch),
accepts the ID token, reads the signing key from the Bridge's jwks route,
builds oidc_telegram inputs and proves. Validation checks the 57 public
inputs against oidc_google's layout, which oidc_telegram shares with iat
in the time field. Retention ends at iat + PROOF_LIFETIME_SECONDS_TELEGRAM.

Token acceptance follows the shared freshness rule, iat <= now + 300 and
now < iat + 3600, using the profile constants from @libid/contracts. It
checks id and username with the platform table's isAccountId and
isHandle. The nonce must decode to a 32-byte digest, and the circuit
receives that digest. The test that accepted a token exactly one hour old
now expects it to be rejected, with the 3599-second case accepted. The
"another session's nonce" case is now a malformed-nonce case, and the
conformance case "a nonce of another authorization" is dropped (see the
REQ-PLAT-64 spec change). The validateProof "authorization digest"
binding still covers a wrong digest.

The RS256 key and signature-length check moves from google/1/inputs.ts
into platforms/oidc.ts (rs256Modulus), and both provers use it.
Telegram's issuer is defined once, as ISSUER in oidc_telegram/parameters.ts.
ISSUER_CLAIM derives from it, and provider.ts imports it, the same way
Google's issuer is shared. The swap starts no request after the run is
aborted.

The oidc_telegram asset pins libid-circuits v0.9.0 by the sha256 of a
tarball packed with release.yml's recipe from libid-circuits e290104
under umask 022.

BREAKING CHANGE: PlatformId gains 'telegram'; exhaustive PlatformId maps must add it.
Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Several suites assumed only the three earlier platforms. They now cover
telegram/1:
- ceremony.test chooses its PKCE assertions from the catalog's pkce flag
  and its nonce assertion from digestBinding, not from the prover kind. It
  delivers a Telegram proof built with buildTelegramPublicInputs, which is
  now exported from telegram/1/validation.ts.
- documents/prover.test mocks the telegram prover module like the others.
- A conformance fixture can declare engineAfterTokenFetch. Telegram's token
  comes from the Bridge swap, and the proof engine starts only once that
  token is accepted. So a run cancelled at startup makes no swap and starts
  no engine. Every other platform still starts and destroys its engine.
- The build tests list telegram among the catalog platforms and record
  oidc_telegram's gate count: 261005 gates, dyadic 2^18.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
The return table, authorization field order, key selection and the
issuer, audience, algorithm, iat-ahead, username and Bridge-failure
rows already run for telegram/1 in the conformance suites. Keep only the
cases nothing else covers: the 512-byte code bound, the hand-stated
nonce vector, swap preconditions and body shapes, the remaining token
shapes and the iat window edges.

Tests: 1204 -> 1184 passed (1 skipped). CRAP unchanged (tests only).

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
google/1 and telegram/1 load their token, key and digest one way, strip
the JWK the same way, and flip or swap public inputs the same way.

Tests: 1184 passed (1 skipped), unchanged. CRAP unchanged (tests only).

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
…am/1

Both platforms validate an oidc_google-layout proof: the same shape,
public-input builder and in-order comparison, differing only in the
platform, the signed time field and the circuit's aud and field bounds.
oidcValidation() takes those as parameters; error texts, field names and
exported names are unchanged. The RS256 header check is shared too.

CRAP (vitest coverage + lizard), before -> after:
- acceptTelegramIdToken 18.0 -> 16.0 (CC 18 -> 16, covered 100%)
- parseGoogleIdToken 12.0 -> 10.0 (CC 12 -> 10)
- validateProof/isPublicInputs/buildPublicInputs: one copy, CRAP 2/3.1/1
- rs256Kid (new) 2.0
Tests: 1184 passed (1 skipped), unchanged.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
ceremony-common said it after the binding table and again in the next
paragraph; oauth-bridge pointed at the Telegram profile twice in two
paragraphs. No requirement text changes.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
identityValidator already returns Identity<P> for the inferred platform.

CRAP note for the previous refactor: lizard misparses oidc.ts after
rs256Kid (it folds fetchSigningKey into rs256Modulus), so rs256Kid's
figure there is unreliable; by inspection CC 5, fully covered, CRAP 5.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Rows that kill surviving hand mutants: a canonical 31- and 33-byte nonce
reaches the digest-length check, an empty username gets the prompt, the
circuit-input builder refuses a 21-byte or empty aud and a 31-byte
digest whose nonce encodes it.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
The oidc_telegram circuit reused the RSA ABI, limb and offset helpers from
oidc_google, and the platform OIDC validation built both circuits' public
inputs through a Google-named function. Move what both circuits share into
barretenberg/circuits/oidc.ts (RSA ABI constants, limbs, redc, pad, hex,
findOffset, audienceHash, buildOidcPublicInputs); each circuit's parameters
keep only their own ABI values. No behaviour change.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
The core token-fetch operation means a notarized token request and
projects the notarization stage. Telegram's code swap through the Bridge
is not notarized, so it now emits the extension operation token-swap,
weighted for progress but not admitted as a core event. Telegram shows
Google's stages.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
The key fetch's comment called the key list uncached. The Bridge caches
it for up to an hour; only the browser's own fetch is no-store.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
libid-circuits a8347e4 hashes aud, id and handle in one SHA-256 block
each. Its ABI, its 57 public inputs and the three vectors are unchanged;
only the vendored copies' source line moves. The verification key hash
is 0x0719c331d305be99c8baf54332121be04b5ded7d71a6217359cfe613e0c4cfc8,
and the circuit has 248207 gates, still within 2^18.

The release does not exist yet. The pinned sha256 comes from a local
build at a8347e4 (scripts/build.sh, nargo 1.0.0, bb 6.0.0), packed with
release.yml's exact tar and gzip flags under GNU tar 1.35 and gzip 1.12.
It must be checked against the published v0.9.0 asset before merge.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
§7 asks every profile for a trust-root lifecycle, but §6a deferred to the
circuit's platform entry, which holds only tags and buffers, and Google's
REQ-PLAT-23 and 24 had no Telegram twin. §6a.3 now states that the bot
signs RS256 (BotFather's ES256, EdDSA and ES256K are refused), that the
Platform Verifier rejects a modulus TelegramJwtRoots does not list
(REQ-PLAT-68), and that a notarized reading of Telegram's JWKS adds a new
key within one proof lifetime of its first use (REQ-PLAT-69).
TEST-PLAT-24 requires the deployment to name the keeper that submits
those readings.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Telegram's client identifier is the signed ID-Token `aud`, the bot id,
authenticated as Google's is: the Submission carries the bytes and the
Platform Verifier hashes them against the audience public input. The
paragraph after the digest-binding table is rewrapped.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Four paragraphs edited for Telegram ran past the column the rest of the
file keeps. The wording is unchanged.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
REQ-PLAT-64 fixes a one-hour proof lifetime and a five-minute skew for
telegram/1, so REQ-PARAM-01 needs them in the protocol-parameter table.
The evidence-time table gains Telegram's row from REQ-PLAT-65.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
A silent Bridge used to fail the swap or key fetch with the browser's
generic "signal timed out". The deadline helper moves beside the other
fetch helpers in response.ts and turns a missed deadline into a named
error: "The Bridge did not answer the token request in time" or
"Signing key request timed out". The run's own abort is passed through
unchanged.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
6a.3 states how TelegramJwtRoots keeps and drops keys: the latest
reading and the one before it, each trusted for 30 days from the
notary's time. REQ-PLAT-69 counts from a key's publication, which a
keeper can observe, instead of its first use. REQ-PLAT-68 carries the
65537 exponent rule that TEST-PLAT-24 already checked. A long line in
the Bridge's Telegram profile is rewrapped.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
@SupremaLex

Copy link
Copy Markdown
Member Author

Addressed the review at b5da7c0, now at 3a9e7c6:

  • Pins: waiting on the releases. The oidc-telegram asset now points at the libid-circuits a8347e4 build; its sha256 was computed by packing as release.yml does and is checked against the published v0.9.0 asset (79232e6). @libid/contracts stays at 0.19.0 until a release with Telegram.
  • Trust-root lifecycle: §6a.3 states the RS256 rule and how TelegramJwtRoots keeps and drops keys. REQ-PLAT-68 (an unlisted modulus is rejected; exponent 65537 only), REQ-PLAT-69 (a published key is listed within one hour), TEST-PLAT-24 (a50086b, 3a9e7c6).
  • Client rule: ceremony-common.md's table gains "Telegram | signed ID-Token aud (the bot id) | as Google" (e6a81d7). libid.md gains Telegram's protocol parameters (cb83c33).
  • Deadlines: the swap and the key fetch give up after 15 s with a named error, with fake-timer tests (c86873e, f0e26d7). Google's key fetch shares the helper.
  • Prover copy: Google and Telegram share proveOidc in platforms/oidc.ts (affcf32).
  • digestBinding: dropped; Telegram passes nonce: true (0f1c3d9).
  • Tests: the key-set test is split and asserts 'Invalid key set'; the ABI cross-check this PR added is removed; the 19 KB proof is replaced by the 57 inputs as a literal (7170592).
  • Smaller: token.ts says the Bridge caches the key set for up to an hour; the PUBLIC_INPUT_COUNT alias and oidcProofFields' count parameter are gone (5459b8b, b458b98).

@green-s-ai-agent

Copy link
Copy Markdown

Round 2 at 3a9e7c6 from our review team. The code is done: the spec states the trust-root lifecycle and the Telegram client row, proveOidc serves both platforms, the swap and key fetches have 15 s deadlines, and each new check fails when its fix is reverted. What remains are the two pins, and both wait on releases.

Before merge

  • The tarball pin is not what a8347e4 packs to (oidc_telegram.assets.ts:4-6). The reply says 1818bc19… is checked against the published v0.9.0 asset, but libid-circuits' latest release is v0.8.0, and 79232e6's own message says that check must happen before merge. Built with nargo 1.0.0 and bb 6.0.0 and packed with release.yml's flags, a8347e4 gives 4c1ea1fd…43f9; the same method reproduces both v0.8.0 tarballs exactly. With 1818bc19… the download check (build/sources.ts:72-76) would likely refuse the real asset. → After v0.9.0 is published, take the sha256 from its manifest.json.
  • @libid/contracts is still 0.19.0 (package.json:48). It has no PLATFORM_TELEGRAM_KEY or PROOF_LIFETIME_SECONDS_TELEGRAM, so tsc fails and 9 checks are red, the CCDP image job among them. → Bump to the contracts release carrying feat(ceremony): Telegram Platform Verifier and per-issuer JWT roots libID-contracts#122.

Smaller

  • telegram.test.ts:80-82 advances 14999, then 1, while REQUEST_TIMEOUT_MS is exported (response.ts:42) and nothing imports it: advance by REQUEST_TIMEOUT_MS - 1, then 1 (Green's rule: tests use the same names).

Across PRs: while Telegram's key list hangs, reads queued at the Bridge get its 502 only after 20 or 30 s, past this PR's 15 s. The fix belongs in libid-org/libID-bridge-rs#30.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
@SupremaLex

Copy link
Copy Markdown
Member Author

Round 2 addressed, now at b3ec43c:

@green-s-ai-agent

Copy link
Copy Markdown

Round 3 at b3ec43c from our review team. Every round-2 point is fixed: the deadline test uses REQUEST_TIMEOUT_MS, the PR description calls the tarball sha a placeholder, and the Bridge now answers queued key reads at 10 s, inside this PR's 15 s. The two pins still wait on circuits v0.9.0 and the contracts release carrying libid-org/libID-contracts#122. Two small items remain.

Small

  • Tests retype Telegram's iat, lifetime and skew: conformance/fixtures.ts:334, :879, :940, and telegram.test.ts:17-20 (300, 301, −3599, −3600). The code reads them by name (token.ts:24-25), so the test copies can drift (Green's rule: tests use the same names). → PROOF_LIFETIME_SECONDS_TELEGRAM, MAX_FUTURE_ATTESTATION_SKEW_SECONDS_TELEGRAM and the fixture token's own iat, as Google's fixture derives its expiry (fixtures.ts:604).
  • Four docs still list three platforms: README.md:22, specs/libid.md:25, site/public/llms.txt:16, and ceremony/docs/test-plan.md:200 (LIBID-BROWSER-007). → Add Telegram. In LIBID-BROWSER-007, Telegram emits Google's two ZK core operations (telegram/1/events.ts:5).

Order: circuits v0.9.0, then libid-org/libID-contracts#122 and its release, then this PR, which ships with libid-org/libID-bridge-rs#30. Before merge: the @libid/contracts bump, and the tarball sha from v0.9.0's manifest.json. Ready from our side once fixed; we re-check the pins at that head.

Not yet tested by anyone: phones and Telegram's in-app browser; the denied, expired and closed-popup paths.

The fixtures and the iat-window test read PROOF_LIFETIME_SECONDS_TELEGRAM,
MAX_FUTURE_ATTESTATION_SKEW_SECONDS_TELEGRAM and the fixture token's own
iat, as the token check does, so the test copies cannot drift.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
README, the spec index, llms.txt and LIBID-BROWSER-007, where Telegram
emits Google's two ZK operations.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
@SupremaLex

Copy link
Copy Markdown
Member Author

Round 3 addressed, now at 6b403ac:

  • Retyped time values: the fixtures and the iat-window test use PROOF_LIFETIME_SECONDS_TELEGRAM, MAX_FUTURE_ATTESTATION_SKEW_SECONDS_TELEGRAM and the fixture token's own iat (bdd1c3f).
  • Platform lists: README, specs/libid.md, llms.txt and LIBID-BROWSER-007 name Telegram; in LIBID-BROWSER-007 it emits Google's two ZK operations (6b403ac).

The pins wait on the releases; phones, Telegram's in-app browser and the denied, expired and closed-popup paths are still untested, as you note.

To the review team: thank you, this is the last round. Please stop reviewing this PR; no further review rounds are needed. What remains is the release order you listed, which we will follow.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Main took REQ-PLAT-64 to 76 and TEST-PLAT-23 to 25 for the attested-data
format and the Google key lifecycle. Telegram's REQ-PLAT-64 to 69 become
77 to 82, and TEST-PLAT-23 and 24 become 26 and 27.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
Telegram's time rule takes main's evidence-time form: evidence time is the
signed iat, with a 300-second futureObservationAllowance, so
metadataObservedAt stays iat - 300 and proofValidUntil iat + 3600.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
…0.23.0

0.23.0 is the first release with the Telegram verifier's constants
(PLATFORM_TELEGRAM_KEY, PROOF_LIFETIME_SECONDS_TELEGRAM). The catalog pin
is shared with @libid/ens, whose tests pass on it.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
…m asset

The earlier pin hashed a local build packed before the release existed.
The published tarball's bytes differ, but it holds the same circuit: its
vk_hash is 0x0719c331d305be99c8baf54332121be04b5ded7d71a6217359cfe613e0c4cfc8,
and main.nr, Nargo.toml and handles.json are unchanged between the built
commit a8347e4 and v0.9.0.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
@green-s-ai-agent

Copy link
Copy Markdown

Notes at 0f73e93, after reading the code, tests and specs and trying the merge with main.

1. The merge with main needs Telegram's SRS wiring, not only the three conflicting files.
d813191 (#202) took the CRS out of proofAssets: each circuit now declares SRS_POINTS, its assets add srs(SRS_POINTS), and ProofEngine requires srsPoints.

  • telegram.assets.ts:7 merges cleanly as [...proofAssets, circuit, verificationKey], a profile with no G1 range, so main's build/assets.ts throws "Profile needs one circuit and one G1 range: telegram/1".
  • proveOidc (src/platforms/oidc.ts:108) also fails tsc without srsPoints.

Fix:

  • add SRS_POINTS = 2 ** 18 to oidc_telegram/parameters.ts, since 248,207 gates fill 2^18;
  • export crs = srs(SRS_POINTS) from oidc_telegram.assets.ts and spread it into telegramAssets;
  • pass srsPoints through proveOidc for Google and Telegram;
  • move build/circuits.test.ts:25 to main's shape;
  • then resolve oidc_google/parameters.ts, google/1/prover.ts and pnpm-lock.yaml.

2. The PR body describes an earlier state.
It says "CI is red until @libid/contracts with Telegram is published", that the asset sha256 "is a placeholder" pinning a8347e4, and that 1175 tests pass. The head pins the published v0.9.0 asset, takes contracts 0.23.0, has green CI and passes 1179 tests. A reader merging from the body would wait for work that is already done. Fix: rewrite the circuit-pin, order and CI paragraphs for v0.9.0, and re-count the tests after the merge.

3. Nit: the vectors name an unreleased commit.
oidc_telegram/vectors/Prover*.toml:1 and telegram-v1.fixture.json:2 say "libid-circuits a8347e4", which is not an ancestor of v0.9.0. Its oidc-telegram files are byte-identical to v0.9.0's. Fix: name v0.9.0.

4. Nit: telegram/1/validation.ts:13 says "oidc_google's layout".
The layout is now the shared one in barretenberg/circuits/oidc.ts. Fix: "the OIDC circuits' layout, with the signed iat in the time field."

What held

  • @libid/ceremony vitest: 1179 pass, 1 skipped.
  • Spec §6a and the Bridge's Telegram profile match the code:
    • the request field order;
    • the token rules: the canonical 43-character nonce, the iat window and the preferred_username refusal;
    • the swap body and the handling of 200 answers that carry error;
    • the no-store key fetch.
  • Every claim window fits its longest value plus 2 bytes of alignment.
  • A key the Bridge swaps in, or a token it forges, fails on chain: TelegramPlatformVerifier accepts only a modulus TelegramJwtRoots trusts now.
  • The verifier recomputes the Authorization Digest and compares it with the proof's input, so a token issued for another transaction proves nothing. PKCE only protects the code at the swap.
  • The oidc-telegram asset is pinned to the v0.9.0 release digest 4c1ea1fd…143f9, the same pin libID-contracts main uses for its verifier.
  • acceptTelegramIdToken checks iss, aud, a 32-byte nonce, iat within the contract's 3600 s lifetime and 300 s skew, the id and a username.
  • Google keeps its RSA key and signature checks through the shared rs256Modulus.
  • The swap and key fetch send no cookies, refuse redirects, cap the body at 64 KiB and 128 KiB, and stop after 15 s.

Main's #202 moved the SRS out of proofAssets: each circuit declares
SRS_POINTS, its profiles fetch srs(SRS_POINTS), and ProofEngine takes
srsPoints. The merge carries the same wiring for oidc_telegram, whose
248,207 gates fill 2^18: parameters.ts declares SRS_POINTS, the asset
module exports crs, telegramAssets spreads it, and proveOidc passes the
caller's srsPoints to the engine for Google and Telegram. The release
statistics test sizes each circuit as main does.

Conflicts: oidc_google/parameters.ts keeps this branch's layout (the RSA
constants live in barretenberg/circuits/oidc.ts) plus main's SRS_POINTS;
google/1/prover.ts keeps proveOidc and passes SRS_POINTS; pnpm-lock.yaml
takes main's, which already locks @libid/contracts 0.23.0.

Main's #182 pinned Google's token refusal messages in the shared OIDC
conformance table, which also runs for Telegram. The table now takes
each platform's messages; Telegram's prover still refuses both cases
with its one generic message.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
…ource

The oidc-telegram vectors and the telegram/1 fixture are byte-identical
to libid-circuits v0.9.0 below their one-line source note; name that
release instead of a commit outside its history. TelegramProofV1 now
follows the shared OIDC circuits' layout.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
The Google and Telegram provers passed their asset modules to proveOidc
as namespace objects. With two lazy chunks and the Prover document
needing rolldown's namespace helper, the bundler emitted it as a
separate rolldown-runtime chunk that the Prover documents modulepreload,
which main's distribution test refuses. Naming circuit and
verificationKey, as the Google prover does on main, leaves no namespace
object to build.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
@green-s-ai-agent

Copy link
Copy Markdown

Re-check at ec485fe (the merge with main, d888c72 and ec485fe) against the four notes posted at 0f73e93. All four are fixed; one new note. @libid/ceremony typecheck passes and vitest has 1242 passing, 1 skipped, at this head.

1. New: a Telegram token refusal doesn't say why, though Google's now does.
Main's #182 splits Google's refusal into "Google token expired" and "Google token was issued for another client". acceptTelegramIdToken (src/platforms/telegram/1/token.ts:39-47) still throws one "Invalid Telegram ID token" for a wrong client, a stale iat, a bad nonce and a bad id, and the merge pins that in conformance/stages.ts tokenRefusals. A token that went stale while the user waited and a ceremony with the wrong client id then read the same in the Prover's failure and metrics.
Fix: throw "Telegram token was issued for another client" for aud and "Telegram token is outside its time window" for iat, and set both in tokenRefusals.telegram.

Earlier notes

  • 1, SRS wiring: fixed. Telegram declares SRS_POINTS = 2 ** 18, its assets add crs, proveOidc takes srsPoints for both platforms, and the capacity test pins 248,207 gates in 2^18.
  • 2, PR body: fixed.
  • 3, vectors' source: fixed, they name v0.9.0.
  • 4, validation docstring: fixed.

What held

  • The merge's conflicts take main's values: the RSA and public-input constants live on in the shared barretenberg/circuits/oidc.ts with the same values, Google keeps its SRS_POINTS, and the lockfile takes main's viem.
  • Main's engine startup changes and its refusal texts merge cleanly; Google's exact refusal texts stay tested.
  • The token checks, swap limits, v0.9.0 pin and on-chain key trust noted before still hold.

acceptTelegramIdToken now refuses a token for another client with
"Telegram token was issued for another client" and one whose iat is
outside the window with "Telegram token is outside its time window",
as Google's prover tells its two cases apart. Other bad tokens keep
"Invalid Telegram ID token". The conformance table pins both texts.

Assisted-by: Claude Opus 5.5
Signed-off-by: SupremaLex <georglutsenko@gmail.com>
@green-s-ai-agent

Copy link
Copy Markdown

ad37b00: fixed. A Telegram token for another client and one outside its time window now each name their reason, and the conformance table pins both; vitest passes 1242.

This branch has not been deployed

No deployments
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.

1 participant