From 682f624207b4ac671c4cc79b3d768c65158ccb62 Mon Sep 17 00:00:00 2001 From: lin1er Date: Mon, 26 Oct 2026 22:55:49 +0700 Subject: [PATCH 1/3] fix(#102): verify the attestor's owner against a pinned app id, not the borrower MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit verify_claim rebuilt the digest's owner as the borrower's G… address, lowercased. A real attestor signs owner = the requesting Reclaim app (RECLAIM_APP_ID), so no real proof, AdSense or AdMob, could ever verify: the first real claim recovers to 0x9726…7896 under the old rebuild and to the attestor under the right one (#102). - DataKey::ClaimOwner, appended; set_claim_owner (admin, 0x + 40 hex, stored lowercase) and claim_owner(). verify_claim uses the pinned owner. Absent, it falls back to the borrower, which is what the rehearsal's test witness signs, so the dev contract and rehearsal.py keep working until it is pinned there. - The fixture is signed a second time with the app as owner. Tests: without a pin that claim is refused (the bug, kept as a test); pinned, it verifies; pinned, a borrower-owner claim is refused; the borrower binding is unchanged; malformed owners are refused; admin only. - docs/interface.md says what owner is and that it never bound the borrower. --- docs/interface.md | 6 + sc/advance/src/claim.rs | 8 + sc/advance/src/lib.rs | 53 ++- sc/advance/src/test_claim.rs | 127 +++++++- .../only_the_admin_can_pin_the_owner.1.json | 99 ++++++ ...r_binding_survives_the_pinned_owner.1.json | 303 +++++++++++++++++ ...ed_lowercase_and_must_look_like_one.1.json | 308 ++++++++++++++++++ ..._signed_for_the_borrower_is_refused.1.json | 303 +++++++++++++++++ ...pinned_as_owner_that_claim_verifies.1.json | 303 +++++++++++++++++ ...as_a_real_attestor_signs_is_refused.1.json | 252 ++++++++++++++ tools/fixtures/forepay-claim.json | 6 +- tools/make_claim_fixture.py | 14 + 12 files changed, 1776 insertions(+), 6 deletions(-) create mode 100644 sc/advance/test_snapshots/test_claim/only_the_admin_can_pin_the_owner.1.json create mode 100644 sc/advance/test_snapshots/test_claim/the_borrower_binding_survives_the_pinned_owner.1.json create mode 100644 sc/advance/test_snapshots/test_claim/the_owner_is_stored_lowercase_and_must_look_like_one.1.json create mode 100644 sc/advance/test_snapshots/test_claim/with_the_app_pinned_a_claim_signed_for_the_borrower_is_refused.1.json create mode 100644 sc/advance/test_snapshots/test_claim/with_the_app_pinned_as_owner_that_claim_verifies.1.json create mode 100644 sc/advance/test_snapshots/test_claim/without_a_pinned_owner_a_claim_signed_as_a_real_attestor_signs_is_refused.1.json diff --git a/docs/interface.md b/docs/interface.md index ae703bf..888aaea 100644 --- a/docs/interface.md +++ b/docs/interface.md @@ -28,6 +28,11 @@ sign_data = identifier \n owner_lowercase \n timestamp_s \n epoch digest = keccak256("\x19Ethereum Signed Message:\n" + len(sign_data) + sign_data) ``` +**`owner` is the Reclaim app that requested the proof, not the borrower** (#102). A real attestor +sets it to the app id the relay proves with (`RECLAIM_APP_ID`), so the contract cannot rebuild it from +the claim and pins it instead (`set_claim_owner`). The borrower is bound by `contextAddress`, inside +`identifier`, and never was by `owner`. + **The revenue figure is not a signed field.** It lives in `context` and reaches the signature only through `identifier`. Nothing may trust a figure that was not fed into the identifier computation. @@ -52,6 +57,7 @@ vary. | `provider` | constant `"http"` | Reclaim's HTTP provider | | `parameters_template` | **admin, `set_claim_template`** | The exact bytes come from the first live proof (#5) | | `provider_hash` | **admin, same call** | Reclaim's provider hash for the AdSense provider | +| `claim_owner` | **admin, `set_claim_owner`** | The attestor's `owner`: Forepay's Reclaim app id, lowercase (#102). Absent means the borrower, which only the rehearsal's test witness signs | `set_claim_template` is admin-gated and may be called again — the template changes whenever the provider version changes. It does **not** invalidate existing advances; it only governs what a new diff --git a/sc/advance/src/claim.rs b/sc/advance/src/claim.rs index 58c459a..dcd4d0e 100644 --- a/sc/advance/src/claim.rs +++ b/sc/advance/src/claim.rs @@ -243,6 +243,14 @@ pub fn borrower_bytes(env: &Env, borrower: &Address) -> Option { string_bytes(env, &borrower.to_string()) } +/// `0x` followed by exactly 40 hex digits, either case: the shape of a Reclaim owner. +pub fn is_eth_address(b: &Bytes) -> bool { + if b.len() != 42 || b.get(0) != Some(b'0') || b.get(1) != Some(b'x') { + return false; + } + (2..42).all(|i| matches!(b.get(i), Some(c) if c.is_ascii_hexdigit())) +} + /// ASCII-lowercase a byte string. /// /// Reclaim lowercases `owner` before signing, so the digest must be built from the diff --git a/sc/advance/src/lib.rs b/sc/advance/src/lib.rs index c96c226..0b4d890 100644 --- a/sc/advance/src/lib.rs +++ b/sc/advance/src/lib.rs @@ -77,6 +77,10 @@ pub enum DataKey { /// One advance, keyed by the nullifier that funded it. Persistent: an advance that /// vanished when its TTL lapsed would erase a debt, which is not a rounding error. Advance(BytesN<32>), + /// The attestor's `owner` every claim must carry: the Reclaim app the relay proves + /// with, `0x…`, lowercase (#102). Absent means the borrower, which is what the + /// rehearsal's test witness signs; no real attestor claim has that owner. + ClaimOwner, } /// An advance that has been paid out, and what is still owed on it. @@ -285,6 +289,13 @@ pub struct ClaimTemplateSet { pub parts: u32, } +#[contractevent] +pub struct ClaimOwnerSet { + #[topic] + pub admin: Address, + pub owner: Bytes, +} + #[contractevent] pub struct NullifierSpent { #[topic] @@ -508,6 +519,37 @@ impl AdvanceContract { env.storage().instance().get(&DataKey::ProviderHash) } + /// Pin the attestor's `owner`: the Reclaim app id the relay proves with (#102). + /// + /// A real attestor signs `identifier \n owner \n timestamp \n epoch` with `owner` set + /// to the **requesting app's** address, not to anything in the claim. The contract + /// cannot read it from the claim, because it rebuilds the digest rather than trusting + /// one, so it has to be pinned like the template. Pinning it also refuses claims made + /// through any other Reclaim app. + /// + /// It carries no part of the borrower binding: that lives in `contextAddress`, inside + /// the identifier, and is unaffected. + /// + /// `owner` must be `0x` and 40 hex digits. It is stored lowercased, because Reclaim + /// lowercases it before signing. + pub fn set_claim_owner(env: Env, owner: Bytes) -> Result<(), Error> { + let admin = Self::require_admin(&env)?; + if !claim::is_eth_address(&owner) { + return Err(Error::ClaimMismatch); + } + let owner = claim::lowercase(&env, &owner); + env.storage().instance().set(&DataKey::ClaimOwner, &owner); + Self::bump(&env); + + ClaimOwnerSet { admin, owner }.publish(&env); + Ok(()) + } + + /// The pinned owner, if one is set. Absent means the borrower (the rehearsal's form). + pub fn claim_owner(env: Env) -> Option { + env.storage().instance().get(&DataKey::ClaimOwner) + } + // -------------------------------------------------- verify a claim (#9) /// Check a Reclaim proof and return only what it actually attested. @@ -574,9 +616,14 @@ impl AdvanceContract { let identifier = claim::identifier(&env, ¶meters, &context); let identifier_hex = claim::hex_prefixed(&identifier); - // The attestor's `owner` is the borrower's own address, lowercased, because that - // is what the relay put in the claim. Reclaim lowercases it before signing. - let owner = claim::lowercase(&env, &borrower_b); + // The attestor's `owner` is the Reclaim app that requested the proof, pinned by the + // admin (#102). Before #102 this was the borrower, which no real attestor claim + // carries; that form survives only where nothing is pinned, for the rehearsal's + // test witness. Reclaim lowercases the owner before signing. + let owner: Bytes = match env.storage().instance().get(&DataKey::ClaimOwner) { + Some(pinned) => pinned, + None => claim::lowercase(&env, &borrower_b), + }; let digest = claim::message_digest(&env, &identifier_hex, &owner, timestamp_s, epoch); let verifier: Address = env diff --git a/sc/advance/src/test_claim.rs b/sc/advance/src/test_claim.rs index b0b3263..109593b 100644 --- a/sc/advance/src/test_claim.rs +++ b/sc/advance/src/test_claim.rs @@ -39,6 +39,11 @@ pub(crate) const TIMESTAMP_S: u64 = 1_760_000_000; pub(crate) const EPOCH: u64 = 1; const SIGNATURE_HEX: &str = "0a1607562845069dcd91874ae32ffc55d2ce799078af623b8300c1765137ca0f577ba3ed8dc8895867e717734d9535536384718e77126229ed28327c54cf202f"; pub(crate) const RECOVERY_ID: u32 = 1; +/// The same claim, signed the way a real attestor signs it: with `owner` set to the +/// requesting Reclaim app rather than the borrower (#102). From the fixture's `appOwner*`. +const APP_OWNER: &str = "0x6415200c713135e77157e1536d488df4f2bb7d04"; +const APP_SIGNATURE_HEX: &str = "be04cabf370de372ce48726350419d76169f5b35fa64ba03ffb5db5b1a5a4a6a773196501dcfd7a42b94a1a510c9aaa0ff5536cb37ed0ada1f917415da9e96c7"; +const APP_RECOVERY_ID: u32 = 0; /// The address the fixture's signature recovers to. const SIGNER: [u8; 20] = [ 0x19, 0xe7, 0xe3, 0x76, 0xe7, 0xc2, 0x13, 0xb7, 0xe7, 0xe7, 0xe4, 0x6c, 0xc7, 0x0a, 0x5d, 0xd0, @@ -160,10 +165,14 @@ fn setup() -> Fixture { } pub(crate) fn signature(env: &Env) -> BytesN<64> { + signature_from(env, SIGNATURE_HEX) +} + +fn signature_from(env: &Env, hex: &str) -> BytesN<64> { let mut raw = [0u8; 64]; for (i, b) in raw.iter_mut().enumerate() { - let hi = SIGNATURE_HEX.as_bytes()[i * 2]; - let lo = SIGNATURE_HEX.as_bytes()[i * 2 + 1]; + let hi = hex.as_bytes()[i * 2]; + let lo = hex.as_bytes()[i * 2 + 1]; let v = |c: u8| if c >= b'a' { c - b'a' + 10 } else { c - b'0' }; *b = (v(hi) << 4) | v(lo); } @@ -413,6 +422,120 @@ fn a_template_with_the_wrong_number_of_parts_is_refused() { ); } +// --- #102: the attestor's owner is the app, pinned, not the borrower --- + +/// `verify_claim` on the fixture signed with the app as owner. +fn verify_app_signed(f: &Fixture) -> Result { + match f.client.try_verify_claim( + &f.borrower, + &String::from_str(&f.env, REVENUE), + &String::from_str(&f.env, PUB_ID), + &String::from_str(&f.env, WINDOW_START), + &String::from_str(&f.env, WINDOW_END), + &TIMESTAMP_S, + &EPOCH, + &signature_from(&f.env, APP_SIGNATURE_HEX), + &APP_RECOVERY_ID, + ) { + Ok(Ok(claim)) => Ok(claim), + Err(Ok(e)) => Err(e), + other => panic!("unexpected host-level result: {other:?}"), + } +} + +#[test] +fn without_a_pinned_owner_a_claim_signed_as_a_real_attestor_signs_is_refused() { + // The #102 bug, kept as a test: rebuilding the owner from the borrower cannot match a + // claim whose owner is the requesting app, which is every real attestor claim. + let f = setup(); + assert_eq!(verify_app_signed(&f), Err(Error::VerifierRejected)); +} + +#[test] +fn with_the_app_pinned_as_owner_that_claim_verifies() { + let f = setup(); + f.client + .set_claim_owner(&Bytes::from_slice(&f.env, APP_OWNER.as_bytes())); + let claim = verify_app_signed(&f).expect("a claim signed for the pinned app must verify"); + assert_eq!(claim.borrower, f.borrower); +} + +#[test] +fn with_the_app_pinned_a_claim_signed_for_the_borrower_is_refused() { + let f = setup(); + f.client + .set_claim_owner(&Bytes::from_slice(&f.env, APP_OWNER.as_bytes())); + assert!(verify(&f, REVENUE, PUB_ID, &f.borrower).is_err()); +} + +#[test] +fn the_borrower_binding_survives_the_pinned_owner() { + // The owner is the app for everyone, so it cannot be what binds the borrower. The + // context still does: another address changes the identifier. + let f = setup(); + f.client + .set_claim_owner(&Bytes::from_slice(&f.env, APP_OWNER.as_bytes())); + let attacker = Address::generate(&f.env); + let out = f.client.try_verify_claim( + &attacker, + &String::from_str(&f.env, REVENUE), + &String::from_str(&f.env, PUB_ID), + &String::from_str(&f.env, WINDOW_START), + &String::from_str(&f.env, WINDOW_END), + &TIMESTAMP_S, + &EPOCH, + &signature_from(&f.env, APP_SIGNATURE_HEX), + &APP_RECOVERY_ID, + ); + assert_eq!(out, Err(Ok(Error::VerifierRejected))); +} + +#[test] +fn the_owner_is_stored_lowercase_and_must_look_like_one() { + let f = setup(); + let upper = APP_OWNER.to_uppercase().replacen("0X", "0x", 1); + f.client + .set_claim_owner(&Bytes::from_slice(&f.env, upper.as_bytes())); + assert_eq!( + f.client.claim_owner(), + Some(Bytes::from_slice(&f.env, APP_OWNER.as_bytes())) + ); + assert!(verify_app_signed(&f).is_ok()); + + for bad in [ + "6415200c713135e77157e1536d488df4f2bb7d04", + "0x6415200c713135e77157e1536d488df4f2bb7d0", + "0x6415200c713135e77157e1536d488df4f2bb7d0g", + "GA2CD6PMHMBTCFAQDO3R22BSZN5ZSVTAKVNOKXL2SONZBLGRAYIOWWH2", + ] { + assert_eq!( + f.client + .try_set_claim_owner(&Bytes::from_slice(&f.env, bad.as_bytes())), + Err(Ok(Error::ClaimMismatch)), + "{bad}" + ); + } +} + +#[test] +fn only_the_admin_can_pin_the_owner() { + let env = Env::default(); + let id = env.register( + AdvanceContract, + ( + Address::generate(&env), + Address::generate(&env), + Address::generate(&env), + ), + ); + let client = AdvanceContractClient::new(&env, &id); + // No auth mocked: require_auth must bite. + assert!(client + .try_set_claim_owner(&Bytes::from_slice(&env, APP_OWNER.as_bytes())) + .is_err()); + assert_eq!(client.claim_owner(), None); +} + // --- #10: the nullifier registry --- fn reserve(f: &Fixture, borrower: &Address) -> Result { diff --git a/sc/advance/test_snapshots/test_claim/only_the_admin_can_pin_the_owner.1.json b/sc/advance/test_snapshots/test_claim/only_the_admin_can_pin_the_owner.1.json new file mode 100644 index 0000000..bb0430f --- /dev/null +++ b/sc/advance/test_snapshots/test_claim/only_the_admin_can_pin_the_owner.1.json @@ -0,0 +1,99 @@ +{ + "generators": { + "address": 4, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [] + ], + "ledger": { + "protocol_version": 29, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Usdc" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Verifier" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 3110400 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a", + "code": "746573745f636f6e74726163745f666f725f636f6e74726163745f69645f4341414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414149544134" + } + }, + "ext": "v0" + }, + "live_until": 3110400 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/sc/advance/test_snapshots/test_claim/the_borrower_binding_survives_the_pinned_owner.1.json b/sc/advance/test_snapshots/test_claim/the_borrower_binding_survives_the_pinned_owner.1.json new file mode 100644 index 0000000..56298c9 --- /dev/null +++ b/sc/advance/test_snapshots/test_claim/the_borrower_binding_survives_the_pinned_owner.1.json @@ -0,0 +1,303 @@ +{ + "generators": { + "address": 5, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "function_name": "set_claim_template", + "args": [ + { + "vec": [ + { + "bytes": "7b226d6574686f64223a22474554222c2275726c223a2268747470733a2f2f616473656e73652e676f6f676c65617069732e636f6d2f76322f6163636f756e74732f" + }, + { + "bytes": "2f7265706f7274733a67656e65726174653f6461746552616e67653d435553544f4d267374617274446174652e796561723d" + }, + { + "bytes": "267374617274446174652e6d6f6e74683d" + }, + { + "bytes": "267374617274446174652e6461793d" + }, + { + "bytes": "26656e64446174652e796561723d" + }, + { + "bytes": "26656e64446174652e6d6f6e74683d" + }, + { + "bytes": "26656e64446174652e6461793d" + }, + { + "bytes": "266d6574726963733d455354494d415445445f4541524e494e47532663757272656e6379436f64653d555344267265706f7274696e6754696d655a6f6e653d4143434f554e545f54494d455f5a4f4e45227d" + } + ] + }, + { + "bytes": "307835363962393332333331383563303534656439666461363862356165663866646131383062366432393131383034353062663735376231316262353266376466" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "function_name": "set_claim_owner", + "args": [ + { + "bytes": "307836343135323030633731333133356537373135376531353336643438386466346632626237643034" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [] + ], + "ledger": { + "protocol_version": 29, + "sequence_number": 0, + "timestamp": 1760000010, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "a41146d7d116b29faf18d228425fa97194e16df1d4f3e5d4f51c58ca557fcc6d" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "vec": [ + { + "symbol": "ClaimOwner" + } + ] + }, + "val": { + "bytes": "307836343135323030633731333133356537373135376531353336643438386466346632626237643034" + } + }, + { + "key": { + "vec": [ + { + "symbol": "ParamsTemplate" + } + ] + }, + "val": { + "vec": [ + { + "bytes": "7b226d6574686f64223a22474554222c2275726c223a2268747470733a2f2f616473656e73652e676f6f676c65617069732e636f6d2f76322f6163636f756e74732f" + }, + { + "bytes": "2f7265706f7274733a67656e65726174653f6461746552616e67653d435553544f4d267374617274446174652e796561723d" + }, + { + "bytes": "267374617274446174652e6d6f6e74683d" + }, + { + "bytes": "267374617274446174652e6461793d" + }, + { + "bytes": "26656e64446174652e796561723d" + }, + { + "bytes": "26656e64446174652e6d6f6e74683d" + }, + { + "bytes": "26656e64446174652e6461793d" + }, + { + "bytes": "266d6574726963733d455354494d415445445f4541524e494e47532663757272656e6379436f64653d555344267265706f7274696e6754696d655a6f6e653d4143434f554e545f54494d455f5a4f4e45227d" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "ProviderHash" + } + ] + }, + "val": { + "bytes": "307835363962393332333331383563303534656439666461363862356165663866646131383062366432393131383034353062663735376231316262353266376466" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Usdc" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Verifier" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 3110400 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a", + "code": "746573745f636f6e74726163745f666f725f636f6e74726163745f69645f4341414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414149544134" + } + }, + "ext": "v0" + }, + "live_until": 3110400 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "a41146d7d116b29faf18d228425fa97194e16df1d4f3e5d4f51c58ca557fcc6d", + "code": "746573745f636f6e74726163745f666f725f636f6e74726163745f69645f4341414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414144324b4d" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/sc/advance/test_snapshots/test_claim/the_owner_is_stored_lowercase_and_must_look_like_one.1.json b/sc/advance/test_snapshots/test_claim/the_owner_is_stored_lowercase_and_must_look_like_one.1.json new file mode 100644 index 0000000..bb07700 --- /dev/null +++ b/sc/advance/test_snapshots/test_claim/the_owner_is_stored_lowercase_and_must_look_like_one.1.json @@ -0,0 +1,308 @@ +{ + "generators": { + "address": 4, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "function_name": "set_claim_template", + "args": [ + { + "vec": [ + { + "bytes": "7b226d6574686f64223a22474554222c2275726c223a2268747470733a2f2f616473656e73652e676f6f676c65617069732e636f6d2f76322f6163636f756e74732f" + }, + { + "bytes": "2f7265706f7274733a67656e65726174653f6461746552616e67653d435553544f4d267374617274446174652e796561723d" + }, + { + "bytes": "267374617274446174652e6d6f6e74683d" + }, + { + "bytes": "267374617274446174652e6461793d" + }, + { + "bytes": "26656e64446174652e796561723d" + }, + { + "bytes": "26656e64446174652e6d6f6e74683d" + }, + { + "bytes": "26656e64446174652e6461793d" + }, + { + "bytes": "266d6574726963733d455354494d415445445f4541524e494e47532663757272656e6379436f64653d555344267265706f7274696e6754696d655a6f6e653d4143434f554e545f54494d455f5a4f4e45227d" + } + ] + }, + { + "bytes": "307835363962393332333331383563303534656439666461363862356165663866646131383062366432393131383034353062663735376231316262353266376466" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "function_name": "set_claim_owner", + "args": [ + { + "bytes": "307836343135323030433731333133354537373135374531353336443438384446344632424237443034" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [], + [], + [], + [], + [], + [] + ], + "ledger": { + "protocol_version": 29, + "sequence_number": 0, + "timestamp": 1760000010, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "a41146d7d116b29faf18d228425fa97194e16df1d4f3e5d4f51c58ca557fcc6d" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "vec": [ + { + "symbol": "ClaimOwner" + } + ] + }, + "val": { + "bytes": "307836343135323030633731333133356537373135376531353336643438386466346632626237643034" + } + }, + { + "key": { + "vec": [ + { + "symbol": "ParamsTemplate" + } + ] + }, + "val": { + "vec": [ + { + "bytes": "7b226d6574686f64223a22474554222c2275726c223a2268747470733a2f2f616473656e73652e676f6f676c65617069732e636f6d2f76322f6163636f756e74732f" + }, + { + "bytes": "2f7265706f7274733a67656e65726174653f6461746552616e67653d435553544f4d267374617274446174652e796561723d" + }, + { + "bytes": "267374617274446174652e6d6f6e74683d" + }, + { + "bytes": "267374617274446174652e6461793d" + }, + { + "bytes": "26656e64446174652e796561723d" + }, + { + "bytes": "26656e64446174652e6d6f6e74683d" + }, + { + "bytes": "26656e64446174652e6461793d" + }, + { + "bytes": "266d6574726963733d455354494d415445445f4541524e494e47532663757272656e6379436f64653d555344267265706f7274696e6754696d655a6f6e653d4143434f554e545f54494d455f5a4f4e45227d" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "ProviderHash" + } + ] + }, + "val": { + "bytes": "307835363962393332333331383563303534656439666461363862356165663866646131383062366432393131383034353062663735376231316262353266376466" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Usdc" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Verifier" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 3110400 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a", + "code": "746573745f636f6e74726163745f666f725f636f6e74726163745f69645f4341414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414149544134" + } + }, + "ext": "v0" + }, + "live_until": 3110400 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "a41146d7d116b29faf18d228425fa97194e16df1d4f3e5d4f51c58ca557fcc6d", + "code": "746573745f636f6e74726163745f666f725f636f6e74726163745f69645f4341414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414144324b4d" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/sc/advance/test_snapshots/test_claim/with_the_app_pinned_a_claim_signed_for_the_borrower_is_refused.1.json b/sc/advance/test_snapshots/test_claim/with_the_app_pinned_a_claim_signed_for_the_borrower_is_refused.1.json new file mode 100644 index 0000000..834ffc4 --- /dev/null +++ b/sc/advance/test_snapshots/test_claim/with_the_app_pinned_a_claim_signed_for_the_borrower_is_refused.1.json @@ -0,0 +1,303 @@ +{ + "generators": { + "address": 4, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "function_name": "set_claim_template", + "args": [ + { + "vec": [ + { + "bytes": "7b226d6574686f64223a22474554222c2275726c223a2268747470733a2f2f616473656e73652e676f6f676c65617069732e636f6d2f76322f6163636f756e74732f" + }, + { + "bytes": "2f7265706f7274733a67656e65726174653f6461746552616e67653d435553544f4d267374617274446174652e796561723d" + }, + { + "bytes": "267374617274446174652e6d6f6e74683d" + }, + { + "bytes": "267374617274446174652e6461793d" + }, + { + "bytes": "26656e64446174652e796561723d" + }, + { + "bytes": "26656e64446174652e6d6f6e74683d" + }, + { + "bytes": "26656e64446174652e6461793d" + }, + { + "bytes": "266d6574726963733d455354494d415445445f4541524e494e47532663757272656e6379436f64653d555344267265706f7274696e6754696d655a6f6e653d4143434f554e545f54494d455f5a4f4e45227d" + } + ] + }, + { + "bytes": "307835363962393332333331383563303534656439666461363862356165663866646131383062366432393131383034353062663735376231316262353266376466" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "function_name": "set_claim_owner", + "args": [ + { + "bytes": "307836343135323030633731333133356537373135376531353336643438386466346632626237643034" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [] + ], + "ledger": { + "protocol_version": 29, + "sequence_number": 0, + "timestamp": 1760000010, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "a41146d7d116b29faf18d228425fa97194e16df1d4f3e5d4f51c58ca557fcc6d" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "vec": [ + { + "symbol": "ClaimOwner" + } + ] + }, + "val": { + "bytes": "307836343135323030633731333133356537373135376531353336643438386466346632626237643034" + } + }, + { + "key": { + "vec": [ + { + "symbol": "ParamsTemplate" + } + ] + }, + "val": { + "vec": [ + { + "bytes": "7b226d6574686f64223a22474554222c2275726c223a2268747470733a2f2f616473656e73652e676f6f676c65617069732e636f6d2f76322f6163636f756e74732f" + }, + { + "bytes": "2f7265706f7274733a67656e65726174653f6461746552616e67653d435553544f4d267374617274446174652e796561723d" + }, + { + "bytes": "267374617274446174652e6d6f6e74683d" + }, + { + "bytes": "267374617274446174652e6461793d" + }, + { + "bytes": "26656e64446174652e796561723d" + }, + { + "bytes": "26656e64446174652e6d6f6e74683d" + }, + { + "bytes": "26656e64446174652e6461793d" + }, + { + "bytes": "266d6574726963733d455354494d415445445f4541524e494e47532663757272656e6379436f64653d555344267265706f7274696e6754696d655a6f6e653d4143434f554e545f54494d455f5a4f4e45227d" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "ProviderHash" + } + ] + }, + "val": { + "bytes": "307835363962393332333331383563303534656439666461363862356165663866646131383062366432393131383034353062663735376231316262353266376466" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Usdc" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Verifier" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 3110400 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a", + "code": "746573745f636f6e74726163745f666f725f636f6e74726163745f69645f4341414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414149544134" + } + }, + "ext": "v0" + }, + "live_until": 3110400 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "a41146d7d116b29faf18d228425fa97194e16df1d4f3e5d4f51c58ca557fcc6d", + "code": "746573745f636f6e74726163745f666f725f636f6e74726163745f69645f4341414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414144324b4d" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/sc/advance/test_snapshots/test_claim/with_the_app_pinned_as_owner_that_claim_verifies.1.json b/sc/advance/test_snapshots/test_claim/with_the_app_pinned_as_owner_that_claim_verifies.1.json new file mode 100644 index 0000000..834ffc4 --- /dev/null +++ b/sc/advance/test_snapshots/test_claim/with_the_app_pinned_as_owner_that_claim_verifies.1.json @@ -0,0 +1,303 @@ +{ + "generators": { + "address": 4, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "function_name": "set_claim_template", + "args": [ + { + "vec": [ + { + "bytes": "7b226d6574686f64223a22474554222c2275726c223a2268747470733a2f2f616473656e73652e676f6f676c65617069732e636f6d2f76322f6163636f756e74732f" + }, + { + "bytes": "2f7265706f7274733a67656e65726174653f6461746552616e67653d435553544f4d267374617274446174652e796561723d" + }, + { + "bytes": "267374617274446174652e6d6f6e74683d" + }, + { + "bytes": "267374617274446174652e6461793d" + }, + { + "bytes": "26656e64446174652e796561723d" + }, + { + "bytes": "26656e64446174652e6d6f6e74683d" + }, + { + "bytes": "26656e64446174652e6461793d" + }, + { + "bytes": "266d6574726963733d455354494d415445445f4541524e494e47532663757272656e6379436f64653d555344267265706f7274696e6754696d655a6f6e653d4143434f554e545f54494d455f5a4f4e45227d" + } + ] + }, + { + "bytes": "307835363962393332333331383563303534656439666461363862356165663866646131383062366432393131383034353062663735376231316262353266376466" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "function_name": "set_claim_owner", + "args": [ + { + "bytes": "307836343135323030633731333133356537373135376531353336643438386466346632626237643034" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [] + ], + "ledger": { + "protocol_version": 29, + "sequence_number": 0, + "timestamp": 1760000010, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "a41146d7d116b29faf18d228425fa97194e16df1d4f3e5d4f51c58ca557fcc6d" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "vec": [ + { + "symbol": "ClaimOwner" + } + ] + }, + "val": { + "bytes": "307836343135323030633731333133356537373135376531353336643438386466346632626237643034" + } + }, + { + "key": { + "vec": [ + { + "symbol": "ParamsTemplate" + } + ] + }, + "val": { + "vec": [ + { + "bytes": "7b226d6574686f64223a22474554222c2275726c223a2268747470733a2f2f616473656e73652e676f6f676c65617069732e636f6d2f76322f6163636f756e74732f" + }, + { + "bytes": "2f7265706f7274733a67656e65726174653f6461746552616e67653d435553544f4d267374617274446174652e796561723d" + }, + { + "bytes": "267374617274446174652e6d6f6e74683d" + }, + { + "bytes": "267374617274446174652e6461793d" + }, + { + "bytes": "26656e64446174652e796561723d" + }, + { + "bytes": "26656e64446174652e6d6f6e74683d" + }, + { + "bytes": "26656e64446174652e6461793d" + }, + { + "bytes": "266d6574726963733d455354494d415445445f4541524e494e47532663757272656e6379436f64653d555344267265706f7274696e6754696d655a6f6e653d4143434f554e545f54494d455f5a4f4e45227d" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "ProviderHash" + } + ] + }, + "val": { + "bytes": "307835363962393332333331383563303534656439666461363862356165663866646131383062366432393131383034353062663735376231316262353266376466" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Usdc" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Verifier" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 3110400 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a", + "code": "746573745f636f6e74726163745f666f725f636f6e74726163745f69645f4341414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414149544134" + } + }, + "ext": "v0" + }, + "live_until": 3110400 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "a41146d7d116b29faf18d228425fa97194e16df1d4f3e5d4f51c58ca557fcc6d", + "code": "746573745f636f6e74726163745f666f725f636f6e74726163745f69645f4341414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414144324b4d" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/sc/advance/test_snapshots/test_claim/without_a_pinned_owner_a_claim_signed_as_a_real_attestor_signs_is_refused.1.json b/sc/advance/test_snapshots/test_claim/without_a_pinned_owner_a_claim_signed_as_a_real_attestor_signs_is_refused.1.json new file mode 100644 index 0000000..83ecd8a --- /dev/null +++ b/sc/advance/test_snapshots/test_claim/without_a_pinned_owner_a_claim_signed_as_a_real_attestor_signs_is_refused.1.json @@ -0,0 +1,252 @@ +{ + "generators": { + "address": 4, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "function_name": "set_claim_template", + "args": [ + { + "vec": [ + { + "bytes": "7b226d6574686f64223a22474554222c2275726c223a2268747470733a2f2f616473656e73652e676f6f676c65617069732e636f6d2f76322f6163636f756e74732f" + }, + { + "bytes": "2f7265706f7274733a67656e65726174653f6461746552616e67653d435553544f4d267374617274446174652e796561723d" + }, + { + "bytes": "267374617274446174652e6d6f6e74683d" + }, + { + "bytes": "267374617274446174652e6461793d" + }, + { + "bytes": "26656e64446174652e796561723d" + }, + { + "bytes": "26656e64446174652e6d6f6e74683d" + }, + { + "bytes": "26656e64446174652e6461793d" + }, + { + "bytes": "266d6574726963733d455354494d415445445f4541524e494e47532663757272656e6379436f64653d555344267265706f7274696e6754696d655a6f6e653d4143434f554e545f54494d455f5a4f4e45227d" + } + ] + }, + { + "bytes": "307835363962393332333331383563303534656439666461363862356165663866646131383062366432393131383034353062663735376231316262353266376466" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [] + ], + "ledger": { + "protocol_version": 29, + "sequence_number": 0, + "timestamp": 1760000010, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "a41146d7d116b29faf18d228425fa97194e16df1d4f3e5d4f51c58ca557fcc6d" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "vec": [ + { + "symbol": "ParamsTemplate" + } + ] + }, + "val": { + "vec": [ + { + "bytes": "7b226d6574686f64223a22474554222c2275726c223a2268747470733a2f2f616473656e73652e676f6f676c65617069732e636f6d2f76322f6163636f756e74732f" + }, + { + "bytes": "2f7265706f7274733a67656e65726174653f6461746552616e67653d435553544f4d267374617274446174652e796561723d" + }, + { + "bytes": "267374617274446174652e6d6f6e74683d" + }, + { + "bytes": "267374617274446174652e6461793d" + }, + { + "bytes": "26656e64446174652e796561723d" + }, + { + "bytes": "26656e64446174652e6d6f6e74683d" + }, + { + "bytes": "26656e64446174652e6461793d" + }, + { + "bytes": "266d6574726963733d455354494d415445445f4541524e494e47532663757272656e6379436f64653d555344267265706f7274696e6754696d655a6f6e653d4143434f554e545f54494d455f5a4f4e45227d" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "ProviderHash" + } + ] + }, + "val": { + "bytes": "307835363962393332333331383563303534656439666461363862356165663866646131383062366432393131383034353062663735376231316262353266376466" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Usdc" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "vec": [ + { + "symbol": "Verifier" + } + ] + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 3110400 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "0d6d61ed9340595cb73d424cebeddb6def971a72143eafd77ef9806c3724701a", + "code": "746573745f636f6e74726163745f666f725f636f6e74726163745f69645f4341414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414149544134" + } + }, + "ext": "v0" + }, + "live_until": 3110400 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "a41146d7d116b29faf18d228425fa97194e16df1d4f3e5d4f51c58ca557fcc6d", + "code": "746573745f636f6e74726163745f666f725f636f6e74726163745f69645f4341414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414144324b4d" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/tools/fixtures/forepay-claim.json b/tools/fixtures/forepay-claim.json index 2d512be..9c39231 100644 --- a/tools/fixtures/forepay-claim.json +++ b/tools/fixtures/forepay-claim.json @@ -35,5 +35,9 @@ "messageDigest": "050cf5ad472b586cdf388991f772f5289e723a19c3347a110c00662794c8dd2f", "signature64": "0a1607562845069dcd91874ae32ffc55d2ce799078af623b8300c1765137ca0f577ba3ed8dc8895867e717734d9535536384718e77126229ed28327c54cf202f", "recoveryId": 1, - "signerAddress": "19e7e376e7c213b7e7e7e46cc70a5dd086daff2a" + "signerAddress": "19e7e376e7c213b7e7e7e46cc70a5dd086daff2a", + "appOwner": "0x6415200c713135e77157e1536d488df4f2bb7d04", + "appOwnerSignData": "0x18303a91f81e35d749d26b04a60e1ae95974128afd7ca66b3950547527480dee\n0x6415200c713135e77157e1536d488df4f2bb7d04\n1760000000\n1", + "appOwnerSignature64": "be04cabf370de372ce48726350419d76169f5b35fa64ba03ffb5db5b1a5a4a6a773196501dcfd7a42b94a1a510c9aaa0ff5536cb37ed0ada1f917415da9e96c7", + "appOwnerRecoveryId": 0 } diff --git a/tools/make_claim_fixture.py b/tools/make_claim_fixture.py index b3e11d7..9dc9ae4 100644 --- a/tools/make_claim_fixture.py +++ b/tools/make_claim_fixture.py @@ -40,6 +40,13 @@ TIMESTAMP_S = 1_760_000_000 EPOCH = 1 +# The attestor's `owner` in a real claim is the Reclaim app the relay proves with, not the +# borrower (#102). This is Forepay's app id, which every real claim carries in public. The +# fixture is signed twice: once with this owner, as a real attestor signs, and once with +# the borrower as owner, which is what the contract rebuilt before #102 and what the +# rehearsal's test witness still signs for a contract with no owner pinned. +APP_OWNER = "0x6415200c713135e77157e1536d488df4f2bb7d04" + # The literal segments of the request, with the seven values interleaved between them. # The query is the one be/src/adsense/request.ts actually builds (#4, #74): AdSense takes # each date as three unpadded integers, because `startDate` is an `object (Date)` and the @@ -88,6 +95,9 @@ def build() -> dict: digest = secp.eip191_digest(sign_data) r, s, rec = secp.sign(digest, TEST_KEY) + app_sign_data = f"{identifier}\n{APP_OWNER.lower()}\n{TIMESTAMP_S}\n{EPOCH}" + app_r, app_s, app_rec = secp.sign(secp.eip191_digest(app_sign_data), TEST_KEY) + return { "_source": ( "Generated by tools/make_claim_fixture.py. Signed with a published test key, " @@ -112,6 +122,10 @@ def build() -> dict: "signature64": (r.to_bytes(32, "big") + s.to_bytes(32, "big")).hex(), "recoveryId": rec, "signerAddress": secp.address_of(TEST_KEY).hex(), + "appOwner": APP_OWNER, + "appOwnerSignData": app_sign_data, + "appOwnerSignature64": (app_r.to_bytes(32, "big") + app_s.to_bytes(32, "big")).hex(), + "appOwnerRecoveryId": app_rec, } From 2d8f6ad6a5b6b87502277c95890b458cc9fbbaae Mon Sep 17 00:00:00 2001 From: lin1er Date: Mon, 26 Oct 2026 22:57:27 +0700 Subject: [PATCH 2/3] fix(#102): the relay's audit checks owner is its own Reclaim app The attestor signs owner = the app id the proof was requested with, and the contract now pins it. The relay and prove:adsense pass RECLAIM_APP_ID to the audit, so a proof with any other owner fails before the front end submits it, not as VerifierRejected on chain. --- be/src/adsense/audit.test.ts | 12 ++++++++++-- be/src/adsense/audit.ts | 16 +++++++++++++--- be/src/api/server.ts | 1 + be/src/cli/prove-adsense.ts | 1 + be/src/relay/prove.test.ts | 6 ++++++ be/src/relay/prove.ts | 3 +++ 6 files changed, 34 insertions(+), 5 deletions(-) diff --git a/be/src/adsense/audit.test.ts b/be/src/adsense/audit.test.ts index 4c7b44b..8285a6c 100644 --- a/be/src/adsense/audit.test.ts +++ b/be/src/adsense/audit.test.ts @@ -17,7 +17,7 @@ import { getIdentifierFromClaimInfo, messageDigest, } from "../reclaim/claim-digest.js"; -import { AuditError, auditRevenueProof, formatFieldReport, recoverSigner, type RevenueProof } from "./audit.js"; +import { AuditError, auditRevenueProof, formatFieldReport, recoverSigner, type AuditExpectations, type RevenueProof } from "./audit.js"; import { CONTEXT_MESSAGE, buildRevenueRequest, type RevenueWindow } from "./request.js"; const PUB = "pub-1234567890123456"; @@ -77,7 +77,7 @@ function makeProof(o: Overrides = {}): RevenueProof { const expectations = { publisherId: PUB, stellarAddress: ALICE, window: Q3, accessToken: TOKEN, now: NOW, attestor: ATTESTOR }; -function failuresOf(proof: RevenueProof, expect = expectations): string[] { +function failuresOf(proof: RevenueProof, expect: AuditExpectations = expectations): string[] { try { auditRevenueProof(proof, expect); } catch (e) { @@ -188,3 +188,11 @@ test("a stale or future-dated claim fails", () => { assert.ok(failuresOf(makeProof({ timestampS: nowS - 8 * 86_400 })).some((m) => /older than/.test(m))); assert.ok(failuresOf(makeProof({ timestampS: nowS + 3600 })).some((m) => /future/.test(m))); }); + +test("with the app id given, a claim requested through another Reclaim app fails (#102)", () => { + const app = "0x96FAF173BB7171A530B3E44F35F32D1307BDA4FA"; + assert.deepEqual(failuresOf(makeProof(), { ...expectations, owner: app }), []); + const other = failuresOf(makeProof(), { ...expectations, owner: "0x6415200c713135e77157e1536d488df4f2bb7d04" }); + assert.equal(other.length, 1); + assert.match(other[0], /not the Reclaim app .* the contract pins/); +}); diff --git a/be/src/adsense/audit.ts b/be/src/adsense/audit.ts index 2c87257..05bd871 100644 --- a/be/src/adsense/audit.ts +++ b/be/src/adsense/audit.ts @@ -84,6 +84,12 @@ export interface AuditExpectations { maxAgeS?: number; /** Expected signer. Defaults to the production attestor; tests pass a throwaway key. */ attestor?: string; + /** + * The Reclaim app id the proof was requested with, which the attestor signs as `owner` + * and the contract pins (#102). When given, a claim with any other owner fails here + * instead of as `VerifierRejected` on chain. + */ + owner?: string; } export interface FieldReport { @@ -299,9 +305,13 @@ export function auditRevenueProof(proof: RevenueProof, expect: AuditExpectations } else fail("context.providerHash is not a 32-byte hex hash"); // 5. owner, timestamp, epoch. - if (/^0x[0-9a-f]{40}$/.test(claim.owner)) { - ok("owner", claim.owner, "Address of the key zkFetch signed the request with. Public by construction."); - } else fail(`owner is not a lowercase 20-byte address: ${claim.owner}`); + if (!/^0x[0-9a-f]{40}$/.test(claim.owner)) { + fail(`owner is not a lowercase 20-byte address: ${claim.owner}`); + } else if (expect.owner && claim.owner !== expect.owner.toLowerCase()) { + fail(`owner is ${claim.owner}, not the Reclaim app ${expect.owner.toLowerCase()} the contract pins (#102)`); + } else { + ok("owner", claim.owner, "The Reclaim app the proof was requested with, which the contract pins (#102). Public by construction."); + } const nowS = Math.floor(now.getTime() / 1000); const maxAge = expect.maxAgeS ?? 7 * 86_400; diff --git a/be/src/api/server.ts b/be/src/api/server.ts index 3dabd79..ff32f5d 100644 --- a/be/src/api/server.ts +++ b/be/src/api/server.ts @@ -56,6 +56,7 @@ function relay(): Prover | undefined { } const client = new ReclaimClient(appId, appSecret, false, 2); const deps = { + owner: appId, google: googleGet, zkFetch: ((url, options, secretOptions) => client.zkFetch(url, { ...options, zkEngine: ZK_ENGINE }, secretOptions)) as Parameters< typeof proveRevenue diff --git a/be/src/cli/prove-adsense.ts b/be/src/cli/prove-adsense.ts index 00718a3..4fd3f50 100644 --- a/be/src/cli/prove-adsense.ts +++ b/be/src/cli/prove-adsense.ts @@ -63,6 +63,7 @@ async function main() { try { proven = await proveRevenue( { + owner: env.appId, google: googleGet, zkFetch: (url, options, secretOptions) => client.zkFetch(url, { ...options, zkEngine: ZK_ENGINE }, secretOptions), months: env.months, diff --git a/be/src/relay/prove.test.ts b/be/src/relay/prove.test.ts index d32c7b2..d208028 100644 --- a/be/src/relay/prove.test.ts +++ b/be/src/relay/prove.test.ts @@ -110,3 +110,9 @@ test("a C… or malformed borrower is refused before anything is read", async () await assert.rejects(proveRevenue(deps({ google }), { borrower: "GABC", accessToken: TOKEN }), /not a Stellar account/); assert.equal(google.calls.length, 0); }); + +test("a proof whose owner is not this relay's Reclaim app is refused by the audit (#102)", async () => { + const other = "0x6415200c713135e77157e1536d488df4f2bb7d04"; + assert.equal(await code(proveRevenue(deps({ owner: other }), { borrower: ALICE, accessToken: TOKEN })), "audit"); + await proveRevenue(deps({ owner: "0x96faf173bb7171a530b3e44f35f32d1307bda4fa" }), { borrower: ALICE, accessToken: TOKEN }); +}); diff --git a/be/src/relay/prove.ts b/be/src/relay/prove.ts index 890bb7d..bdd38b3 100644 --- a/be/src/relay/prove.ts +++ b/be/src/relay/prove.ts @@ -43,6 +43,8 @@ export interface ProveDeps { months?: number; /** Expected signer. Defaults to the production attestor; tests pass a throwaway key. */ attestor?: string; + /** The Reclaim app id proofs are requested with: the `owner` the contract pins (#102). */ + owner?: string; } export interface ProveInput { @@ -98,6 +100,7 @@ export async function proveRevenue(deps: ProveDeps, input: ProveInput, onStep: ( now: deps.now?.(), maxAgeS: MAX_AGE_S, attestor: deps.attestor, + owner: deps.owner, }); } catch (e) { throw new ProveError("audit", (e as Error).message); From 367c491383b68d948309a7adfb6d730ee9ffc5cf Mon Sep 17 00:00:00 2001 From: lin1er Date: Tue, 27 Oct 2026 19:26:47 +0700 Subject: [PATCH 3/3] fix(#102): re-record the linux wasm hash for the claim-owner contract Measured by CI with stellar-cli 28.1.0 on x86_64-unknown-linux-gnu. The contract changed, so the bytes did. --- sc/wasm-hashes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc/wasm-hashes.txt b/sc/wasm-hashes.txt index b53c1ec..3b78d90 100644 --- a/sc/wasm-hashes.txt +++ b/sc/wasm-hashes.txt @@ -18,7 +18,7 @@ # triple stellar-cli sha256 # --- verified by CI on every push --- -x86_64-unknown-linux-gnu 28.1.0 34692faae6a80f7c9bcf2eeaf213b25eb217e356e7b1e8453cafe482114b2ea1 +x86_64-unknown-linux-gnu 28.1.0 c8ca0ee5d8f157a2d76cb0bfa3f05e09e4a2fc2627042ab8b621bbfe850673bb # @@UNVERIFIED@@ rows below this marker are reference only and are not checked aarch64-apple-darwin 27.0.0 2aefbf745ea1b8ac4faea4018b08679adcf233fd0e0590136e46dbbe9756ed25