ipld / ipld/py-ipld-dag

`multicodec_codes.py` has incomplete hash code definitions

Open
#29 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
13
Forks
9
PR merge metrics
No merged PRs in 30d

Description

`multicodec_codes.py` only defines 6 hash codes (identity, sha2-256, sha2-512, sha3-256, sha3-512, blake2b-256). Many commonly used hash functions are missing (shake-128, shake-256, keccak-*, blake3, blake2s-*, murmur3-*, etc.).

### Problem

In `dag/multicodec_codes.py`:

```python
SHA2_256_CODE = 0x12
SHA2_512_CODE = 0x13
SHA3_256_CODE = 0x16
SHA3_512_CODE = 0x17
BLAKE2B_256_CODE = 0xB220
IDENTITY_CODE = 0x00
```

Missing codes include:
- `shake-128` (0x18), `shake-256` (0x19)
- `keccak-224` (0x1A), `keccak-256` (0x1B), `keccak-384` (0x1C), `keccak-512` (0x1D)
- `blake3` (0x1E)
- `dbl-sha2-256` (0x56)
- `sha2-224` (0x1013), `sha2-384` (0x20)
- `blake2b-8` through `blake2b-512` (0xB201–0xB240)
- `blake2s-8` through `blake2s-256` (0xB241–0xB260)
- And many more...

### Proposed Solution

Add all hash codes from the multicodec table. Consider importing from `py-multihash` constants instead of duplicating:

```python
# Option 1: Import from py-multihash
from multihash.constants import HASH_CODES

# Option 2: Add missing codes manually
SHAKE_128_CODE = 0x18
SHAKE_256_CODE = 0x19
KECCAK_224_CODE = 0x1A
KECCAK_256_CODE = 0x1B
KECCAK_384_CODE = 0x1C
KECCAK_512_CODE = 0x1D
BLAKE3_CODE = 0x1E
# ... etc
```

### Related

- Multicodec table: https://github.com/multiformats/multicodec/blob/master/table.csv
- File: `dag/multicodec_codes.py`

Contributor guide

Open the contributing guide

Research direction

Start in dag/multicodec_codes.py and compare the existing constants with the linked multicodec table. Check whether py-multihash exposes the needed HASH_CODES before deciding how to represent the missing entries; the work is done when the hash codes requested by the table are available consistently in this module.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cryptography
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.