Skip to content

test: pin cross-module nonce scoping for create-and-bind - #917

Open
kilianglas wants to merge 1 commit into
mainfrom
kilianglas/create-and-bind-nonce-scope-test
Open

test: pin cross-module nonce scoping for create-and-bind#917
kilianglas wants to merge 1 commit into
mainfrom
kilianglas/create-and-bind-nonce-scope-test

Conversation

@kilianglas

Copy link
Copy Markdown
Contributor

A create-and-bind request (ProofType::Uniqueness × SessionRef::Create) drives two OPRF queries under a single RP nonce: the uniqueness nullifier (OprfModule::Nullifier) and the session seed (OprfModule::Session). Both modules are handed the same NonceHistory at startup (services/oprf-node/src/lib.rs:130-152), so acceptance rests entirely on the two queries consuming the nonce in different NonceScopes — derived in authenticate_inner (services/oprf-node/src/auth/rp_module.rs:389-426).

That invariant was only covered at the cache level (nonce_history::test_nonce_history_allows_distinct_scopes, which asserts nothing about how the modules pick a scope) and indirectly by the full-stack e2e in crates/core/tests/generate_proof.rs. This adds the assertion at the layer that derives the scope.

The test also replays both queries and expects DUPLICATE_NONCE, so it cannot pass vacuously if replay protection were disabled outright.

Test plan

  • cargo test -p world-id-oprf-node --all-features — 76 passed.
  • Mutation check: changing the session-seed arm in authenticate_inner to return NonceScope::Uniqueness makes the new test fail with 4503 signature nonce already used.

A create-and-bind request drives two OPRF queries under a single RP nonce:
the uniqueness nullifier and the session seed. Both modules share one
node-local NonceHistory, so acceptance depends entirely on the two queries
consuming the nonce in different scopes.

That was only covered at the cache level (nonce_history unit test) and by
the full-stack e2e. This adds the assertion at the layer that derives the
scope, so collapsing or dropping a NonceScope variant fails here instead of
in the heavyweight e2e.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants