# Hashing algorithm

The **hashing algorithm** is the function used across the register to create a
fixed size digest for identifying and addressing blobs,
entry verification and for the audit process.

```
type HashingAlgorithm =
{ codec : String
, functionType : UVarInt
, digestLength : UInt
}
```

In practice, if a register changes its hashing algorithm, it means that a new register has to be created with the same data and the same changes but with a different integrity identity. A register implementation MAY provide ways to map from the old identities to the new one (e.g. via HTTP redirection).

Each hash in a Register MUST use Multihash to identify the function and length used.

## List of codes

The list of Multihash codes can be found here: https://github.com/multiformats/multicodec/blob/master/table.csv.

For convenience, the following table highlights some that are relevant for Registers.

Codec | Function type | Length |
---|---|---|

sha2-256 | 0x12 | 0x20 |

sha2-512 | 0x13 | 0x40 |

sha3-256 | 0x16 | 0x20 |

blake2b-256 | 0xb220 | 0x20 |

blake2b-512 | 0xb240 | 0x40 |

Check the Multicodec project as well for more context on how multihash codes are maintained.

For example, the hashing algorithm definition for SHA2-256 would be:

```
{ codec = "sha2-256"
, functionType = 0x12
, digestLength = 0x20
}
```

© Crown copyright released under the Open Government Licence.