mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 03:35:51 +00:00
Hashes - clarify hash prefixes, SHA-512Half size.
This commit is contained in:
@@ -21,6 +21,24 @@ Each closed [Ledger](ledger-data-formats.html) has a [Ledger Index][] and a [Has
|
||||
{% include '_snippets/data_types/hash.md' %}
|
||||
<!--{#_ #}-->
|
||||
|
||||
### Hash Prefixes
|
||||
[[Source]<br>](https://github.com/ripple/rippled/blob/master/src/ripple/protocol/HashPrefix.h "Source")
|
||||
|
||||
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 hash prefixes for some common types of data:
|
||||
|
||||
| Object Type | Hash Prefix (Hex) | Hash Prefix (Text) |
|
||||
|:----------------------------------------------------|:------------------|:---|
|
||||
| Transaction (Signed) | `0x54584E00` | `TXN\0` |
|
||||
| Ledger Version (`ledger_hash`) | `0x4C575200` | `LWR\0` |
|
||||
| [Ledger state tree information](ledger-header.html) | `0x4D4C4E00` | `MLN\0` |
|
||||
| Transaction (Unsigned, for single-signing) | `0x53545800` | `STX\0` |
|
||||
| Transaction (Unsigned, for multi-signing) | `0x534D5400` | `SMT\0` |
|
||||
| Validation vote | `0x56414C00` | `VAL\0` |
|
||||
|
||||
[Ledger objects IDs](ledger-object-ids.html) are calculated in a similar way, with 16-bit "space key" prefixes for each object type.
|
||||
|
||||
|
||||
## Account Sequence
|
||||
[Sequence Number]: #account-sequence
|
||||
|
||||
@@ -6,7 +6,7 @@ Every ledger version has a unique header that describes the contents. You can lo
|
||||
| Field | JSON Type | [Internal Type][] | Description |
|
||||
|:-------------------------------|:----------|:------------------|:------------|
|
||||
| [`ledger_index`][Ledger Index] | String | UInt32 | The sequence number of the ledger. Some API methods display this as a quoted integer; some display it as a native JSON number. |
|
||||
| `ledger_hash` | String | Hash256 | The [SHA-512Half][] of the ledger header, excluding the `ledger_hash` itself. This serves as a unique identifier for this ledger and all its contents. |
|
||||
| `ledger_hash` | String | Hash256 | The [SHA-512Half][] of this ledger version. This serves as a unique identifier for this ledger and all its contents. |
|
||||
| `account_hash` | String | Hash256 | The [SHA-512Half][] of this ledger's state tree information. |
|
||||
| `close_time` | Number | UInt32 | The approximate time this ledger closed, as the number of seconds since the Ripple Epoch of 2000-01-01 00:00:00. This value is rounded based on the `close_time_resolution`, so later ledgers can have the same value. |
|
||||
| `closed` | Boolean | bool | If true, this ledger version is no longer accepting new transactions. (However, unless this ledger version is validated, it might be replaced by a different ledger version with a different set of transactions.) |
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
# Ledger Object IDs
|
||||
<a id="sha512half"></a>
|
||||
|
||||
All objects in a ledger's state tree have a unique ID. This field is returned as the `index` field in JSON, at the same level as the object's contents. The ID is derived by hashing important contents of the object, along with a [namespace identifier](https://github.com/ripple/rippled/blob/master/src/ripple/protocol/LedgerFormats.h#L99). The [ledger object type](ledger-object-types.html) determines which namespace identifier to use and which contents to include in the hash. This ensures every ID is unique. To calculate the hash, `rippled` uses SHA-512 and then truncates the result to the first 256 bytes. This algorithm, informally called **SHA-512Half**, provides an output that has comparable security to SHA-256, but runs faster on 64-bit processors.
|
||||
All objects in a ledger's state tree have a unique ID. This field is returned as the `index` field in JSON, at the same level as the object's contents. The ID is derived by hashing important contents of the object, along with a [namespace identifier](https://github.com/ripple/rippled/blob/master/src/ripple/protocol/LedgerFormats.h#L99). The [ledger object type](ledger-object-types.html) determines which namespace identifier to use and which contents to include in the hash. This ensures every ID is unique. To calculate the hash, `rippled` uses SHA-512 and then truncates the result to the first 256 bits. This algorithm, informally called **SHA-512Half**, provides an output that has comparable security to SHA-256, but runs faster on 64-bit processors.
|
||||
|
||||

|
||||
|
||||
|
||||
## See Also
|
||||
|
||||
For ledger basics, see [Ledgers](ledgers.html).
|
||||
- For more information how the XRP Ledger creates and uses hashes, see [Hashes](basic-data-types.html#hashes).
|
||||
- For ledger basics, see [Ledgers](ledgers.html).
|
||||
|
||||
|
||||
<!--{# common link defs #}-->
|
||||
|
||||
Reference in New Issue
Block a user