PresentationNonceStore

Single-use guard for the SD-JWT Key Binding JWT nonce (the verifier's challenge).

By default a KB-JWT is only bound to a nonce the verifier expects (expectedChallenge) and to a freshness window; the same signed presentation can still be shown twice inside that window. A verifier that issues one nonce per transaction can close that gap by supplying a store:

val options = VerificationOptions(
expectedChallenge = nonceIssuedForThisTransaction,
additionalOptions = mapOf(PresentationNonceStore.OPTION_KEY to InMemoryPresentationNonceStore()),
)

The nonce is consumed only after the presentation has passed every other check (KB-JWT signature, sd_hash, freshness, expected challenge and domain), so a request that was going to be rejected anyway cannot burn a nonce. A second presentation carrying the same nonce is rejected as a replay. When a store is configured the proof MUST carry a non-blank nonce (SD-JWT-VC KB-JWT nonce, or the challenge of a Linked Data proof; other proof types are rejected as unable to honour the guard), and presentation-proof verification must be enabled (the nonce is untrustworthy otherwise). The string passed to consume is "<scopeLength>:<scope>:<nonce>", scoping single-use per verifier/audience (see SCOPE_OPTION_KEY). A full or failing store makes verification fail with an Invalid result.

Opt-in and additive: with no store configured nothing changes.

Inheritors

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract suspend fun consume(nonce: String): Boolean

Atomically marks nonce as used.