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:
- If the block height is
0(genesis), verification is skipped entirely. - It extracts the VP
ExtensionOptionsfrom the transaction. A VP extension option is anAnywhose type URL is the module'sExtensionOptionTypeUrl(/d.vcv.v1.VerifiablePresentation). - For every message in order it calls
GetMsgExtensionOptionRequirements(msg)on each keeper. That method returns theRouteand thecompareToclaim map when the message is gated, ornilwhen it is not. The vcv keeper gates casting a governance vote:cosmos.gov.v1.MsgVote,cosmos.gov.v1.MsgVoteWeightedand theirv1beta1legacy equivalents (which the gov module's legacy msg server forwards to the v1 server) all resolve to the single canonicalcosmos.gov.v1.MsgVote:extoproute, so one registered route covers every way of voting. The notary keeper gates its own messages. - 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).
- 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):
- Receives the
RouteandcompareTomap resolved byGetMsgExtensionOptionRequirementsin the ante loop. - Unmarshals the extension option bytes into a
VerifiablePresentationand reads the compact SD-JWT frompresentation. - Calls
sdjwt.Verify(token, {Now: ctx.BlockTime(), IssuerKeysResolver: route}). TheRouteitself acts as the issuer-key resolver, supplying the issuer's public JWK for signature verification. - For each of the issuer's
content_requirements, resolves the requirement'sCriterionagainst the disclosed claim and acompareTovalue taken from the message - forMsgVotethe voter address (claimvoter).
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.