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
- Unsigned integers (
uint8,uint32,uint64,*big.Intinpip) and booleans serialize as minimal big-endian byte slices with no leading0x00bytes:0andfalseencode as an empty slice (0x80), while1andtrueencode as0x01. A single byte in0x00..0x7fencodes as itself without a0x81prefix. - Double RLP wrapping of
Data(index5) andSignatureData(index9): both fields are declared as[]byteintransaction.go. Encode the operation's inner fields intodataBytes = RLP(innerFields)first, then passdataBytesas a byte string in the outer 10-element list. For example, emptyLockStakeData(0x25) encodes internally to the 1-byte empty list0xc0(>= 0x80), which wraps at outer index5as0x81 0xc0. - Fixed 10-byte
CoinSymbol([10]bytein0x05,0x10,0x11,0x1E,0x1F): creation tickers match^[A-Z0-9]{3,10}$(cannot parse solely as digits) and are right-padded with0x00(NUL) bytes to exactly10bytes under RLP prefix0x8a("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):
| Index | Field | Go / RLP type | Encoding and precondition rule |
|---|---|---|---|
0 | Nonce | uint64 | Equals Accounts.GetNonce(sender) + 1 (1 -> 0x01) |
1 | ChainID | byte | 1 (0x01) for Mainnet; 2 (0x02) for Testnet |
2 | GasPrice | uint32 | Fee multiplier >= 1 (equals 1 for RedeemCheck 0x09) |
3 | GasCoin | uint32 | Numeric fee CoinID (0 = BIP -> 0x80, 1993 = USDTE -> 0x82 0x07 0xc9) |
4 | Type | byte | Opcode 0x01..0x26 (see transaction registry) |
5 | Data | []byte | Byte string holding inner RLP(innerFields) |
6 | Payload | []byte | Arbitrary byte slice <= 10,000 bytes (empty -> 0x80) |
7 | ServiceData | []byte | Arbitrary service metadata <= 128 bytes (empty -> 0x80) |
8 | SignatureType | byte | 0x01 single secp256k1 signature; 0x02 weighted multisig |
9 | SignatureData | []byte | Byte 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):
signingHash = Keccak256(RLP([Nonce, ChainID, GasPrice, GasCoin, Type, Data, Payload, ServiceData, SignatureType]))
txHash = "Mt" + hexLower(SHA256(RLP([Nonce, ..., SignatureType, SignatureData])))- For
SignatureType == 0x01, signsigningHashwithsecp256k1(RFC 6979) andlow-Snormalization (1 <= S <= n / 2). SetV = recoveryId + 27(27or28) and strip leading0x00bytes fromRandSbefore encodingRLP([V, R, S]). - For
SignatureType == 0x02, encode the 20-byte multisig address followed by1..32[V, R, S]tuples from distinct participants (DuplicatedAddresseson repeats) whose weights sum to at leastThreshold.
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).
- Compute
HashWithoutLock = Keccak256(RLP([Nonce, ChainID, DueBlock, Coin, Value, GasCoin]))(6fields) andpassKey = SHA256(passphrase). - Sign
HashWithoutLockwithpassKeyto obtain the 65-byte recoverable signature[R(32) || S(32) || V(0|1)], encoded inLockas an unsigned*big.Intwith no leading zero bytes (left-padded back to65bytes on decode). - Compute
CheckHash = Keccak256(RLP([Nonce, ChainID, DueBlock, Coin, Value, GasCoin, Lock]))(7fields) and sign it with theissuerkey (V = 27 | 28, R, S). - The redeemer computes
Proof([65]byte, RLP0xb8 0x41 ...) by signingKeccak256(RLP([redeemerAddress20B]))withpassKey.
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(32bytes, wrapped with0xa0in the outer list)signingHash:0x4fdf01449f56ca56b2310e91e17d5cf07d930578ccf620d2354b0bf8edb47617txHash:Mte53eeda7a4268983a7ea5481cf150ae9d6ef76c1e497f7489d99805a812b7011
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...