Hash prefixes: actually just re-add all prefixes

This commit is contained in:
mDuo13
2018-12-10 17:36:19 -08:00
parent a19b3c2e42
commit 13e5f183bb

View File

@@ -26,17 +26,25 @@ Each closed [Ledger](ledger-data-formats.html) has a [Ledger Index][] and a [Has
In many cases, the XRP Ledger prefixes an object's binary data with a 4-byte code before calculating its hash, so that objects of different types have different hashes even if their binary formats are the same. The 4-byte codes are structured as three bytes of ASCII followed by a zero byte. In many cases, the XRP Ledger prefixes an object's binary data with a 4-byte code before calculating its hash, so that objects of different types have different hashes even if their binary formats are the same. The 4-byte codes are structured as three bytes of ASCII followed by a zero byte.
The following table shows the prefixes for some hash types that appear in API requests and responses: Some types of hash appear in API requests and responses. Others are only calculated as the first step of signing a certain type of data, or calculating a higher-level hash. The following table shows all 4-byte hash prefixes the XRP Ledger uses:
| Object Type | Hash Prefix (Hex) | Hash Prefix (Text) | | Object Type | API Fields | Hash Prefix (Hex) | Hash Prefix (Text) |
|:----------------------------------------------------------------------------|:------------------|:--| |:--------------------------------------|:-------------------------------------|:------------------|:--|
| Signed Transaction (`hash` field of transactions) | `0x54584E00` | `TXN\0` | | Consensus proposal | N/A | `0x50525000` | `PRP\0` |
| Ledger Version (`ledger_hash` fields) | `0x4C575200` | `LWR\0` | | Ledger Version | `ledger_hash` | `0x4C575200` | `LWR\0` |
| [Ledger state tree information (`account_state` field)](ledger-header.html) | `0x4D4C4E00` | `MLN\0` | | Ledger state data | `account_state` in [ledger header][] | `0x4D4C4E00` | `MLN\0` |
| Unsigned Transaction (For single-signing) | `0x53545800` | `STX\0` | | Ledger data inner node | N/A | `0x4D494E00` | `MIN\0` |
| Unsigned Transaction (For multi-signing) | `0x534D5400` | `SMT\0` | | Ledger data inner node ([SHAMapv2][]) | N/A | `0x494E5200` | `INR\0` |
| Payment Channel Claim | N/A | `0x434C4D00` | `CLM\0` |
| Signed Transaction | `hash` of transactions | `0x54584E00` | `TXN\0` |
| Transaction with metadata | N/A | `0x534E4400` | `SND\0` |
| Unsigned Transaction (Single-signing) | N/A | `0x53545800` | `STX\0` |
| Unsigned Transaction (Multi-signing) | N/A | `0x534D5400` | `SMT\0` |
| Validation vote | N/A | `0x56414C00` | `VAL\0` |
| Validator ephemeral key update | N/A | `0x4D414E00` | `MAN\0` |
**Note:** There are several other hash prefixes which are only used when calculating the hash as the first step of signing a specific type of data. For the complete list, see [the source code](https://github.com/ripple/rippled/blob/master/src/ripple/protocol/impl/HashPrefix.cpp). [ledger header]: ledger-header.html
[SHAMapv2]: known-amendments.html#shamapv2
[Ledger objects IDs](ledger-object-ids.html) are calculated in a similar way, but they use a 2-byte prefix called a "space key" instead of a prefix in the form described here. [Ledger objects IDs](ledger-object-ids.html) are calculated in a similar way, but they use a 2-byte prefix called a "space key" instead of a prefix in the form described here.