Merge pull request #182 from multiformats/rvagg/naming-rules

Naming restrictions (doc & validate), rename `0xcert` to be code-friendly
This commit is contained in:
Rod Vagg 2020-07-21 07:34:34 +10:00 committed by GitHub
commit 00960cf9a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -47,6 +47,10 @@ This ["first come, first assign"](https://github.com/multiformats/multicodec/pul
The first 127 bits are encoded as a single-byte varint, hence they are reserved for the most widely used multicodecs. So if you are adding your own codec to the table, you most likely would want to ask for a codec bigger than `0x80`.
Codec names should be easily convertible to constants in common programming languages using basic transformation rules (e.g. upper-case, conversion of `-` to `_`, etc.). Therefore they should contain alphanumeric characters, with the first character being alphabetic. The primary delimiter for multi-part names should be `-`, with `_` reserved for cases where a secondary delimiter is required. For example: `bls12_381-g1-pub` contains 3 parts: `bls_381`, `g1` and `pub`, where `bls_381` is "BLS 381" which is not commonly written as "BLS381" and therefore requires a secondary separator.
The `validate.py` script can be used to validate the table once it's edited.
## Implementations
- [go](https://github.com/multiformats/go-multicodec/)

View File

@ -437,7 +437,7 @@ skein1024-1016, multihash, 0xb3df,
skein1024-1024, multihash, 0xb3e0,
poseidon-bls12_381-a2-fc1, multihash, 0xb401, Poseidon using BLS12-381 and arity of 2 with Filecoin parameters
poseidon-bls12_381-a2-fc1-sc, multihash, 0xb402, Poseidon using BLS12-381 and arity of 2 with Filecoin parameters - high-security variant
0xcert-imprint-256, 0xcert, 0xce11, 0xcert Asset Imprint (root hash)
zeroxcert-imprint-256, zeroxcert, 0xce11, 0xcert Asset Imprint (root hash)
fil-commitment-unsealed, filecoin, 0xf101, Filecoin piece or sector data commitment merkle node/root (CommP & CommD)
fil-commitment-sealed, filecoin, 0xf102, Filecoin sector data commitment merkle node/root - sealed and replicated (CommR)
holochain-adr-v0, holochain, 0x807124, Holochain v0 address + 8 R-S (63 x Base-32)

1 name tag code description
437 skein1024-1024 multihash 0xb3e0
438 poseidon-bls12_381-a2-fc1 multihash 0xb401 Poseidon using BLS12-381 and arity of 2 with Filecoin parameters
439 poseidon-bls12_381-a2-fc1-sc multihash 0xb402 Poseidon using BLS12-381 and arity of 2 with Filecoin parameters - high-security variant
440 0xcert-imprint-256 zeroxcert-imprint-256 0xcert zeroxcert 0xce11 0xcert Asset Imprint (root hash)
441 fil-commitment-unsealed filecoin 0xf101 Filecoin piece or sector data commitment merkle node/root (CommP & CommD)
442 fil-commitment-sealed filecoin 0xf102 Filecoin sector data commitment merkle node/root - sealed and replicated (CommR)
443 holochain-adr-v0 holochain 0x807124 Holochain v0 address + 8 R-S (63 x Base-32)

View File

@ -43,6 +43,10 @@ def check(fname='table.csv'):
if not re.match(r"^0x([0-9a-f][0-9a-f])+$", code):
raise CheckError(f"code for '{name}' does not look like a byte sequence: '{code}'")
# Check name format
if not re.match(r"^[a-z][a-z0-9_-]+$", name):
raise CheckError(f"name '{name}' violates naming restrictions")
# Parse the code
try:
code = int(code, 16)