Repository navigation
fix(#76): rebuild the claim in the encoding AdSense actually produces - #79
Merged
Merged
Conversation
The frozen interface described a request the AdSense API cannot serve, so every real proof would have been refused with a bare ClaimMismatch and no indication of which byte was wrong. Found by @Lin1er on #6 while building the provider. Verified against Google's own reference before changing anything: `startDate` and `endDate` on accounts.reports.generate are `object (Date)` — {year, month, day} as integers — which the REST transport flattens into startDate.year=2026&startDate.month=7&startDate.day=1. Unpadded: 7, never 07. There is no string date form to use instead. Two changes, both inside the rebuild: The template now has eight parts and takes seven values — pub_id, then each date as year, month and day. `claim::split_date` converts YYYY-MM-DD on the way in: ten bytes of fixed-width parsing, every byte checked, no JSON. The interface is untouched. `request_advance` still takes YYYY-MM-DD and the nullifier is still computed over those strings, so nothing about what is being borrowed against has moved. `extractedParameters` is now {"revenueUsd": "<x>"} alone. A responseMatches regex captures one contiguous substring and AdSense echoes the window back as {"year":2026,"month":7,"day":1}, so "2026-07-01" cannot be extracted from any response. The currency and the window did not leave the signature, they moved to where the provider actually puts them: the "currencyCode": "USD" match and the URL, both inside the pinned `parameters`. set_claim_template now refuses a four-part template outright. Accepting one and failing per-proof later would hide the cause behind the hardest error in this pipeline to read. The fixture had to be regenerated, and it was a hand-pasted blob nobody could re-derive — which is why nothing caught that it had gone stale. It now comes from tools/make_claim_fixture.py, and CI runs that script with --check so the two cannot drift apart again. Four new tests: a date becomes three unpadded numbers (7, not 07); a window that is not exactly dddd-dd-dd is refused rather than guessed; the rebuilt context is pinned byte for byte, because a context with the old keys still compiles and still hashes and is simply never what an attestor signed; and the template the contract used to accept is refused now. 43 tests pass, fmt and clippy clean. Refs #76, #6, #61, #17, #5 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #76. Unblocks #61, #17 and the on-chain half of #5.
Found by @Lin1er on #6 while building the provider. He was right, and I verified it against Google's reference before changing anything rather than taking the report on trust.
The fact
startDateandendDateonaccounts.reports.generateareobject (Date)— andDateis{year, month, day}as integers. The REST transport flattens that intostartDate.year=2026&startDate.month=7&startDate.day=1. Unpadded, because they are integers:7, never07.There is no string form of a date in that API. So
?startDate=2026-07-01— whatdocs/interface.mdfroze and what is pinned on the dev contract right now — describes a request Google cannot serve, and every real AdSense proof would have been refused, with a bareClaimMismatchand nothing to say which byte was wrong.Two changes, both inside the rebuild
The template takes seven values instead of three:
pub_id, sy, sm, sd, ey, em, ed, so eight parts.claim::split_dateconvertsYYYY-MM-DDon the way in — ten bytes of fixed-width parsing, every byte checked, no JSON, no allocation beyond the three outputs.extractedParametersis{"revenueUsd":"<x>"}alone. AresponseMatchesregex captures one contiguous substring, and AdSense echoes the window back as"startDate":{"year":2026,"month":7,"day":1}—"2026-07-01"does not appear anywhere in the response, so it cannot be captured from one.What did not change, and this is the part worth checking
The interface.
request_advance(…, window_start: "YYYY-MM-DD", window_end, …)is byte-identical, and the nullifier is stillsha256over those two strings pluspub_id. Nothing about what is being borrowed against moved. This is a re-encoding on the way into the template.The strength of the currency and window checks. Both left
extractedParameters; neither left the signature:extractedParameters.currency"currencyCode": "USD"response matchextractedParameters.startDate/.endDateBoth of those live in
parameters, which this contract pins and rebuilds. If anything, the window is held more tightly now: it is in the thing Google computed from, not in an echo of it.set_claim_templaterefuses a four-part template outrightAccepting the old shape and failing per-proof later would bury the cause under the least readable error in this pipeline. Better to refuse the template.
This means the dev contract's currently pinned template has to be re-pinned after the upgrade. I will do that and re-run the rehearsal; details below.
The fixture was the real failure
tools/fixtures/forepay-claim.jsonwas a hand-pasted blob. Nobody could re-derive it, so when the encoding changed there was no mechanism by which anyone would notice it had gone stale — the digest tests would just keep passing against bytes that no longer described anything.It now comes from
tools/make_claim_fixture.py, and CI runs that script with--check. The signing key is a published test constant, the same onetools/rehearsal.pyuses; the real attestor vector is stillreal-reclaim-proof.jsonand is untouched.Tests
43 pass,
fmtandclippy -D warningsclean. Four new:a_date_becomes_three_unpadded_numbers—7, not07. A padded month produces a URL Google never sent.a_window_that_is_not_yyyy_mm_dd_is_refused_rather_than_guessed— eight malformed inputs.the_context_carries_only_the_figure— pinned byte for byte, because a context with the old keys still compiles, still hashes, and is simply never what an attestor signed. No type catches that.the_template_the_contract_used_to_accept_is_refused_now.Cross-checked that
tools/rehearsal.py,tools/make_claim_fixture.pyandbe/src/adsense/request.ts(#74) all produce the same URL bytes.After this merges
v0.3.0→ release artifact, attested to StellarExpert.propose_upgradeon both contracts, 24h timelock,execute_upgrade.TemplateNotSetuntil Pin the AdSense claim template on the deployed advance contract #61, which still waits on FEASIBILITY GATE: one real AdSense revenue proof verified on testnet #5 — and on Find an approved (READY) AdSense account for the gate and the demo #77, which nobody has picked up.@Lin1er — once this is deployed, hand me the real template parts and
provider_hashfrom the first proof and #61 is one admin call. The eight parts you will need to supply are the literal segments around those seven values, in the order above.🤖 Generated with Claude Code