Minter Docsv3.3.0
Protocol / Encoding and signing
Protocol

Encoding and signing

Canonical Minter v3.3.0 RLP rules, 10-field transaction envelope, Keccak-256 signing digest vs SHA-256 Mt... hash, Mc... check cryptography, and the Send (0x01) reference vector.

The transaction decoder in coreV2/transaction/transaction.go enforces canonical Recursive Length Prefix (go-ethereum/rlp) serialization for transactions and off-chain checks. Non-canonical length prefixes or leading zero bytes in integers fail immediately with rlp: non-canonical integer.

Canonical RLP rules in Minter

  1. Unsigned integers (uint8, uint32, uint64, *big.Int in pip) and booleans serialize as minimal big-endian byte slices with no leading 0x00 bytes: 0 and false encode as an empty slice (0x80), while 1 and true encode as 0x01. A single byte in 0x00..0x7f encodes as itself without a 0x81 prefix.
  2. Double RLP wrapping of Data (index 5) and SignatureData (index 9): both fields are declared as []byte in transaction.go. Encode the operation's inner fields into dataBytes = RLP(innerFields) first, then pass dataBytes as a byte string in the outer 10-element list. For example, empty LockStakeData (0x25) encodes internally to the 1-byte empty list 0xc0 (>= 0x80), which wraps at outer index 5 as 0x81 0xc0.
  3. Fixed 10-byte CoinSymbol ([10]byte in 0x05, 0x10, 0x11, 0x1E, 0x1F): creation tickers match ^[A-Z0-9]{3,10}$ (cannot parse solely as digits) and are right-padded with 0x00 (NUL) bytes to exactly 10 bytes under RLP prefix 0x8a ("STUDIO" -> 8a 53 54 55 44 49 4f 00 00 00 00).

Outer transaction envelope (10 fields)

Serialized signed transactions are bounded to 16,144 bytes (maxTxLength in executor_v3.go):

IndexFieldGo / RLP typeEncoding and precondition rule
0Nonceuint64Equals Accounts.GetNonce(sender) + 1 (1 -> 0x01)
1ChainIDbyte1 (0x01) for Mainnet; 2 (0x02) for Testnet
2GasPriceuint32Fee multiplier >= 1 (equals 1 for RedeemCheck 0x09)
3GasCoinuint32Numeric fee CoinID (0 = BIP -> 0x80, 1993 = USDTE -> 0x82 0x07 0xc9)
4TypebyteOpcode 0x01..0x26 (see transaction registry)
5Data[]byteByte string holding inner RLP(innerFields)
6Payload[]byteArbitrary byte slice <= 10,000 bytes (empty -> 0x80)
7ServiceData[]byteArbitrary service metadata <= 128 bytes (empty -> 0x80)
8SignatureTypebyte0x01 single secp256k1 signature; 0x02 weighted multisig
9SignatureData[]byteByte string holding RLP([V, R, S]) (0x01) or RLP([MultisigAddr20B, [[V, R, S], ...]]) (0x02)

Dual-hash scheme and secp256k1 signing

Signatures cover the Keccak-256 digest of the first 9 fields, whereas the network transaction hash uses SHA-256 over all 10 fields (for Mx, Mp, Mt, Mc prefixes, see the protocol overview):

text
signingHash = Keccak256(RLP([Nonce, ChainID, GasPrice, GasCoin, Type, Data, Payload, ServiceData, SignatureType]))
txHash      = "Mt" + hexLower(SHA256(RLP([Nonce, ..., SignatureType, SignatureData])))
  • For SignatureType == 0x01, sign signingHash with secp256k1 (RFC 6979) and low-S normalization (1 <= S <= n / 2). Set V = recoveryId + 27 (27 or 28) and strip leading 0x00 bytes from R and S before encoding RLP([V, R, S]).
  • For SignatureType == 0x02, encode the 20-byte multisig address followed by 1..32 [V, R, S] tuples from distinct participants (DuplicatedAddresses on repeats) whose weights sum to at least Threshold.

Two-key checks (Mc...) and RedeemCheck (0x09) preconditions

A Check body (coreV2/check/check.go) is a 10-field RLP list: [Nonce []byte, ChainID byte, DueBlock uint64, Coin uint32, Value *big.Int, GasCoin uint32, Lock *big.Int, V *big.Int, R *big.Int, S *big.Int] (DueBlock is uint64 in check.go, whereas Lock 0x26 in lock.go:14 uses uint32).

  1. Compute HashWithoutLock = Keccak256(RLP([Nonce, ChainID, DueBlock, Coin, Value, GasCoin])) (6 fields) and passKey = SHA256(passphrase).
  2. Sign HashWithoutLock with passKey to obtain the 65-byte recoverable signature [R(32) || S(32) || V(0|1)], encoded in Lock as an unsigned *big.Int with no leading zero bytes (left-padded back to 65 bytes on decode).
  3. Compute CheckHash = Keccak256(RLP([Nonce, ChainID, DueBlock, Coin, Value, GasCoin, Lock])) (7 fields) and sign it with the issuer key (V = 27 | 28, R, S).
  4. The redeemer computes Proof ([65]byte, RLP 0xb8 0x41 ...) by signing Keccak256(RLP([redeemerAddress20B])) with passKey.

RedeemCheck (0x09) (redeem_check.go) enforces five preconditions: tx.GasPrice == 1 (TooHighGasPrice), tx.GasCoin == check.GasCoin (WrongGasCoin; check.GasCoin must be BIP, a CRR coin, or a coin with a BIP pool), len(check.Nonce) <= 16 bytes (TooLongNonce), check.ChainID == CurrentChainID, and check.DueBlock >= currentBlock with !IsCheckUsed. On execution, Value and price.RedeemCheck are deducted from issuer.

Send (0x01) reference vector

The tx-0x01-send fixture from /test-vectors.json transfers 12.5 BIP to Mx6fac4d18c912343bf86fa7049364dd4e424ab9c0 with payload = "invoice:2026-11", nonce = 1, chainId = 1, gasPrice = 1, gasCoin = 0. It is a regression fixture generated by @minter-network/tx-core; see Test vectors and porting for its Go verification status:

  • dataBytesHex: 0xdf80946fac4d18c912343bf86fa7049364dd4e424ab9c088ad78ebc5ac620000 (32 bytes, wrapped with 0xa0 in the outer list)
  • signingHash: 0x4fdf01449f56ca56b2310e91e17d5cf07d930578ccf620d2354b0bf8edb47617
  • txHash: Mte53eeda7a4268983a7ea5481cf150ae9d6ef76c1e497f7489d99805a812b7011
typescript
import { buildSendTx, parsePip, signTx } from "@minter-network/tx-core";

// Public test private key from /test-vectors.json (do not fund on Mainnet)
const TEST_PRIV_KEY =
  "1ab42cc412b618bdea3a599e3c9bae199ebf030895b039e9db1e30dafb12b727";

const unsigned = buildSendTx(
  {
    coinId: 0,
    to: "Mx6fac4d18c912343bf86fa7049364dd4e424ab9c0",
    valuePip: parsePip("12.5"),
  },
  {
    nonce: 1n,
    chainId: 1,
    gasPrice: 1,
    gasCoin: 0,
    payload: "invoice:2026-11",
  },
);

const signed = signTx(unsigned, TEST_PRIV_KEY);
console.log(signed.signingHash);    // 0x4fdf01449f56ca56b2310e91e17d5cf07d930578ccf620d2354b0bf8edb47617
console.log(signed.txHash);         // Mte53eeda7a4268983a7ea5481cf150ae9d6ef76c1e497f7489d99805a812b7011
console.log(signed.signedRawTxHex); // 0xf87f0101018001a0df80946fac4d18c912343bf86fa7049364dd4e424ab9c0...