From 325a0063698640952e23e41f834511495faea93f Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Wed, 12 May 2021 21:18:43 +1000 Subject: [PATCH] Check codes are ascending with validation script (#212) Ref: https://github.com/multiformats/multicodec/pull/210 --- table.csv | 2 +- validate.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/table.csv b/table.csv index bbf0e0f..40c0f4e 100644 --- a/table.csv +++ b/table.csv @@ -79,7 +79,6 @@ swarm-ns, namespace, 0xe4, draft, Swarm ipns-ns, namespace, 0xe5, draft, IPNS path zeronet, namespace, 0xe6, draft, ZeroNet site address secp256k1-pub, key, 0xe7, draft, Secp256k1 public key -secp256k1-priv, key, 0x1301, draft, Secp256k1 private key bls12_381-g1-pub, key, 0xea, draft, BLS12-381 public key in the G1 field bls12_381-g2-pub, key, 0xeb, draft, BLS12-381 public key in the G2 field x25519-pub, key, 0xec, draft, Curve25519 public key @@ -127,6 +126,7 @@ p521-pub, key, 0x1202, draft, P-521 ed448-pub, key, 0x1203, draft, Ed448 public Key x448-pub, key, 0x1204, draft, X448 public Key ed25519-priv, key, 0x1300, draft, Ed25519 private key +secp256k1-priv, key, 0x1301, draft, Secp256k1 private key kangarootwelve, multihash, 0x1d01, draft, KangarooTwelve is an extendable-output hash function based on Keccak-p sm3-256, multihash, 0x534d, draft, blake2b-8, multihash, 0xb201, draft, Blake2b consists of 64 output lengths that give different hashes diff --git a/validate.py b/validate.py index 89d6229..bc29334 100755 --- a/validate.py +++ b/validate.py @@ -24,6 +24,7 @@ def check(fname='table.csv'): codes = {} names = {} headerOffsets = [] + lastCode = -1 for line, row in enumerate(tablereader): try: # Check the padding of each column @@ -69,6 +70,12 @@ def check(fname='table.csv'): except Exception as e: raise CheckError(f"failed to parse code '{code}' for '{name}': {e}") + # Check codes are ascending + ooo = code < lastCode + lastCode = code + if ooo: + raise CheckError(f"code {code} is out of order, previous code was {lastCode}") + # Finally, check for duplicates if name in names: