Skip to main content

AnteHandler

Dchain and other apps that use this AnteHandler decorator can specify fine-grained verifiable presentation requirements for individual messages in a transaction. Each required verifiable presentation is verified natively (in Go) before the messages are processed by the app.

For example, a cosmos.gov.v1.MsgVote message can be gated so that it only passes if the transaction also carries an SD-JWT presentation whose disclosed voter claim equals the voter address in the message, derived from a credential issued by one of a set of trusted issuers. That requirement is configured in the message's Route (see state). The AnteHandler decorator looks up the Route for the message type, reads the presentation from the transaction's ExtensionOptions, and verifies it against the issuer's public JWK and requirements - no smart contract is invoked. cosmos.staking.v1beta1.MsgCreateValidator was gated this way until v1.0.0-rc.3; the requirement was removed and any leftover route is ignored (and removable via MsgRemoveRoute).

AnteHandler verifying ExtensionOptions​

The decorator is VcvExtensionOptionsDecorator (x/vcv/ante/ante.go). It is constructed with a list of VPVerifierI keepers - the vcv keeper and any other module keeper (e.g. the x/notary keeper) that registers gated routes and reuses the verification.

The decorator's flow on each transaction is:

  1. If the block height is 0 (genesis), verification is skipped entirely.
  2. It extracts the VP ExtensionOptions from the transaction. A VP extension option is an Any whose type URL is the module's ExtensionOptionTypeUrl (/d.vcv.v1.VerifiablePresentation).
  3. For every message in order it calls GetMsgExtensionOptionRequirements(msg) on each keeper. That method returns the Route and the compareTo claim map when the message is gated, or nil when it is not. The vcv keeper gates casting a governance vote: cosmos.gov.v1.MsgVote, cosmos.gov.v1.MsgVoteWeighted and their v1beta1 legacy equivalents (which the gov module's legacy msg server forwards to the v1 server) all resolve to the single canonical cosmos.gov.v1.MsgVote:extop route, so one registered route covers every way of voting. The notary keeper gates its own messages.
  4. It asserts that every message requiring verification has a VP extension option available at its position; if there are fewer VP options than gated messages the transaction is rejected (surplus options are ignored).
  5. For each gated message it calls VerifyVerifiablePresentation(route, vp, compareTo) with the next VP extension option in order.
TxBody {
Messages [MsgSend, MsgVote]
ExtensionOptions[ VP1 ]
}

MsgSend does not require a presentation, so a single VP extension option is supplied for MsgVote.

The ExtensionOptions value is the protobuf-encoded d.vcv.v1.VerifiablePresentation carrying a compact SD-JWT in its presentation bytes:

message VerifiablePresentation { bytes presentation = 1; }

If no Route is registered for a message that a keeper considers "required", verification returns ErrRouteNotFound, which the decorator tolerates - the message is allowed to pass. Any other verification error rejects the transaction.

Verification flow​

VerifyVerifiablePresentation (x/vcv/keeper/keeper_sdjwt_verify.go):

  1. Receives the Route and compareTo map resolved by GetMsgExtensionOptionRequirements in the ante loop.
  2. Unmarshals the extension option bytes into a VerifiablePresentation and reads the compact SD-JWT from presentation.
  3. Calls sdjwt.Verify(token, {Now: ctx.BlockTime(), IssuerKeysResolver: route}). The Route itself acts as the issuer-key resolver, supplying the issuer's public JWK for signature verification.
  4. For each of the issuer's content_requirements, resolves the requirement's Criterion against the disclosed claim and a compareTo value taken from the message - for MsgVote the voter address (claim voter).

Verification in the proposal pipeline​

Beyond the AnteHandler, the vcv keeper also verifies VPs in the ABCI proposal pipeline: the proposer's VP (MsgProcessProposal, comparing the proposer to the validator claim) and each validator's vote-extension VP (ValidatorVoteExtension, comparing the validator consensus address to the validator claim). The same VerifyVerifiablePresentation routine is used.

Implementation into app​

The ExtensionOptions AnteHandler decorator is wired into the app's ante chain. In Dchain, see app/ante.go.