← Book map

Chapter 03 · Foundations

Hash order is the security model

The login-shaped ancestors of the generic envelope show the one detail that has to be right: what exactly gets hashed, in which order, for which signature version.

Challenge hash order, signature version 1 versus 2 Version 1 hashes the signature prefix first, then system id, block height, signing id and challenge. Version 2 moves the prefix after the signing id. getChallengeHash(signedBlockheight, signatureVersion) V1 PREFIX system_id height signing_id challenge V2 system_id height signing_id PREFIX challenge The prefix moved because v1 was vulnerable to a cross-protocol replay between address types.

FIGURE 3.1 · Two hash orders, selected by signatureVersion.

Request is the login-shaped ancestor

Request predates the generic envelope. It carries four things: system_id (the chain), signing_id (the identity proving itself), an optional signature, and a challenge. Response mirrors it with the decision and the responder's signature.

The whole security story of a login is in getChallengeHash(): bind the signer to a specific block height, so a signature cannot be replayed against a different chain state.

Signature version 1 versus 2

VERUS_DATA_SIGNATURE_PREFIX is a domain separator. In version 1 it is hashed first; in version 2 it moves after signing_id. The order is not cosmetic — the moved prefix prevents a signature made for one Verus address type from validating as another. When you verify someone else's signature, you must know which version they used, or you will compute a hash that never matches.

v1: sha256(PREFIX ‖ system_id ‖ height ‖ signing_id ‖ challenge_hash)
v2: sha256(system_id ‖ height ‖ signing_id ‖ PREFIX ‖ challenge_hash)

Challenge, Hash160, and the address dance

Reading the code

src/vdxf/classes/Request.ts        # getChallengeHash, toJson, length calculation
src/vdxf/classes/Response.ts       # decision + responder signature
src/vdxf/classes/Challenge.ts      # toSha256
src/vdxf/classes/Hash160.ts        # address ⇄ hash160
src/constants/vdxf.ts              # VERUS_DATA_SIGNATURE_PREFIX