From 384beacd7935f4050adfa86487afc18526e9790c Mon Sep 17 00:00:00 2001 From: Kent Bull Date: Sat, 31 Oct 2026 17:58:49 -0600 Subject: [PATCH] Scope the Oracle protocol and consume owner-published artifacts Define oracle-api-v1 around trusted receipt, validation, conflicts, selection and confirmed publication; reference Verifier for credential/proof and shared delivery requirements. Keep operational guidance separate, own implemented selection rationale and the maintained full-system diagrams, and remove product-hosted execution plans now preserved in ENCTX. Remove the duplicate schema, proof fixtures/generator and conformance suite moved to Verifier, and use the existing Comply-owned publication vector at the mapping/calldata integration boundary. Advance exact Verifier and Comply test/demo/CI pins so the selected launcher reads schema bytes from its installed owner. Oracle gains no runtime Verifier dependency. Validation: 61 fresh installed-wheel Oracle cases pass including the unchanged paired scenario in 47.319 seconds, with 223 Verifier cases, 28 Forge cases and four launcher cases passing. Schema/credential bytes, SAIDs, application source and paired assertions remain unchanged. No architecture/docs enforcement machinery or empty-policy behavior change is included. --- .github/workflows/tests.yml | 6 +- README.md | 39 +- adrs/0001-wallet-association-selection.md | 24 + docs/architecture-cleanup-plan.md | 825 ------------------ .../diagrams/sequence/local-setup-sequence.md | 33 + .../sequence/local-setup-sequence.svg | 1 + .../sequence/oracle-endorsement-sequence.md | 36 + .../sequence/oracle-endorsement-sequence.svg | 1 + .../sequence/revocation-status-sequence.md | 36 + .../sequence/revocation-status-sequence.svg | 1 + .../stablecoin-end-to-end-sequence.md | 43 + .../stablecoin-end-to-end-sequence.svg | 1 + docs/status-inbox.md | 118 +-- docs/testing.md | 7 +- docs/two-service-qualification.md | 30 +- protocol/external-association-v1/README.md | 36 - .../association.schema.json | 154 ---- .../external-association-v1/eoa-v1/README.md | 116 --- .../eoa-v1/association.json | 1 - .../eoa-v1/challenge.json | 48 - .../eoa-v1/endorsement.json | 5 - .../eoa-v1/test-vector.json | 60 -- protocol/oracle-api-v1/README.md | 88 ++ scripts/dev/demo-dependencies.json | 2 +- scripts/dev/prepare-demo.py | 1 + scripts/protocol/README.md | 15 - scripts/protocol/generate_vectors.py | 105 --- scripts/protocol/requirements.txt | 6 - tests/endorsement/test_effects.py | 17 + tests/integration/test_association_profile.py | 367 -------- tests/requirements.txt | 2 +- 31 files changed, 336 insertions(+), 1888 deletions(-) create mode 100644 adrs/0001-wallet-association-selection.md delete mode 100644 docs/architecture-cleanup-plan.md create mode 100644 docs/diagrams/sequence/local-setup-sequence.md create mode 100644 docs/diagrams/sequence/local-setup-sequence.svg create mode 100644 docs/diagrams/sequence/oracle-endorsement-sequence.md create mode 100644 docs/diagrams/sequence/oracle-endorsement-sequence.svg create mode 100644 docs/diagrams/sequence/revocation-status-sequence.md create mode 100644 docs/diagrams/sequence/revocation-status-sequence.svg create mode 100644 docs/diagrams/sequence/stablecoin-end-to-end-sequence.md create mode 100644 docs/diagrams/sequence/stablecoin-end-to-end-sequence.svg delete mode 100644 protocol/external-association-v1/README.md delete mode 100644 protocol/external-association-v1/association.schema.json delete mode 100644 protocol/external-association-v1/eoa-v1/README.md delete mode 100644 protocol/external-association-v1/eoa-v1/association.json delete mode 100644 protocol/external-association-v1/eoa-v1/challenge.json delete mode 100644 protocol/external-association-v1/eoa-v1/endorsement.json delete mode 100644 protocol/external-association-v1/eoa-v1/test-vector.json create mode 100644 protocol/oracle-api-v1/README.md delete mode 100644 scripts/protocol/README.md delete mode 100644 scripts/protocol/generate_vectors.py delete mode 100644 scripts/protocol/requirements.txt delete mode 100644 tests/integration/test_association_profile.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fbdcf94..e7b1d2e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: repository: GLEIF-IT/vlei-comply - ref: aeba4883dadb30e06a0316d93394b08ff9a9e97d + ref: 9efde5e3db818cf3129e89c9fd08c0f5c0f8dee1 path: comply ssh-key: ${{ secrets.VLEI_COMPLY_READ_KEY }} persist-credentials: false @@ -33,13 +33,13 @@ jobs: run: | python -m pip wheel --no-deps --wheel-dir dist . python -m venv "$RUNNER_TEMP/oracle-tests" - "$RUNNER_TEMP/oracle-tests/bin/python" -m pip install dist/*.whl -r tests/requirements.txt -r scripts/protocol/requirements.txt + "$RUNNER_TEMP/oracle-tests/bin/python" -m pip install dist/*.whl -r tests/requirements.txt - name: Test installed packages outside checkout env: VLEI_COMPLY_DIR: ${{ github.workspace }}/comply run: | mkdir "$RUNNER_TEMP/qualification" - cp -R tests scripts protocol "$RUNNER_TEMP/qualification/" + cp -R tests scripts "$RUNNER_TEMP/qualification/" cp pytest.ini "$RUNNER_TEMP/qualification/" cd "$RUNNER_TEMP/qualification" "$RUNNER_TEMP/oracle-tests/bin/vlei-oracle" server receive --help diff --git a/README.md b/README.md index c4793cb..655acb0 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ event storage and publishes or withdraws the selected association mapping as an runs the same inbox without contract posting. Initial credential, wallet and account verification belongs to EOA Verifier; the oracle does not repeat it. -Accepted associations remain valid until their association credential is revoked -or a newer same-LE issuance supersedes them. Revocation withdraws only the matching +Verifier acceptance persists until verified association revocation. Oracle selection +can supersede an older same-LE issuance without changing that upstream acceptance. Revocation withdraws only the matching association SAID. Storage ACKs do not mean an on-chain transaction has succeeded. The [two-service qualification](docs/two-service-qualification.md) exercises the installed applications with witnessed KEL/TEL evidence, signed HTTP and Anvil. @@ -29,10 +29,9 @@ See the [testing guide](docs/testing.md) for module/class/function lookup and pa qualification. Initializers contain no import facades; the root package retains only its literal version metadata. -The [architecture cleanup plan](docs/architecture-cleanup-plan.md) sequences the -remaining cross-repository removals and operating fixes. This application has -one service model: authenticated verifier status followed by local selection and -optional contract posting. Credential evidence is delivered to EOA Verifier. +The [Oracle API](protocol/oracle-api-v1/README.md) defines receipt, selection and +publication. The [selection ADR](adrs/0001-wallet-association-selection.md) explains +the rationale. Credential evidence is delivered to EOA Verifier. ## Install @@ -41,7 +40,7 @@ import paths and must not share an environment with upstream distributions. ```sh uv venv --python 3.12 .venv -uv pip install --python .venv/bin/python -e '.[dev]' -r tests/requirements.txt -r scripts/protocol/requirements.txt +uv pip install --python .venv/bin/python -e '.[dev]' -r tests/requirements.txt .venv/bin/python scripts/dev/prepare-demo.py --schemas-only # For the full suite, first prepare Foundry/comply as described below. .venv/bin/python -m pytest -q @@ -67,8 +66,7 @@ no identities. Existing mismatched/dirty dependency checkouts are never reset; choose a new directory when changing pins. Install Foundry 1.5.1 separately, then follow the prepared comply checkout's `docs/gl1-vlei-local-infra-setup.md` for service configuration. Run its `scripts/dev/init-local-vlei-fixture.sh` with these -exports for the witnessed two-wallet test; keep this prepared environment rather than -reinstalling the guide's earlier qualification snapshot. +exports for the witnessed two-wallet test; keep this prepared environment with the selected compatible revisions. The schema-server tool `vlei` still declares upstream `keri`/`hio` distribution names. The preparer installs it with `--no-deps` into the GLEIF demo environment; @@ -76,17 +74,16 @@ names. The preparer installs it with `--no-deps` into the GLEIF demo environment install the overlapping upstream packages to silence them. This exception belongs to demo schema tooling, not either application wheel. -## Association issuance boundary +## Protocol ownership -The oracle has no wallet challenge, signing, credential finalization or association -nonce store. Issuers present their credentials and supporting witnessed KEL/TEL -evidence to EOA Verifier. The verifier consumes an exact issuer/nonce only on -application acceptance, atomically with status and optional webhook delivery. -Association nonces contain 1–128 ASCII letters, digits, underscores or hyphens -(`[A-Za-z0-9_-]`); the verifier stores ordinary `issuer.nonce` Komer keys. -A different credential reusing that pair is rejected, even after revocation. +[EOA Verifier](https://github.com/GLEIF-IT/eoa-verifier/tree/master/protocol) owns +external-association-v1, its packaged schema/proof vectors, and verifier-api-v1 +including shared webhook authentication/ACKs. Oracle owns only +[oracle-api-v1](protocol/oracle-api-v1/README.md). +[Comply](https://github.com/GLEIF-IT/vlei-comply/blob/main/docs/oracle-registry.md) +owns registry methods, identity encoding, ABI and calldata fixtures. -The canonical profile and reference vectors remain under `protocol/`. Issuance -assembly in `tests/support/issuers.py` belongs only to qualification; these helpers are -not installed oracle APIs or an operational issuer tool. The oracle retains -signed-webhook replay protection and Ethereum transaction nonce recovery. +Issuance assembly in `tests/support/issuers.py` serves the maintained paired +qualification; it is not an installed Oracle issuance API. Oracle has no wallet +challenge, credential finalization or association-nonce store. Transport replay +claims and Ethereum transaction nonces remain separate concerns. diff --git a/adrs/0001-wallet-association-selection.md b/adrs/0001-wallet-association-selection.md new file mode 100644 index 0000000..55f9fe9 --- /dev/null +++ b/adrs/0001-wallet-association-selection.md @@ -0,0 +1,24 @@ +# ADR 0001: Select one current association for each chain and wallet + +Status: Accepted; implemented +Date: 2026-10-31 + +Verifier acceptance proves an association under its configured policy. An Oracle +deployment still needs one current LE claim for a canonical chain/wallet, so +selection belongs here rather than in credential verification. LE identity is +the issuer AID, verified by the producer against the LE credential's holder. + +Use strictly later issuance within the same issuer's KEL. A different issuer +cannot replace an active claim until the current association's verified revocation +releases it. Never compare sequence numbers across issuers. Retain issuance +history after release so a superseded predecessor cannot return. Reordered +revocation of an older association cannot withdraw its successor. + +Commit receipt, newest verifier status and selection in one LMDB transaction. +Keep local selection distinct from the producer's accepted/revoked status. A +rejected claim is still durably received; its ACK does not authorize publication. +Submission and confirmation remain separate from selection. + +[oracle-api-v1](../protocol/oracle-api-v1/README.md) owns the complete rules and +error/duplicate handling. No same-event conflict detector or retrospective +withdrawal of verifier acceptance is implemented. diff --git a/docs/architecture-cleanup-plan.md b/docs/architecture-cleanup-plan.md deleted file mode 100644 index 0e6419a..0000000 --- a/docs/architecture-cleanup-plan.md +++ /dev/null @@ -1,825 +0,0 @@ -# Commit to the EOA verifier association model - -Status: active, 2026-10-31. Baseline: oracle PR #46 merged as `f6b66af`. -This plan owns the architecture cleanup across -[EOA Verifier](https://github.com/GLEIF-IT/eoa-verifier), -[vLEI Oracle](https://github.com/GLEIF-IT/vlei-oracle), and -[vlei-comply](https://github.com/GLEIF-IT/vlei-comply). -Implementation source and tests remain authoritative. Each row below is a -separate, reviewable PR; complete removal precedes new mechanisms. - -## Binding decisions - -1. EOA Verifier alone accepts native KERI credential evidence, validates the - wallet proof and initial account state, and observes association revocation. - Acceptance continues until that exact association is revoked or superseded; - neither the oracle nor the contracts re-run source-credential or account checks. -2. Oracle authenticates and durably receives verifier status, selects the current - association for the exact chain/wallet, and posts or withdraws that selection. - A stored webhook ACK is not an Ethereum transaction receipt. -3. Contracts evaluate the current wallet's identity and exact association - endorsement. The supported wrapper workflow is a direct, wallet-associated, - owner-authorized transfer with auditable compliance records. -4. wUSDC is a noncustodial route for adding auditable compliance records. Direct - USDC transfers may bypass it. Asset-wide USDC enforcement is intentionally - outside scope and is not a cleanup or readiness blocker. -5. No backward compatibility is required. Delete obsolete commands, APIs, - storage records, adapters, tests, fixtures and runnable instructions together. - Do not leave aliases, deprecated shims, migration readers or fallback imports. - Git history preserves the retired implementation. Do not delete operator data. -6. Keep HIO scheduling, LMDB durability, native KERI evidence stores, explicit - trust/deployment scopes, and locally encoded contract ABIs with HIO RPC waits. - Do not add another service concurrency model or persistence abstraction. - -7. Association nonces contain **1–128 ASCII characters from `[A-Za-z0-9_-]`**. - Preserve case and bytes; reject whitespace, dots, other punctuation and - non-ASCII text. Use ordinary Komer `(issuerAid, nonce)` keys (`issuer.nonce`), - bounded to 173 bytes by the credential schema. No hashing, JSON key encoding, - migration, alternate key reader or old schema acceptance. This decision - supersedes the earlier Unicode/digest-key requirements in historical receipts. - -## Ordered PRs and acceptance gates - -### 1. Remove the combined verifier/oracle runtime (merged: PR #47) - -Owner: vlei-oracle. Start from merged PR #46. - -- Delete `server legacy-start` and its handler/configuration, `serving.py`, - credential ingestion/Grant endpoints, parser/mailbox composition, credential - verification coordinator and EOA account worker, and legacy reconciliation. -- Delete verification/managed-association LMDB records and their APIs. Remove - cancellation/reorg machinery only used by that runtime. Preserve the active - trusted-status inbox, ownership selection, signed transaction journal, - immutable-attempt checks and trust/chain/deployment guards. -- Delete the combined-runtime issuance exercise, restart/replacement fixtures, - legacy-only tests and runbooks. Remove deployment/demo instructions that still - offer the retired path. Do not retain a second authority to satisfy a fixture. -- Rehome the live association profile (canonical identifiers, wallet challenge, - issuer-side proof checks and schema resource) into the `association/` wire-profile - package with issuer-side helpers. Retain issuer ceremony, nonce ledger and - protocol vectors; - these prepare association evidence and do not compose an oracle verifier. -- Inspect remaining compatibility surfaces in the three repositories. Delete - aliases/fallbacks when encountered in this dependency closure; record separately - owned removals below rather than quietly preserving them. - -Acceptance: retired command fails argument parsing; retired runtime modules are -absent from a fresh wheel; current challenge/ceremony/profile behavior passes; -full installed-wheel oracle suite passes; real two-process verifier/oracle -qualification still proves authenticated receipt, posting, replacement, -revocation, restart/redelivery and accepted/rejected contract transfers. No test -may regain credential verification inside the oracle. - -### 2. Remove wrapper workflows incompatible with wallet association v1 (merged: comply #11, oracle #48) - -Owner: vlei-comply. [Removal PR #11](https://github.com/GLEIF-IT/vlei-comply/pull/11). -Follow PR 1 immediately, before adding recovery features. - -- Remove `transferWithBeneficiary` and `transferFromWithBeneficiary` mediation - workflows that construct parties without an associated wallet. Remove their - interfaces, events, helper branches, scripts and tests. -- Remove `PendingTransaction`, pending nonce/storage, queue events, pending - transfer branches and `resolvePendingTransaction`. Current policy has no - supported producer of Pending decisions; administrative settlement bypasses - current policy evaluation. Remove unused decision values/types as their full - caller graph permits; no empty placeholders for hypothetical future workflows. -- Keep direct wallet-based transfer and allowance/ownership semantics. Evaluate - the current exact wallet association on every supported route and preserve - audit records for allowed transfers and meaningful rejection behavior. -- Trace generic KYC/jurisdiction/VASP enrichment and the empty-config - `CredentialRegistryIdentityValidator` through deploy scripts and actual policy - consumption. Delete unused v1 scaffolding. Keep a Chainlink/GL1 seam only where - a current integration consumes it; document the concrete consumer. -- Delete generated-wrapper compatibility APIs/types in `IPolicyManager` and - backward-compatibility enum/tuple fields in `IPolicy` as their caller graph - permits. The existing contract launcher already delegates to the paired test; - preserve that one maintained qualification route. Update packaged ABI - consumers and oracle contract pin in the same coordinated qualification wave. - -Acceptance: Forge unit/integration tests and ABI/caller searches establish that -no removed route remains; exact-wallet valid, revoked, superseded, unassociated -and cross-entity cases behave correctly; fresh deployment and the installed-wheel -paired suite pass against the new contract revision. No compatibility selectors, -old queue settlement or abstract-beneficiary fallback remains. - -### 3. Complete PR #49 without application locking (merged) - -Historical requirements below describe the removed issuer ledger. Its former -Unicode nonce and digest-key choices are superseded by binding decision 7 and -have no current runtime/API support. - -Owner: vlei-oracle. Added by Kent on 2026-10-31. This is a separate focused -refactor after the wrapper-removal qualification. Preserve -[vlei-comply PR #11](https://github.com/GLEIF-IT/vlei-comply/pull/11) and -[oracle companion PR #48](https://github.com/GLEIF-IT/vlei-oracle/pull/48). -Both wrapper PRs are merged. Nonce implementation is isolated on -`refactor/nonce-ledger-lmdber`; PR #49 merged as -`7734146c9f5bb23607e9434180651ef514f4274b`. Task 4 supersedes its issuer ledger. - -**Publication approved:** Kent authorized committing and pushing the PR on -2026-10-31 after local qualification. PR #49 is now merged; the following -requirements and receipts describe that completed wave. - -Required source inspection, before implementation: - -- Inspect the actual installed, pinned GLEIF KERIpy/HIO implementations of - `dbing.LMDBer`, `dbing.openLMDB`, `koming.Komer` and `Filer`, plus this - application's `OracleBaser`. The currently qualified distributions are - `gleif_keri==1.2.19` and `gleif_hio==0.6.22`. Verify those pins when starting; - do not design against another local KERIpy checkout or revision. -- Trace environment opening, subdatabase serialization/handles, synchronous - commit defaults, deferred opening, normal/temporary closure and Filer's - alternate-directory behavior. Explicit selection of a nonce store must never - silently redirect consumption into a different store. - -Required implementation: - -- Keep the NonceLedger domain API (`claim(issuer=..., nonce=...)`), but subclass - `dbing.LMDBer`. Use standard `name`, `base`, `headDirPath`, `temp` and `reopen` - construction with ledger-specific directory constants. -- Remove direct `lmdb.open`, manual directory management and custom context-manager - lifecycle methods. Owning call sites use `dbing.openLMDB(cls=NonceLedger, ...)`; - ceremony functions borrow the already-open ledger. Persistent closure must - never delete consumed nonces. Standard temporary closure must clean its store. -- Define a minimal typed `NonceClaim` record containing only `issuer` and `nonce`. - Bind a non-duplicate `Komer` subdatabase in `reopen()` after the base environment - opens. Close acquired resources if later initialization fails. -- Preserve the exact issuer and nonce strings, including Unicode and whitespace. - Retain an unambiguous encoding of the pair and use its SHA-256 digest as a - fixed-length 64-character hexadecimal Komer key. No normalization, expiry or - release of consumed nonces is introduced. -- Implement `claim()` with one explicit LMDB write transaction. Insert without - overwrite; if occupied, deserialize and inspect the existing claim inside that - same transaction. Return False only for the identical pair; fail closed on - inconsistent or malformed stored data. Follow OracleBaser's use of Komer - serialization and subdatabase handles for atomic operations. -- Kent's correction supersedes the original thread-serialization requirement: - remove the Python mutex, thread pools, barriers and custom coordination from - nonce handling and its tests. Use native LMDB transactions and process locking. - The pinned binding may reject overlapping writes on one environment; surface - that error without retries or a new serialization mechanism. Follow the - synchronous, single-owner KERIpy/HIO calling model. -- Update CLI storage options, all callers, tests and documentation together. - Replace positional-path construction and the current `--nonce-dir` selection - with explicit standard storage options; document the resulting layout after - inspecting the pinned Filer behavior. No positional-path compatibility - constructor, deprecated flag aliases, migrations, old-format readers or - fallback APIs are required. -- Consumption must commit before usable credential bytes are published. Preserve - proof validation before consumption, existing-output handling and the rule that - an output failure after commit leaves the nonce consumed. -- Introduce no generic repository framework or unrelated persistence cleanup. - -Validation and completion: - -1. Run focused checks for persistent reopen, persistent closure without deletion, - standard temporary cleanup, deferred opening, stable selected paths and rejected - alternate-directory fallback. Exercise failure during post-open initialization - and verify acquired resources close. -2. Exercise issuer scoping, exact Unicode/whitespace nonces, native overlapping- - writer rejection, independent-process contention and inconsistent stored claims. Preserve the - ceremony's invalid-proof, existing-output and post-commit output-failure - assertions; do not replace meaningful contention with serial calls. -3. Build and install a fresh oracle wheel outside the checkout. Run the full - oracle suite and maintained two-process qualification against the appropriate - qualified contracts and verifier. At this plan update those are contracts - `4c83e465b3d7937f02b95e805cca5b79f5015078` and verifier - `486fb42f92b6c3269d7968934448f21121ef08aa`; re-verify merge/pin state at execution. - Do not restore deleted combined-runtime fixtures or weaken assertions. -4. Report the resulting on-disk storage layout, removed custom lifecycle code, - exact test/artifact evidence and remaining limitations. Leave the refactor - uncommitted and unpushed until Kent authorizes publication (now approved). - -### 4. Remove association-nonce ownership from vlei-oracle (oracle #50 merged; verifier #20 open) - -Owners: vlei-oracle removal PR, with an EOA Verifier acceptance-policy companion. -This is the authorized next task after PR #49 merged. It remains separate from -that locking correction. Kent explicitly -rejected consolidating this issuer ledger into the oracle AID store. The oracle -receives verified status and posts selected associations; it must not own EOA -proof nonce consumption or credential issuance policy. - -**Oracle removal:** - -- Delete `NonceLedger`, `NonceClaim`, the separate nonce store and all - `--nonce-*` options and call sites. Do not rename those flags onto oracle - `--name`/`--base`/`--head-dir`, open the ledger alongside the oracle AID, or move - issuance nonce claims into OracleBaser/Habery. No aliases or migration readers. -- Remove issuer-facing ceremony/finalization code from the oracle package and - user CLI. Do not leave `write_credential` as an unchecked credential writer - after removing its nonce guard. Audit challenge/signing/profile commands for - the same ownership and remove issuer-only surfaces from the oracle product. -- Keep only consumer-side canonical identifier parsing required by status - receipt/chain selection. Rehome the minimal credential assembly/signing needed - for qualification into test-owned issuer helpers or the actual issuer tool; - keep those helpers outside the installed oracle runtime and production CLI. -- Remove obsolete nonce/ceremony tests and operational recipes with the code. - Preserve the maintained witnessed issuance and two-process qualification, - including topology and real transfer/replacement/revocation assertions. -- Keep OracleBaser's authenticated-webhook replay claims and Ethereum signed - transaction nonce journal. Those are oracle transport/posting state and are - distinct from the association proof's `u` nonce. - -**Verifier acceptance-policy companion:** - -- Record an ADR that consumes an exact `(issuerAid, nonce)` only when an - association becomes application-accepted. Re-delivery of that same association - SAID is idempotent. A different SAID with an already accepted pair is rejected, - including another wallet or LE credential. Another issuer may use the same - nonce. Revocation or supersession never releases a consumed nonce. -- Read the issuer and exact `u` from the verified native association credential; - do not trust a new webhook field or infer the nonce from status metadata. - Enforce the 1–128 ASCII `[A-Za-z0-9_-]` contract without normalization. Use - ordinary Komer `(issuerAid, nonce)` keys and a minimal typed claim that binds - issuer, nonce and the accepted SAID. The schema's 44-byte issuer plus separator - and 128-byte nonce yields a maximum 173-byte key. -- Bind claims in the existing VerifierBaser using its current service - `name`/`base`/`head_dir` and owning LMDB context. Add no separate environment, - nonce CLI options, mutex, thread pool, locking layer or generic repository. -- Extend the existing `VerifierBaser.accept()` write transaction so the nonce - claim, accepted association and any outbox obligation commit together. A - conflicting claim must produce a terminal local `NONCE_REUSED` rejection, - with no acceptance event/outbox entry and no retry loop. Keep this policy - outcome distinguishable from invalid signature/evidence. -- Do not consume for pending/missing evidence, failed proof/account checks or - otherwise unaccepted candidates. Existing accepted-SAID redelivery must return - the original status/event without re-consuming or issuing another delivery. -- Apply the policy regardless of webhook configuration. Today AcceptanceDoer is - composed only when a webhook is configured; resolve that domain/delivery - coupling explicitly in the companion design. Optional delivery must not become - a bypass of accepted-nonce uniqueness. -- Keep the verifier-to-oracle wire contract unchanged. This acceptance policy - belongs entirely to the producer; the oracle needs no association nonce field - or duplicate nonce check. - -**Acceptance gates and rollout:** - -1. Prove sequential duplicate handling and real independent-process races with - native LMDB: one accepted SAID for a pair, idempotent same-SAID replay, terminal - rejection for another SAID, different-issuer reuse, exact ASCII case/bytes, - 1/128-character boundaries, invalid-input rejection, restart, revocation/supersession without reuse, and malformed claim rejection. -2. Crash/fault tests cover rollback before acceptance commit and recovery after - commit but before ACK. There must never be a consumed-but-unaccepted claim or - accepted-but-unclaimed association. Rejected candidates create no accepted - outbox event; invalid proofs cannot burn a nonce. -3. Qualify with delivery enabled and disabled. Test the actual verifier intake - path with a newly issued, otherwise valid second association reusing a nonce; - do not substitute injected acceptance records for that integration evidence. -4. Use a deliberate fresh acceptance-state baseline for the new policy. Do not - silently adopt a populated store that has accepted associations but no nonce - history, or claim global uniqueness across independent verifier stores. No - historical backfill/migration is implied by this plan. -5. Run verifier focused/full installed-wheel checks, oracle full installed-wheel - checks and the maintained paired qualification. The oracle wheel/CLI must - contain no association issuance nonce store or issuer finalization workflow; - webhook replay rejection and Ethereum posting recovery must remain covered. -6. Review the coordinated changes, merge the verifier policy first if the oracle - removal PR advances its producer pin, then merge the oracle removal. Publish - exact qualified revisions and remaining deployment limits. The ownership changes are now authorized as the next coordinated PR wave; - neither is part of the merged locking correction. - -### 5. Make an empty policy configuration explicit and fail closed - -Owner: vlei-comply, `src/policy/PolicyManager.sol`. - -The current empty loop returns Pass. Make zero policies reject authorization, -including removal of the final policy, or require an explicit separately governed -bypass mode if a concrete requirement emerges. Do not infer bypass from missing -configuration. Keep the documented AllowAll engine confined to explicit demos. - -Acceptance: unconfigured manager, last-policy removal, configured Pass and -configured Fail tests; deploy scripts demonstrate an intentional active policy. - -### 6. Close LMDB readers before yielding to RPC - -Owner: vlei-oracle, `endorsement/posting.py`. - -The status iterator currently holds a read transaction across network yields. -Copy a bounded page out, close the cursor/transaction, then perform effects. -Use a resumable fair scan so a failing or inactive first page cannot starve other -wallets. Do not replace this with an unbounded full-database snapshot. - -Acceptance: real LMDB reader lifetime is checked during suspended RPC work; -concurrent receipt/writes continue; multiple pages progress fairly; selected -association is rechecked before a newly prepared effect. Preserve single-writer -ordering and recorded transaction identities. - -### 7. Give the current transaction journal bounded recovery - -Owner: vlei-oracle, `endorsement/posting.py` and `basing.py`. - -A signed intent persisted before submission can have no receipt forever, blocking -all later actions. Add a small, explicit inspect/resubmit/reconcile path for that -same signed intent. Resolve unknown submission, pending receipt, canonical -confirmation/reversion and consumed-nonce conflict deliberately. Never allocate a -second action while the first nonce is unresolved. Do not resurrect the deleted -combined-runtime cancellation/reorg framework. - -Acceptance: process interruption before send and after send, lost response, -restart, exact-byte resubmission, conflicting nonce and reorg evidence; later -withdrawals progress after supported recovery. Document operator actions and -limits, rather than calling receipt-only polling recovery. - -### 8. Support validated peer key updates during operation - -Owners: EOA Verifier and oracle delivery/receipt boundaries. - -Startup `--verifier-kel` alone requires file replacement and service restart after -rotation. Add a narrow native KERI update path for the configured peer, with -validated contiguous KEL processing and explicit trust identity. Do not accept -new key material just because an HTTP signature claims a known AID, and do not -bring credential verification back into the oracle. - -Acceptance: live peer rotation, stale signer, out-of-order/missing key events, -untrusted peer and restart tests through the real signed transport. - -### 9. Establish one signed transport profile and remove duplicate policy - -Owners: EOA Verifier `delivery/authing.py` and oracle `authing.py`. - -Both maintain the same manual signature-base rules around pinned KERIpy APIs. -First define one authoritative closed profile and shared conformance vectors for -headers, target URI, body digest, nonce, timestamps and ACKs. Then use a narrow -shared implementation only if it reduces real maintenance cost; no general -cross-repository core framework. Remove old import fallbacks and duplicated -implementations when the chosen owner is consumed by both installed wheels. - -Acceptance: both installed packages pass the same positive and tampered vectors, -including rotation and replay; cross-process delivery remains qualified without -checkout imports or monkeypatch compatibility. - -## Review and completion discipline - -For every PR, inventory the inbound callers before deleting an API, then inspect -source, CLI help, tests, scripts, docs and the built wheel for stale entry points. -Tests of intentionally removed behavior leave with that behavior. Retain or add -regressions at surviving authority and durability boundaries, not frozen file -rosters. Run the smallest relevant checks first, then installed artifacts and -paired qualification where shared contracts change. Report exact revisions and -unrun integration limits. Do not treat a green fixture as deployment readiness. - -PRs 1 and 2 are merged. Task 3 is qualified without application locking and awaits PR review. Subsequent PRs follow in this order after review; this -plan is not authorization to deploy, migrate stores or merge without review. - -## PR 1 qualification record - -On 2026-10-31, the full installed-wheel oracle suite passed: **141 passed** in -144.34 seconds. This includes the real two-process paired qualification, with -verifier `486fb42f92b6c3269d7968934448f21121ef08aa`, comply -`cdaa111041e50f56d2820b84cf15f18c96c45ac4` and Foundry 1.5.1. Tests ran from a -temporary source copy against a fresh environment, outside the working checkout. -The final wheel's Python/JSON contents match the current source byte for byte; -all 24 installed oracle modules import, and the removed runtime modules are absent. -Current service CLI help succeeds and the retired command fails parsing. The -suite retains HIO's existing datetime deprecation warnings. - -The removed tests exercised intentionally removed behavior. The witnessed issuer, -two application processes, two wallets, real contract transfers, lost ACK, -restart, replacement and exact revocation scenario remains intact. This is local -qualification, not deployment evidence. The active posting-reader lifetime, -receipt-only recovery and other later PRs above remain unfinished. - -## PR 2 qualification record - -On 2026-10-31, the reduced contract deployment passed **28 Forge tests** with -Foundry 1.5.1 and **four launcher checks**. The oracle companion passed **141 -installed-wheel tests** in 153.74 seconds, including the unchanged two-process -witnessed issuance, signed receipt, transfer, replacement, restart and revocation -scenario against the new contract source. The qualified contract revision is -`4c83e465b3d7937f02b95e805cca5b79f5015078`; the verifier remains pinned to -`486fb42f92b6c3269d7968934448f21121ef08aa`. - -The wrapper has only direct owner-initiated transfer routes. Mediation, pending -settlement, unused enrichment fields, credential/trusted-issuer deployments and -compatibility aliases are removed. Wallet lookup always resolves the registry's -current identity; caller hints cannot substitute for it. Audit-hash and rejection -regressions pass. The oracle's two packaged registry ABIs match the new build; -the deploy-log parser no longer requires a credential-registry address. CI, -demo setup and current operator guides now select the new contract revision. - -Review and merge the contract removal before the oracle pin companion. Use the -oracle companion's head commit as `ORACLE_REVISION` for the contract guide's local -qualification. PR 3 is now the separately requested NonceLedger refactor. Task 4 now removes misplaced association-nonce ownership; task 5 addresses the -existing empty-policy limitation documented in the contract security model. Later operating fixes -remain separate. No storage or contract migration is provided. - -## Initial task 3 qualification (superseded by the no-mutex correction) - -Implemented on `refactor/nonce-ledger-lmdber`, based on merged oracle -`2b028c9299426a61a7dab68a80b6357d53ac572f`. Kent authorized publishing the -qualified refactor on 2026-10-31; PR #49 subsequently merged. - -The ledger now subclasses LMDBer, binds a typed, non-duplicate `consumed.` Komer -in `reopen()`, and uses explicit insert-without-overwrite plus same-transaction -conflict inspection. The initial candidate retained a per-ledger writer lock; Kent has rejected it. -The correction below removes it. Direct environment -opening, manual directory creation and custom enter/exit lifecycle methods are -removed. Owning call sites use `dbing.openLMDB`; ceremonies borrow the ledger. - -Persistent layout: `/vlei-oracle/nonces///data.mdb` and -`lock.mdb`. The CLI requires `--nonce-head-dir`, with optional `--nonce-base` -and `--nonce-name` (default `issuer-nonces`). Exact issuer/nonce pairs are stored -as typed NonceClaim records under 64-character hexadecimal SHA-256 keys. Relative -roots are frozen to an absolute path. Primary and alternate Filer directory -settings resolve to the same selected store; unavailable roots fail instead of -redirecting to a fresh namespace. Explicit root or temporary-mode changes override cached-path reuse. Failed -remakes preserve the previous persistent mode and invalidate stale cached paths; -cleanup cannot delete a previous persistent store or retry against the wrong -namespace. Post-open initialization failures close acquired resources and -preserve persistent consumption. - -Validation on 2026-10-31: - -- **37 focused checks passed from the fresh installed wheel.** Coverage includes - persistent reopen/closure, temporary cleanup, deferred opening, stable relative - paths, explicit root changes, rejected fallback, failed initialization cleanup, - failed temporary reopen and persistent-path protection during temporary reuse, - Unicode and issuer scoping, 64 contending thread claims and four simultaneous - independent processes, malformed/conflicting rows, and current CLI selection. - Existing proof-before-consumption, existing-output and post-commit output-failure - assertions remain intact, including two-process artifact publication. -- **156 full installed-wheel oracle tests passed in 146.62 seconds**, including - the unchanged maintained two-process qualification. Verifier: - `486fb42f92b6c3269d7968934448f21121ef08aa`; qualified contracts: - `4c83e465b3d7937f02b95e805cca5b79f5015078` (the merged contract tree); - Foundry 1.5.1. Existing HIO datetime deprecation warnings remain. -- Inspected the installed `gleif_keri==1.2.19`, `gleif_hio==0.6.22` and - `lmdb==1.8.1` implementations. The fresh environment's dbing, koming and Filer - source files match those inspected byte for byte. Native synchronous commit - and process-lock flags are asserted. The wheel's Python/JSON files match the - working source byte for byte. -- Candidate wheel SHA-256: - `04ca27c156b56c90e3678e281634e99c54baf4e1a387255f0b7b0dc21d008a00`. - -Remaining limits: use one open ledger per store in each process, shared by its -borrowers. Keep persistent namespace selection consistent and use fresh nonces -for a deliberately new store; there is no migration, old-format reader or replay -protection across independently selected empty stores. A post-commit failure can -burn a nonce by design. Native temporary cleanup removes the ledger directory; -the pinned Filer can leave empty ancestor directories. Qualification was local macOS; Linux CI is not run before review. This task adds -no custom parent-directory cleanup or unrelated persistence changes. PR #49 is -merged; task 4 now removes association-nonce ownership from the oracle with the -verifier-policy companion. The empty-policy configuration fix follows as task 5. - -## Historical PR #49 locking correction qualification - -Kent's 2026-10-31 correction removes the application mutex and all shared-thread -coordination from nonce handling. The implementation now relies solely on one -native LMDB transaction per claim. There is no application lock, thread pool, -barrier, queue or retry loop. Synchronous caller ordering follows KERIpy/HIO's -normal execution model; native LMDB coordinates separate processes. - -The pinned binding rejects overlapping writes on the same environment with -`lmdb.Error` / Resource busy. The removed shared-thread tests required the -application to queue those calls; that is no longer the contract. A deterministic -native-overlap regression now verifies the error propagates without consuming a -nonce. Synchronous duplicate-publication checks remain, as do the actual four- -process ledger test and two-process ceremony test. The process harness now uses -ordinary subprocesses instead of threading, multiprocessing barriers or queues. -No error is converted into a duplicate or hidden by a retry. - -**28 focused checks passed. The full fresh installed-wheel suite passed 147 tests -in 153.38 seconds**, including the unchanged maintained two-process qualification. -The reduced count reflects removal of the ten parametrized shared-thread ceremony -cases in favor of one synchronous duplicate case; no maintained paired-system -assertion or topology was weakened. Native durability, issuer scope, exact -Unicode, malformed-claim rejection, failure cleanup and persistent lifecycle -coverage remain. Existing dependency warnings remain. - -The qualified contracts remain `4c83e465b3d7937f02b95e805cca5b79f5015078`; verifier -remains `486fb42f92b6c3269d7968934448f21121ef08aa`, with Foundry 1.5.1 and GLEIF -KERI/HIO 1.2.19/0.6.22 plus LMDB 1.8.1. Candidate wheel SHA-256: -`7d6a899d5d9cdd17a7f794a7e4796f17968841b07848154662d681b48726488f`. - -This PR deliberately does not move issuer nonce state into the oracle AID store, -rename its temporary nonce flags or implement verifier nonce policy. Task 4 is -the subsequent ownership-removal wave. Oracle transport replay claims and -Ethereum transaction nonces are outside that removal. - - -## Original task 4 implementation and qualification (before ASCII revision) - -PR #49 is merged at `7734146c9f5bb23607e9434180651ef514f4274b`. -The current coordinated wave removes the oracle's issuer ledger, ceremony -finalization, challenge/signing CLI and installed association schema/proof package. -Only canonical status identifier parsing remains in `identifiers.py`. Minimal -ACDC assembly is test-owned in `tests/association_issuer.py`; protocol conformance -and vector generation use the installed producer. Canonical SAID-bearing schema -bytes are unchanged; application acceptance policy does not change the schema. - -The verifier companion implements ADR 0005: permanent exact issuer/nonce/SAID -claims in `VerifierBaser.accepted_nonces`, committed with accepted status and any -outbox obligation. Nonce reuse produces terminal local `NONCE_REUSED`, preserving -the independent verified result. Acceptance runs without webhook delivery too; -those records have no delivery obligation, and later enabling delivery does not -backfill them. Revocation retains claims. The scope now requires `issuer-nonce-v1`; -pre-policy scopes and missing/inconsistent accepted history are refused, without -migration. There is no new store, option, application lock or concurrency runtime. - -Kent authorized committing, pinning and opening both coordinated PRs on -2026-10-31. The test-only producer requirement now pins companion commit -`2a81727e81be19d4ebcef007e7c373881313bc27` from -[verifier PR #20](https://github.com/GLEIF-IT/eoa-verifier/pull/20). Merge it first. -Candidate qualification installed both fresh wheels; the published pin's installed -Python/JSON files are checked against the qualified verifier artifact. The final -oracle wheel passed the full suite again against that published Git pin; all -10 focused inbox/import checks also passed. -Qualification completed locally on macOS with Python 3.12.10, GLEIF KERI/HIO -1.2.19/0.6.22, LMDB 1.8.1 and Foundry 1.5.1: - -- Full standalone verifier installed-wheel suite: **114 passed**, 268.30 seconds. - Its fresh environment contains no oracle package. The four witnessed intake - cases cover POST/PUT with delivery enabled/disabled, valid different-wallet - nonce reuse, pending evidence, invalid proof and revocation during initial RPC. -- Full oracle installed-wheel suite: **119 passed**, 150.68 seconds. The reduced - count removes the retired 28 ledger/ceremony cases, packaged issuer-schema test - and deleted normalization API test, and adds two rejected issuer-command cases. - Protocol conformance now checks the installed producer; its canonical fixtures - remain unchanged. No maintained paired assertion was removed. -- Maintained paired scenario: **passed**, 44.492 seconds within that oracle suite. - It rejects a valid newly issued second-wallet credential sharing the first pair, - then accepts a fresh-nonce credential and retains witnessed issuance, real USDC - balance changes, signed retry/lost ACK, independent restart, replacement and - exact revocation/withdrawal checks. -- Native storage tests include same/different-SAID four-process races, issuer - scope, exact composed/decomposed Unicode and whitespace, persistent reopen, - malformed/orphaned claims, missing history and abrupt process death before - and after acceptance commit. Fault injection confirms claim/status/outbox - rollback. Referenced-but-missing delivery is refused, while explicitly local - acceptance/retirement has no event. Public NONCE_REUSED GET returns HTTP 200 - without attempting an empty LMDB key lookup. -- Oracle-only runtime smoke: all 18 modules import and CLI help loads in another - fresh environment with no verifier installed. Wheel audits match all 30 - verifier and 21 oracle Python/JSON files to current source and exclude the - deleted issuer package, nonce ledger and commands. Component architecture and - whitespace checks pass. - -Contracts remain `4c83e465b3d7937f02b95e805cca5b79f5015078`, tree-equivalent to -merged comply `9f93d8da3601ae12a747731dc0767128ac95c102`. All 17 contract-source -and build-configuration files used by qualification match that clean checkout. -Candidate wheel SHA-256 values: - -- Verifier: `7ffb46d0d1b37052b2c158d685d7a7fe582703665734ea284fea2bdd4a3b6e84`. -- Oracle: `07491f8d43a991fcc55b5095ba77a6863616d585fba1b2add348042c4d3edef7`. - -The runtime source of both artifacts matches the implementation branches based on -verifier `486fb42f92b6c3269d7968934448f21121ef08aa` and oracle -`7734146c9f5bb23607e9434180651ef514f4274b`. Remaining limits: nonce uniqueness -is per preserved verifier store, pre-policy stores require a deliberate fresh -baseline, and startup history audit scans all accepted SAIDs into memory. No -migration, cross-store authority or Linux CI result is claimed. Existing KERIpy -malformed-input limitations remain outside this ownership change. -Task 5 (empty policy configuration) remains the next architecture cleanup; the -wrapper's noncustodial audit role and direct USDC bypass remain accepted. - - -## ASCII nonce contract revision - -Kent approved replacing the pre-use nonce contract on 2026-10-31. The current -contract is 1–128 ASCII letters, digits, underscores or hyphens. Proof validation, -acceptance storage and the canonical/packaged schema enforce it. Komer joins the -issuer and nonce with its standard dot separator; there is no digest or JSON key -encoding. The acceptance scope is `issuer-nonce-ascii-v1`, with fresh stores and -no old-key readers or migrations. - -The canonical schema, packaged verifier resource, policy SAID, reference ACDC, -protocol vectors and comply publication calldata change together. Signed challenge -fields are unchanged for the valid reference nonce; the new schema changes the -credential SAID. Independent-process locking remains entirely native LMDB. -Verifier PR #20 receives the implementation. Oracle #50 is already merged, so -its canonical fixture/docs and producer-pin update require a new companion PR. -The comply companion changes its public fixture and documents the upstream nonce -contract; Solidity does not interpret or store association nonces. - - -Current schema SAID: `EOgZ5tOZ0f7U-4H004zKoz75Pi8XwUM2FjKoMYrkBnmu`. Current reference association SAID: -`EIMtYfwyE2KoT65Tze54g0IyPfw41Zly2sXvo9Mrgzv3`. This replaces the preceding schema and fixture; -no previous schema ID is accepted by the current verifier policy. - -Qualification: **134 standalone installed-wheel verifier tests passed** in -322.04 seconds; **130 installed-wheel oracle tests passed** in 247.38 seconds, -including the maintained paired qualification in 52.825 seconds; **28 -Forge tests passed** against the updated publication vector. Focused checks passed -53 verifier and 72 oracle tests. The new matrix covers the 1/128 boundaries, -129-character rejection, exact ASCII case, Unicode, whitespace, embedded dots, -trailing newlines, controls and disallowed punctuation. Existing thread-free -native LMDB process races, crash rollback/recovery, issuer scope and idempotent -acceptance remain covered. All witnessed intake cases and maintained transfer, -restart, lost-ACK, replacement and exact retirement assertions remain intact. - -The canonical/packaged schema bytes agree. The regenerated ACDC, protocol vectors, -and Solidity publication calldata agree. Wheel audit matches all 30 verifier and -21 oracle Python/JSON files to source. Qualified wheel SHA-256 values: - -- Verifier: `14a5a55f7847eaa4cf9b09b223711528b25576285602467ddd481e7f928552fc`. -- Oracle: `763af399ab391b2a72235f275d43665926e809eb0c17dcdf1b681a5946eb5953`. - -Python 3.12.10, GLEIF KERI/HIO 1.2.19/0.6.22, LMDB 1.8.1 and Foundry 1.5.1 -were used locally on macOS. Native LMDB supplies locking; no mutex, migration, -old-format reader, fallback API or separate nonce environment was added. - -The coordinated producer pin is verifier `ba1971f54fd26191eb147fec0e7a75ed179eda7f` (PR #20). The comply fixture/docs -pin is `13c6ae3506f6c6f398b37f12d646da4f2c21577b`; its Solidity and ABI are unchanged from the preceding qualified -contracts. Merge those companions before the oracle schema/vector update. The -qualification snapshots match those commits' runtime/schema/vector contents. - -The published verifier install matches all 30 qualified Python/JSON files. CI and -demo contract pins agree with comply PR #12, and its publication fixture matches -the qualified snapshot. No runtime source changed after installed-wheel testing. - -## Cohesive production and test organization wave - -Status: authorized 2026-10-31. All preceding nonce PRs are merged: verifier #20 -at `d2ba48f28f5268b35dd7b86a7d73f3e82f90613a`, oracle #51 at -`4432a274ed78cf532d0fa1e316ccebeedd78858d`, comply #12 at -`da8ea58084890806665fab648bb87e77189d0faa`. Their trees match the qualified nonce -heads. No empty-policy implementation has started. Task 5 and the other behavioral -cleanup remain separate; this wave changes organization only. Kent authorized -inspection, implementation, qualification, commits, pushes and three focused PRs. -Do not merge them. - -### Baseline inventory and constraints - -- Verifier: six established production components (`runtime`, `receiving`, - `verification`, `associations`, `delivery`, `persistence`), 134 collected cases, - flat tests and one mixed `keripy_helpers.py` support module. -- Oracle: root-level transport/domain/persistence modules, `commands/`, one mixed - `receiving/service.py` configuration/composition module, and existing - `endorsement/`; 130 cases. Selection and posting tests import fixtures/helpers - from other test modules. Witnessed issuer/contract support is split between - tests and `scripts/protocol`. -- Comply: topical admin/identity/wrappers, split policy/policies and attestation, - global interfaces, demo contracts in assets/policy; 28 cases in three flat - test files. Policy test doubles share a test file. - -Preserve all LMDB tables/fields, status and ACK bytes, transaction boundaries, -resource ownership, contract selectors/events, authorization, transfer semantics, -and the accepted noncustodial audit model. Empty policy sets retain their current -behavior until the separate task 5 PR. No issuer/combined runtime, compatibility -imports, repository abstraction or new concurrency mechanism is introduced. - -### Verifier mapping - -Production packages stay unchanged. Test files follow the modules they exercise: - -| Old tests | New location | -|---|---| -| `test_runtime.py` | `runtime/test_serving.py`, with CLI/config cases in `runtime/test_cli.py` and `runtime/test_config.py` | -| `test_directing.py` | `receiving/test_directing.py`; service-composition case in `runtime/test_serving.py` | -| `test_intake.py` | `receiving/test_grants.py`; coordinator wrong-schema case in `verification/test_coordinating.py` | -| `test_account.py` | `verification/test_worker.py` | -| `test_coordinating.py` | `verification/test_coordinating.py` | -| `test_authing.py` | `delivery/test_authing.py` | -| `test_delivering.py`, `test_retry.py` | `delivery/test_delivering.py` | -| `test_basing.py` | `persistence/test_basing.py` | -| `test_accepted_nonces.py` | `persistence/test_accepted_nonces.py` | -| `test_accepting.py` | storage cases in `persistence/test_basing.py`, public GET in `associations/test_statusing.py`, whole cross-boundary retirement/GET scenario in `integration/test_acceptance_status.py` | -| `test_nonce_contract.py` | schema/proof inputs in `verification/test_eoa.py`; native key/consumption assertions in `persistence/test_accepted_nonces.py` | -| `test_ipex_integration.py` | `integration/test_ipex_verification.py` | -| `keripy_helpers.py` | `support/issuers.py`, `support/services.py`, `support/network.py` | -| acceptance construction from `test_accepting.py` | `support/acceptance.py`; shared fixture in the narrowest common conftest | - -The nonce contract's 4 valid and 16 invalid parameter cases currently combine two -independent boundaries. Splitting them preserves every assertion/matrix and adds -20 collected cases (expected verifier total: 154), rather than mixing persistence -assertions into proof tests. Other scenarios move whole. Acceptance/retirement -workers remain covered by witnessed IPEX integration; do not add mock unit cases -merely to populate a directory. - -Dependencies remain: runtime may compose all verifier components; each other -component may depend on itself and persistence. Tests must not import test modules. - -### Oracle production mapping and dependency rules - -| Old source | New owner | -|---|---| -| `cli.py`, `commands/server.py`, command registration | `runtime/cli.py` | -| `commands/parse_deploy_log.py` | `runtime/deploy_log.py` | -| `identity.py` | `runtime/identity.py` | -| `receiving/service.py` configuration | `runtime/config.py` | -| `receiving/service.py` composition/lifetime | `runtime/serving.py` | -| `authing.py` | `receiving/authing.py` | -| `receiving/status.py` | remains authenticated ingress | -| `statusing.py`, `identifiers.py` | `associations/statusing.py`; identifier parsing has no independent consumer | -| status/event records and `selecting.WalletClaim` | `associations/records.py` | -| `selecting.py` policy | `associations/selecting.py` | -| `basing.py` storage | `persistence/basing.py` | -| journal, replay and deployment/trust records | `persistence/records.py` | -| `rpc.py` | `endorsement/rpc.py` | -| existing endorsement workflow/effects/resources | remain in `endorsement/` | - -Allowed component edges: runtime → all; receiving → associations/persistence; -endorsement → associations/persistence; persistence → associations; associations → -no other oracle component. Selection stays a pure record mutation called inside -the existing receipt write transaction. No callbacks or repository facade. - -Oracle test mapping: - -| Old tests/support | New location | -|---|---| -| `test_cli.py`, `test_demo_checkout.py` | `runtime/test_cli.py`, `runtime/test_demo_checkout.py` | -| runtime cases in `test_status_inbox.py` | `runtime/test_serving.py` | -| status/auth ingress cases | `receiving/test_status.py`, `receiving/test_authing.py` | -| `test_selection.py` | `associations/test_selecting.py`; atomic receipt rollback in `persistence/test_basing.py`, missing-facts ingress in `receiving/test_status.py` | -| `test_posting.py` pure desired actions | `endorsement/test_decisions.py` | -| `test_contract_effects.py`, `test_contract_rpc.py` | `endorsement/test_effects.py`; storage scope/immutability cases in `persistence/test_basing.py` | -| `test_status_posting.py` | `integration/test_status_posting.py` | -| `test_association_protocol.py` | `integration/test_association_profile.py` (producer-profile conformance, not oracle verification) | -| `test_two_services.py` | `qualification/test_two_services.py` (the sole maintained paired scenario) | -| `association_issuer.py`, `scripts/protocol/issuance_helpers.py` | `support/issuers.py` | -| contract fixture/construction from test files and scripts | `support/contracts.py` | -| `service_processes.py` | `support/processes.py` | -| status construction and signed posting helpers from test files | `support/status_events.py` | - -Shared peer/deployment fixtures keep their existing lifetimes in the narrowest -common conftest. In particular, module-scoped chain deployments remain per test -module. Preserve all scenarios and matrices; expected oracle total remains 130. - -### Comply mapping and dependency rules - -| Old source | New owner | -|---|---| -| `identity/interfaces/IIdentityRegistry.sol` | `identity/IIdentityRegistry.sol` | -| `interfaces/IGL1IdentityRegistry.sol` | `identity/IGL1IdentityRegistry.sol` | -| `attestation/VLEIOracleRegistry.sol`, `VLEIEndorsementChecker.sol`, `interfaces/IVLEIOracleRegistry.sol` | `associations/` | -| `interfaces/IPolicy.sol`, `IPolicyManager.sol`, `IAttestationServiceVerifier.sol`, `policies/VLEIWalletAssociationPolicy.sol` | `policy/` | -| `assets/USDC.sol`, `policy/AllowAllPolicyEngine.sol` | `demo/`; concrete consumers are DeployAll/tests only | -| admin, identity implementation/adapter, PolicyManager, wUSDC | remain in their topical components | - -Allowed source edges from actual imports: identity/admin → their own components; -policy → identity/admin; associations → policy/admin; wrappers → policy/admin; -demo → admin. DeployAll composes all components. Production components may not -import demo contracts. External vendor interfaces remain external dependencies. - -Tests move to `test/associations/VLEIOracleRegistry.t.sol`, -`test/policy/PolicyManager.t.sol`, and -`test/integration/WalletAssociationCompliance.t.sol`. Extract policy doubles into -`test/support/doubles/PolicyDoubles.sol`; keep the genuine multi-contract fixture -and scenarios intact. Public ABI and publication-vector files stay under `abi/` -because oracle qualification and contract documentation consume them as published -encoding artifacts, not private test fixtures. Expected Foundry count remains 28. - -### Rollout and validation gates - -1. Capture baseline test functions, decorators/parameterization, assertion counts, - contract ABI/storage layouts and source bodies before moves. Record final - old-to-new locations and explain any corrections to this mapping. -2. Use explicit Python test/support packages and pytest importlib mode. Invocations - run from the repository or copied qualification root via `python -m pytest`; - remove PYTHONPATH/sys.path workarounds. Copy test configuration outside the - checkout in CI. Keep test support out of wheels. -3. Review component dependencies, cycles and test support imports as part of code - review. Keep the documented boundaries; do not add custom architecture-check - scripts or replacement enforcement machinery. -4. Run focused collection/import/boundary checks, full fresh installed-wheel - Python suites outside checkouts, full Forge suite, and unchanged launcher tests. - Compare ABI exactly and storage semantically, accounting for moved source paths - and compiler AST identifiers. Contract bodies must differ only in imports. -5. Qualify all final components/contracts through the relocated maintained paired - scenario. Preserve witnesses, actors, independent processes, real LMDB/RPC, - transfers and all recovery assertions. Do not invent a second paired scenario. -6. Publish three focused PRs. Verifier tests and contract layout may publish first; - oracle publishes last so it can pin their exact qualified commits and update - CI/demo/launcher references. Verify packaged ABI/schema content identity. -7. Add concise testing guides with module/class/function/contract and integration - lookup examples. Report exact checks, revisions and limitations. Task 5 stays - queued as a separate behavioral PR after this organization wave. - - -Organization wave implementation notes: - -- Root oracle literal version metadata is retained; initializers have no import - facades or startup side effects. -- Signed Grant construction from verifier intake tests is now named issuer - support. Shared fixtures retain their original function/module scopes. The - standalone standard-library shell-launcher harness remains beside its scripts; - its four cases and invocation are documented separately from Foundry tests. -- Verifier production: 30 files unchanged byte-for-byte; all 267 test assertion - expressions preserved. Oracle: all 190 test assertion expressions preserved, - plus identical ASTs for 14 critical record/config/policy/storage/lifetime nodes. -- All 16 Solidity production bodies differ only in imports. Fresh compiler ABI - and structural storage comparisons match for all 16. All 28 Forge tests and - four launcher checks pass. -- The new oracle components reopen all seven baseline LMDB tables with identical - stored bytes. All four CLI help surfaces remain identical. Python collection - is 154 verifier cases (the documented split) and 130 oracle cases. -- Focused checks: 74 verifier and 112 oracle cases pass. Full fresh installed-wheel - suites now pass: 154 verifier cases in 297.77 seconds and 130 oracle cases in - 210.36 seconds. The maintained paired scenario passes in 48.204 seconds. -- Qualified publication pins are verifier `895713e66e6057590cf8247f8e8c1829371c6c71` and comply - `aeba4883dadb30e06a0316d93394b08ff9a9e97d`. The component payloads retain the qualified code and tests; - custom architecture-check scripts and CI hooks are removed. Empty-policy - behavior remains separate. - -Qualified artifacts exclude test support. Verifier wheel contains the same 30 -production code/resources as baseline; oracle wheel contains 24 files in the new -components, with no deleted flat-module aliases. Packaged ABIs remain identical -to the moved contracts. Wheel SHA-256 values: - -- Verifier: `f3a640402b38b3f4830d2c484c9e7bedf121e6d763bfb12152c25da0aa7b7f47`. -- Oracle: `fac80beda0d3dfa522f791f0e0144238f98f26ef36d445d53130efc77525d9be`. - -Local qualification uses Python 3.12.10, GLEIF KERI/HIO 1.2.19/0.6.22, LMDB -1.8.1 and Foundry 1.5.1. The shell -launcher selects exactly one maintained scenario from an external working dir. -Native parser shortage limitations remain outside this organizational change. diff --git a/docs/diagrams/sequence/local-setup-sequence.md b/docs/diagrams/sequence/local-setup-sequence.md new file mode 100644 index 0000000..28415c4 --- /dev/null +++ b/docs/diagrams/sequence/local-setup-sequence.md @@ -0,0 +1,33 @@ +# Local independent-service setup + +Use explicitly pinned installed applications, fresh demo stores and a separately authorized Oracle writer. + +![Local independent-service setup](local-setup-sequence.svg) + +
+Editable Mermaid source + +```mermaid +%%{init: {"theme":"base","themeVariables":{"actorBkg":"#003336","actorTextColor":"#FFFFFF","signalColor":"#003336","signalTextColor":"#003336","noteBkgColor":"#E5DCE6","noteTextColor":"#003336","loopTextColor":"#003336","labelTextColor":"#003336","labelBoxBkgColor":"#DFFBC0","labelBoxBorderColor":"#6A7B7F","actorLineColor":"#6A7B7F","lineColor":"#6A7B7F"},"sequence":{"mirrorActors":true,"wrap":true}}}%% +sequenceDiagram + autonumber + participant U as Operator + participant L as Comply launcher + participant V as Installed Verifier environment + participant O as Oracle + participant C as Anvil / contracts + U->>L: Select asset checkouts, executables and EOA_VERIFIER_PYTHON + L->>V: Read packaged association schema + L->>L: Prepare witness / schema service + L->>C: Deploy contracts and configure wallet policy + U->>U: Create independent service AIDs and stores + U->>C: Fund and authorize dedicated Oracle writer + L->>V: Start verifier with trusted GEDA, chain/RPC and webhook peer + L->>O: Start Oracle with trusted Verifier, chain and registry addresses + L->>V: Introduce Oracle public KEL + L->>O: Introduce Verifier public KEL +``` + +
+ +See the [portable Comply setup guide](https://github.com/GLEIF-IT/vlei-comply/blob/main/docs/gl1-vlei-local-infra-setup.md). Startup does not issue association credentials. diff --git a/docs/diagrams/sequence/local-setup-sequence.svg b/docs/diagrams/sequence/local-setup-sequence.svg new file mode 100644 index 0000000..4d42160 --- /dev/null +++ b/docs/diagrams/sequence/local-setup-sequence.svg @@ -0,0 +1 @@ +Anvil / contractsOracleInstalled VerifierenvironmentComply launcherOperatorAnvil / contractsOracleInstalled VerifierenvironmentComply launcherOperatorSelect asset checkouts,executables andEOA_VERIFIER_PYTHON1Read packaged associationschema2Prepare witness /schema service3Deploy contracts and configure wallet policy4Create independentservice AIDs and stores5Fund and authorize dedicated Oracle writer6Start verifier with trusted GEDA,chain/RPC and webhook peer7Start Oracle with trusted Verifier, chain and registry addresses8Introduce Oracle public KEL9Introduce Verifier public KEL10 \ No newline at end of file diff --git a/docs/diagrams/sequence/oracle-endorsement-sequence.md b/docs/diagrams/sequence/oracle-endorsement-sequence.md new file mode 100644 index 0000000..6017349 --- /dev/null +++ b/docs/diagrams/sequence/oracle-endorsement-sequence.md @@ -0,0 +1,36 @@ +# Oracle receipt, selection and publication + +Verifier has completed initial verification and application acceptance. Oracle trusts authenticated producer facts. + +![Oracle receipt, selection and publication](oracle-endorsement-sequence.svg) + +
+Editable Mermaid source + +```mermaid +%%{init: {"theme":"base","themeVariables":{"actorBkg":"#003336","actorTextColor":"#FFFFFF","signalColor":"#003336","signalTextColor":"#003336","noteBkgColor":"#E5DCE6","noteTextColor":"#003336","loopTextColor":"#003336","labelTextColor":"#003336","labelBoxBkgColor":"#DFFBC0","labelBoxBorderColor":"#6A7B7F","actorLineColor":"#6A7B7F","lineColor":"#6A7B7F"},"sequence":{"mirrorActors":true,"wrap":true}}}%% +sequenceDiagram + autonumber + participant V as EOA Verifier + participant O as Oracle inbox + participant P as Oracle posting worker + participant C as Ethereum registries + V->>O: Authenticated immutable status event + O->>O: Validate trusted sender, event identifiers and chain + O->>O: Atomically commit receipt, newest status and selection + O-->>V: Authenticated durable-storage ACK + Note over V,O: ACK does not mean selected or published + alt Selected accepted association + P->>P: Read desired action, prepare RPC effect + P->>P: Recheck durable selection, journal signed intent + P->>C: Submit registration / exact-wallet endorsement + C-->>P: Receipt and observed registry state + P->>P: Record confirmation, reconcile next desired action + else Rejected or superseded selection + P->>P: Do not publish this claim + end +``` + +
+ +[Oracle API](../../../protocol/oracle-api-v1/README.md) defines selection and conflicts. Supersession changes Oracle selection, not Verifier acceptance. See [operations](../../status-inbox.md) for unresolved-transaction limits. diff --git a/docs/diagrams/sequence/oracle-endorsement-sequence.svg b/docs/diagrams/sequence/oracle-endorsement-sequence.svg new file mode 100644 index 0000000..ab58ba3 --- /dev/null +++ b/docs/diagrams/sequence/oracle-endorsement-sequence.svg @@ -0,0 +1 @@ +Ethereum registriesOracle postingworkerOracle inboxEOA VerifierEthereum registriesOracle postingworkerOracle inboxEOA VerifierACK does not mean selected orpublishedalt[Selected accepted association][Rejected or superseded selection]Authenticated immutable statusevent1Validate trusted sender,event identifiers andchain2Atomically commitreceipt, newest statusand selection3Authenticated durable-storageACK4Read desired action,prepare RPC effect5Recheck durableselection, journalsigned intent6Submit registration / exact-walletendorsement7Receipt and observed registrystate8Record confirmation,reconcile next desiredaction9Do not publish thisclaim10 \ No newline at end of file diff --git a/docs/diagrams/sequence/revocation-status-sequence.md b/docs/diagrams/sequence/revocation-status-sequence.md new file mode 100644 index 0000000..a1b35fc --- /dev/null +++ b/docs/diagrams/sequence/revocation-status-sequence.md @@ -0,0 +1,36 @@ +# Verified revocation and exact withdrawal + +Only verified revocation retires upstream acceptance. Replacement selection does not. + +![Verified revocation and exact withdrawal](revocation-status-sequence.svg) + +
+Editable Mermaid source + +```mermaid +%%{init: {"theme":"base","themeVariables":{"actorBkg":"#003336","actorTextColor":"#FFFFFF","signalColor":"#003336","signalTextColor":"#003336","noteBkgColor":"#E5DCE6","noteTextColor":"#003336","loopTextColor":"#003336","labelTextColor":"#003336","labelBoxBkgColor":"#DFFBC0","labelBoxBorderColor":"#6A7B7F","actorLineColor":"#6A7B7F","lineColor":"#6A7B7F"},"sequence":{"mirrorActors":true,"wrap":true}}}%% +sequenceDiagram + autonumber + participant E as KERI evidence + participant V as EOA Verifier + participant O as Oracle + participant C as Contract registry + E->>V: Revocation TEL and witnessed issuer KEL anchor + V->>V: Native validation accepts revocation + V->>V: Atomically retire SAID and create its own delivery event + V->>O: Authenticated revoked event + O->>O: Commit receipt, terminal status and selection update + O-->>V: Authenticated ACK for this event/attempt + O->>C: Withdraw exact association SAID + alt Current mapping still names revoked SAID + C->>C: Clear endorsement and emit withdrawal + else A successor is already mapped + C->>C: Preserve successor, return false + end + C-->>O: Receipt / actual state + Note over V,C: Outages and latency can leave on-chain authority until withdrawal +``` + +
+ +Missing evidence is not revocation. Already confirmed token transfers are not undone. [Oracle API](../../../protocol/oracle-api-v1/README.md) and [Verifier API](https://github.com/GLEIF-IT/eoa-verifier/blob/master/protocol/verifier-api-v1/README.md) own their respective transitions. diff --git a/docs/diagrams/sequence/revocation-status-sequence.svg b/docs/diagrams/sequence/revocation-status-sequence.svg new file mode 100644 index 0000000..2e8bfbc --- /dev/null +++ b/docs/diagrams/sequence/revocation-status-sequence.svg @@ -0,0 +1 @@ +Contract registryOracleEOA VerifierKERI evidenceContract registryOracleEOA VerifierKERI evidencealt[Currentmappingstill namesrevokedSAID][A successoris alreadymapped]Outages and latency can leave on-chain authority until withdrawalRevocation TEL and witnessedissuer KEL anchor1Native validationaccepts revocation2Atomically retire SAIDand create its owndelivery event3Authenticated revoked event4Commit receipt,terminal status andselection update5Authenticated ACK for thisevent/attempt6Withdraw exact association SAID7Clear endorsement andemit withdrawal8Preserve successor,return false9Receipt / actual state10 \ No newline at end of file diff --git a/docs/diagrams/sequence/stablecoin-end-to-end-sequence.md b/docs/diagrams/sequence/stablecoin-end-to-end-sequence.md new file mode 100644 index 0000000..623b89b --- /dev/null +++ b/docs/diagrams/sequence/stablecoin-end-to-end-sequence.md @@ -0,0 +1,43 @@ +# Witnessed associations to audited token transfers + +This is the single full-system scenario, maintained alongside [paired qualification](../../two-service-qualification.md). It repeats association acceptance for both wallets. + +![Witnessed associations to audited token transfers](stablecoin-end-to-end-sequence.svg) + +
+Editable Mermaid source + +```mermaid +%%{init: {"theme":"base","themeVariables":{"actorBkg":"#003336","actorTextColor":"#FFFFFF","signalColor":"#003336","signalTextColor":"#003336","noteBkgColor":"#E5DCE6","noteTextColor":"#003336","loopTextColor":"#003336","labelTextColor":"#003336","labelBoxBkgColor":"#DFFBC0","labelBoxBorderColor":"#6A7B7F","actorLineColor":"#6A7B7F","lineColor":"#6A7B7F"},"sequence":{"mirrorActors":true,"wrap":true}}}%% +sequenceDiagram + autonumber + participant I as Witnessed GEDA / QVI / LE issuers + participant V as Installed EOA Verifier + participant O as Installed Oracle + participant C as Registries and wUSDC on Anvil + participant U as Wallet owner + I->>V: Source chain and association proof over IPEX / CESR + V->>V: Initial validation, account observation and acceptance-time nonce claim + V->>O: Signed accepted status + O->>O: Durable receipt and wallet selection + O-->>V: Signed ACK (drop once, retry exact event) + O->>C: Publish selected exact-wallet mapping + C-->>O: Confirm receipt and actual mapping + U->>C: Approve underlying USDC to wUSDC + U->>C: Owner calls wrapper transfer + C->>C: Evaluate both wallet endorsements, move USDC on Pass + Note over U,C: Check actual sender/recipient balances + V->>V: Restart from preserved store without another Grant + O->>O: Restart independently, retain selection and journal + I->>V: Higher-issuance same-LE replacement + V->>O: Accepted replacement status + O->>C: Replace selected endorsement + I->>V: Verified revocation evidence for old, then current SAID + V->>O: Separate terminal events and ACKs + O->>C: Old withdrawal preserves successor, current withdrawal clears it + U->>C: Wrapper transfer rejected, token balances unchanged +``` + +
+ +Selection and receipt do not change upstream acceptance. The fixture also rejects reuse of an accepted issuer/nonce by another credential. Direct USDC transfers can bypass wUSDC; its role is auditable compliance for routed transfers. No production-readiness or malformed-stream liveness claim follows from this scenario. diff --git a/docs/diagrams/sequence/stablecoin-end-to-end-sequence.svg b/docs/diagrams/sequence/stablecoin-end-to-end-sequence.svg new file mode 100644 index 0000000..b0cae9d --- /dev/null +++ b/docs/diagrams/sequence/stablecoin-end-to-end-sequence.svg @@ -0,0 +1 @@ +Wallet ownerRegistries andwUSDC on AnvilInstalled OracleInstalled EOAVerifierWitnessed GEDA /QVI / LE issuersWallet ownerRegistries andwUSDC on AnvilInstalled OracleInstalled EOAVerifierWitnessed GEDA /QVI / LE issuersCheck actual sender/recipientbalancesSource chain and associationproof over IPEX / CESR1Initial validation,account observationand acceptance-timenonce claim2Signed accepted status3Durable receipt andwallet selection4Signed ACK (drop once, retryexact event)5Publish selected exact-walletmapping6Confirm receipt and actualmapping7Approve underlying USDC towUSDC8Owner calls wrapper transfer9Evaluate both walletendorsements, moveUSDC on Pass10Restart from preservedstore without anotherGrant11Restart independently,retain selection andjournal12Higher-issuance same-LEreplacement13Accepted replacement status14Replace selected endorsement15Verified revocation evidence forold, then current SAID16Separate terminal events andACKs17Old withdrawal preservessuccessor, current withdrawalclears it18Wrapper transfer rejected, tokenbalances unchanged19 \ No newline at end of file diff --git a/docs/status-inbox.md b/docs/status-inbox.md index 0f1ef84..241dffc 100644 --- a/docs/status-inbox.md +++ b/docs/status-inbox.md @@ -1,9 +1,10 @@ -# Trusted verifier status and contract posting +# Operate the trusted-status Oracle -`vlei-oracle server receive` accepts EOA Verifier webhooks and signs ACKs after -committing receipt, verifier status and ownership selection to LMDB. -`server start` adds trusted-status contract posting. Initial credential, proof and -account verification belongs exclusively to EOA Verifier. +Oracle authenticates Verifier status, commits receipt/selection, then optionally +publishes or withdraws contract endorsements. [Oracle API v1](../protocol/oracle-api-v1/README.md) +owns validation/errors, duplicate handling and selection. The shared delivery +profile belongs to [Verifier API v1](https://github.com/GLEIF-IT/eoa-verifier/blob/master/protocol/verifier-api-v1/README.md). +A storage ACK does not mean selection or confirmed publication. ## Start @@ -31,81 +32,6 @@ verifier or chain; use another store for a different trust scope. Use fresh application stores for demonstrations and preserve existing operator data separately. There are no storage migrations or previous-format readers. -## Status delivery and acknowledgment - -POST the verifier's ordinary v1 JSON object to `/v1/status-events`. The -[producer's API note](https://github.com/GLEIF-IT/eoa-verifier/blob/895713e66e6057590cf8247f8e8c1829371c6c71/adrs/0002-verifier-result-object.md) -defines acceptance and retirement. The receiver supports these two states: - -- `status: "accepted"`: initially verified and accepted association. -- `status: "revoked", reasonCode: "REVOKED"`: verified association revocation. - Retain the same `associationSaid` and `association` facts, increase `statusRevision`, - and set `eventId` to `associationSaid:statusRevision`. - -The oracle trusts the configured verifier's authenticated facts. It checks the -object's identifiers, revision and configured chain, derives the wallet from -`extId` and `identityRef` as Keccak-256 of the issuer AID's UTF-8 bytes. It does -not reverify the ACDC, wallet proof or account. `accountObservation` is informational and -not required by the receiver; age never invalidates accepted status. - -The inbox preserves immutable event bytes. Event receipt, the newest stored -status and selection commit in one transaction. Reordered older events and exact duplicates -are ACKed without replacing newer state. Revocation is terminal for that SAID. -Conflicting bytes at a revision or changed association facts return HTTP 409. -Selection policy may decline ownership while retaining and acknowledging the -verifier's accepted status; it does not declare the credential cryptographically invalid. - -HTTP 200 carries the signed body `{"eventId":":","stored":true}`. -It acknowledges durable receipt, **not ownership approval or an on-chain endorsement**. KERI -signatures cover the exact body digest, method/path, destination, audience, -action, nonce and expiry. The ACK additionally binds the request attempt and HTTP -status. Transport nonces are persisted separately from application event IDs. -A retry uses the same event bytes with a new signature/nonce. A crash after commit -but before either side records the ACK is safe to redeliver. Invalid signatures -or replay return 401; malformed/unsupported events return 400. No error completes -delivery. Authentication expiry does not expire association validity. - -The v1 object now uses `status`, `statusRevision`, `accountObservation` and -`association.issuanceAnchor`. Deploy this consumer with the pinned verifier on -fresh PoC application stores and contracts. There are no old-shape readers, -aliases or migrations; preserve existing stores separately. The replay table -uses `replay_claims` records with `expiresAt`. HTTP signature `expires` remains -a transport parameter and does not expire associations. - -EOA Verifier owns association-nonce acceptance policy. It permanently binds each -exact issuer/nonce to one accepted SAID and rejects a different SAID reusing that -pair, including after revocation. The nonce is not added to this status wire -contract. The oracle has no issuance nonce ledger or credential finalization API; -its webhook replay claims and signed Ethereum transaction nonces remain separate. -Association nonces contain 1–128 ASCII characters from `[A-Za-z0-9_-]`. The -verifier stores ordinary `issuer.nonce` Komer keys under policy -`issuer-nonce-ascii-v1`. Use fresh verifier stores; no issuer-ledger or digest-key -migration exists. - -## Ownership selection - -`selecting.py` applies [ADR 0001](https://github.com/GLEIF-IT/eoa-verifier/blob/895713e66e6057590cf8247f8e8c1829371c6c71/adrs/0001-eoa-association-ownership-and-replacement.md) -to trusted facts. One canonical `extId` (chain/address) has one current association: - -- Same LE holder AID: a strictly higher issuer-KEL issuance sequence supersedes - the predecessor. LE credential SAIDs, status revisions and arrival times - do not establish priority. Never compare different issuers' sequence numbers. -- Another LE: reject the competing claim while the current claim is active. - Verified current-SAID revocation releases it. Previously rejected associations do - not activate automatically or on duplicate delivery; a new association is required. -- Old-SAID revocation cannot release its successor. Issuance history survives - release, transfer and restart, so a superseded predecessor cannot return. - A newer same-LE retirement arriving before its acceptance still supersedes the - older claim; replaying either acceptance cannot restore it. - -`statuses` retains verifier `status` separately from local `selection`: -`selected`, `superseded`, `rejected` or `revoked`. `claims` retains the current SAID -and highest known issuance sequence per issuer for that chain/address. -`OracleBaser.selected_association(ext_id)` reads the selected stored facts without -RPC or credential checks. -No background selection worker is needed. Same-anchor -multiple-association detection remains deferred as described in the ADR appendix. - ## Contract posting ```sh @@ -144,25 +70,17 @@ rebroadcast, cancellation, nonce reconciliation and reorg recovery are outside t runtime. Never share its writer with another process. Use fresh demonstration stores. Changing chain, writer or contract addresses requires another store. -## Checks - -Install the test-only sender with `pip install -r tests/requirements.txt`. CI tests -installed wheels against Foundry 1.5.1 and comply revision -`aeba4883dadb30e06a0316d93394b08ff9a9e97d`. For local contract tests, set -`VLEI_COMPLY_DIR` to that checkout with its submodules and put `forge`/`anvil` on PATH. -Missing prerequisites fail the contract suite. `test_status_posting.py` covers -accepted-to-published, replacement, exact withdrawal, duplicate receipt, pending -and uncertain sends, restart and a replacement during RPC preparation. Its facts -start after upstream initial verification. The [two-service qualification](two-service-qualification.md) -additionally runs witnessed credential issuance through two installed CLI processes. - -The signature adapter matches the merged verifier's profile without importing -that application at runtime. Interoperability tests guard this intentional small -cross-application duplication. KERI 1.2.19 and HIO 0.6.22 match that producer's pins; -KERI 1.2.19 requires HIO 0.6.22 exactly; do not override the resolver. +## Tests and limitations +Install test-only producer requirements from `tests/requirements.txt`; this is not +an Oracle runtime dependency. Contract/CI and demo revisions are explicit in +`.github/workflows/tests.yml` and `scripts/dev/demo-dependencies.json`. Use the +qualified checkout with submodules and Foundry 1.5.1 on PATH as `VLEI_COMPLY_DIR`. +See [testing](testing.md) and [two-service qualification](two-service-qualification.md). -The separately identified KERIpy receipt-couple shortage parser limitation remains -unresolved in the producer dependency. This naming rollout does not establish -intake liveness for that malformed stream; see the pinned verifier's -[operations note](https://github.com/GLEIF-IT/eoa-verifier/blob/895713e66e6057590cf8247f8e8c1829371c6c71/docs/operations.md). +Transport interoperability is tested against the installed producer while the +small adapters remain independent. Both applications pin GLEIF KERI 1.2.19 and +HIO 0.6.22. Keep those package pins; do not install overlapping upstream keri/hio +distributions. The known KERIpy receipt-couple shortage can monopolize producer +intake on malformed evidence; a valid-stream qualification does not establish +malformed-stream liveness. See [Verifier operations](https://github.com/GLEIF-IT/eoa-verifier/blob/master/docs/operations.md). diff --git a/docs/testing.md b/docs/testing.md index c664cdc..fc393ff 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -15,18 +15,17 @@ tests is an explicit package. No PYTHONPATH/sys.path workarounds are required. | endorsement/decisions.py | tests/endorsement/test_decisions.py | | ContractEffects, RPC and ABI | tests/endorsement/test_effects.py | | Signed ingress through real posting/recovery | tests/integration/test_status_posting.py | -| Producer-profile conformance | tests/integration/test_association_profile.py | | Both services, witnessed issuers and real transfers | tests/qualification/test_two_services.py | Use ::test_function_name for one function or -k expression for a class/method. Named support modules are tests/support/issuers.py, contracts.py, processes.py and status_events.py. Shared peer/deployment fixtures retain function/module scope in -conftest. No test imports another test module. Profile tests check the installed -producer; the oracle does not own proof verification. Collection remains 130. +conftest. No test imports another test module. Proof/schema conformance belongs to Verifier; Oracle retains mapping/ABI +integration and the maintained paired scenario. Collection is 61 cases. Run python -m pytest for the full suite. Full tests need Foundry 1.5.1 and VLEI_COMPLY_DIR pointing to the qualified checkout. CI installs -fresh wheels and copies tests, scripts, protocol and pytest.ini outside checkout. +fresh wheels and copies tests, scripts and pytest.ini outside checkout. Support is excluded from wheels. Run one repository's test package per invocation. The qualification file is the only maintained paired scenario. The comply diff --git a/docs/two-service-qualification.md b/docs/two-service-qualification.md index ad29b71..3258c8c 100644 --- a/docs/two-service-qualification.md +++ b/docs/two-service-qualification.md @@ -35,8 +35,8 @@ focused policy/transport tests; this is not a second fault-matrix suite. Install the oracle wheel and `tests/requirements.txt` in a fresh Python 3.12 environment. Put Foundry 1.5.1 on PATH and set `VLEI_COMPLY_DIR` to comply revision -`aeba4883dadb30e06a0316d93394b08ff9a9e97d` with submodules and built contracts. -From a directory containing the copied `tests`, `scripts` and `protocol` trees: +`9efde5e3db818cf3129e89c9fd08c0f5c0f8dee1` with submodules and built contracts. +From a directory containing the copied `tests` tree and `pytest.ini`: ```sh python -m pytest -q tests/qualification/test_two_services.py @@ -47,28 +47,22 @@ Test logs and stores live beneath pytest's temporary directory; the fixture stop only its own subprocesses. On macOS hosts with LMDB vnode exhaustion, copy the inputs into a Linux container with no host bind mounts and run there. -The producer is pinned to verifier companion revision -`895713e66e6057590cf8247f8e8c1829371c6c71` in `tests/requirements.txt`, not as an -oracle runtime import. Merge the verifier acceptance-policy companion before -this oracle schema/vector companion PR. Its source matches the qualified verifier wheel. -Existing status-posting tests establish old-observation -acceptance and failure handling without the verifier. The paired comply launcher invokes this same scenario; it does not copy the -KERIpy issuance or process-ownership code. - -Both applications use GLEIF KERI 1.2.19 and HIO 0.6.22. This qualification uses -the coordinated nonce-policy candidate wheels; the closed ingress and -replay-pruning candidates remain excluded. The known KERIpy receipt-couple shortage limitation remains unresolved; -a passing valid-stream workflow does not establish liveness for that malformed input. +The producer revision is pinned in `tests/requirements.txt`, only for testing. +CI's contract checkout and the demo manifest pin compatible contract revisions. +Both applications use GLEIF KERI 1.2.19 and HIO 0.6.22. Valid-stream qualification +does not resolve the producer's known native receipt-couple shortage limitation. +The paired Comply launcher invokes this scenario without copying its issuance or +process-ownership code. ## Qualify local application changes To qualify unmerged verifier/oracle changes, build wheels from clean temporary copies of both working trees and install both wheels into the same fresh Python -3.12 environment with pytest and `scripts/protocol/requirements.txt`. Omit +3.12 environment with pytest. Omit `tests/requirements.txt` for this run: its Git requirement deliberately installs the merged verifier and would replace the candidate being qualified. -Copy the oracle's `tests`, `scripts` and `protocol` trees plus `pytest.ini` outside the checkouts, +Copy the oracle's `tests` tree plus `pytest.ini` outside the checkouts, then use the same pinned comply revision and Foundry version documented above: ```sh @@ -81,7 +75,3 @@ The paired test verifies the installed CLIs and wire/resource compatibility. `tests/receiving/test_status.py` additionally exercises Python imports from the installed producer through its `delivery`/`persistence` components. These imports require the reorganized producer revision pinned in `tests/requirements.txt`. - -The current schema restricts association nonces to 1–128 ASCII characters from -`[A-Za-z0-9_-]`; the verifier uses direct issuer/nonce Komer keys. The reference -ACDC, schema SAID and endorsement fixture have been regenerated together. diff --git a/protocol/external-association-v1/README.md b/protocol/external-association-v1/README.md deleted file mode 100644 index faf294b..0000000 --- a/protocol/external-association-v1/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# vLEI External Association v1 - -## File reference - -- [README.md](README.md): Association purpose, structure, and source documents. -- [association.schema.json](association.schema.json): Common ACDC schema and field definitions. -- [eoa-v1/](eoa-v1/README.md): Ethereum wallet challenge, EOA profile, examples, and test vector. - -## Overview - -A vLEI External Association links a Legal Entity's vLEI-controlled AID to an -external identifier. The external controller signs a challenge, and the Legal -Entity embeds that signature in an ACDC it issues. A relying party can then -verify both the entity's authority and the external controller's agreement. - -The association nonce `u` contains 1–128 ASCII characters from `[A-Za-z0-9_-]`. -Whitespace, dots, other punctuation and non-ASCII text are rejected. Its exact -case and bytes are signed unchanged. EOA Verifier consumes it per issuer at -application acceptance; there are no old-schema readers or nonce-key migrations. - -The association has an issuer and no issuee. Its LE vLEI edge identifies the -credential held by that issuer and supplies the authoritative LEI. The common -schema leaves identifier and signature formats to profiles such as the -[Ethereum EOA profile](eoa-v1/README.md). - -The association stands on its own; an oracle may separately publish a verified -association mapping for on-chain use. See the [schema](association.schema.json) for field -constraints and the [paired qualification helpers](../../scripts/protocol/README.md) for a -complete delegated test chain presented to EOA Verifier. The oracle receives -authenticated accepted/revoked status and publishes selected mappings. - -## Sources - -- *Associating External Identifiers with a LE vLEI*: common methodology. -- *Associating an Ethereum EOA with a LE vLEI — EOA Implementation Profile*: Ethereum account signing and verification. -- *Associating an ENS Name with a LE vLEI — ENS Implementation Profile*: ENS associations and the distinction between verification and endorsement. diff --git a/protocol/external-association-v1/association.schema.json b/protocol/external-association-v1/association.schema.json deleted file mode 100644 index e89aaed..0000000 --- a/protocol/external-association-v1/association.schema.json +++ /dev/null @@ -1,154 +0,0 @@ -{ - "$id": "EOgZ5tOZ0f7U-4H004zKoz75Pi8XwUM2FjKoMYrkBnmu", - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "vLEI External Association v1", - "description": "An untargeted credential issued by a Legal Entity to associate its AID with an external identifier.", - "type": "object", - "properties": { - "v": { - "description": "ACDC version, JSON serialization format, and serialized credential byte count.", - "type": "string", - "pattern": "^ACDC10JSON[0-9a-f]{6}_$" - }, - "d": { - "description": "BLAKE3-256 SAID of the complete association credential.", - "type": "string", - "pattern": "^E[A-Za-z0-9_-]{43}$" - }, - "u": { - "description": "Issuer-scoped nonce of 1–128 ASCII letters, digits, underscores or hyphens, signed unchanged and consumed by the verifier at association acceptance.", - "type": "string", - "minLength": 1, - "maxLength": 128, - "not": { - "pattern": "[^A-Za-z0-9_-]" - } - }, - "i": { - "description": "AID of the issuing Legal Entity that holds the referenced LE vLEI credential.", - "type": "string", - "pattern": "^[BDE][A-Za-z0-9_-]{43}$" - }, - "ri": { - "description": "SAID of the issuer's credential registry tracking issuance and revocation.", - "type": "string", - "pattern": "^E[A-Za-z0-9_-]{43}$" - }, - "s": { - "description": "SAID of this association schema.", - "type": "string", - "pattern": "^E[A-Za-z0-9_-]{43}$" - }, - "a": { - "description": "Association attributes containing the external identifier and its signed proof.", - "type": "object", - "properties": { - "d": { - "description": "BLAKE3-256 SAID of the association attributes.", - "type": "string", - "pattern": "^E[A-Za-z0-9_-]{43}$" - }, - "extId": { - "description": "External identifier associated with the Legal Entity AID; its profile defines the canonical form.", - "type": "string", - "minLength": 1 - }, - "proof": { - "description": "External signature collected before issuance, binding the issuer AID, LE vLEI SAID, external identifier, and nonce.", - "type": "object", - "properties": { - "d": { - "description": "BLAKE3-256 SAID of this proof block, covering alg, tag, and sig.", - "type": "string", - "pattern": "^E[A-Za-z0-9_-]{43}$" - }, - "alg": { - "description": "Identifies the signature scheme and cryptographic algorithm used for the external proof.", - "type": "string", - "minLength": 1 - }, - "tag": { - "description": "Domain-separation tag identifying the association protocol and version.", - "const": "vlei-external-association/v1" - }, - "sig": { - "description": "External signature over the association challenge, encoded as defined by the identifier profile and signature scheme.", - "type": "string", - "minLength": 1 - } - }, - "required": [ - "d", - "alg", - "tag", - "sig" - ], - "additionalProperties": false - }, - "dt": { - "description": "Optional issuer-declared timestamp in KERI UTC format with microseconds; TEL evidence supplies authenticated issuance time.", - "type": "string", - "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}\\+00:00$" - } - }, - "required": [ - "d", - "extId", - "proof" - ], - "additionalProperties": false - }, - "e": { - "description": "Credential edges linking the association to the Legal Entity's LE vLEI.", - "type": "object", - "properties": { - "d": { - "description": "BLAKE3-256 SAID of the credential edges.", - "type": "string", - "pattern": "^E[A-Za-z0-9_-]{43}$" - }, - "le": { - "description": "Reference to the LE vLEI credential held by the association issuer.", - "type": "object", - "properties": { - "n": { - "description": "SAID of the referenced LE vLEI credential, also signed in the external challenge.", - "type": "string", - "pattern": "^E[A-Za-z0-9_-]{43}$" - }, - "s": { - "description": "SAID of the LE vLEI credential schema.", - "const": "ENPXp1vQzRF6JwIuS-mp2U8Uf1MoADoP_GqQ62VsDZWY" - }, - "o": { - "description": "I2I edge operator requiring the association issuer to equal the LE vLEI issuee.", - "const": "I2I" - } - }, - "required": [ - "n", - "s", - "o" - ], - "additionalProperties": false - } - }, - "required": [ - "d", - "le" - ], - "additionalProperties": false - } - }, - "required": [ - "v", - "d", - "u", - "i", - "ri", - "s", - "a", - "e" - ], - "additionalProperties": false -} diff --git a/protocol/external-association-v1/eoa-v1/README.md b/protocol/external-association-v1/eoa-v1/README.md deleted file mode 100644 index e6f9e2a..0000000 --- a/protocol/external-association-v1/eoa-v1/README.md +++ /dev/null @@ -1,116 +0,0 @@ -# vLEI External Association — Ethereum EOA v1 - -## File reference - -- [README.md](README.md): Wallet challenge purpose, signed fields, verification, endorsements, and fixture reproduction. -- [association.json](association.json): Sample EOA association ACDC in the exact compact bytes used to calculate its SAID. -- [challenge.json](challenge.json): EIP-712 message binding the issuer, LE vLEI credential, Ethereum account, and nonce. -- [endorsement.json](endorsement.json): Example oracle result containing the wallet, entity reference, and association SAID. -- [test-vector.json](test-vector.json): Known-answer data with a public signing key, challenge, expected hashes, signature, and SAIDs. -- [../association.schema.json](../association.schema.json): Common vLEI External Association ACDC schema used by this profile. - -This profile applies the [common association structure](../README.md) to an -Ethereum externally owned account. Its profile identifier is -`vlei-external-association/eoa/v1`. The examples use synthetic KERI credential -references and a public test signing key. - -## What the wallet challenge means - -The wallet holder signs an off-chain EIP-712 challenge agreeing to associate -their account, on a specified chain, with the Legal Entity identified by an AID -and LE vLEI credential. Signing requires no transaction or gas. The signature -is embedded in the association ACDC so a relying party can verify that agreement. - -### Why each field is signed - -| Message field | What the wallet holder agrees to | Downstream use | -|---|---|---| -| `issuerAid` | Associate the account with **this entity's AID**. | Rebuilt from `i`; checked against the LE credential's holder. Its hash supplies the endorsement's `identityRef`. | -| `leVleiSaid` | Refer to **this particular LE credential**. | Rebuilt from `e.le.n`; followed to establish the LEI, trust chain, and credential status. Signing it prevents substituting another credential while retaining the wallet signature. | -| `extId` | Associate **this account on this chain**. | Rebuilt from `a.extId`; the address must match the recovered signer and supplies the endorsement's `wallet`. The chain scopes signing and registry posting. | -| `nonce` | Authorize **this individual ceremony**. | Rebuilt from `u`; a new nonce requires a new signature. EOA Verifier consumes the exact issuer/nonce on application acceptance; another SAID cannot reuse it. | - -These fields are the association protocol's signed commitments; EIP-712 supplies -the typed-data format and signing rules. Binding the exact LE credential means -an association referencing a replacement credential requires a fresh wallet -signature. Nonce reuse prevention belongs to the application; EIP-712 does not -provide it automatically. - -The verifier reconstructs the challenge from the ACDC and checks the embedded -signature. The resulting compact wallet/entity/association mapping is the proposed -registry input described [below](#verification-and-endorsement). - -### EIP-712 payload - -`build_challenge` returns only `types`, `primaryType`, `domain`, and `message`. -The message has four ordered string fields: - -```text -ExternalAssociation(string issuerAid,string leVleiSaid,string extId,string nonce) -``` - -The domain name is `vlei-external-association/v1`, version is `1`, and `chainId` is derived from -`extId`, represented as a decimal JSON string to preserve large integer precision -across JSON clients. EIP-712 encodes it as `uint256`. The domain has no -`verifyingContract` or `salt`. - -### Identifier and signature encoding - -`a.extId` is canonical CAIP-10: `eip155::
`. The chain ID is a -positive decimal integer without leading zeros, limited to 32 digits. The -address is `0x` followed by 40 lowercase hexadecimal characters. Mixed-case -presentations undergo EIP-55 checksum validation before normalization. - -The nonce `u` contains 1–128 ASCII characters from `[A-Za-z0-9_-]`, with no -normalization. Whitespace, dots and non-ASCII text are invalid. EOA Verifier uses -the ordinary Komer key tuple `(issuerAid, nonce)`; neither component contains a -dot, and the schema bounds the resulting key to at most 173 bytes. - -The proof uses `alg` of `EIP-712/ES256K` and tag -`vlei-external-association/v1`. Its signature is 65 bytes: concatenated 32-byte -`r`, 32-byte `s`, and one-byte `v`, encoded as lowercase `0x` hex. -For secp256k1 order `n`, require `1 <= r < n`, `1 <= s <= n/2`, and -`v` of 27 or 28. The recovered signer must match the bound account. - -## Verification and endorsement - -EOA Verifier owns challenge reconstruction and proof verification in -`eoa_verifier.verification.eoa`. Issuers deliver native KERI credentials and -supporting evidence to that service, which checks credential trust, wallet proof -and initial account state before application acceptance. Its accepted-nonce -policy is independent of optional webhook delivery and never releases a nonce -on revocation. This is a fresh acceptance-store baseline, not global uniqueness -across independent verifier stores. - -The oracle receives authenticated accepted/revoked status and selects the current -wallet association before posting or withdrawing the exact endorsement. It has -no credential issuance, proof verification or association nonce persistence API. -See the root README and the maintained paired qualification. - -## Reproducing the examples - -Requires Python 3.12.6+ and `uv`. From the repository root: - -```sh -uv venv --python 3.12 .venv -uv pip install --python .venv/bin/python -e '.[dev]' -r scripts/protocol/requirements.txt -r tests/requirements.txt -.venv/bin/python -m pytest -q -``` - -Tests use KERIpy for SAIDs and eth-account for signing and recovery. They check -known hashes and signatures and reject tampering. To regenerate the supporting vectors from the existing public-test-key ACDC: - -```sh -.venv/bin/python scripts/protocol/generate_vectors.py -``` - -The generator reads `association.json` (or `--association `) and preserves -its bytes. It calls `eoa_verifier.verification.eoa` and eth-account to derive the challenge, -signature, hashes, and endorsement fields; it does not construct credentials or -change schemas. The live exercise uses KERIpy directly for credential issuance. - -Related standards: [EIP-712](https://eips.ethereum.org/EIPS/eip-712), -[EIP-55](https://eips.ethereum.org/EIPS/eip-55), -[CAIP-10](https://standards.chainagnostic.org/CAIPs/caip-10), -[CAIP-2](https://standards.chainagnostic.org/CAIPs/caip-2), and -[EIP-7702](https://eips.ethereum.org/EIPS/eip-7702). diff --git a/protocol/external-association-v1/eoa-v1/association.json b/protocol/external-association-v1/eoa-v1/association.json deleted file mode 100644 index fe40794..0000000 --- a/protocol/external-association-v1/eoa-v1/association.json +++ /dev/null @@ -1 +0,0 @@ -{"v":"ACDC10JSON000332_","d":"EIMtYfwyE2KoT65Tze54g0IyPfw41Zly2sXvo9Mrgzv3","u":"0AAAAQIDBAUGBwgJCgsMDQ4P","i":"DIqI4910CfGV_VLbLTy6XXLKZwm_HZQSG_N0iAG0D29c","ri":"EL5BLAjSMOPHAq0_-U7i0X3hzhMgXOTobsPoXh1sXX7j","s":"EOgZ5tOZ0f7U-4H004zKoz75Pi8XwUM2FjKoMYrkBnmu","a":{"d":"EI1sFAANV-BU6YBcM0kvn0kKniHBW3BX-CQZ_--zcVUR","extId":"eip155:1:0x7e5f4552091a69125d5dfcb7b8c2659029395bdf","proof":{"d":"EPTwWHZ5p4AlLo4U4IM8zsmtObavT59EsnCO8a4RP7X8","alg":"EIP-712/ES256K","tag":"vlei-external-association/v1","sig":"0x67ba7282954e74c5742fc3bc0c6eedc8750deb2089f8193f163fe7b1851a55a91d14452d0ccfd5a1d85f6d893e9171bf48127e4989c755dd4095481c63d737b21b"}},"e":{"d":"EPy-9ok3jovjCkjvCFtWU0Ew_5Igdp663_wIry7CGq_y","le":{"n":"EDtvFDCx-Kjtac85bs5PenfQlm41Y5BlWlpooRhF-RGn","s":"ENPXp1vQzRF6JwIuS-mp2U8Uf1MoADoP_GqQ62VsDZWY","o":"I2I"}}} \ No newline at end of file diff --git a/protocol/external-association-v1/eoa-v1/challenge.json b/protocol/external-association-v1/eoa-v1/challenge.json deleted file mode 100644 index 8fe7ea3..0000000 --- a/protocol/external-association-v1/eoa-v1/challenge.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - } - ], - "ExternalAssociation": [ - { - "name": "issuerAid", - "type": "string" - }, - { - "name": "leVleiSaid", - "type": "string" - }, - { - "name": "extId", - "type": "string" - }, - { - "name": "nonce", - "type": "string" - } - ] - }, - "primaryType": "ExternalAssociation", - "domain": { - "name": "vlei-external-association/v1", - "version": "1", - "chainId": "1" - }, - "message": { - "issuerAid": "DIqI4910CfGV_VLbLTy6XXLKZwm_HZQSG_N0iAG0D29c", - "leVleiSaid": "EDtvFDCx-Kjtac85bs5PenfQlm41Y5BlWlpooRhF-RGn", - "extId": "eip155:1:0x7e5f4552091a69125d5dfcb7b8c2659029395bdf", - "nonce": "0AAAAQIDBAUGBwgJCgsMDQ4P" - } -} diff --git a/protocol/external-association-v1/eoa-v1/endorsement.json b/protocol/external-association-v1/eoa-v1/endorsement.json deleted file mode 100644 index 56c92ec..0000000 --- a/protocol/external-association-v1/eoa-v1/endorsement.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "wallet": "0x7e5f4552091a69125d5dfcb7b8c2659029395bdf", - "identityRef": "0x586fe275b21de7b7fd19ccdf88a2c241b346d7e00546fdfb70bc85f2f9c1307b", - "associationSaid": "EIMtYfwyE2KoT65Tze54g0IyPfw41Zly2sXvo9Mrgzv3" -} diff --git a/protocol/external-association-v1/eoa-v1/test-vector.json b/protocol/external-association-v1/eoa-v1/test-vector.json deleted file mode 100644 index d7be9ff..0000000 --- a/protocol/external-association-v1/eoa-v1/test-vector.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "purpose": "Encoding fixture only; synthetic KERI evidence MUST NOT pass production verification.", - "publicTestPrivateKey": "0x0000000000000000000000000000000000000000000000000000000000000001", - "signer": "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf", - "typedData": { - "types": { - "EIP712Domain": [ - { - "name": "name", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "chainId", - "type": "uint256" - } - ], - "ExternalAssociation": [ - { - "name": "issuerAid", - "type": "string" - }, - { - "name": "leVleiSaid", - "type": "string" - }, - { - "name": "extId", - "type": "string" - }, - { - "name": "nonce", - "type": "string" - } - ] - }, - "primaryType": "ExternalAssociation", - "domain": { - "name": "vlei-external-association/v1", - "version": "1", - "chainId": "1" - }, - "message": { - "issuerAid": "DIqI4910CfGV_VLbLTy6XXLKZwm_HZQSG_N0iAG0D29c", - "leVleiSaid": "EDtvFDCx-Kjtac85bs5PenfQlm41Y5BlWlpooRhF-RGn", - "extId": "eip155:1:0x7e5f4552091a69125d5dfcb7b8c2659029395bdf", - "nonce": "0AAAAQIDBAUGBwgJCgsMDQ4P" - } - }, - "domainSeparator": "0xab984fd384878045f931921ab500e2888f9c6626cfe92697809d0742a05e7f0f", - "messageHash": "0xe4bfdb2f83030cc33c0e713a2ddb23799300aec91c7b9648865f6022a1a408aa", - "signingDigest": "0x068a2e6c0f87a4e2250e3b980bfb11f727d951d5e3d450aff2e93e41e46d73b8", - "signature": "0x67ba7282954e74c5742fc3bc0c6eedc8750deb2089f8193f163fe7b1851a55a91d14452d0ccfd5a1d85f6d893e9171bf48127e4989c755dd4095481c63d737b21b", - "schemaSaid": "EOgZ5tOZ0f7U-4H004zKoz75Pi8XwUM2FjKoMYrkBnmu", - "associationSaid": "EIMtYfwyE2KoT65Tze54g0IyPfw41Zly2sXvo9Mrgzv3", - "proofSaid": "EPTwWHZ5p4AlLo4U4IM8zsmtObavT59EsnCO8a4RP7X8" -} diff --git a/protocol/oracle-api-v1/README.md b/protocol/oracle-api-v1/README.md new file mode 100644 index 0000000..35a7ba2 --- /dev/null +++ b/protocol/oracle-api-v1/README.md @@ -0,0 +1,88 @@ +# Oracle API v1 + +Oracle receives trusted Verifier status and selects/publishes a current wallet +association. It does not accept credential evidence, issue credentials, verify +wallet proofs or consume association nonces. + +## Dependencies and trust + +[Verifier API v1](https://github.com/GLEIF-IT/eoa-verifier/blob/master/protocol/verifier-api-v1/README.md) +is authoritative for event fields/vocabulary and the shared authenticated webhook +and ACK profile, including context strings, header coverage, signatures, replay +claims and request correlation. Oracle implements that profile without importing +Verifier at runtime. [External association v1](https://github.com/GLEIF-IT/eoa-verifier/blob/master/protocol/external-association-v1/README.md) +is owned by Verifier. [Comply's registry](https://github.com/GLEIF-IT/vlei-comply/blob/main/docs/oracle-registry.md) +owns methods, roles, events and mapping encoding. + +Trust exactly the configured verifier AID, chain and absolute destination URL. +The peer key must come from locally accepted KERI state, not an incoming header. +`server receive` serves the inbox; `server start` adds publication. Both expose +`POST /v1/status-events` and the receiver's native KERIpy OOBI introduction route. +There is no public Oracle association-status GET endpoint. + +## Validation and responses + +Match the configured path/query, authenticate the exact body first, then decode +the producer's v1 object. Require canonical association/LE SAIDs and issuer AID, +a positive integer status revision and matching event identity. Accept producer +acceptance or explicit verified retirement. Validate nonnegative integer issuance +sequence and anchor SAID, and a canonical EOA extId on the configured chain. +Observation metadata is informational and is not required by this consumer. +Credential, proof and account verification are trusted producer responsibilities. + +| Result | HTTP response | Durable application effect | +| --- | --- | --- | +| Valid new event | 200, authenticated producer-profile ACK | Receipt, newest status and selection commit together | +| Exact duplicate | 200, newly authenticated ACK | No repeated selection/effect | +| Valid older revision | 200, authenticated ACK | Receipt retained; newer status preserved | +| Wrong path/query or malformed/unsupported event | 400 | No event receipt | +| Invalid/missing signature, wrong peer or replay | 401 | No event receipt | +| Conflicting bytes at an event revision, changed association facts, reacceptance after revocation, or revocation revision before accepted revision | 409 | Application transaction aborts | + +Authentication claims a transport nonce before decoding or application receipt. +Thus a validly signed malformed/conflicting event may consume that attempt nonce; +retry with fresh transport authentication. Error responses never complete delivery. +Sign the success ACK only after LMDB commit. A crash/signing failure after commit +is safe to redeliver. **ACK means durable receipt, not selected ownership or +confirmed endorsement.** + +## Selection and replacement + +One canonical chain/wallet extId has one selected association. Store the producer's +status separately from Oracle selection: selected, superseded, rejected or revoked. + +- Same issuer: a strictly higher issuer-KEL issuance-anchor sequence supersedes + the predecessor. LE credential SAIDs, status revisions and arrival timestamps do + not establish priority. A later same-issuer retirement arriving before acceptance + still prevents an older claim from remaining selected. +- Different issuer: retain/reject the competing claim while a current claim is + active. Current-SAID verified revocation releases that claim. An earlier rejected + association does not activate on duplicates or later revisions; a new association + is required. Never compare sequence numbers from different issuers' KELs. +- Revocation is terminal for its association SAID. Old-SAID revocation cannot release + a successor. Issuance history survives release, transfer and restart; a superseded + predecessor cannot return. Distinct associations sharing an issuance anchor have + no additional conflict-detection policy. + +Selection never revokes upstream Verifier acceptance. See the +[selection ADR](../../adrs/0001-wallet-association-selection.md) for rationale. + +## Publication and withdrawal + +A selected accepted association is eligible for publication; exact-SAID retirement +requests withdrawal. Derive wallet from extId and the contract identity reference +from the issuer AID using Comply's encoding. Identity registration alone supplies +no endorsement. + +Receipt, selection, signed transaction submission, confirmed transaction and actual +current registry state are distinct milestones. Recheck durable selection after +RPC preparation. An already broadcast transaction may still land after replacement +or revocation; after its receipt the next cycle applies current desired state. +Withdrawal of an older SAID must not remove its replacement. + +This runtime journals signed intent before submission and polls confirmation. It +does not cancel/rebroadcast automatically, reconcile nonce conflicts or recover +reorgs comprehensively. A permanently unresolved attempt can block later actions. +There is no periodic credential/account revalidation or automatic mapping expiry. +See [operations](../../docs/status-inbox.md) for scope, keys, recovery and limitations, +and [qualification](../../docs/two-service-qualification.md) for maintained evidence. diff --git a/scripts/dev/demo-dependencies.json b/scripts/dev/demo-dependencies.json index 5a8a1b7..3e10969 100644 --- a/scripts/dev/demo-dependencies.json +++ b/scripts/dev/demo-dependencies.json @@ -10,6 +10,6 @@ }, "vlei-comply": { "url": "https://github.com/GLEIF-IT/vlei-comply.git", - "commit": "aeba4883dadb30e06a0316d93394b08ff9a9e97d" + "commit": "9efde5e3db818cf3129e89c9fd08c0f5c0f8dee1" } } diff --git a/scripts/dev/prepare-demo.py b/scripts/dev/prepare-demo.py index ce42a0b..fa6bf5b 100644 --- a/scripts/dev/prepare-demo.py +++ b/scripts/dev/prepare-demo.py @@ -200,6 +200,7 @@ def main() -> None: "VLEI_SERVER": str(bin_dir / "vLEI-server"), "VLEI_ORACLE": str(bin_dir / "vlei-oracle"), "EOA_VERIFIER": str(bin_dir / "eoa-verifier"), + "EOA_VERIFIER_PYTHON": str(python), }, ) print(f"Dependencies prepared. Load exports with: source {shlex.quote(str(path))}") diff --git a/scripts/protocol/README.md b/scripts/protocol/README.md deleted file mode 100644 index dcb1296..0000000 --- a/scripts/protocol/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Protocol vectors and qualification dependencies - -Generate reference vectors with generate_vectors.py and the installed producer. -requirements.txt pins protocol dependencies; install the producer from -tests/requirements.txt as well. - -Test-owned witnessed issuance and ACDC assembly live in tests/support/issuers.py; -contract construction/RPC is in tests/support/contracts.py; processes and signed -status have their own support modules. They are outside the oracle wheel. There -is no issuer ceremony or association nonce store in the oracle. - -Run python -m pytest tests/qualification/test_two_services.py from the oracle -root with the qualified installed applications, Foundry and comply checkout. -See [testing](../../docs/testing.md) and -[two-service qualification](../../docs/two-service-qualification.md). diff --git a/scripts/protocol/generate_vectors.py b/scripts/protocol/generate_vectors.py deleted file mode 100644 index e606245..0000000 --- a/scripts/protocol/generate_vectors.py +++ /dev/null @@ -1,105 +0,0 @@ -"""Generate vLEI External Association EOA examples and a known-answer test vector. - -Run from any directory using the project's Python environment. The private key -below is the PUBLIC test key 1; it must never hold funds or sign real claims. -""" - -from __future__ import annotations - -import argparse -import json -from pathlib import Path - -from eth_account import Account -from eth_account.messages import encode_typed_data -from eth_utils import keccak -from keri.core import serdering - -from eoa_verifier.verification.eoa import ( - build_challenge, -) - -ROOT = Path(__file__).resolve().parents[2] -EOA_PROFILE = ROOT / "protocol" / "external-association-v1" / "eoa-v1" -PUBLIC_TEST_KEY = "0x" + "0" * 63 + "1" - - -def generate_fixtures(association_raw: bytes) -> dict[str, bytes]: - """Derive EOA vectors from a serialized ACDC without constructing a credential. - - The input uses public test key 1. KERIpy parses its ACDC; eth-account - reproduces its signature. The input credential bytes are preserved exactly. - """ - association = serdering.SerderACDC(raw=association_raw).sad - issuer = association["i"] - account = Account.from_key(PUBLIC_TEST_KEY) - challenge = build_challenge( - issuer_aid=issuer, - le_vlei_said=association["e"]["le"]["n"], - ext_id=association["a"]["extId"], - nonce=association["u"], - ) - signature = ( - "0x" - + Account.sign_message( - encode_typed_data(full_message=challenge), PUBLIC_TEST_KEY - ).signature.hex() - ) - if signature != association["a"]["proof"]["sig"]: - raise ValueError( - "association must contain the signature from public test key 1" - ) - if association["a"]["extId"].split(":")[2] != account.address.lower(): - raise ValueError("association must identify the public test account") - signable = encode_typed_data(full_message=challenge) - hashes = { - "domainSeparator": "0x" + signable.header.hex(), - "messageHash": "0x" + signable.body.hex(), - "signingDigest": "0x" + keccak(b"\x19" + signable.version + signable.header + signable.body).hex(), - } - endorsement = { - "wallet": account.address.lower(), - "identityRef": "0x" + keccak(text=issuer).hex(), - "associationSaid": association["d"], - } - vector = { - "purpose": "Encoding fixture only; synthetic KERI evidence MUST NOT pass production verification.", - "publicTestPrivateKey": PUBLIC_TEST_KEY, - "signer": account.address, - "typedData": challenge, - **hashes, - "signature": signature, - "schemaSaid": association["s"], - "associationSaid": association["d"], - "proofSaid": association["a"]["proof"]["d"], - } - return { - "challenge.json": json_bytes(challenge), - "association.json": association_raw, - "endorsement.json": json_bytes(endorsement), - "test-vector.json": json_bytes(vector), - } - - -def json_bytes(value: object) -> bytes: - """Pretty-print supporting fixtures; ACDC bytes use compact_json instead.""" - return (json.dumps(value, indent=2, ensure_ascii=False) + "\n").encode("utf-8") - - -def main() -> None: - """Derive the four EOA fixtures from an existing public-test-key association.""" - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument( - "--association", - type=Path, - default=EOA_PROFILE / "association.json", - help="serialized association ACDC signed with public test key 1", - ) - args = parser.parse_args() - for name, raw in generate_fixtures(args.association.read_bytes()).items(): - (EOA_PROFILE / name).write_bytes(raw) - print("Association, challenge, endorsement, and test vector generated.") - - -if __name__ == "__main__": - main() diff --git a/scripts/protocol/requirements.txt b/scripts/protocol/requirements.txt deleted file mode 100644 index 3dfe381..0000000 --- a/scripts/protocol/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Dependencies for association test-vector generation and schema tests. -gleif_keri==1.2.19 -gleif_hio==0.6.22 -eth-account==0.14.0 -eth-utils==6.0.0 -jsonschema==4.26.0 diff --git a/tests/endorsement/test_effects.py b/tests/endorsement/test_effects.py index b37ed31..8358b07 100644 --- a/tests/endorsement/test_effects.py +++ b/tests/endorsement/test_effects.py @@ -13,6 +13,7 @@ from web3 import Web3 from tests.support.contracts import drive, effects_for, signed_intent +from vlei_oracle.associations.statusing import read_status from vlei_oracle.endorsement.effects import ContractEffects from vlei_oracle.persistence.basing import OracleBaser @@ -28,6 +29,22 @@ def test_python_encoding_matches_owned_solidity_vector(deployment): ) ) vector = json.loads((comply / "abi/endorsement-vector.json").read_text()) + # The contract fixture owns mapping/calldata; proof conformance lives in Verifier. + facts = { + "issuerAid": 'DIqI4910CfGV_VLbLTy6XXLKZwm_HZQSG_N0iAG0D29c', + "leSaid": 'EDtvFDCx-Kjtac85bs5PenfQlm41Y5BlWlpooRhF-RGn', + "extId": "eip155:1:" + vector["wallet"], + "issuanceAnchor": {"sequenceNumber": 3, "said": 'EIMtYfwyE2KoT65Tze54g0IyPfw41Zly2sXvo9Mrgzv3'}, + } + _, mapped = read_status(json.dumps({ + "version": "1", "eventId": vector["associationSaid"] + ":1", + "associationSaid": vector["associationSaid"], "statusRevision": 1, + "status": "accepted", "association": facts, + }).encode(), chain_id=1) + assert mapped.associationSaid == vector["associationSaid"] + assert mapped.identityRef == vector["identityRef"] + assert mapped.wallet == vector["wallet"] + assert "expiresAt" not in json.dumps(vector) contracts = effects_for(deployment).contracts contract = contracts["endorsement"] assert contract.abi == json.loads( diff --git a/tests/integration/test_association_profile.py b/tests/integration/test_association_profile.py deleted file mode 100644 index 04a7337..0000000 --- a/tests/integration/test_association_profile.py +++ /dev/null @@ -1,367 +0,0 @@ -"""integration/test_association_profile.py.""" - -from __future__ import annotations - -import json -from copy import deepcopy -from pathlib import Path - -import pytest -from eoa_verifier.verification.eoa import ( - build_challenge, - ext_id_chain, - verify_eoa_proof, -) -from eth_account import Account -from eth_account.messages import encode_typed_data -from eth_utils import keccak -from jsonschema import Draft7Validator, ValidationError -from keri.core import coring, scheming, serdering, signing - -PROTOCOL = Path(__file__).resolve().parents[2] / "protocol" / "external-association-v1" - -EOA_PROFILE = PROTOCOL / "eoa-v1" - - -def load(name: str) -> dict: - directory = PROTOCOL if name == "association.schema.json" else EOA_PROFILE - return json.loads((directory / name).read_bytes()) - - -def test_reproduce_exact_schema_proof_and_acdc_bytes() -> None: - schema = load("association.schema.json") - association = load("association.json") - reconstructed = serdering.SerderACDC(sad=association, makify=True) - assert reconstructed.raw == (EOA_PROFILE / "association.json").read_bytes() - assert ( - scheming.Schemer(raw=(PROTOCOL / "association.schema.json").read_bytes()).said - == schema["$id"] - ) - assert ( - serdering.SerderACDC(raw=(EOA_PROFILE / "association.json").read_bytes()).said - == association["d"] - ) - for block in [ - association, - association["a"], - association["a"]["proof"], - association["e"], - ]: - assert coring.Saider(qb64=block["d"]).verify(sad=block, prefixed=True) - assert association["s"] == schema["$id"] - - -def test_signature_tampering_invalidates_proof_and_enclosing_acdc() -> None: - association = load("association.json") - proof = association["a"]["proof"] - proof["sig"] = "0x" + "00" * 64 + "1b" - assert not coring.Saider(qb64=proof["d"]).verify(sad=proof, prefixed=True) - assert not coring.Saider(qb64=association["d"]).verify( - sad=association, prefixed=True - ) - - -@pytest.mark.parametrize( - "mutation", - [ - "issuee", - "lei", - "nonce_attribute", - "expiry", - "oor_edge", - "missing_proof", - "missing_u", - "invalid_algorithm_type", - "wrong_tag", - "wrong_edge_operator", - ], -) -def test_reject_obsolete_or_incomplete_shapes( - mutation: str, -) -> None: - association = load("association.json") - if mutation == "issuee": - association["a"]["i"] = association["i"] - elif mutation == "lei": - association["a"]["LEI"] = "529900TEST" - elif mutation == "nonce_attribute": - association["a"]["nonce"] = association["u"] - elif mutation == "expiry": - association["a"]["expiresAt"] = 1791244900 - elif mutation == "oor_edge": - association["e"]["oor"] = deepcopy(association["e"]["le"]) - elif mutation == "missing_proof": - del association["a"]["proof"] - elif mutation == "missing_u": - del association["u"] - elif mutation == "invalid_algorithm_type": - association["a"]["proof"]["alg"] = 7 - elif mutation == "wrong_tag": - association["a"]["proof"]["tag"] = "other/v1" - else: - association["e"]["le"]["o"] = "NI2I" - with pytest.raises(ValidationError): - Draft7Validator(load("association.schema.json")).validate(association) - - -@pytest.mark.parametrize("algorithm", ["EIP-191/ES256K", "Ed25519"]) -def test_schema_accepts_external_proof_algorithm_identifiers(algorithm: str) -> None: - association = load("association.json") - association["a"]["proof"]["alg"] = algorithm - Draft7Validator(load("association.schema.json")).validate(association) - - -def test_schema_requires_nonempty_algorithm_identifier() -> None: - association = load("association.json") - association["a"]["proof"]["alg"] = "" - with pytest.raises(ValidationError): - Draft7Validator(load("association.schema.json")).validate(association) - - -@pytest.mark.parametrize( - "ext_id", ["did:example:organization", "external:organization"] -) -def test_schema_accepts_profile_defined_external_identifiers(ext_id: str) -> None: - association = load("association.json") - association["a"]["extId"] = ext_id - Draft7Validator(load("association.schema.json")).validate(association) - - -@pytest.mark.parametrize("ext_id", ["", 7]) -def test_schema_requires_nonempty_external_identifier_string(ext_id: object) -> None: - association = load("association.json") - association["a"]["extId"] = ext_id - with pytest.raises(ValidationError): - Draft7Validator(load("association.schema.json")).validate(association) - - -@pytest.mark.parametrize( - "signature", ["dGVzdC1zaWduYXR1cmU=", "external-signature-value"] -) -def test_schema_accepts_profile_defined_signature_strings(signature: str) -> None: - association = load("association.json") - association["a"]["proof"]["sig"] = signature - Draft7Validator(load("association.schema.json")).validate(association) - - -@pytest.mark.parametrize("signature", ["", 7]) -def test_schema_requires_nonempty_signature_string(signature: object) -> None: - association = load("association.json") - association["a"]["proof"]["sig"] = signature - with pytest.raises(ValidationError): - Draft7Validator(load("association.schema.json")).validate(association) - - -def test_association_schema_and_payloads_have_no_intrinsic_expiry() -> None: - for name in [ - "association.schema.json", - "endorsement.json", - "challenge.json", - ]: - assert "expiresAt" not in json.dumps(load(name)) - - -@pytest.mark.parametrize( - "ext_id", - [ - "eip155:01:0x" + "ab" * 20, - "eip155:0:0x" + "ab" * 20, - "eip155:1:0x" + "AB" * 20, - "eip155:-1:0x" + "ab" * 20, - "eip155:" + "1" * 33 + ":0x" + "ab" * 20, - "cosmos:1:0x" + "ab" * 20, - "eip155:1:0x123", - "eip155:" + str(2**256) + ":0x" + "ab" * 20, - ], -) -def test_reject_noncanonical_chain_or_account(ext_id: str) -> None: - with pytest.raises(ValueError): - ext_id_chain(ext_id) - - -@pytest.mark.parametrize( - "nonce", - [ - "25C89E61-21F8-4CCF-948D-46D1FBB7BAE8", - "0123456789abcdef" * 4, - "0AAAAQIDBAUGBwgJCgsMDQ4P", - "x", - "N" * 128, - ], -) -def test_nonce_encoding_is_preserved_in_challenge_and_credential(nonce: str) -> None: - fixture = load("association.json") - values = { - "issuer_aid": fixture["i"], - "le_vlei_said": fixture["e"]["le"]["n"], - "ext_id": fixture["a"]["extId"], - "nonce": nonce, - } - challenge = build_challenge(**values) - private_key = load("test-vector.json")["publicTestPrivateKey"] - signature = Account.sign_message( - encode_typed_data(full_message=challenge), private_key - ).signature - fixture["u"] = nonce - assert challenge["message"]["nonce"] == fixture["u"] == nonce - Draft7Validator(load("association.schema.json")).validate(fixture) - assert ( - Account.recover_message( - encode_typed_data(full_message=challenge), signature=signature - ) - == Account.from_key(private_key).address - ) - - -@pytest.mark.parametrize( - "nonce", - [ - "", - "x" * 129, - "é", - "e\u0301", - "😀", - " nonce", - "nonce ", - "nonce.nonce", - "nonce\n", - "nonce\r", - "nonce\x00", - "nonce/", - "nonce+", - "nonce=", - None, - 7, - ], -) -def test_nonce_type_and_length_match_schema_and_challenge(nonce: object) -> None: - association = load("association.json") - association["u"] = nonce - with pytest.raises(ValidationError): - Draft7Validator(load("association.schema.json")).validate(association) - values = { - "issuer_aid": association["i"], - "le_vlei_said": association["e"]["le"]["n"], - "ext_id": association["a"]["extId"], - "nonce": nonce, - } - with pytest.raises(ValueError, match="nonce"): - build_challenge(**values) - - -def test_challenge_matches_known_signature_and_hashes() -> None: - association = load("association.json") - challenge = build_challenge( - issuer_aid=association["i"], - le_vlei_said=association["e"]["le"]["n"], - ext_id=association["a"]["extId"], - nonce=association["u"], - ) - assert challenge == load("challenge.json") - vector = load("test-vector.json") - signable = encode_typed_data(full_message=challenge) - assert "0x" + signable.header.hex() == vector["domainSeparator"] - assert "0x" + signable.body.hex() == vector["messageHash"] - assert ( - "0x" - + keccak(b"\x19" + signable.version + signable.header + signable.body).hex() - == vector["signingDigest"] - ) - assert ( - Account.recover_message( - encode_typed_data(full_message=challenge), signature=vector["signature"] - ) - == vector["signer"] - ) - - -@pytest.mark.parametrize( - "field", ["issuer", "le", "account", "chain", "nonce", "domain"] -) -def test_signature_cannot_be_transplanted(field: str) -> None: - association = load("association.json") - if field == "issuer": - association["i"] = signing.Signer(raw=b"\x02" * 32).verfer.qb64 - elif field == "le": - association["e"]["le"]["n"] = association["ri"] - elif field == "account": - association["a"]["extId"] = "eip155:1:0x" + "ab" * 20 - elif field == "chain": - association["a"]["extId"] = association["a"]["extId"].replace( - "eip155:1:", "eip155:2:" - ) - elif field == "nonce": - association["u"] = "another-ceremony" - elif field == "domain": - association["a"]["proof"]["tag"] = "another-protocol/v1" - with pytest.raises(ValueError, match="signer|domain"): - verify_eoa_proof(association) - - -@pytest.mark.parametrize( - "field,value,reason", - [ - ("alg", "Ed25519", "algorithm"), - ("sig", "0x1234", "encoding"), - ("sig", "0x" + "00" * 64 + "1b", "scalars"), - ("sig", "0x" + "01" * 32 + "ff" * 32 + "1b", "scalars"), - ], -) -def test_invalid_eoa_proof_fails_before_rpc(field, value, reason): - association = load("association.json") - association["a"]["proof"][field] = value - with pytest.raises(ValueError, match=reason): - verify_eoa_proof(association) - - -def test_endorsement_identifies_verified_wallet_and_association() -> None: - association = load("association.json") - endorsement = load("endorsement.json") - validator = Draft7Validator(load("association.schema.json")) - validator.check_schema(validator.schema) - validator.validate(association) - assert endorsement["associationSaid"] == association["d"] - assert endorsement["identityRef"] == "0x" + keccak(text=association["i"]).hex() - signer = Account.recover_message( - encode_typed_data(full_message=load("challenge.json")), - signature=association["a"]["proof"]["sig"], - ) - assert endorsement["wallet"] == signer.lower() - assert endorsement["wallet"] == association["a"]["extId"].split(":")[2] - - -@pytest.mark.parametrize("field", ["issuer_aid", "le_vlei_said"]) -def test_challenge_rejects_trailing_cesr_identifier_material(field: str) -> None: - association = load("association.json") - values = { - "issuer_aid": association["i"], - "le_vlei_said": association["e"]["le"]["n"], - "ext_id": association["a"]["extId"], - "nonce": association["u"], - } - values[field] += "extra" - with pytest.raises(ValueError, match="trailing"): - build_challenge(**values) - - -def test_large_caip_reference_preserves_integer_precision() -> None: - association = load("association.json") - chain_id = 10**32 - 1 - ext_id = f"eip155:{chain_id}:{load("test-vector.json")["signer"].lower()}" - challenge = build_challenge( - issuer_aid=association["i"], - le_vlei_said=association["e"]["le"]["n"], - ext_id=ext_id, - nonce=association["u"], - ) - assert challenge["domain"]["chainId"] == str(chain_id) - - -def test_optional_acdc_timestamp_accepts_keripy_utc_form() -> None: - association = load("association.json") - validator = Draft7Validator(load("association.schema.json")) - association["a"]["dt"] = "2026-10-06T00:00:00.000000+00:00" - validator.validate(association) - association["a"]["dt"] = "2026-10-06T00:00:00.000000Z" - with pytest.raises(ValidationError): - validator.validate(association) diff --git a/tests/requirements.txt b/tests/requirements.txt index 517364b..ece7ca7 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,3 +1,3 @@ # Test-only producer; never a vlei-oracle runtime dependency. -eoa-verifier @ git+https://github.com/GLEIF-IT/eoa-verifier.git@895713e66e6057590cf8247f8e8c1829371c6c71 +eoa-verifier @ git+https://github.com/GLEIF-IT/eoa-verifier.git@4e2b5c35818602576d307d02f6cb921382740766 pytest>=9