<p>The <code>Hash256</code> is essentially a <code>uint256</code>.  However, after reading through much of the wiki and source, it appears that the <code>Hash256</code> type is meant to be a generic, unsigned integer type that can store any form of hash that is larger than 128 bits.</p>

<p>As an example, all hashes mentioned in the <a href="https://ripple.com/wiki/Ledger_Format#Tree_Formats" rel="nofollow">Tree Formats</a> portion of the wiki are stored in <code>Hash256</code> fields.  Some are 256-bits (I think?) while other mentioned hashes are 160-bit hashes that are padded with 0's.</p>

<p>As an aside, I also noticed that when working with 256-bit hashes, Ripple often uses the first 256-bits of SHA-512 hash.  This is different than the typical SHA-256 hashes that are used with Bitcoin and most other alt-coins.</p>

<p><strong>NOTE:</strong> I know that a few of the Ripple devs participate in this site.  I would be greatly interested in their input.  The wiki and the source is quite cryptic in design-- almost obfuscated.  I had to follow quite a few rabbit trails to come up with the answer that I've provided.</p>

CC BY-SA 3.0
2013-10-26T05:03:17.433Z
Everything you have said above is correct. Except the tree indexes are always actual 256-bit hashes. For example, the 256-bit index for an account root node is the 256-bit hash of a 16-bit "space identifier" followed by the 160-bit account ID.
David Schwartz
CC BY-SA 3.0
2013-10-25T20:08:20.323Z
2013-10-25T20:19:50.670Z
2013-10-25T20:19:50.670Z
RLH
<p>In various places on Ripple Wiki we can see the type <code>Hash256</code> (for example <a href="https://ripple.com/wiki/Transaction_Format" rel="nofollow">here</a>). What data structure is it exactly? Is it just a 256 byte array, or are there some rules governing this type (and preventing potential misuse)?</p>

CC BY-SA 3.0
2013-10-24T11:39:21.763Z
It's a 256 bit hash.
dchapes
CC BY-SA 3.0
2013-10-25T12:05:42.303Z
perhaps the same thing Bitcoin calls Hash256: SHA256(SHA256(x))
CodesInChaos
<ripple><raw-data><hash><standard>
In Ripple, what exactly is "Hash256"?
ThePiachu
# In Ripple, what exactly is "Hash256"?

(Asked by: username_0 on 2013-10-24)

In various places on Ripple Wiki we can see the type `Hash256` (for example [here](https://ripple.com/wiki/Transaction_Format)). What data structure is it exactly? Is it just a 256 byte array, or are there some rules governing this type (and preventing potential misuse)?

**Tags:** ripple, raw-data, hash, standard

> **Comments:**
> **username_1**: It's a 256 bit hash.  
> **username_2**: perhaps the same thing Bitcoin calls Hash256: SHA256(SHA256(x))  

---

## 1 answers

### Answer by username_3 on 2013-10-25. Score: 2

The `Hash256` is essentially a `uint256`. However, after reading through much of the wiki and source, it appears that the `Hash256` type is meant to be a generic, unsigned integer type that can store any form of hash that is larger than 128 bits.

As an example, all hashes mentioned in the [Tree Formats](https://ripple.com/wiki/Ledger_Format#Tree_Formats) portion of the wiki are stored in `Hash256` fields. Some are 256-bits (I think?) while other mentioned hashes are 160-bit hashes that are padded with 0's.

As an aside, I also noticed that when working with 256-bit hashes, Ripple often uses the first 256-bits of SHA-512 hash. This is different than the typical SHA-256 hashes that are used with Bitcoin and most other alt-coins.

**NOTE:** I know that a few of the Ripple devs participate in this site. I would be greatly interested in their input. The wiki and the source is quite cryptic in design-- almost obfuscated. I had to follow quite a few rabbit trails to come up with the answer that I've provided.

> **Comments:**
> **username_4**: Everything you have said above is correct. Except the tree indexes are always actual 256-bit hashes. For example, the 256-bit index for an account root node is the 256-bit hash of a 16-bit "space identifier" followed by the 160-bit account ID.  

---

