Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions multicodec/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ def _get_tag(code: int) -> str:
if name in ("multicodec", "multihash", "multiaddr", "multibase", "varsig"):
return "multiformat"

# Multikey
if name == "chacha20-poly1305":
return "multikey"

# Multisig
if "-msig" in name or ("lamport-" in name and "-sig" in name):
return "multisig"

# Multihash
if any(
h in name
Expand Down Expand Up @@ -387,6 +395,10 @@ def _get_tag(code: int) -> str:
):
return "namespace"

# Nonce
if name == "nonce":
return "nonce"

# Serialization
if name in (
"protobuf",
Expand All @@ -402,6 +414,14 @@ def _get_tag(code: int) -> str:
):
return "serialization"

# Shelter
if name.startswith("shelter-"):
return "shelter"

# Softhash
if name == "iscc":
return "softhash"

# Transport
if name in (
"transport-bitswap",
Expand All @@ -425,6 +445,10 @@ def _get_tag(code: int) -> str:
):
return "varsig"

# Vlad
if name == "vlad":
return "vlad"

# Zeroxcert
if name in ("zeroxcert-imprint-256",):
return "zeroxcert"
Expand Down
26 changes: 26 additions & 0 deletions tests/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,32 @@ def test_code_tag(self):
code = Code(0x55) # raw
assert code.tag() == "ipld"

# Multikey
code = Code(0xA000) # chacha20-poly1305
assert code.tag() == "multikey"

# Multisig
code = Code(0xD01300) # es256k-msig
assert code.tag() == "multisig"
code = Code(0x1A44) # lamport-sha3-512-sig
assert code.tag() == "multisig"

# Nonce
code = Code(0x123B) # nonce
assert code.tag() == "nonce"

# Shelter
code = Code(0x511E00) # shelter-contract-manifest
assert code.tag() == "shelter"

# Softhash
code = Code(0xCC01) # iscc
assert code.tag() == "softhash"

# Vlad
code = Code(0x1207) # vlad
assert code.tag() == "vlad"


class ReservedRangeTestCase:
"""Tests for reserved range constants and functions."""
Expand Down
Loading