From ea221577dff12199ff6562e946da920f5387fc6e Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Wed, 15 Jul 2026 01:31:37 -0400 Subject: [PATCH] bip-138 add test vectors for sorting and deduplication --- bip-0138/test_vectors/derivation_path.json | 10 ++++++++++ bip-0138/test_vectors/individual_secrets.json | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/bip-0138/test_vectors/derivation_path.json b/bip-0138/test_vectors/derivation_path.json index c7c4093f..10349244 100644 --- a/bip-0138/test_vectors/derivation_path.json +++ b/bip-0138/test_vectors/derivation_path.json @@ -59,6 +59,16 @@ "paths": ["m/0", "m/1"], "expected": "0201000000000100000001" }, + { + "description": "Unsorted paths are sorted when encoded", + "paths": ["m/84'/0'/0'/2'", "m/0/1'/2/3'"], + "expected": "0204000000008000000100000002800000030480000054800000008000000080000002" + }, + { + "description": "Duplicate paths are deduplicated", + "paths": ["m/1", "m/0", "m/1"], + "expected": "0201000000000100000001" + }, { "description": "BIP-44 account 0: m/44'/0'/0'", "paths": ["m/44'/0'/0'"], diff --git a/bip-0138/test_vectors/individual_secrets.json b/bip-0138/test_vectors/individual_secrets.json index cfe0ee78..ff4e7b36 100644 --- a/bip-0138/test_vectors/individual_secrets.json +++ b/bip-0138/test_vectors/individual_secrets.json @@ -14,6 +14,23 @@ ], "expected": "0201010101010101010101010101010101010101010101010101010101010101010202020202020202020202020202020202020202020202020202020202020202" }, + { + "description": "Unsorted secrets are sorted when encoded", + "secrets": [ + "0202020202020202020202020202020202020202020202020202020202020202", + "0101010101010101010101010101010101010101010101010101010101010101" + ], + "expected": "0201010101010101010101010101010101010101010101010101010101010101010202020202020202020202020202020202020202020202020202020202020202" + }, + { + "description": "Duplicate secrets are deduplicated", + "secrets": [ + "0202020202020202020202020202020202020202020202020202020202020202", + "0101010101010101010101010101010101010101010101010101010101010101", + "0202020202020202020202020202020202020202020202020202020202020202" + ], + "expected": "0201010101010101010101010101010101010101010101010101010101010101010202020202020202020202020202020202020202020202020202020202020202" + }, { "description": "Three secrets with different patterns", "secrets": [