From 199c7beb447ae55edd5cdd6d0eb3b365800c3973 Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Fri, 22 Aug 2025 11:59:20 +0200 Subject: [PATCH 01/12] bip encrypted_backup --- bip-encrypted-backup.md | 373 ++++++++++++ .../chacha20poly1305_encryption.json | 37 ++ .../test_vectors/content_type.json | 67 +++ .../test_vectors/derivation_path.json | 146 +++++ .../test_vectors/encrypted_backup.json | 67 +++ .../test_vectors/encryption_secret.json | 89 +++ .../test_vectors/individual_secrets.json | 554 ++++++++++++++++++ .../test_vectors/keys_types.json | 47 ++ 8 files changed, 1380 insertions(+) create mode 100644 bip-encrypted-backup.md create mode 100644 bip-encrypted-backup/test_vectors/chacha20poly1305_encryption.json create mode 100644 bip-encrypted-backup/test_vectors/content_type.json create mode 100644 bip-encrypted-backup/test_vectors/derivation_path.json create mode 100644 bip-encrypted-backup/test_vectors/encrypted_backup.json create mode 100644 bip-encrypted-backup/test_vectors/encryption_secret.json create mode 100644 bip-encrypted-backup/test_vectors/individual_secrets.json create mode 100644 bip-encrypted-backup/test_vectors/keys_types.json diff --git a/bip-encrypted-backup.md b/bip-encrypted-backup.md new file mode 100644 index 0000000000..09583bfd14 --- /dev/null +++ b/bip-encrypted-backup.md @@ -0,0 +1,373 @@ +``` +BIP: ? +Layer: Applications +Title: Compact encryption scheme for non-seed wallet data +Authors: Pyth +Status: Draft +Type: Specification +Assigned: ? +License: BSD-2-Clause +Discussion: https://delvingbitcoin.org/t/a-simple-backup-scheme-for-wallet-accounts/1607 + https://groups.google.com/g/bitcoindev/c/5NgJbpVDgEc/m/TtGK9sF9BgAJ +``` + +## Introduction + +### Abstract + +This BIP defines a compact encryption scheme for **output script descriptors** (BIP-0380), +**wallet policies** (BIP-0388), **labels** (BIP-0329), and **wallet backup metadata** (draft [BIP](https://github.com/bitcoin/bips/pull/2130)). +The payload must not contain any private key material. + +Users can store encrypted backups on untrusted media or cloud services without leaking +addresses, script structures, or cosigner counts. The encryption key derives from the +lexicographically-sorted public keys in the descriptor, allowing any keyholder to decrypt +without additional secrets. + +Though designed for descriptors and policies, the scheme works equally well for labels +and backup metadata. + +### Copyright + +This BIP is licensed under the BSD 2-Clause License. +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the above copyright notice and this permission notice appear +in all copies. + +### Motivation + +Losing the **wallet descriptor** (or **wallet policy**) is just as catastrophic as +losing the seed itself. The seed lets you sign, but the descriptor maps you to your coins. +For multisig or miniscript wallets, keys alone won't help: without the descriptor, you +can't reconstruct the script. + +Offline storage of descriptors has two practical obstacles: + +1. **Descriptors are hard to store offline.** + Descriptors can be much longer than a 12/24-word seed. Paper and steel backups + become impractical or error-prone. + +2. **Online redundancy carries privacy risk.** + USB drives, phones, and cloud storage solve the length problem but expose your + wallet structure. Plaintext descriptors leak your pubkeys and script details. + Cloud storage is often unencrypted, and even cloud encryption could be compromised, + depending on (often opaque) implementation details. Its security also reduces to + that of the weakest device with cloud access. Each copy increases the attack surface. + +This BIP therefore proposes an **encrypted**, compact backup format that: + +* can be **safely stored in multiple places**, including untrusted online services, +* can be **decrypted only by intended holders** of specified public keys, + +See the original [Delving post](https://delvingbitcoin.org/t/a-simple-backup-scheme-for-wallet-accounts/1607/31) +for more background. + +### Expected properties + +* **Encrypted**: safe to store with untrusted cloud providers or backup services +* **Access controlled**: only designated cosigners can decrypt +* **Easy to implement**: it should not require any sophisticated tools/libraries. +* **Vendor-neutral**: works with any hardware signer + +### Scope + +This proposal targets output script descriptors (BIP-0380) and policies (BIP-0388), but the +scheme also works for labels (BIP-0329) and other wallet metadata like +[wallet backup metadata](https://github.com/bitcoin/bips/pull/2130). + +Private key material MUST be removed before encrypting any payload. + +## Specification + +Note: in the followings sections, the operator ⊕ refers to the bitwise XOR operation. + +### Secret generation + +- Let $p_1, p_2, \dots, p_n$, be the public keys in the descriptor/wallet policy, in + increasing lexicographical order. The scheme is defined for any $n \geq 1$, + in particular it supports single-signature descriptors ($n = 1$). Each $p_i$ + is the x-only-normalized root public key of one *allowed* key expression + (see [Descriptor key requirements](#descriptor-key-requirements)). +- Let $s$ = sha256(sha256("BIPXXX_DECRYPTION_SECRET") | sha256("BIPXXX_DECRYPTION_SECRET") | $p_1$ | $p_2$ | ... | $p_n$) +- Let $s_i$ = sha256(sha256("BIPXXX_INDIVIDUAL_SECRET") | sha256("BIPXXX_INDIVIDUAL_SECRET") | $p_i$) +- Let $c_i$ = $s$ ⊕ $s_i$ + +Because $s$ and $s_i$ use distinct domain-separation tags, $s \neq s_i$ and +therefore $c_i$ is never the all-zero string. + +**Note:** To prevent attackers from decrypting the backup using publicly known +keys, explicitly exclude any public keys with x coordinate +`50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0` (the BIP341 NUMS +point, used as a taproot internal key in some applications). Additionally, exclude any +other publicly known keys. + +Applications that exclude additional keys SHOULD document this, although decryption +using these keys will simply fail. This does not affect decryption with the remaining +keys. + +### Descriptor key requirements + +Only key expressions of the extended-public-key type with a trailing +derivation step or wildcard contribute to $\{p_1, \dots, p_n\}$. Without +that derivation, the xpub's root pubkey, used to seed $s$, would also be +the on-chain pubkey of every spend, so observing one spend would let +anyone recompute $s$ and decrypt the backup.[^trailing-derivation] The +rule generalizes to any network prefix (`xpub`/`tpub`/`Vpub`/...). + +[^trailing-derivation]: **Why require trailing derivation?** + Any trailing derivation step, or the implicit child derivation forced by + a wildcard, breaks the identity between the xpub root pubkey and the + on-chain pubkey. Fixed-derivation expressions like `xpub.../0/5` are + allowed because the on-chain key (`xpub/0/5`) already differs from the + encryption seed (the xpub root). Literal pubkeys and bare xpubs are + disallowed for the same reason: the literal value is exactly what goes + on-chain, so $s$ would become recoverable from a single observed spend. + +Allowed forms (origin information `[...]` is optional and orthogonal): + +| Form | Example | +|-------------------------------------------------------------|-------------------| +| `/` (fixed derivation, no wildcard) | `xpub.../0/5` | +| `/*` (wildcard only) | `xpub.../*` | +| `//*` (fixed derivation followed by a wildcard) | `xpub.../0/*` | +| `/` (multipath, no wildcard) | `xpub.../<0;1>` | +| `//*` (multipath followed by a wildcard) | `xpub.../<0;1>/*` | + +Implementations: + +- MUST exclude every other form (literal pubkeys, bare xpubs, ...) from + $\{p_1, \dots, p_n\}$. +- MUST refuse to encode a backup if the resulting set is empty. +- SHOULD make the user aware of each excluded expression, since the + cosigner holding that key will be unable to decrypt the backup with + their key. + +### Key Normalization + +For each allowed expression, take the root extended public key (ignoring +origin information, the trailing derivation path, the wildcard, and any +multipath specifiers) and extract its x-coordinate. The result is the +32-byte **x-only public key** $p_i$.[^x-only] + +[^x-only]: **Why x-only keys?** + X-only public keys are 32 bytes, a natural size for cryptographic operations. + This format is also used in BIP340 (Schnorr signatures) and BIP341 (Taproot). + +### Encryption + +The format uses CHACHA20_POLY1305 (RFC 8439) as the encryption algorithm, +with a 96-bit random nonce and a 128-bit authentication tag to provide confidentiality +and integrity. + +[^chacha-default]: **Why CHACHA20-POLY1305 ?** + ChaCha20-Poly1305 is already used in Bitcoin Core (e.g., BIP324) and is widely + available in cryptographic libraries. It performs well in software without + hardware acceleration, making it suitable for hardware wallets and embedded devices. + +* let $nonce$ = random(96 bits) +* let $ciphertext$ = encrypt($payload$, $secret$, $nonce$) + +### Decryption + +In order to decrypt the payload of a backup, the owner of a certain public key p +computes: + +* let $s_i$ = sha256(sha256("BIPXXX_INDIVIDUAL_SECRET") ‖ sha256("BIPXXX_INDIVIDUAL_SECRET") ‖ $p$) +* for each `individual_secret_i` generate `reconstructed_secret_i` = +`individual_secret_i` ⊕ `si` +* for each `reconstructed_secret_i` process $payload$ = +decrypt($ciphertext$, $secret$, $nonce$) + +Decryption will succeed if and only if **p** was one of the keys in the +descriptor/wallet policy. + +### Encoding + +The encrypted backup must be encoded as follows: + +`MAGIC` `VERSION` `DERIVATION_PATHS` `INDIVIDUAL_SECRETS` `ENCRYPTION` +`ENCRYPTED_PAYLOAD` + +#### Magic + +`MAGIC`: 6 bytes which are ASCII/UTF-8 representation of **BIPXXX** (TBD). + +#### Version + +`VERSION`: 1 byte unsigned integer representing the format version. The current +specification defines version `0x01`. + +#### Derivation Paths + +Note: the derivation-path vector should not contain duplicates. +Derivation paths are optional; they can be useful to simplify the recovery process +if one has used a non-common derivation path to derive his key.[^derivation-optional] + +[^derivation-optional]: **Why are derivation paths optional?** + When standard derivation paths are used, they are easily discoverable, making + them straightforward to brute-force. Omitting them enhances privacy by reducing + the information shared publicly about the descriptor scheme. + +`DERIVATION_PATH` follows this format: + +`COUNT` +`CHILD_COUNT` `CHILD` `...` `CHILD` +`...` +`CHILD_COUNT` `CHILD` `...` `CHILD` + +`COUNT`: 1-byte unsigned integer (0–255) indicating how many derivation paths are +included. +`CHILD_COUNT`: 1-byte unsigned integer (1–255) indicating how many children are in +the current path. +`CHILD`: 4-byte big-endian unsigned integer representing a child index per BIP-32. + +#### Individual Secrets + +At least one individual secret must be supplied.[^no-fingerprints] + +[^no-fingerprints]: **Why no fingerprints in plaintext encoding?** + Including fingerprints would leak direct information about the descriptor + participants, which compromises privacy. + +The `INDIVIDUAL_SECRETS` section follows this format: + +`COUNT` +`INDIVIDUAL_SECRET` +`INDIVIDUAL_SECRET` + +`COUNT`: 1-byte unsigned integer (1–255) indicating how many secrets are included. +`INDIVIDUAL_SECRET`: 32-byte serialization of the derived individual secret. + +Note: the individual secrets vector should not contain duplicates. Implementations +MAY deduplicate secrets during encoding or parsing. + +#### Encryption + +`ENCRYPTION`: 1-byte unsigned integer identifying the encryption algorithm. + +| Value | Definition | +|:-------|:---------------------------------------| +| 0x00 | Reserved | +| 0x01 | CHACHA20_POLY1305 | + +#### Payload Size Limits + +CHACHA20_POLY1305 (per RFC 8439) supports plaintext up to 2^38 - 64 bytes. +Implementations MAY impose stricter limits based on platform constraints +(e.g., limiting to 2^32 - 1 bytes on 32-bit architectures). + +Implementations MUST reject empty payloads. + +#### Ciphertext + +`CIPHERTEXT` is the encrypted data resulting from encryption of `PAYLOAD` with algorithm +defined in `ENCRYPTION` where `PAYLOAD` is encoded following this format: + +`CONTENT` `PLAINTEXT` + +#### Integer Encodings + +All variable-length integers are encoded as +[compact size](https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer). + +#### Content + +`CONTENT` is a variable length field defining the type of `PLAINTEXT` being encrypted, +it follows this format: + +`TYPE` (`LENGTH`) `DATA` + +`TYPE`: 1-byte unsigned integer identifying how to interpret `DATA`. + +| Value | Definition | +|:-------|:---------------------------------------| +| 0x00 | Reserved | +| 0x01 | BIP Number (big-endian uint16) | +| 0x02 | Vendor-Specific Opaque Tag | + +`LENGTH`: variable-length integer representing the length of `DATA` in bytes. + +For all `TYPE` values except `0x01`, `LENGTH` MUST be present. + +`DATA`: variable-length field whose encoding depends on `TYPE`. + +For `TYPE` values defined above: +- 0x00: parsers MUST reject the payload. +- 0x01: `LENGTH` MUST be omitted and `DATA` is a 2-byte big-endian unsigned integer + representing the BIP number that defines it. +- 0x02: `DATA` MUST be `LENGTH` bytes of opaque, vendor-specific data. + +For all `TYPE` values except `0x01`, parsers MUST reject `CONTENT` if `LENGTH` exceeds +the remaining payload bytes. + +Parsers MUST skip unknown `TYPE` values less than `0x80`, by consuming `LENGTH` bytes +of `DATA`. + +For unknown `TYPE` values greater than or equal to `0x80`, parsers MUST stop parsing +`CONTENT`.[^type-upgrade] + +[^type-upgrade]: **Why the 0x80 threshold?** + The `TYPE >= 0x80` rule means we're not stuck with the current TLV encoding. + It has a nice upgrade property: you can still encode backward compatible stuff + at the start. + +#### Encrypted Payload + +`ENCRYPTED_PAYLOAD` follows this format: + +`NONCE` `LENGTH` `CIPHERTEXT` + +`NONCE`: 12-byte (96-bit) nonce. +`LENGTH`: variable-length integer representing ciphertext length. +`CIPHERTEXT`: variable-length ciphertext. + +Note: `CIPHERTEXT` is followed by the end of the `ENCRYPTED_PAYLOAD` section. +Compliant parsers MUST stop reading after consuming `LENGTH` bytes of ciphertext; +additional trailing bytes are reserved for vendor-specific extensions and MUST +be ignored. + +### Text Representation + +Implementations SHOULD encode and decode the backup using Base64 (RFC 4648).[^psbt-base64] + +[^psbt-base64]: **Why Base64?** + PSBT (BIP174) is commonly exchanged as a Base64 string, so wallet software + likely already supports this representation. + +## Rationale + +See footnotes throughout the specification for design rationale. + +### Future Extensions + +The version field enables possible future enhancements: + +- Additional encryption algorithms +- Support for threshold-based decryption +- Hiding number of participants +- bech32m export + +### Implementation + +- Rust [implementation](https://github.com/pythcoiner/bitcoin-encrypted-backup) + +### Test Vectors + +[key_types.json](./bip-encrypted-backup/test_vectors/keys_types.json) contains test +vectors for key serialisations. +[content_type.json](./bip-encrypted-backup/test_vectors/content_type.json) contains test +vectors for contents types serialisations. +[derivation_path.json](./bip-encrypted-backup/test_vectors/derivation_path.json) contains +test vectors for derivation paths serialisations. +[individual_secrets.json](./bip-encrypted-backup/test_vectors/individual_secrets.json) +contains test vectors for individual secrets serialization. +[encryption_secret.json](./bip-encrypted-backup/test_vectors/encryption_secret.json) +contains test vectors for generation of encryption secret. +[chacha20poly1305_encryption.json](./bip-encrypted-backup/test_vectors/chacha20poly1305_encryption.json) +contains test vectors for ciphertexts generated using CHACHA20-POLY1305. +[encrypted_backup.json](./bip-encrypted-backup/test_vectors/encrypted_backup.json) +contains test vectors for generation of complete encrypted backup. + +## Acknowledgements + +// TBD diff --git a/bip-encrypted-backup/test_vectors/chacha20poly1305_encryption.json b/bip-encrypted-backup/test_vectors/chacha20poly1305_encryption.json new file mode 100644 index 0000000000..625862d177 --- /dev/null +++ b/bip-encrypted-backup/test_vectors/chacha20poly1305_encryption.json @@ -0,0 +1,37 @@ +[ + { + "description": "Basic encryption with short plaintext", + "nonce": "000102030405060708090a0b", + "plaintext": "48656c6c6f", + "secret": "0000000000000000000000000000000000000000000000000000000000000000", + "ciphertext": "7df9cb9a0ac5851cc054b14d05f781127b2b0d31fa" + }, + { + "description": "Empty plaintext should fail", + "nonce": "000102030405060708090a0b", + "plaintext": "", + "secret": "0000000000000000000000000000000000000000000000000000000000000000", + "ciphertext": null + }, + { + "description": "Encryption with zeroed nonce should fail", + "nonce": "000000000000000000000000", + "plaintext": "00000000000000000000000000000000", + "secret": "0000000000000000000000000000000000000000000000000000000000000000", + "ciphertext": null + }, + { + "description": "Encryption with all FFs", + "nonce": "ffffffffffffffffffffffff", + "plaintext": "ffffffffffffffffffffffffffffffff", + "secret": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "ciphertext": "22d8bfc313e141bd692c82cec7785b29a0e5d5014c0d3b2d3a8b00548cd8d221" + }, + { + "description": "Longer plaintext", + "nonce": "0f1e2d3c4b5a69788796a5b4", + "plaintext": "546869732069732061206c6f6e67657220706c61696e746578742074686174207368756c6420626520656e637279707465642070726f7065726c792e", + "secret": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef", + "ciphertext": "2af094190e2b43a02b8dd6bfc25a8833f84f81bc6f690d75f0214e466ef392616c4644bee65118c444a926e1e365b3a7ba0509a5636524eb4e5722f5926938f32e4df79237acb6dd4a6ccbc4" + } +] \ No newline at end of file diff --git a/bip-encrypted-backup/test_vectors/content_type.json b/bip-encrypted-backup/test_vectors/content_type.json new file mode 100644 index 0000000000..f688fd47fc --- /dev/null +++ b/bip-encrypted-backup/test_vectors/content_type.json @@ -0,0 +1,67 @@ +[ + { + "description": "Bip 380", + "valid": true, + "content": "01017c" + }, + { + "description": "Bip 388", + "valid": true, + "content": "010184" + }, + { + "description": "Bip 329", + "valid": true, + "content": "010149" + }, + { + "description": "Bip 999", + "valid": true, + "content": "0103e7" + }, + { + "description": "Bip max", + "valid": true, + "content": "01ffff" + }, + { + "description": "Bip min", + "valid": true, + "content": "010000" + }, + { + "description": "Propietary 00010203", + "valid": true, + "content": "020400010203" + }, + { + "description": "TYPE 0x00 is reserved", + "valid": false, + "content": "00" + }, + { + "description": "Invalid BIP (insufficient bytes)", + "valid": false, + "content": "0100" + }, + { + "description": "Invalid proprietary (missing data)", + "valid": false, + "content": "0201" + }, + { + "description": "Invalid proprietary (LENGTH exceeds payload)", + "valid": false, + "content": "020500" + }, + { + "description": "TYPE >= 0x80 stops parsing", + "valid": false, + "content": "ff" + }, + { + "description": "TYPE >= 0x80 stops parsing", + "valid": false, + "content": "ff000000" + } +] diff --git a/bip-encrypted-backup/test_vectors/derivation_path.json b/bip-encrypted-backup/test_vectors/derivation_path.json new file mode 100644 index 0000000000..05402f1d79 --- /dev/null +++ b/bip-encrypted-backup/test_vectors/derivation_path.json @@ -0,0 +1,146 @@ +[ + { + "description": "Empty derivation paths", + "paths": [], + "expected": "00" + }, + { + "description": "Single path with one child: m/0", + "paths": ["m/0"], + "expected": "010100000000" + }, + { + "description": "Single path with hardened child: m/44'", + "paths": ["m/44'"], + "expected": "01018000002c" + }, + { + "description": "Standard BIP-84 path: m/84'/0'/0'", + "paths": ["m/84'/0'/0'"], + "expected": "0103800000548000000080000000" + }, + { + "description": "Mixed hardened and normal: m/0/1'/2/3'", + "paths": ["m/0/1'/2/3'"], + "expected": "010400000000800000010000000280000003" + }, + { + "description": "Multiple paths: m/0/1'/2/3' and m/84'/0'/0'/2'", + "paths": ["m/0/1'/2/3'", "m/84'/0'/0'/2'"], + "expected": "0204000000008000000100000002800000030480000054800000008000000080000002" + }, + { + "description": "Path with large indices: m/2147483647'/2147483646", + "paths": ["m/2147483647'/2147483646"], + "expected": "0102ffffffff7ffffffe" + }, + { + "description": "Single child path: m/1", + "paths": ["m/1"], + "expected": "010100000001" + }, + { + "description": "Path with max normal index: m/2147483647", + "paths": ["m/2147483647"], + "expected": "01017fffffff" + }, + { + "description": "Path with multiple normal indices: m/0/1/2/3/4", + "paths": ["m/0/1/2/3/4"], + "expected": "01050000000000000001000000020000000300000004" + }, + { + "description": "Path with all hardened: m/0'/1'/2'", + "paths": ["m/0'/1'/2'"], + "expected": "0103800000008000000180000002" + }, + { + "description": "Two different single-child paths: m/0 and m/1", + "paths": ["m/0", "m/1"], + "expected": "0201000000000100000001" + }, + { + "description": "BIP-44 account 0: m/44'/0'/0'", + "paths": ["m/44'/0'/0'"], + "expected": "01038000002c8000000080000000" + }, + { + "description": "BIP-49 account 0: m/49'/0'/0'", + "paths": ["m/49'/0'/0'"], + "expected": "0103800000318000000080000000" + }, + { + "description": "Single path with 255 children (maximum depth, success)", + "paths": ["m/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0"], + "expected": "01ff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + }, + { + "description": "256 paths should fail (exceeds u8::MAX)", + "paths": [ + "m/0", "m/1", "m/2", "m/3", "m/4", "m/5", "m/6", "m/7", "m/8", "m/9", + "m/10", "m/11", "m/12", "m/13", "m/14", "m/15", "m/16", "m/17", "m/18", "m/19", + "m/20", "m/21", "m/22", "m/23", "m/24", "m/25", "m/26", "m/27", "m/28", "m/29", + "m/30", "m/31", "m/32", "m/33", "m/34", "m/35", "m/36", "m/37", "m/38", "m/39", + "m/40", "m/41", "m/42", "m/43", "m/44", "m/45", "m/46", "m/47", "m/48", "m/49", + "m/50", "m/51", "m/52", "m/53", "m/54", "m/55", "m/56", "m/57", "m/58", "m/59", + "m/60", "m/61", "m/62", "m/63", "m/64", "m/65", "m/66", "m/67", "m/68", "m/69", + "m/70", "m/71", "m/72", "m/73", "m/74", "m/75", "m/76", "m/77", "m/78", "m/79", + "m/80", "m/81", "m/82", "m/83", "m/84", "m/85", "m/86", "m/87", "m/88", "m/89", + "m/90", "m/91", "m/92", "m/93", "m/94", "m/95", "m/96", "m/97", "m/98", "m/99", + "m/100", "m/101", "m/102", "m/103", "m/104", "m/105", "m/106", "m/107", "m/108", "m/109", + "m/110", "m/111", "m/112", "m/113", "m/114", "m/115", "m/116", "m/117", "m/118", "m/119", + "m/120", "m/121", "m/122", "m/123", "m/124", "m/125", "m/126", "m/127", "m/128", "m/129", + "m/130", "m/131", "m/132", "m/133", "m/134", "m/135", "m/136", "m/137", "m/138", "m/139", + "m/140", "m/141", "m/142", "m/143", "m/144", "m/145", "m/146", "m/147", "m/148", "m/149", + "m/150", "m/151", "m/152", "m/153", "m/154", "m/155", "m/156", "m/157", "m/158", "m/159", + "m/160", "m/161", "m/162", "m/163", "m/164", "m/165", "m/166", "m/167", "m/168", "m/169", + "m/170", "m/171", "m/172", "m/173", "m/174", "m/175", "m/176", "m/177", "m/178", "m/179", + "m/180", "m/181", "m/182", "m/183", "m/184", "m/185", "m/186", "m/187", "m/188", "m/189", + "m/190", "m/191", "m/192", "m/193", "m/194", "m/195", "m/196", "m/197", "m/198", "m/199", + "m/200", "m/201", "m/202", "m/203", "m/204", "m/205", "m/206", "m/207", "m/208", "m/209", + "m/210", "m/211", "m/212", "m/213", "m/214", "m/215", "m/216", "m/217", "m/218", "m/219", + "m/220", "m/221", "m/222", "m/223", "m/224", "m/225", "m/226", "m/227", "m/228", "m/229", + "m/230", "m/231", "m/232", "m/233", "m/234", "m/235", "m/236", "m/237", "m/238", "m/239", + "m/240", "m/241", "m/242", "m/243", "m/244", "m/245", "m/246", "m/247", "m/248", "m/249", + "m/250", "m/251", "m/252", "m/253", "m/254", "m/255" + ], + "expected": null + }, + { + "description": "Path with 256 children should fail (exceeds u8::MAX)", + "paths": ["m/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0"], + "expected": null + }, + { + "description": "255 paths should succeed (maximum allowed)", + "paths": [ + "m/0", "m/1", "m/2", "m/3", "m/4", "m/5", "m/6", "m/7", "m/8", "m/9", + "m/10", "m/11", "m/12", "m/13", "m/14", "m/15", "m/16", "m/17", "m/18", "m/19", + "m/20", "m/21", "m/22", "m/23", "m/24", "m/25", "m/26", "m/27", "m/28", "m/29", + "m/30", "m/31", "m/32", "m/33", "m/34", "m/35", "m/36", "m/37", "m/38", "m/39", + "m/40", "m/41", "m/42", "m/43", "m/44", "m/45", "m/46", "m/47", "m/48", "m/49", + "m/50", "m/51", "m/52", "m/53", "m/54", "m/55", "m/56", "m/57", "m/58", "m/59", + "m/60", "m/61", "m/62", "m/63", "m/64", "m/65", "m/66", "m/67", "m/68", "m/69", + "m/70", "m/71", "m/72", "m/73", "m/74", "m/75", "m/76", "m/77", "m/78", "m/79", + "m/80", "m/81", "m/82", "m/83", "m/84", "m/85", "m/86", "m/87", "m/88", "m/89", + "m/90", "m/91", "m/92", "m/93", "m/94", "m/95", "m/96", "m/97", "m/98", "m/99", + "m/100", "m/101", "m/102", "m/103", "m/104", "m/105", "m/106", "m/107", "m/108", "m/109", + "m/110", "m/111", "m/112", "m/113", "m/114", "m/115", "m/116", "m/117", "m/118", "m/119", + "m/120", "m/121", "m/122", "m/123", "m/124", "m/125", "m/126", "m/127", "m/128", "m/129", + "m/130", "m/131", "m/132", "m/133", "m/134", "m/135", "m/136", "m/137", "m/138", "m/139", + "m/140", "m/141", "m/142", "m/143", "m/144", "m/145", "m/146", "m/147", "m/148", "m/149", + "m/150", "m/151", "m/152", "m/153", "m/154", "m/155", "m/156", "m/157", "m/158", "m/159", + "m/160", "m/161", "m/162", "m/163", "m/164", "m/165", "m/166", "m/167", "m/168", "m/169", + "m/170", "m/171", "m/172", "m/173", "m/174", "m/175", "m/176", "m/177", "m/178", "m/179", + "m/180", "m/181", "m/182", "m/183", "m/184", "m/185", "m/186", "m/187", "m/188", "m/189", + "m/190", "m/191", "m/192", "m/193", "m/194", "m/195", "m/196", "m/197", "m/198", "m/199", + "m/200", "m/201", "m/202", "m/203", "m/204", "m/205", "m/206", "m/207", "m/208", "m/209", + "m/210", "m/211", "m/212", "m/213", "m/214", "m/215", "m/216", "m/217", "m/218", "m/219", + "m/220", "m/221", "m/222", "m/223", "m/224", "m/225", "m/226", "m/227", "m/228", "m/229", + "m/230", "m/231", "m/232", "m/233", "m/234", "m/235", "m/236", "m/237", "m/238", "m/239", + "m/240", "m/241", "m/242", "m/243", "m/244", "m/245", "m/246", "m/247", "m/248", "m/249", + "m/250", "m/251", "m/252", "m/253", "m/254" + ], + "expected": "ff0100000000010000000101000000020100000003010000000401000000050100000006010000000701000000080100000009010000000a010000000b010000000c010000000d010000000e010000000f0100000010010000001101000000120100000013010000001401000000150100000016010000001701000000180100000019010000001a010000001b010000001c010000001d010000001e010000001f0100000020010000002101000000220100000023010000002401000000250100000026010000002701000000280100000029010000002a010000002b010000002c010000002d010000002e010000002f0100000030010000003101000000320100000033010000003401000000350100000036010000003701000000380100000039010000003a010000003b010000003c010000003d010000003e010000003f0100000040010000004101000000420100000043010000004401000000450100000046010000004701000000480100000049010000004a010000004b010000004c010000004d010000004e010000004f0100000050010000005101000000520100000053010000005401000000550100000056010000005701000000580100000059010000005a010000005b010000005c010000005d010000005e010000005f0100000060010000006101000000620100000063010000006401000000650100000066010000006701000000680100000069010000006a010000006b010000006c010000006d010000006e010000006f0100000070010000007101000000720100000073010000007401000000750100000076010000007701000000780100000079010000007a010000007b010000007c010000007d010000007e010000007f0100000080010000008101000000820100000083010000008401000000850100000086010000008701000000880100000089010000008a010000008b010000008c010000008d010000008e010000008f0100000090010000009101000000920100000093010000009401000000950100000096010000009701000000980100000099010000009a010000009b010000009c010000009d010000009e010000009f01000000a001000000a101000000a201000000a301000000a401000000a501000000a601000000a701000000a801000000a901000000aa01000000ab01000000ac01000000ad01000000ae01000000af01000000b001000000b101000000b201000000b301000000b401000000b501000000b601000000b701000000b801000000b901000000ba01000000bb01000000bc01000000bd01000000be01000000bf01000000c001000000c101000000c201000000c301000000c401000000c501000000c601000000c701000000c801000000c901000000ca01000000cb01000000cc01000000cd01000000ce01000000cf01000000d001000000d101000000d201000000d301000000d401000000d501000000d601000000d701000000d801000000d901000000da01000000db01000000dc01000000dd01000000de01000000df01000000e001000000e101000000e201000000e301000000e401000000e501000000e601000000e701000000e801000000e901000000ea01000000eb01000000ec01000000ed01000000ee01000000ef01000000f001000000f101000000f201000000f301000000f401000000f501000000f601000000f701000000f801000000f901000000fa01000000fb01000000fc01000000fd01000000fe" + } +] diff --git a/bip-encrypted-backup/test_vectors/encrypted_backup.json b/bip-encrypted-backup/test_vectors/encrypted_backup.json new file mode 100644 index 0000000000..327913b2cc --- /dev/null +++ b/bip-encrypted-backup/test_vectors/encrypted_backup.json @@ -0,0 +1,67 @@ +[ + { + "description": "Single key, no derivation paths, BIP380 content", + "version": 1, + "encryption": 1, + "content": "01017c", + "keys": [ + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443" + ], + "derivation_paths": [], + "plaintext": "00", + "nonce": "a1b2c3d4e5f607080910a1b2", + "expected": "424950585858010001ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae0001a1b2c3d4e5f607080910a1b2151d8f44dba6f420976b9343f792b4bd58c06289d234", + "trailing": "deadbeef00ff", + "expected_base64": "QklQWFhYAQAB/zSzQR94Entxyi48xg0P1xNQ7lV8N9cfTYH7kTRhrgABobLD1OX2BwgJEKGyFR2PRNum9CCXa5ND95K0vVjAYonSNA==" + }, + { + "description": "Two keys, 1 derivation paths, BIP380 content", + "version": 1, + "encryption": 1, + "content": "01017c", + "keys": [ + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443", + "0384526253c27c7aef56c7b71a5cd25bebb66dddda437826defc5b2568bde81f07" + ], + "derivation_paths": [ + "m/48'/1'/0'/2'" + ], + "plaintext": "wsh(or_d(pk([9d69155f/48'/1'/0'/2']tpubDDxT9mkZzWwkKwpGT5fY6iiM9muYTPkTx6Eig8dpHR7TChuGGCWYAHVmpW1ciido5RiFWwjzYsF1GZHkEHg2nrYp3zNtx3QQRkznyLhQ77x/<0;1>/*),and_v(v:pkh([9d69155f/48'/1'/0'/2']tpubDDxT9mkZzWwkKwpGT5fY6iiM9muYTPkTx6Eig8dpHR7TChuGGCWYAHVmpW1ciido5RiFWwjzYsF1GZHkEHg2nrYp3zNtx3QQRkznyLhQ77x/<2;3>/*),older(52596))))#gx5f42wh", + "nonce": "0102030405060708090a0b0c", + "expected": "42495058585801010480000030800000018000000080000002024900d4ef9021cb059b8fb35c6de9b6db91949a328527ede0645be237899100bd5e3eb8a36f7bf32e02810c14666476f2b28a15cd499c30f8f98e926639a0765c010102030405060708090a0b0cfd63012f51db36ae620d6522a86e4ce7d9daff2f50826aae70c1d3707d18b8075543da1848ad904b11be465e768d8b1ea74a1b21f21f882262bd0d5f7165991720c1836f1bce2dec7ba3813fc1c0bc6404a0fd6228e239f8bddd398c32f8274f9de0f0b5662854ce900d7d5b14a16605eb2a49d031b98513b73777685693b45b17e08a60e095b66403efcc7036cd82a8d675362eab43bcdecb158e8b0dcca476173345d189c2277dc25b9851b2be92c7ef8b69a565af1ccf9726e322db2b8d5266a5df4296527c716b8ba004fb1408cbd7cc7a18575286e6f03e1793b25eea11223fd6cc7a497d8328997b1eb770fcc8125e60511eefb8232b780d80f1d71e9e937627dfb62cd6c5807b35e7d7bb9aaf18d5a46c6ea271f2be26bd1cc35bb2b70cc1930ad5f472b1bf0d7b3bed3dfe358a69beabdafd6316968c530237f21e1c89662ada34d666735f791db5eb68ee29d2d06f42421ec311d6284f5be9850d63e0cfd6cfe207", + "expected_base64": "QklQWFhYAQEEgAAAMIAAAAGAAAAAgAAAAgJJANTvkCHLBZuPs1xt6bbbkZSaMoUn7eBkW+I3iZEAvV4+uKNve/MuAoEMFGZkdvKyihXNSZww+PmOkmY5oHZcAQECAwQFBgcICQoLDP1jAS9R2zauYg1lIqhuTOfZ2v8vUIJqrnDB03B9GLgHVUPaGEitkEsRvkZedo2LHqdKGyHyH4giYr0NX3FlmRcgwYNvG84t7HujgT/BwLxkBKD9YijiOfi93TmMMvgnT53g8LVmKFTOkA19WxShZgXrKknQMbmFE7c3d2hWk7RbF+CKYOCVtmQD78xwNs2CqNZ1Ni6rQ7zeyxWOiw3MpHYXM0XRicInfcJbmFGyvpLH74tppWWvHM+XJuMi2yuNUmal30KWUnxxa4ugBPsUCMvXzHoYV1KG5vA+F5OyXuoRIj/WzHpJfYMomXset3D8yBJeYFEe77gjK3gNgPHXHp6TdifftizWxYB7NefXu5qvGNWkbG6icfK+Jr0cw1uytwzBkwrV9HKxvw17O+09/jWKab6r2v1jFpaMUwI38h4ciWYq2jTWZnNfeR2162juKdLQb0JCHsMR1ihPW+mFDWPgz9bP4gc=" + }, + { + "description": "Three keys, multiple derivation paths, BIP329 content", + "version": 1, + "encryption": 1, + "content": "010149", + "keys": [ + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443", + "0384526253c27c7aef56c7b71a5cd25bebb66dddda437826defc5b2568bde81f07", + "03c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5" + ], + "derivation_paths": [ + "m/84'/0'/0'", + "m/0/1'/2/3'" + ], + "plaintext": "{\"type\":\"tx\",\"ref\":\"f91d0a8a78462bc59398f2c5d7a84fcff491c26ba54c4833478b202796c8aafd\",\"label\":\"Transaction\",\"origin\":\"wpkh([d34db33f/84'/0'/0'])\"}\n{\"type\":\"addr\",\"ref\":\"bc1q34aq5drpuwy3wgl9lhup9892qp6svr8ldzyy7c\",\"label\":\"Address\"}\n{\"type\":\"pubkey\",\"ref\":\"0283409659355b6d1cc3c32decd5d561abaac86c37a353b52895a5e6c196d6f448\",\"label\":\"Public Key\"}\n{\"type\":\"input\",\"ref\":\"f91d0a8a78462bc59398f2c5d7a84fcff491c26ba54c4833478b202796c8aafd:0\",\"label\":\"Input\"}\n{\"type\":\"output\",\"ref\":\"f91d0a8a78462bc59398f2c5d7a84fcff491c26ba54c4833478b202796c8aafd:1\",\"label\":\"Output\",\"spendable\":false}\n{\"type\":\"xpub\",\"ref\":\"xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8\",\"label\":\"Extended Public Key\"}\n{\"type\":\"tx\",\"ref\":\"f546156d9044844e02b181026a1a407abfca62e7ea1159f87bbeaa77b4286c74\",\"label\":\"Account #1 Transaction\",\"origin\":\"wpkh([d34db33f/84'/0'/1'])\"}", + "nonce": "deadbeefcafebabe12345678", + "expected": "4249505858580102040000000080000001000000028000000303800000548000000080000000032424c7f03a4b1ec573f64738c2a61ac0a9480750f6a641ff8dd1e85acf5b8008331aabbcc51126eeeaf8f870c92bdae98a5688af3a1d9ce71004980b7f6af6e96e5f3aab8b6dfe2f8c09da023a29f797d8333736fb7b7c64958d0ff4109ba93a01deadbeefcafebabe12345678fd9c03f6ebb8e2e9c02c5194e453edd274ec677e0dea5f18cda3e00f7cc4e8c8d4821bda377728eb2f6d2f69eef72070a2a7bc01cc720bb989346102076d475cab2802f1e3766526d2c0bfd257a8e424045cd91356e8789458d06aa055fe2ed0c42fb338b43ae394ae3f9807e1840171965708c89e3b42e68dc4bf84c51bcc8738475e8325e07398753327c1afa6a96032cf73b9387c0f4cb6825adf383c8135b63394b1372fb2752c5297a595099d91c59f25ad6e0d136013ce64d67a53fc88861bf1f558fc2c775644fba1bba9efd23f562f6edb9a2cb476c40cc2ae3f006d3f839a9607271b6eed6f58efcf435eb0cf79c12b5f3c4160f8c3de8e9e311c7698090be2c8e2a3ef702daf88612179e21ee4ac401cab342f7a1d1c141eed8f1a7c60d6dd34324ed6bd07e03ae596d7c04350698ce4592660b841aadf5c2a372b0fc57539094bc0af80febc92aa10578c0b35efd164f4c94217d2e0de72461bdea40d881858eb4b16f1c361fa98cfe0fcbc83787c492238ea745a84265e907c8a07d98852fef62a2a360b75c8b700b24d503a0e54260a1a94e0a980d69aa76e34ba8c304f85e0e7f4cfa3cf3c0c4ac8ddad1548bf20dabd4b316ed53903701677e78d3cfd46980acfe482110be8be64a27ce1dd4d7502338d087e9b86b7ca6144fc81a2a7b806a4e397dfb8d8ad9ea54130d9b46d2cd9002e372094399078e0bce1af9f2dfb5a69a16ec88e53ec9c6f34d784596afcece4d8abd33e937d9ea4ddf170088270cc4f59f68b978368833dc7713b0351da5f690991c841f17c42e7b4d89c35a821e110c4b2a9a1f0cfebd14cfb39d938569614ee62bb488049c6b7ed636dd90cfb00170dd80f4a6e6c9a45a3bed0fa1340ecddb538bb888fdaaa1680d711d6f94297a9f7ed3401cecb25b6779b4ba5415a343a95597cb85b074d8e19def182d8581fb7b4bc716ba887af1bd51a10c699f6ddfdb5439c7eac02d9220a0417489a79bbc6da4d10325317a6630da9303c433f261e0d36f977cea8113c7e4581e5d27f6607be0f9f7058fd6730d64377b7d1e70f4858974896e3ae9fbde9fb6eb66be4d0c36544cf8cfb80166875f1672f5aa4991951248414a54457e3f3bea0a2953d27de6d0a299cc06471d9f331ace87937b96547e7bcfa7ae972fd9e08cfa69fae42fe786f1cb1d5ee0bc3bbd9277f38b290eb2033f39dc65bfc963c60d3f01d493ab7546cd72504303f68bd5e376d2b6a2dc59d4c3cfbef490d1cdcb73065f756620528bb0bd92301a26f53f0c1ae61962416c746d1b3b38fd202", + "expected_base64": "QklQWFhYAQIEAAAAAIAAAAEAAAACgAAAAwOAAABUgAAAAIAAAAADJCTH8DpLHsVz9kc4wqYawKlIB1D2pkH/jdHoWs9bgAgzGqu8xREm7ur4+HDJK9rpilaIrzodnOcQBJgLf2r26W5fOquLbf4vjAnaAjop95fYMzc2+3t8ZJWND/QQm6k6Ad6tvu/K/rq+EjRWeP2cA/bruOLpwCxRlORT7dJ07Gd+DepfGM2j4A98xOjI1IIb2jd3KOsvbS9p7vcgcKKnvAHMcgu5iTRhAgdtR1yrKALx43ZlJtLAv9JXqOQkBFzZE1boeJRY0GqgVf4u0MQvszi0OuOUrj+YB+GEAXGWVwjInjtC5o3Ev4TFG8yHOEdegyXgc5h1MyfBr6apYDLPc7k4fA9MtoJa3zg8gTW2M5SxNy+ydSxSl6WVCZ2RxZ8lrW4NE2ATzmTWelP8iIYb8fVY/Cx3VkT7obup79I/Vi9u25ostHbEDMKuPwBtP4OalgcnG27tb1jvz0NesM95wStfPEFg+MPejp4xHHaYCQviyOKj73Atr4hhIXniHuSsQByrNC96HRwUHu2PGnxg1t00Mk7WvQfgOuWW18BDUGmM5FkmYLhBqt9cKjcrD8V1OQlLwK+A/rySqhBXjAs179Fk9MlCF9Lg3nJGG96kDYgYWOtLFvHDYfqYz+D8vIN4fEkiOOp0WoQmXpB8igfZiFL+9ioqNgt1yLcAsk1QOg5UJgoalOCpgNaap240uowwT4Xg5/TPo888DErI3a0VSL8g2r1LMW7VOQNwFnfnjTz9RpgKz+SCEQvovmSifOHdTXUCM40IfpuGt8phRPyBoqe4BqTjl9+42K2epUEw2bRtLNkALjcglDmQeOC84a+fLftaaaFuyI5T7JxvNNeEWWr87OTYq9M+k32epN3xcAiCcMxPWfaLl4Nogz3HcTsDUdpfaQmRyEHxfELntNicNagh4RDEsqmh8M/r0Uz7Odk4VpYU7mK7SIBJxrftY23ZDPsAFw3YD0pubJpFo77Q+hNA7N21OLuIj9qqFoDXEdb5Qpep9+00Ac7LJbZ3m0ulQVo0OpVZfLhbB02OGd7xgthYH7e0vHFrqIevG9UaEMaZ9t39tUOcfqwC2SIKBBdImnm7xtpNEDJTF6ZjDakwPEM/Jh4NNvl3zqgRPH5FgeXSf2YHvg+fcFj9ZzDWQ3e30ecPSFiXSJbjrp+96ftutmvk0MNlRM+M+4AWaHXxZy9apJkZUSSEFKVEV+PzvqCilT0n3m0KKZzAZHHZ8zGs6Hk3uWVH57z6euly/Z4Iz6afrkL+eG8csdXuC8O72Sd/OLKQ6yAz853GW/yWPGDT8B1JOrdUbNclBDA/aL1eN20rai3FnUw8++9JDRzctzBl91ZiBSi7C9kjAaJvU/DBrmGWJBbHRtGzs4/SAg==" + }, + { + "description": "Single key, proprietary content (3 bytes)", + "version": 1, + "encryption": 1, + "content": "0204deadbeef", + "keys": [ + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443" + ], + "derivation_paths": [], + "plaintext": "706c61696e74657874", + "nonce": "000102030405060708090a0b", + "expected": "424950585858010001ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae0001000102030405060708090a0b2803da142accb6215cecfe50629224496c4d35cfc7ee64e906e77cc3398689748c325907c7d5dafef3", + "expected_base64": "QklQWFhYAQAB/zSzQR94Entxyi48xg0P1xNQ7lV8N9cfTYH7kTRhrgABAAECAwQFBgcICQoLKAPaFCrMtiFc7P5QYpIkSWxNNc/H7mTpBud8wzmGiXSMMlkHx9Xa/vM=" + } +] \ No newline at end of file diff --git a/bip-encrypted-backup/test_vectors/encryption_secret.json b/bip-encrypted-backup/test_vectors/encryption_secret.json new file mode 100644 index 0000000000..a04b37af93 --- /dev/null +++ b/bip-encrypted-backup/test_vectors/encryption_secret.json @@ -0,0 +1,89 @@ +[ + { + "description": "Single public key", + "keys": [ + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443" + ], + "decryption_secret": "a37acb446622cf11ffe44e1f17892d7b330b721b992513f680a52b128fb181b1", + "individual_secrets": [ + "ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae00" + ] + }, + { + "description": "Two public keys", + "keys": [ + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443", + "0384526253c27c7aef56c7b71a5cd25bebb66dddda437826defc5b2568bde81f07" + ], + "decryption_secret": "154eaceae97b166f15a1d37fbc6d9477b1cf067c60352909a97f32b432412f0c", + "individual_secrets": [ + "5e3eb8a36f7bf32e02810c14666476f2b28a15cd499c30f8f98e926639a0765c", + "4900d4ef9021cb059b8fb35c6de9b6db91949a328527ede0645be237899100bd" + ] + }, + { + "description": "Three public keys", + "keys": [ + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443", + "0384526253c27c7aef56c7b71a5cd25bebb66dddda437826defc5b2568bde81f07", + "03c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5" + ], + "decryption_secret": "6f54d3b9bc4bfb8464d6985318aff845aa0d14e1df0f580edd204888c4bad958", + "individual_secrets": [ + "2424c7f03a4b1ec573f64738c2a61ac0a9480750f6a641ff8dd1e85acf5b8008", + "6e5f3aab8b6dfe2f8c09da023a29f797d8333736fb7b7c64958d0ff4109ba93a", + "331aabbcc51126eeeaf8f870c92bdae98a5688af3a1d9ce71004980b7f6af6e9" + ] + }, + { + "description": "Three public keys bis (different sorting)", + "keys": [ + "03c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5", + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443", + "0384526253c27c7aef56c7b71a5cd25bebb66dddda437826defc5b2568bde81f07" + ], + "decryption_secret": "6f54d3b9bc4bfb8464d6985318aff845aa0d14e1df0f580edd204888c4bad958", + "individual_secrets": [ + "2424c7f03a4b1ec573f64738c2a61ac0a9480750f6a641ff8dd1e85acf5b8008", + "6e5f3aab8b6dfe2f8c09da023a29f797d8333736fb7b7c64958d0ff4109ba93a", + "331aabbcc51126eeeaf8f870c92bdae98a5688af3a1d9ce71004980b7f6af6e9" + ] + }, + { + "description": "Three public keys ter (different sorting)", + "keys": [ + "0384526253c27c7aef56c7b71a5cd25bebb66dddda437826defc5b2568bde81f07", + "03c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5", + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443" + ], + "decryption_secret": "6f54d3b9bc4bfb8464d6985318aff845aa0d14e1df0f580edd204888c4bad958", + "individual_secrets": [ + "2424c7f03a4b1ec573f64738c2a61ac0a9480750f6a641ff8dd1e85acf5b8008", + "6e5f3aab8b6dfe2f8c09da023a29f797d8333736fb7b7c64958d0ff4109ba93a", + "331aabbcc51126eeeaf8f870c92bdae98a5688af3a1d9ce71004980b7f6af6e9" + ] + }, + { + "description": "Keys processed in sorted order", + "keys": [ + "0384526253c27c7aef56c7b71a5cd25bebb66dddda437826defc5b2568bde81f07", + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443" + ], + "decryption_secret": "154eaceae97b166f15a1d37fbc6d9477b1cf067c60352909a97f32b432412f0c", + "individual_secrets": [ + "5e3eb8a36f7bf32e02810c14666476f2b28a15cd499c30f8f98e926639a0765c", + "4900d4ef9021cb059b8fb35c6de9b6db91949a328527ede0645be237899100bd" + ] + }, + { + "description": "Duplicate keys should be handled", + "keys": [ + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443", + "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443" + ], + "decryption_secret": "a37acb446622cf11ffe44e1f17892d7b330b721b992513f680a52b128fb181b1", + "individual_secrets": [ + "ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae00" + ] + } +] \ No newline at end of file diff --git a/bip-encrypted-backup/test_vectors/individual_secrets.json b/bip-encrypted-backup/test_vectors/individual_secrets.json new file mode 100644 index 0000000000..cfe0ee786d --- /dev/null +++ b/bip-encrypted-backup/test_vectors/individual_secrets.json @@ -0,0 +1,554 @@ +[ + { + "description": "Single secret", + "secrets": [ + "0101010101010101010101010101010101010101010101010101010101010101" + ], + "expected": "010101010101010101010101010101010101010101010101010101010101010101" + }, + { + "description": "Two different secrets", + "secrets": [ + "0101010101010101010101010101010101010101010101010101010101010101", + "0202020202020202020202020202020202020202020202020202020202020202" + ], + "expected": "0201010101010101010101010101010101010101010101010101010101010101010202020202020202020202020202020202020202020202020202020202020202" + }, + { + "description": "Three secrets with different patterns", + "secrets": [ + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "5555555555555555555555555555555555555555555555555555555555555555", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "expected": "035555555555555555555555555555555555555555555555555555555555555555aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + }, + { + "description": "Empty secrets should fail", + "secrets": [], + "expected": null + }, + { + "description": "256 distinct non-zero secrets should fail (exceeds u8::MAX)", + "secrets": [ + "0000000000000000000000000000000000000000000000000000000000000001", + "0000000000000000000000000000000000000000000000000000000000000002", + "0000000000000000000000000000000000000000000000000000000000000003", + "0000000000000000000000000000000000000000000000000000000000000004", + "0000000000000000000000000000000000000000000000000000000000000005", + "0000000000000000000000000000000000000000000000000000000000000006", + "0000000000000000000000000000000000000000000000000000000000000007", + "0000000000000000000000000000000000000000000000000000000000000008", + "0000000000000000000000000000000000000000000000000000000000000009", + "000000000000000000000000000000000000000000000000000000000000000a", + "000000000000000000000000000000000000000000000000000000000000000b", + "000000000000000000000000000000000000000000000000000000000000000c", + "000000000000000000000000000000000000000000000000000000000000000d", + "000000000000000000000000000000000000000000000000000000000000000e", + "000000000000000000000000000000000000000000000000000000000000000f", + "0000000000000000000000000000000000000000000000000000000000000010", + "0000000000000000000000000000000000000000000000000000000000000011", + "0000000000000000000000000000000000000000000000000000000000000012", + "0000000000000000000000000000000000000000000000000000000000000013", + "0000000000000000000000000000000000000000000000000000000000000014", + "0000000000000000000000000000000000000000000000000000000000000015", + "0000000000000000000000000000000000000000000000000000000000000016", + "0000000000000000000000000000000000000000000000000000000000000017", + "0000000000000000000000000000000000000000000000000000000000000018", + "0000000000000000000000000000000000000000000000000000000000000019", + "000000000000000000000000000000000000000000000000000000000000001a", + "000000000000000000000000000000000000000000000000000000000000001b", + "000000000000000000000000000000000000000000000000000000000000001c", + "000000000000000000000000000000000000000000000000000000000000001d", + "000000000000000000000000000000000000000000000000000000000000001e", + "000000000000000000000000000000000000000000000000000000000000001f", + "0000000000000000000000000000000000000000000000000000000000000020", + "0000000000000000000000000000000000000000000000000000000000000021", + "0000000000000000000000000000000000000000000000000000000000000022", + "0000000000000000000000000000000000000000000000000000000000000023", + "0000000000000000000000000000000000000000000000000000000000000024", + "0000000000000000000000000000000000000000000000000000000000000025", + "0000000000000000000000000000000000000000000000000000000000000026", + "0000000000000000000000000000000000000000000000000000000000000027", + "0000000000000000000000000000000000000000000000000000000000000028", + "0000000000000000000000000000000000000000000000000000000000000029", + "000000000000000000000000000000000000000000000000000000000000002a", + "000000000000000000000000000000000000000000000000000000000000002b", + "000000000000000000000000000000000000000000000000000000000000002c", + "000000000000000000000000000000000000000000000000000000000000002d", + "000000000000000000000000000000000000000000000000000000000000002e", + "000000000000000000000000000000000000000000000000000000000000002f", + "0000000000000000000000000000000000000000000000000000000000000030", + "0000000000000000000000000000000000000000000000000000000000000031", + "0000000000000000000000000000000000000000000000000000000000000032", + "0000000000000000000000000000000000000000000000000000000000000033", + "0000000000000000000000000000000000000000000000000000000000000034", + "0000000000000000000000000000000000000000000000000000000000000035", + "0000000000000000000000000000000000000000000000000000000000000036", + "0000000000000000000000000000000000000000000000000000000000000037", + "0000000000000000000000000000000000000000000000000000000000000038", + "0000000000000000000000000000000000000000000000000000000000000039", + "000000000000000000000000000000000000000000000000000000000000003a", + "000000000000000000000000000000000000000000000000000000000000003b", + "000000000000000000000000000000000000000000000000000000000000003c", + "000000000000000000000000000000000000000000000000000000000000003d", + "000000000000000000000000000000000000000000000000000000000000003e", + "000000000000000000000000000000000000000000000000000000000000003f", + "0000000000000000000000000000000000000000000000000000000000000040", + "0000000000000000000000000000000000000000000000000000000000000041", + "0000000000000000000000000000000000000000000000000000000000000042", + "0000000000000000000000000000000000000000000000000000000000000043", + "0000000000000000000000000000000000000000000000000000000000000044", + "0000000000000000000000000000000000000000000000000000000000000045", + "0000000000000000000000000000000000000000000000000000000000000046", + "0000000000000000000000000000000000000000000000000000000000000047", + "0000000000000000000000000000000000000000000000000000000000000048", + "0000000000000000000000000000000000000000000000000000000000000049", + "000000000000000000000000000000000000000000000000000000000000004a", + "000000000000000000000000000000000000000000000000000000000000004b", + "000000000000000000000000000000000000000000000000000000000000004c", + "000000000000000000000000000000000000000000000000000000000000004d", + "000000000000000000000000000000000000000000000000000000000000004e", + "000000000000000000000000000000000000000000000000000000000000004f", + "0000000000000000000000000000000000000000000000000000000000000050", + "0000000000000000000000000000000000000000000000000000000000000051", + "0000000000000000000000000000000000000000000000000000000000000052", + "0000000000000000000000000000000000000000000000000000000000000053", + "0000000000000000000000000000000000000000000000000000000000000054", + "0000000000000000000000000000000000000000000000000000000000000055", + "0000000000000000000000000000000000000000000000000000000000000056", + "0000000000000000000000000000000000000000000000000000000000000057", + "0000000000000000000000000000000000000000000000000000000000000058", + "0000000000000000000000000000000000000000000000000000000000000059", + "000000000000000000000000000000000000000000000000000000000000005a", + "000000000000000000000000000000000000000000000000000000000000005b", + "000000000000000000000000000000000000000000000000000000000000005c", + "000000000000000000000000000000000000000000000000000000000000005d", + "000000000000000000000000000000000000000000000000000000000000005e", + "000000000000000000000000000000000000000000000000000000000000005f", + "0000000000000000000000000000000000000000000000000000000000000060", + "0000000000000000000000000000000000000000000000000000000000000061", + "0000000000000000000000000000000000000000000000000000000000000062", + "0000000000000000000000000000000000000000000000000000000000000063", + "0000000000000000000000000000000000000000000000000000000000000064", + "0000000000000000000000000000000000000000000000000000000000000065", + "0000000000000000000000000000000000000000000000000000000000000066", + "0000000000000000000000000000000000000000000000000000000000000067", + "0000000000000000000000000000000000000000000000000000000000000068", + "0000000000000000000000000000000000000000000000000000000000000069", + "000000000000000000000000000000000000000000000000000000000000006a", + "000000000000000000000000000000000000000000000000000000000000006b", + "000000000000000000000000000000000000000000000000000000000000006c", + "000000000000000000000000000000000000000000000000000000000000006d", + "000000000000000000000000000000000000000000000000000000000000006e", + "000000000000000000000000000000000000000000000000000000000000006f", + "0000000000000000000000000000000000000000000000000000000000000070", + "0000000000000000000000000000000000000000000000000000000000000071", + "0000000000000000000000000000000000000000000000000000000000000072", + "0000000000000000000000000000000000000000000000000000000000000073", + "0000000000000000000000000000000000000000000000000000000000000074", + "0000000000000000000000000000000000000000000000000000000000000075", + "0000000000000000000000000000000000000000000000000000000000000076", + "0000000000000000000000000000000000000000000000000000000000000077", + "0000000000000000000000000000000000000000000000000000000000000078", + "0000000000000000000000000000000000000000000000000000000000000079", + "000000000000000000000000000000000000000000000000000000000000007a", + "000000000000000000000000000000000000000000000000000000000000007b", + "000000000000000000000000000000000000000000000000000000000000007c", + "000000000000000000000000000000000000000000000000000000000000007d", + "000000000000000000000000000000000000000000000000000000000000007e", + "000000000000000000000000000000000000000000000000000000000000007f", + "0000000000000000000000000000000000000000000000000000000000000080", + "0000000000000000000000000000000000000000000000000000000000000081", + "0000000000000000000000000000000000000000000000000000000000000082", + "0000000000000000000000000000000000000000000000000000000000000083", + "0000000000000000000000000000000000000000000000000000000000000084", + "0000000000000000000000000000000000000000000000000000000000000085", + "0000000000000000000000000000000000000000000000000000000000000086", + "0000000000000000000000000000000000000000000000000000000000000087", + "0000000000000000000000000000000000000000000000000000000000000088", + "0000000000000000000000000000000000000000000000000000000000000089", + "000000000000000000000000000000000000000000000000000000000000008a", + "000000000000000000000000000000000000000000000000000000000000008b", + "000000000000000000000000000000000000000000000000000000000000008c", + "000000000000000000000000000000000000000000000000000000000000008d", + "000000000000000000000000000000000000000000000000000000000000008e", + "000000000000000000000000000000000000000000000000000000000000008f", + "0000000000000000000000000000000000000000000000000000000000000090", + "0000000000000000000000000000000000000000000000000000000000000091", + "0000000000000000000000000000000000000000000000000000000000000092", + "0000000000000000000000000000000000000000000000000000000000000093", + "0000000000000000000000000000000000000000000000000000000000000094", + "0000000000000000000000000000000000000000000000000000000000000095", + "0000000000000000000000000000000000000000000000000000000000000096", + "0000000000000000000000000000000000000000000000000000000000000097", + "0000000000000000000000000000000000000000000000000000000000000098", + "0000000000000000000000000000000000000000000000000000000000000099", + "000000000000000000000000000000000000000000000000000000000000009a", + "000000000000000000000000000000000000000000000000000000000000009b", + "000000000000000000000000000000000000000000000000000000000000009c", + "000000000000000000000000000000000000000000000000000000000000009d", + "000000000000000000000000000000000000000000000000000000000000009e", + "000000000000000000000000000000000000000000000000000000000000009f", + "00000000000000000000000000000000000000000000000000000000000000a0", + "00000000000000000000000000000000000000000000000000000000000000a1", + "00000000000000000000000000000000000000000000000000000000000000a2", + "00000000000000000000000000000000000000000000000000000000000000a3", + "00000000000000000000000000000000000000000000000000000000000000a4", + "00000000000000000000000000000000000000000000000000000000000000a5", + "00000000000000000000000000000000000000000000000000000000000000a6", + "00000000000000000000000000000000000000000000000000000000000000a7", + "00000000000000000000000000000000000000000000000000000000000000a8", + "00000000000000000000000000000000000000000000000000000000000000a9", + "00000000000000000000000000000000000000000000000000000000000000aa", + "00000000000000000000000000000000000000000000000000000000000000ab", + "00000000000000000000000000000000000000000000000000000000000000ac", + "00000000000000000000000000000000000000000000000000000000000000ad", + "00000000000000000000000000000000000000000000000000000000000000ae", + "00000000000000000000000000000000000000000000000000000000000000af", + "00000000000000000000000000000000000000000000000000000000000000b0", + "00000000000000000000000000000000000000000000000000000000000000b1", + "00000000000000000000000000000000000000000000000000000000000000b2", + "00000000000000000000000000000000000000000000000000000000000000b3", + "00000000000000000000000000000000000000000000000000000000000000b4", + "00000000000000000000000000000000000000000000000000000000000000b5", + "00000000000000000000000000000000000000000000000000000000000000b6", + "00000000000000000000000000000000000000000000000000000000000000b7", + "00000000000000000000000000000000000000000000000000000000000000b8", + "00000000000000000000000000000000000000000000000000000000000000b9", + "00000000000000000000000000000000000000000000000000000000000000ba", + "00000000000000000000000000000000000000000000000000000000000000bb", + "00000000000000000000000000000000000000000000000000000000000000bc", + "00000000000000000000000000000000000000000000000000000000000000bd", + "00000000000000000000000000000000000000000000000000000000000000be", + "00000000000000000000000000000000000000000000000000000000000000bf", + "00000000000000000000000000000000000000000000000000000000000000c0", + "00000000000000000000000000000000000000000000000000000000000000c1", + "00000000000000000000000000000000000000000000000000000000000000c2", + "00000000000000000000000000000000000000000000000000000000000000c3", + "00000000000000000000000000000000000000000000000000000000000000c4", + "00000000000000000000000000000000000000000000000000000000000000c5", + "00000000000000000000000000000000000000000000000000000000000000c6", + "00000000000000000000000000000000000000000000000000000000000000c7", + "00000000000000000000000000000000000000000000000000000000000000c8", + "00000000000000000000000000000000000000000000000000000000000000c9", + "00000000000000000000000000000000000000000000000000000000000000ca", + "00000000000000000000000000000000000000000000000000000000000000cb", + "00000000000000000000000000000000000000000000000000000000000000cc", + "00000000000000000000000000000000000000000000000000000000000000cd", + "00000000000000000000000000000000000000000000000000000000000000ce", + "00000000000000000000000000000000000000000000000000000000000000cf", + "00000000000000000000000000000000000000000000000000000000000000d0", + "00000000000000000000000000000000000000000000000000000000000000d1", + "00000000000000000000000000000000000000000000000000000000000000d2", + "00000000000000000000000000000000000000000000000000000000000000d3", + "00000000000000000000000000000000000000000000000000000000000000d4", + "00000000000000000000000000000000000000000000000000000000000000d5", + "00000000000000000000000000000000000000000000000000000000000000d6", + "00000000000000000000000000000000000000000000000000000000000000d7", + "00000000000000000000000000000000000000000000000000000000000000d8", + "00000000000000000000000000000000000000000000000000000000000000d9", + "00000000000000000000000000000000000000000000000000000000000000da", + "00000000000000000000000000000000000000000000000000000000000000db", + "00000000000000000000000000000000000000000000000000000000000000dc", + "00000000000000000000000000000000000000000000000000000000000000dd", + "00000000000000000000000000000000000000000000000000000000000000de", + "00000000000000000000000000000000000000000000000000000000000000df", + "00000000000000000000000000000000000000000000000000000000000000e0", + "00000000000000000000000000000000000000000000000000000000000000e1", + "00000000000000000000000000000000000000000000000000000000000000e2", + "00000000000000000000000000000000000000000000000000000000000000e3", + "00000000000000000000000000000000000000000000000000000000000000e4", + "00000000000000000000000000000000000000000000000000000000000000e5", + "00000000000000000000000000000000000000000000000000000000000000e6", + "00000000000000000000000000000000000000000000000000000000000000e7", + "00000000000000000000000000000000000000000000000000000000000000e8", + "00000000000000000000000000000000000000000000000000000000000000e9", + "00000000000000000000000000000000000000000000000000000000000000ea", + "00000000000000000000000000000000000000000000000000000000000000eb", + "00000000000000000000000000000000000000000000000000000000000000ec", + "00000000000000000000000000000000000000000000000000000000000000ed", + "00000000000000000000000000000000000000000000000000000000000000ee", + "00000000000000000000000000000000000000000000000000000000000000ef", + "00000000000000000000000000000000000000000000000000000000000000f0", + "00000000000000000000000000000000000000000000000000000000000000f1", + "00000000000000000000000000000000000000000000000000000000000000f2", + "00000000000000000000000000000000000000000000000000000000000000f3", + "00000000000000000000000000000000000000000000000000000000000000f4", + "00000000000000000000000000000000000000000000000000000000000000f5", + "00000000000000000000000000000000000000000000000000000000000000f6", + "00000000000000000000000000000000000000000000000000000000000000f7", + "00000000000000000000000000000000000000000000000000000000000000f8", + "00000000000000000000000000000000000000000000000000000000000000f9", + "00000000000000000000000000000000000000000000000000000000000000fa", + "00000000000000000000000000000000000000000000000000000000000000fb", + "00000000000000000000000000000000000000000000000000000000000000fc", + "00000000000000000000000000000000000000000000000000000000000000fd", + "00000000000000000000000000000000000000000000000000000000000000fe", + "00000000000000000000000000000000000000000000000000000000000000ff", + "0000000000000000000000000000000000000000000000000000000000000100" + ], + "expected": null + }, + { + "description": "255 distinct non-zero secrets should pass", + "secrets": [ + "0000000000000000000000000000000000000000000000000000000000000001", + "0000000000000000000000000000000000000000000000000000000000000002", + "0000000000000000000000000000000000000000000000000000000000000003", + "0000000000000000000000000000000000000000000000000000000000000004", + "0000000000000000000000000000000000000000000000000000000000000005", + "0000000000000000000000000000000000000000000000000000000000000006", + "0000000000000000000000000000000000000000000000000000000000000007", + "0000000000000000000000000000000000000000000000000000000000000008", + "0000000000000000000000000000000000000000000000000000000000000009", + "000000000000000000000000000000000000000000000000000000000000000a", + "000000000000000000000000000000000000000000000000000000000000000b", + "000000000000000000000000000000000000000000000000000000000000000c", + "000000000000000000000000000000000000000000000000000000000000000d", + "000000000000000000000000000000000000000000000000000000000000000e", + "000000000000000000000000000000000000000000000000000000000000000f", + "0000000000000000000000000000000000000000000000000000000000000010", + "0000000000000000000000000000000000000000000000000000000000000011", + "0000000000000000000000000000000000000000000000000000000000000012", + "0000000000000000000000000000000000000000000000000000000000000013", + "0000000000000000000000000000000000000000000000000000000000000014", + "0000000000000000000000000000000000000000000000000000000000000015", + "0000000000000000000000000000000000000000000000000000000000000016", + "0000000000000000000000000000000000000000000000000000000000000017", + "0000000000000000000000000000000000000000000000000000000000000018", + "0000000000000000000000000000000000000000000000000000000000000019", + "000000000000000000000000000000000000000000000000000000000000001a", + "000000000000000000000000000000000000000000000000000000000000001b", + "000000000000000000000000000000000000000000000000000000000000001c", + "000000000000000000000000000000000000000000000000000000000000001d", + "000000000000000000000000000000000000000000000000000000000000001e", + "000000000000000000000000000000000000000000000000000000000000001f", + "0000000000000000000000000000000000000000000000000000000000000020", + "0000000000000000000000000000000000000000000000000000000000000021", + "0000000000000000000000000000000000000000000000000000000000000022", + "0000000000000000000000000000000000000000000000000000000000000023", + "0000000000000000000000000000000000000000000000000000000000000024", + "0000000000000000000000000000000000000000000000000000000000000025", + "0000000000000000000000000000000000000000000000000000000000000026", + "0000000000000000000000000000000000000000000000000000000000000027", + "0000000000000000000000000000000000000000000000000000000000000028", + "0000000000000000000000000000000000000000000000000000000000000029", + "000000000000000000000000000000000000000000000000000000000000002a", + "000000000000000000000000000000000000000000000000000000000000002b", + "000000000000000000000000000000000000000000000000000000000000002c", + "000000000000000000000000000000000000000000000000000000000000002d", + "000000000000000000000000000000000000000000000000000000000000002e", + "000000000000000000000000000000000000000000000000000000000000002f", + "0000000000000000000000000000000000000000000000000000000000000030", + "0000000000000000000000000000000000000000000000000000000000000031", + "0000000000000000000000000000000000000000000000000000000000000032", + "0000000000000000000000000000000000000000000000000000000000000033", + "0000000000000000000000000000000000000000000000000000000000000034", + "0000000000000000000000000000000000000000000000000000000000000035", + "0000000000000000000000000000000000000000000000000000000000000036", + "0000000000000000000000000000000000000000000000000000000000000037", + "0000000000000000000000000000000000000000000000000000000000000038", + "0000000000000000000000000000000000000000000000000000000000000039", + "000000000000000000000000000000000000000000000000000000000000003a", + "000000000000000000000000000000000000000000000000000000000000003b", + "000000000000000000000000000000000000000000000000000000000000003c", + "000000000000000000000000000000000000000000000000000000000000003d", + "000000000000000000000000000000000000000000000000000000000000003e", + "000000000000000000000000000000000000000000000000000000000000003f", + "0000000000000000000000000000000000000000000000000000000000000040", + "0000000000000000000000000000000000000000000000000000000000000041", + "0000000000000000000000000000000000000000000000000000000000000042", + "0000000000000000000000000000000000000000000000000000000000000043", + "0000000000000000000000000000000000000000000000000000000000000044", + "0000000000000000000000000000000000000000000000000000000000000045", + "0000000000000000000000000000000000000000000000000000000000000046", + "0000000000000000000000000000000000000000000000000000000000000047", + "0000000000000000000000000000000000000000000000000000000000000048", + "0000000000000000000000000000000000000000000000000000000000000049", + "000000000000000000000000000000000000000000000000000000000000004a", + "000000000000000000000000000000000000000000000000000000000000004b", + "000000000000000000000000000000000000000000000000000000000000004c", + "000000000000000000000000000000000000000000000000000000000000004d", + "000000000000000000000000000000000000000000000000000000000000004e", + "000000000000000000000000000000000000000000000000000000000000004f", + "0000000000000000000000000000000000000000000000000000000000000050", + "0000000000000000000000000000000000000000000000000000000000000051", + "0000000000000000000000000000000000000000000000000000000000000052", + "0000000000000000000000000000000000000000000000000000000000000053", + "0000000000000000000000000000000000000000000000000000000000000054", + "0000000000000000000000000000000000000000000000000000000000000055", + "0000000000000000000000000000000000000000000000000000000000000056", + "0000000000000000000000000000000000000000000000000000000000000057", + "0000000000000000000000000000000000000000000000000000000000000058", + "0000000000000000000000000000000000000000000000000000000000000059", + "000000000000000000000000000000000000000000000000000000000000005a", + "000000000000000000000000000000000000000000000000000000000000005b", + "000000000000000000000000000000000000000000000000000000000000005c", + "000000000000000000000000000000000000000000000000000000000000005d", + "000000000000000000000000000000000000000000000000000000000000005e", + "000000000000000000000000000000000000000000000000000000000000005f", + "0000000000000000000000000000000000000000000000000000000000000060", + "0000000000000000000000000000000000000000000000000000000000000061", + "0000000000000000000000000000000000000000000000000000000000000062", + "0000000000000000000000000000000000000000000000000000000000000063", + "0000000000000000000000000000000000000000000000000000000000000064", + "0000000000000000000000000000000000000000000000000000000000000065", + "0000000000000000000000000000000000000000000000000000000000000066", + "0000000000000000000000000000000000000000000000000000000000000067", + "0000000000000000000000000000000000000000000000000000000000000068", + "0000000000000000000000000000000000000000000000000000000000000069", + "000000000000000000000000000000000000000000000000000000000000006a", + "000000000000000000000000000000000000000000000000000000000000006b", + "000000000000000000000000000000000000000000000000000000000000006c", + "000000000000000000000000000000000000000000000000000000000000006d", + "000000000000000000000000000000000000000000000000000000000000006e", + "000000000000000000000000000000000000000000000000000000000000006f", + "0000000000000000000000000000000000000000000000000000000000000070", + "0000000000000000000000000000000000000000000000000000000000000071", + "0000000000000000000000000000000000000000000000000000000000000072", + "0000000000000000000000000000000000000000000000000000000000000073", + "0000000000000000000000000000000000000000000000000000000000000074", + "0000000000000000000000000000000000000000000000000000000000000075", + "0000000000000000000000000000000000000000000000000000000000000076", + "0000000000000000000000000000000000000000000000000000000000000077", + "0000000000000000000000000000000000000000000000000000000000000078", + "0000000000000000000000000000000000000000000000000000000000000079", + "000000000000000000000000000000000000000000000000000000000000007a", + "000000000000000000000000000000000000000000000000000000000000007b", + "000000000000000000000000000000000000000000000000000000000000007c", + "000000000000000000000000000000000000000000000000000000000000007d", + "000000000000000000000000000000000000000000000000000000000000007e", + "000000000000000000000000000000000000000000000000000000000000007f", + "0000000000000000000000000000000000000000000000000000000000000080", + "0000000000000000000000000000000000000000000000000000000000000081", + "0000000000000000000000000000000000000000000000000000000000000082", + "0000000000000000000000000000000000000000000000000000000000000083", + "0000000000000000000000000000000000000000000000000000000000000084", + "0000000000000000000000000000000000000000000000000000000000000085", + "0000000000000000000000000000000000000000000000000000000000000086", + "0000000000000000000000000000000000000000000000000000000000000087", + "0000000000000000000000000000000000000000000000000000000000000088", + "0000000000000000000000000000000000000000000000000000000000000089", + "000000000000000000000000000000000000000000000000000000000000008a", + "000000000000000000000000000000000000000000000000000000000000008b", + "000000000000000000000000000000000000000000000000000000000000008c", + "000000000000000000000000000000000000000000000000000000000000008d", + "000000000000000000000000000000000000000000000000000000000000008e", + "000000000000000000000000000000000000000000000000000000000000008f", + "0000000000000000000000000000000000000000000000000000000000000090", + "0000000000000000000000000000000000000000000000000000000000000091", + "0000000000000000000000000000000000000000000000000000000000000092", + "0000000000000000000000000000000000000000000000000000000000000093", + "0000000000000000000000000000000000000000000000000000000000000094", + "0000000000000000000000000000000000000000000000000000000000000095", + "0000000000000000000000000000000000000000000000000000000000000096", + "0000000000000000000000000000000000000000000000000000000000000097", + "0000000000000000000000000000000000000000000000000000000000000098", + "0000000000000000000000000000000000000000000000000000000000000099", + "000000000000000000000000000000000000000000000000000000000000009a", + "000000000000000000000000000000000000000000000000000000000000009b", + "000000000000000000000000000000000000000000000000000000000000009c", + "000000000000000000000000000000000000000000000000000000000000009d", + "000000000000000000000000000000000000000000000000000000000000009e", + "000000000000000000000000000000000000000000000000000000000000009f", + "00000000000000000000000000000000000000000000000000000000000000a0", + "00000000000000000000000000000000000000000000000000000000000000a1", + "00000000000000000000000000000000000000000000000000000000000000a2", + "00000000000000000000000000000000000000000000000000000000000000a3", + "00000000000000000000000000000000000000000000000000000000000000a4", + "00000000000000000000000000000000000000000000000000000000000000a5", + "00000000000000000000000000000000000000000000000000000000000000a6", + "00000000000000000000000000000000000000000000000000000000000000a7", + "00000000000000000000000000000000000000000000000000000000000000a8", + "00000000000000000000000000000000000000000000000000000000000000a9", + "00000000000000000000000000000000000000000000000000000000000000aa", + "00000000000000000000000000000000000000000000000000000000000000ab", + "00000000000000000000000000000000000000000000000000000000000000ac", + "00000000000000000000000000000000000000000000000000000000000000ad", + "00000000000000000000000000000000000000000000000000000000000000ae", + "00000000000000000000000000000000000000000000000000000000000000af", + "00000000000000000000000000000000000000000000000000000000000000b0", + "00000000000000000000000000000000000000000000000000000000000000b1", + "00000000000000000000000000000000000000000000000000000000000000b2", + "00000000000000000000000000000000000000000000000000000000000000b3", + "00000000000000000000000000000000000000000000000000000000000000b4", + "00000000000000000000000000000000000000000000000000000000000000b5", + "00000000000000000000000000000000000000000000000000000000000000b6", + "00000000000000000000000000000000000000000000000000000000000000b7", + "00000000000000000000000000000000000000000000000000000000000000b8", + "00000000000000000000000000000000000000000000000000000000000000b9", + "00000000000000000000000000000000000000000000000000000000000000ba", + "00000000000000000000000000000000000000000000000000000000000000bb", + "00000000000000000000000000000000000000000000000000000000000000bc", + "00000000000000000000000000000000000000000000000000000000000000bd", + "00000000000000000000000000000000000000000000000000000000000000be", + "00000000000000000000000000000000000000000000000000000000000000bf", + "00000000000000000000000000000000000000000000000000000000000000c0", + "00000000000000000000000000000000000000000000000000000000000000c1", + "00000000000000000000000000000000000000000000000000000000000000c2", + "00000000000000000000000000000000000000000000000000000000000000c3", + "00000000000000000000000000000000000000000000000000000000000000c4", + "00000000000000000000000000000000000000000000000000000000000000c5", + "00000000000000000000000000000000000000000000000000000000000000c6", + "00000000000000000000000000000000000000000000000000000000000000c7", + "00000000000000000000000000000000000000000000000000000000000000c8", + "00000000000000000000000000000000000000000000000000000000000000c9", + "00000000000000000000000000000000000000000000000000000000000000ca", + "00000000000000000000000000000000000000000000000000000000000000cb", + "00000000000000000000000000000000000000000000000000000000000000cc", + "00000000000000000000000000000000000000000000000000000000000000cd", + "00000000000000000000000000000000000000000000000000000000000000ce", + "00000000000000000000000000000000000000000000000000000000000000cf", + "00000000000000000000000000000000000000000000000000000000000000d0", + "00000000000000000000000000000000000000000000000000000000000000d1", + "00000000000000000000000000000000000000000000000000000000000000d2", + "00000000000000000000000000000000000000000000000000000000000000d3", + "00000000000000000000000000000000000000000000000000000000000000d4", + "00000000000000000000000000000000000000000000000000000000000000d5", + "00000000000000000000000000000000000000000000000000000000000000d6", + "00000000000000000000000000000000000000000000000000000000000000d7", + "00000000000000000000000000000000000000000000000000000000000000d8", + "00000000000000000000000000000000000000000000000000000000000000d9", + "00000000000000000000000000000000000000000000000000000000000000da", + "00000000000000000000000000000000000000000000000000000000000000db", + "00000000000000000000000000000000000000000000000000000000000000dc", + "00000000000000000000000000000000000000000000000000000000000000dd", + "00000000000000000000000000000000000000000000000000000000000000de", + "00000000000000000000000000000000000000000000000000000000000000df", + "00000000000000000000000000000000000000000000000000000000000000e0", + "00000000000000000000000000000000000000000000000000000000000000e1", + "00000000000000000000000000000000000000000000000000000000000000e2", + "00000000000000000000000000000000000000000000000000000000000000e3", + "00000000000000000000000000000000000000000000000000000000000000e4", + "00000000000000000000000000000000000000000000000000000000000000e5", + "00000000000000000000000000000000000000000000000000000000000000e6", + "00000000000000000000000000000000000000000000000000000000000000e7", + "00000000000000000000000000000000000000000000000000000000000000e8", + "00000000000000000000000000000000000000000000000000000000000000e9", + "00000000000000000000000000000000000000000000000000000000000000ea", + "00000000000000000000000000000000000000000000000000000000000000eb", + "00000000000000000000000000000000000000000000000000000000000000ec", + "00000000000000000000000000000000000000000000000000000000000000ed", + "00000000000000000000000000000000000000000000000000000000000000ee", + "00000000000000000000000000000000000000000000000000000000000000ef", + "00000000000000000000000000000000000000000000000000000000000000f0", + "00000000000000000000000000000000000000000000000000000000000000f1", + "00000000000000000000000000000000000000000000000000000000000000f2", + "00000000000000000000000000000000000000000000000000000000000000f3", + "00000000000000000000000000000000000000000000000000000000000000f4", + "00000000000000000000000000000000000000000000000000000000000000f5", + "00000000000000000000000000000000000000000000000000000000000000f6", + "00000000000000000000000000000000000000000000000000000000000000f7", + "00000000000000000000000000000000000000000000000000000000000000f8", + "00000000000000000000000000000000000000000000000000000000000000f9", + "00000000000000000000000000000000000000000000000000000000000000fa", + "00000000000000000000000000000000000000000000000000000000000000fb", + "00000000000000000000000000000000000000000000000000000000000000fc", + "00000000000000000000000000000000000000000000000000000000000000fd", + "00000000000000000000000000000000000000000000000000000000000000fe", + "00000000000000000000000000000000000000000000000000000000000000ff" + ], + "expected": "ff000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000013000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000150000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001b000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001d000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000001f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002100000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000023000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000250000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002700000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000029000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002b000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002d000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000002f0000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003100000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000033000000000000000000000000000000000000000000000000000000000000003400000000000000000000000000000000000000000000000000000000000000350000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000003700000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000039000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000003b000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000003d000000000000000000000000000000000000000000000000000000000000003e000000000000000000000000000000000000000000000000000000000000003f0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004100000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000043000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000004700000000000000000000000000000000000000000000000000000000000000480000000000000000000000000000000000000000000000000000000000000049000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000004b000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000000004d000000000000000000000000000000000000000000000000000000000000004e000000000000000000000000000000000000000000000000000000000000004f0000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000005100000000000000000000000000000000000000000000000000000000000000520000000000000000000000000000000000000000000000000000000000000053000000000000000000000000000000000000000000000000000000000000005400000000000000000000000000000000000000000000000000000000000000550000000000000000000000000000000000000000000000000000000000000056000000000000000000000000000000000000000000000000000000000000005700000000000000000000000000000000000000000000000000000000000000580000000000000000000000000000000000000000000000000000000000000059000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000005c000000000000000000000000000000000000000000000000000000000000005d000000000000000000000000000000000000000000000000000000000000005e000000000000000000000000000000000000000000000000000000000000005f0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000006100000000000000000000000000000000000000000000000000000000000000620000000000000000000000000000000000000000000000000000000000000063000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000006700000000000000000000000000000000000000000000000000000000000000680000000000000000000000000000000000000000000000000000000000000069000000000000000000000000000000000000000000000000000000000000006a000000000000000000000000000000000000000000000000000000000000006b000000000000000000000000000000000000000000000000000000000000006c000000000000000000000000000000000000000000000000000000000000006d000000000000000000000000000000000000000000000000000000000000006e000000000000000000000000000000000000000000000000000000000000006f0000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000007100000000000000000000000000000000000000000000000000000000000000720000000000000000000000000000000000000000000000000000000000000073000000000000000000000000000000000000000000000000000000000000007400000000000000000000000000000000000000000000000000000000000000750000000000000000000000000000000000000000000000000000000000000076000000000000000000000000000000000000000000000000000000000000007700000000000000000000000000000000000000000000000000000000000000780000000000000000000000000000000000000000000000000000000000000079000000000000000000000000000000000000000000000000000000000000007a000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007c000000000000000000000000000000000000000000000000000000000000007d000000000000000000000000000000000000000000000000000000000000007e000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000008100000000000000000000000000000000000000000000000000000000000000820000000000000000000000000000000000000000000000000000000000000083000000000000000000000000000000000000000000000000000000000000008400000000000000000000000000000000000000000000000000000000000000850000000000000000000000000000000000000000000000000000000000000086000000000000000000000000000000000000000000000000000000000000008700000000000000000000000000000000000000000000000000000000000000880000000000000000000000000000000000000000000000000000000000000089000000000000000000000000000000000000000000000000000000000000008a000000000000000000000000000000000000000000000000000000000000008b000000000000000000000000000000000000000000000000000000000000008c000000000000000000000000000000000000000000000000000000000000008d000000000000000000000000000000000000000000000000000000000000008e000000000000000000000000000000000000000000000000000000000000008f0000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009100000000000000000000000000000000000000000000000000000000000000920000000000000000000000000000000000000000000000000000000000000093000000000000000000000000000000000000000000000000000000000000009400000000000000000000000000000000000000000000000000000000000000950000000000000000000000000000000000000000000000000000000000000096000000000000000000000000000000000000000000000000000000000000009700000000000000000000000000000000000000000000000000000000000000980000000000000000000000000000000000000000000000000000000000000099000000000000000000000000000000000000000000000000000000000000009a000000000000000000000000000000000000000000000000000000000000009b000000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000009d000000000000000000000000000000000000000000000000000000000000009e000000000000000000000000000000000000000000000000000000000000009f00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a100000000000000000000000000000000000000000000000000000000000000a200000000000000000000000000000000000000000000000000000000000000a300000000000000000000000000000000000000000000000000000000000000a400000000000000000000000000000000000000000000000000000000000000a500000000000000000000000000000000000000000000000000000000000000a600000000000000000000000000000000000000000000000000000000000000a700000000000000000000000000000000000000000000000000000000000000a800000000000000000000000000000000000000000000000000000000000000a900000000000000000000000000000000000000000000000000000000000000aa00000000000000000000000000000000000000000000000000000000000000ab00000000000000000000000000000000000000000000000000000000000000ac00000000000000000000000000000000000000000000000000000000000000ad00000000000000000000000000000000000000000000000000000000000000ae00000000000000000000000000000000000000000000000000000000000000af00000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000b100000000000000000000000000000000000000000000000000000000000000b200000000000000000000000000000000000000000000000000000000000000b300000000000000000000000000000000000000000000000000000000000000b400000000000000000000000000000000000000000000000000000000000000b500000000000000000000000000000000000000000000000000000000000000b600000000000000000000000000000000000000000000000000000000000000b700000000000000000000000000000000000000000000000000000000000000b800000000000000000000000000000000000000000000000000000000000000b900000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000bb00000000000000000000000000000000000000000000000000000000000000bc00000000000000000000000000000000000000000000000000000000000000bd00000000000000000000000000000000000000000000000000000000000000be00000000000000000000000000000000000000000000000000000000000000bf00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000c100000000000000000000000000000000000000000000000000000000000000c200000000000000000000000000000000000000000000000000000000000000c300000000000000000000000000000000000000000000000000000000000000c400000000000000000000000000000000000000000000000000000000000000c500000000000000000000000000000000000000000000000000000000000000c600000000000000000000000000000000000000000000000000000000000000c700000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000000c900000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000cb00000000000000000000000000000000000000000000000000000000000000cc00000000000000000000000000000000000000000000000000000000000000cd00000000000000000000000000000000000000000000000000000000000000ce00000000000000000000000000000000000000000000000000000000000000cf00000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000d100000000000000000000000000000000000000000000000000000000000000d200000000000000000000000000000000000000000000000000000000000000d300000000000000000000000000000000000000000000000000000000000000d400000000000000000000000000000000000000000000000000000000000000d500000000000000000000000000000000000000000000000000000000000000d600000000000000000000000000000000000000000000000000000000000000d700000000000000000000000000000000000000000000000000000000000000d800000000000000000000000000000000000000000000000000000000000000d900000000000000000000000000000000000000000000000000000000000000da00000000000000000000000000000000000000000000000000000000000000db00000000000000000000000000000000000000000000000000000000000000dc00000000000000000000000000000000000000000000000000000000000000dd00000000000000000000000000000000000000000000000000000000000000de00000000000000000000000000000000000000000000000000000000000000df00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000e100000000000000000000000000000000000000000000000000000000000000e200000000000000000000000000000000000000000000000000000000000000e300000000000000000000000000000000000000000000000000000000000000e400000000000000000000000000000000000000000000000000000000000000e500000000000000000000000000000000000000000000000000000000000000e600000000000000000000000000000000000000000000000000000000000000e700000000000000000000000000000000000000000000000000000000000000e800000000000000000000000000000000000000000000000000000000000000e900000000000000000000000000000000000000000000000000000000000000ea00000000000000000000000000000000000000000000000000000000000000eb00000000000000000000000000000000000000000000000000000000000000ec00000000000000000000000000000000000000000000000000000000000000ed00000000000000000000000000000000000000000000000000000000000000ee00000000000000000000000000000000000000000000000000000000000000ef00000000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000000f100000000000000000000000000000000000000000000000000000000000000f200000000000000000000000000000000000000000000000000000000000000f300000000000000000000000000000000000000000000000000000000000000f400000000000000000000000000000000000000000000000000000000000000f500000000000000000000000000000000000000000000000000000000000000f600000000000000000000000000000000000000000000000000000000000000f700000000000000000000000000000000000000000000000000000000000000f800000000000000000000000000000000000000000000000000000000000000f900000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000000000000000fb00000000000000000000000000000000000000000000000000000000000000fc00000000000000000000000000000000000000000000000000000000000000fd00000000000000000000000000000000000000000000000000000000000000fe00000000000000000000000000000000000000000000000000000000000000ff" + } +] diff --git a/bip-encrypted-backup/test_vectors/keys_types.json b/bip-encrypted-backup/test_vectors/keys_types.json new file mode 100644 index 0000000000..a2346e0b50 --- /dev/null +++ b/bip-encrypted-backup/test_vectors/keys_types.json @@ -0,0 +1,47 @@ +[ + { + "description": "Xpub with origin and multipath wildcard", + "key": "[58b7f8dc/48'/1'/0'/2']tpubDEPBvXvhta3pjVaKokqC3eeMQnszj9ehFaA2zD5nSdkaccwGAizu8jVB2NeSpvmP2P52MBoZvNCixqXRJnTyXx51FQzARR63tjxQSyP3Btw/<0;1>/*", + "expected": "ebd252ca0877aae09b9d058219682775aa3cbcd049c12f07832f2cf6a3b51708" + }, + { + "description": "Xpub with single-path wildcard", + "key": "[58b7f8dc/48'/1'/0'/2']tpubDEPBvXvhta3pjVaKokqC3eeMQnszj9ehFaA2zD5nSdkaccwGAizu8jVB2NeSpvmP2P52MBoZvNCixqXRJnTyXx51FQzARR63tjxQSyP3Btw/0/*", + "expected": "ebd252ca0877aae09b9d058219682775aa3cbcd049c12f07832f2cf6a3b51708" + }, + { + "description": "Xpub with bare wildcard (no preceding path)", + "key": "[58b7f8dc/48'/1'/0'/2']tpubDEPBvXvhta3pjVaKokqC3eeMQnszj9ehFaA2zD5nSdkaccwGAizu8jVB2NeSpvmP2P52MBoZvNCixqXRJnTyXx51FQzARR63tjxQSyP3Btw/*", + "expected": "ebd252ca0877aae09b9d058219682775aa3cbcd049c12f07832f2cf6a3b51708" + }, + { + "description": "Xpub with fixed deep derivation, no wildcard", + "key": "[58b7f8dc/48'/1'/0'/2']tpubDEPBvXvhta3pjVaKokqC3eeMQnszj9ehFaA2zD5nSdkaccwGAizu8jVB2NeSpvmP2P52MBoZvNCixqXRJnTyXx51FQzARR63tjxQSyP3Btw/0/5", + "expected": "ebd252ca0877aae09b9d058219682775aa3cbcd049c12f07832f2cf6a3b51708" + }, + { + "description": "Xpub with multipath, no wildcard", + "key": "[58b7f8dc/48'/1'/0'/2']tpubDEPBvXvhta3pjVaKokqC3eeMQnszj9ehFaA2zD5nSdkaccwGAizu8jVB2NeSpvmP2P52MBoZvNCixqXRJnTyXx51FQzARR63tjxQSyP3Btw/<0;1>", + "expected": "ebd252ca0877aae09b9d058219682775aa3cbcd049c12f07832f2cf6a3b51708" + }, + { + "description": "Bare xpub (no derivation, no wildcard); DISALLOWED", + "key": "[d4ab66f1/48'/1'/1'/2']tpubDFTxBKyUCgkwp5enwZh3t2FJ5AMJqmCWoh1NRT13qNYQb1iKTUrAG6u5gpsDYhG8cZGXouYWuQtzcuSVjPStTc4dwU6JqPMFtgaLGvSQXhi", + "expected": null + }, + { + "description": "Compressed literal pubkey; DISALLOWED", + "key": "02ebd252ca0877aae09b9d058219682775aa3cbcd049c12f07832f2cf6a3b51708", + "expected": null + }, + { + "description": "X-only literal pubkey; DISALLOWED", + "key": "ebd252ca0877aae09b9d058219682775aa3cbcd049c12f07832f2cf6a3b51708", + "expected": null + }, + { + "description": "Uncompressed literal pubkey; DISALLOWED", + "key": "04ebd252ca0877aae09b9d058219682775aa3cbcd049c12f07832f2cf6a3b517089e956909c4c07e8529f45f3ff8904d28df5a181619e21bdf748a896322530039", + "expected": null + } +] From e9858e8bbee3fbf12510f7af9816772a10a82392 Mon Sep 17 00:00:00 2001 From: Murch Date: Mon, 11 May 2026 12:26:05 -0700 Subject: [PATCH 02/12] Assign BIP138 --- README.mediawiki | 7 +++++++ bip-encrypted-backup.md => bip-0138.md | 20 +++++++++---------- .../chacha20poly1305_encryption.json | 0 .../test_vectors/content_type.json | 0 .../test_vectors/derivation_path.json | 0 .../test_vectors/encrypted_backup.json | 0 .../test_vectors/encryption_secret.json | 0 .../test_vectors/individual_secrets.json | 0 .../test_vectors/keys_types.json | 0 9 files changed, 17 insertions(+), 10 deletions(-) rename bip-encrypted-backup.md => bip-0138.md (97%) rename {bip-encrypted-backup => bip-0138}/test_vectors/chacha20poly1305_encryption.json (100%) rename {bip-encrypted-backup => bip-0138}/test_vectors/content_type.json (100%) rename {bip-encrypted-backup => bip-0138}/test_vectors/derivation_path.json (100%) rename {bip-encrypted-backup => bip-0138}/test_vectors/encrypted_backup.json (100%) rename {bip-encrypted-backup => bip-0138}/test_vectors/encryption_secret.json (100%) rename {bip-encrypted-backup => bip-0138}/test_vectors/individual_secrets.json (100%) rename {bip-encrypted-backup => bip-0138}/test_vectors/keys_types.json (100%) diff --git a/README.mediawiki b/README.mediawiki index 0e67e7b02e..24b7572513 100644 --- a/README.mediawiki +++ b/README.mediawiki @@ -820,6 +820,13 @@ users (see also: [https://en.bitcoin.it/wiki/Economic_majority economic majority | Christopher Gilliard | Specification | Deployed +|- +| [[bip-0138.md|138]] +| Applications +| Compact encryption scheme for non-seed wallet data +| Pyth +| Specification +| Draft |- style="background-color: #ffcfcf" | [[bip-0140.mediawiki|140]] | Consensus (soft fork) diff --git a/bip-encrypted-backup.md b/bip-0138.md similarity index 97% rename from bip-encrypted-backup.md rename to bip-0138.md index 09583bfd14..0b0b8d0034 100644 --- a/bip-encrypted-backup.md +++ b/bip-0138.md @@ -1,14 +1,14 @@ ``` -BIP: ? -Layer: Applications -Title: Compact encryption scheme for non-seed wallet data -Authors: Pyth -Status: Draft -Type: Specification -Assigned: ? -License: BSD-2-Clause -Discussion: https://delvingbitcoin.org/t/a-simple-backup-scheme-for-wallet-accounts/1607 - https://groups.google.com/g/bitcoindev/c/5NgJbpVDgEc/m/TtGK9sF9BgAJ + BIP: 138 + Layer: Applications + Title: Compact encryption scheme for non-seed wallet data + Authors: Pyth + Status: Draft + Type: Specification + Assigned: 2026-05-11 + License: BSD-2-Clause + Discussion: https://delvingbitcoin.org/t/a-simple-backup-scheme-for-wallet-accounts/1607 + https://groups.google.com/g/bitcoindev/c/5NgJbpVDgEc/m/TtGK9sF9BgAJ ``` ## Introduction diff --git a/bip-encrypted-backup/test_vectors/chacha20poly1305_encryption.json b/bip-0138/test_vectors/chacha20poly1305_encryption.json similarity index 100% rename from bip-encrypted-backup/test_vectors/chacha20poly1305_encryption.json rename to bip-0138/test_vectors/chacha20poly1305_encryption.json diff --git a/bip-encrypted-backup/test_vectors/content_type.json b/bip-0138/test_vectors/content_type.json similarity index 100% rename from bip-encrypted-backup/test_vectors/content_type.json rename to bip-0138/test_vectors/content_type.json diff --git a/bip-encrypted-backup/test_vectors/derivation_path.json b/bip-0138/test_vectors/derivation_path.json similarity index 100% rename from bip-encrypted-backup/test_vectors/derivation_path.json rename to bip-0138/test_vectors/derivation_path.json diff --git a/bip-encrypted-backup/test_vectors/encrypted_backup.json b/bip-0138/test_vectors/encrypted_backup.json similarity index 100% rename from bip-encrypted-backup/test_vectors/encrypted_backup.json rename to bip-0138/test_vectors/encrypted_backup.json diff --git a/bip-encrypted-backup/test_vectors/encryption_secret.json b/bip-0138/test_vectors/encryption_secret.json similarity index 100% rename from bip-encrypted-backup/test_vectors/encryption_secret.json rename to bip-0138/test_vectors/encryption_secret.json diff --git a/bip-encrypted-backup/test_vectors/individual_secrets.json b/bip-0138/test_vectors/individual_secrets.json similarity index 100% rename from bip-encrypted-backup/test_vectors/individual_secrets.json rename to bip-0138/test_vectors/individual_secrets.json diff --git a/bip-encrypted-backup/test_vectors/keys_types.json b/bip-0138/test_vectors/keys_types.json similarity index 100% rename from bip-encrypted-backup/test_vectors/keys_types.json rename to bip-0138/test_vectors/keys_types.json From 7707cf2935d9b2d033fa3eaea597d76c9b912a93 Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Wed, 17 Jun 2026 22:45:43 -0400 Subject: [PATCH 03/12] bip-0138: make PLAINTEXT LENGTH mandatory and add optional payload padding --- bip-0138.md | 48 +++++++++++++++++---- bip-0138/test_vectors/encrypted_backup.json | 16 +++---- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/bip-0138.md b/bip-0138.md index 0b0b8d0034..484989b1f8 100644 --- a/bip-0138.md +++ b/bip-0138.md @@ -263,7 +263,39 @@ Implementations MUST reject empty payloads. `CIPHERTEXT` is the encrypted data resulting from encryption of `PAYLOAD` with algorithm defined in `ENCRYPTION` where `PAYLOAD` is encoded following this format: -`CONTENT` `PLAINTEXT` +`CONTENT` `LENGTH` `PLAINTEXT` (`PADDING`) + +`LENGTH`: variable-length integer representing the length of `PLAINTEXT` in bytes. It MUST +be present. + +`PLAINTEXT`: the `LENGTH` bytes of payload data. + +`PADDING`: OPTIONAL bytes after `PLAINTEXT`, up to the end of the decrypted `PAYLOAD`. +Parsers MUST consume exactly `LENGTH` bytes of `PLAINTEXT` and MUST ignore everything after +it. These bytes are reserved for size padding (see Padding) and/or vendor-specific data, +the same way trailing bytes after `CIPHERTEXT` are reserved and ignored. + +#### Padding + +Backups that are updated over time can leak information through their size even when the +contents are encrypted. A wallet that uploads a new backup after every received transaction +can reveal activity to the storage provider through changing payload sizes. This is relevant +for mutable payloads such as BIP-329 or BIP-0139.[^padding-privacy] + +Padding is OPTIONAL and is an encoder concern only: decoders ignore the `PADDING` bytes and +MUST NOT validate any bucket. Because the padding sits inside `CIPHERTEXT`, the +`ENCRYPTED_PAYLOAD` `LENGTH` reveals only the padded size, not the real `PLAINTEXT` size. + +Encoders that pad SHOULD zero-fill `PAYLOAD` up to the smallest bucket `S_n` that fits it, +with `S_0 = 10240` (10 KiB) and `S_n = floor(S_0 * (5 / 4)^n)`. Payloads of 10 KiB or less +are padded to 10 KiB. This keeps padding overhead under 25% above the smallest fitting bucket +while coarsening the observable size. Padding is RECOMMENDED for mutable payloads and +unnecessary for static ones such as BIP-380 descriptors and BIP-388 wallet policies. + +[^padding-privacy]: **Why pad inside the ciphertext?** + Padding the encrypted payload, rather than appending bytes after the backup, hides the + real payload size from anyone who parses the backup, not just from someone who measures + the file size. The size field a parser sees is the padded `LENGTH`. #### Integer Encodings @@ -353,19 +385,19 @@ The version field enables possible future enhancements: ### Test Vectors -[key_types.json](./bip-encrypted-backup/test_vectors/keys_types.json) contains test +[key_types.json](./bip-0138/test_vectors/keys_types.json) contains test vectors for key serialisations. -[content_type.json](./bip-encrypted-backup/test_vectors/content_type.json) contains test +[content_type.json](./bip-0138/test_vectors/content_type.json) contains test vectors for contents types serialisations. -[derivation_path.json](./bip-encrypted-backup/test_vectors/derivation_path.json) contains +[derivation_path.json](./bip-0138/test_vectors/derivation_path.json) contains test vectors for derivation paths serialisations. -[individual_secrets.json](./bip-encrypted-backup/test_vectors/individual_secrets.json) +[individual_secrets.json](./bip-0138/test_vectors/individual_secrets.json) contains test vectors for individual secrets serialization. -[encryption_secret.json](./bip-encrypted-backup/test_vectors/encryption_secret.json) +[encryption_secret.json](./bip-0138/test_vectors/encryption_secret.json) contains test vectors for generation of encryption secret. -[chacha20poly1305_encryption.json](./bip-encrypted-backup/test_vectors/chacha20poly1305_encryption.json) +[chacha20poly1305_encryption.json](./bip-0138/test_vectors/chacha20poly1305_encryption.json) contains test vectors for ciphertexts generated using CHACHA20-POLY1305. -[encrypted_backup.json](./bip-encrypted-backup/test_vectors/encrypted_backup.json) +[encrypted_backup.json](./bip-0138/test_vectors/encrypted_backup.json) contains test vectors for generation of complete encrypted backup. ## Acknowledgements diff --git a/bip-0138/test_vectors/encrypted_backup.json b/bip-0138/test_vectors/encrypted_backup.json index 327913b2cc..9ce95d6d2e 100644 --- a/bip-0138/test_vectors/encrypted_backup.json +++ b/bip-0138/test_vectors/encrypted_backup.json @@ -10,9 +10,9 @@ "derivation_paths": [], "plaintext": "00", "nonce": "a1b2c3d4e5f607080910a1b2", - "expected": "424950585858010001ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae0001a1b2c3d4e5f607080910a1b2151d8f44dba6f420976b9343f792b4bd58c06289d234", + "expected": "424950585858010001ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae0001a1b2c3d4e5f607080910a1b2161d8f44e9a6196e61ac587ad2a3243b7c26949d848121", "trailing": "deadbeef00ff", - "expected_base64": "QklQWFhYAQAB/zSzQR94Entxyi48xg0P1xNQ7lV8N9cfTYH7kTRhrgABobLD1OX2BwgJEKGyFR2PRNum9CCXa5ND95K0vVjAYonSNA==" + "expected_base64": "QklQWFhYAQAB/zSzQR94Entxyi48xg0P1xNQ7lV8N9cfTYH7kTRhrgABobLD1OX2BwgJEKGyFh2PROmmGW5hrFh60qMkO3wmlJ2EgSE=" }, { "description": "Two keys, 1 derivation paths, BIP380 content", @@ -28,8 +28,8 @@ ], "plaintext": "wsh(or_d(pk([9d69155f/48'/1'/0'/2']tpubDDxT9mkZzWwkKwpGT5fY6iiM9muYTPkTx6Eig8dpHR7TChuGGCWYAHVmpW1ciido5RiFWwjzYsF1GZHkEHg2nrYp3zNtx3QQRkznyLhQ77x/<0;1>/*),and_v(v:pkh([9d69155f/48'/1'/0'/2']tpubDDxT9mkZzWwkKwpGT5fY6iiM9muYTPkTx6Eig8dpHR7TChuGGCWYAHVmpW1ciido5RiFWwjzYsF1GZHkEHg2nrYp3zNtx3QQRkznyLhQ77x/<2;3>/*),older(52596))))#gx5f42wh", "nonce": "0102030405060708090a0b0c", - "expected": "42495058585801010480000030800000018000000080000002024900d4ef9021cb059b8fb35c6de9b6db91949a328527ede0645be237899100bd5e3eb8a36f7bf32e02810c14666476f2b28a15cd499c30f8f98e926639a0765c010102030405060708090a0b0cfd63012f51db36ae620d6522a86e4ce7d9daff2f50826aae70c1d3707d18b8075543da1848ad904b11be465e768d8b1ea74a1b21f21f882262bd0d5f7165991720c1836f1bce2dec7ba3813fc1c0bc6404a0fd6228e239f8bddd398c32f8274f9de0f0b5662854ce900d7d5b14a16605eb2a49d031b98513b73777685693b45b17e08a60e095b66403efcc7036cd82a8d675362eab43bcdecb158e8b0dcca476173345d189c2277dc25b9851b2be92c7ef8b69a565af1ccf9726e322db2b8d5266a5df4296527c716b8ba004fb1408cbd7cc7a18575286e6f03e1793b25eea11223fd6cc7a497d8328997b1eb770fcc8125e60511eefb8232b780d80f1d71e9e937627dfb62cd6c5807b35e7d7bb9aaf18d5a46c6ea271f2be26bd1cc35bb2b70cc1930ad5f472b1bf0d7b3bed3dfe358a69beabdafd6316968c530237f21e1c89662ada34d666735f791db5eb68ee29d2d06f42421ec311d6284f5be9850d63e0cfd6cfe207", - "expected_base64": "QklQWFhYAQEEgAAAMIAAAAGAAAAAgAAAAgJJANTvkCHLBZuPs1xt6bbbkZSaMoUn7eBkW+I3iZEAvV4+uKNve/MuAoEMFGZkdvKyihXNSZww+PmOkmY5oHZcAQECAwQFBgcICQoLDP1jAS9R2zauYg1lIqhuTOfZ2v8vUIJqrnDB03B9GLgHVUPaGEitkEsRvkZedo2LHqdKGyHyH4giYr0NX3FlmRcgwYNvG84t7HujgT/BwLxkBKD9YijiOfi93TmMMvgnT53g8LVmKFTOkA19WxShZgXrKknQMbmFE7c3d2hWk7RbF+CKYOCVtmQD78xwNs2CqNZ1Ni6rQ7zeyxWOiw3MpHYXM0XRicInfcJbmFGyvpLH74tppWWvHM+XJuMi2yuNUmal30KWUnxxa4ugBPsUCMvXzHoYV1KG5vA+F5OyXuoRIj/WzHpJfYMomXset3D8yBJeYFEe77gjK3gNgPHXHp6TdifftizWxYB7NefXu5qvGNWkbG6icfK+Jr0cw1uytwzBkwrV9HKxvw17O+09/jWKab6r2v1jFpaMUwI38h4ciWYq2jTWZnNfeR2162juKdLQb0JCHsMR1ihPW+mFDWPgz9bP4gc=" + "expected": "42495058585801010480000030800000018000000080000002024900d4ef9021cb059b8fb35c6de9b6db91949a328527ede0645be237899100bd5e3eb8a36f7bf32e02810c14666476f2b28a15cd499c30f8f98e926639a0765c010102030405060708090a0b0cfd66012f51dbbc8d0b527938df6516c8d6dad47d1cef6afb73cd846a7c46b01c5c43da1948ad924b63f8117660b9ba04b7370e1e9108b40f73a10d447d46dc362dc28c5f609e29d41b9aa40dc1e8e17515f1806f3f920fbfa1cc66ad36d7115f83e2efba4a1055928333255c12fd5003982f57fc1c979c2fdf036b117a8cb45760c69f0bfed4955a44edb1551facb883ea6700288338e3f7d31ec69f00c2b06d00300e96c1fc3f31eb17c04ce0e6a296a3e669f066a34bd59678eb39d22b8d5366a5dd42e4142b597dbf911eeb691df4b4db4635464e86fdfc1d52b2bf5de521596fd2f41a7058b128b1260fa62181c5052e561602fee7022f573b90efd50191bf4e2683a5128ec2862703e1a4be848335fbbd5006966d8b9239bd10b47da7dc1280b03492f60f94966c4110d12fc833a212e182c2f629029980471b20f15b59c16c349664967b7f5b650daaeb62a078c4d1234553425de19e2856a708edd21bf5f080f7d5ebc899a1", + "expected_base64": "QklQWFhYAQEEgAAAMIAAAAGAAAAAgAAAAgJJANTvkCHLBZuPs1xt6bbbkZSaMoUn7eBkW+I3iZEAvV4+uKNve/MuAoEMFGZkdvKyihXNSZww+PmOkmY5oHZcAQECAwQFBgcICQoLDP1mAS9R27yNC1J5ON9lFsjW2tR9HO9q+3PNhGp8RrAcXEPaGUitkktj+BF2YLm6BLc3Dh6RCLQPc6ENRH1G3DYtwoxfYJ4p1BuapA3B6OF1FfGAbz+SD7+hzGatNtcRX4Pi77pKEFWSgzMlXBL9UAOYL1f8HJecL98DaxF6jLRXYMafC/7UlVpE7bFVH6y4g+pnACiDOOP30x7GnwDCsG0AMA6Wwfw/MesXwEzg5qKWo+Zp8GajS9WWeOs50iuNU2al3ULkFCtZfb+RHutpHfS020Y1Rk6G/fwdUrK/XeUhWW/S9BpwWLEosSYPpiGBxQUuVhYC/ucCL1c7kO/VAZG/TiaDpRKOwoYnA+GkvoSDNfu9UAaWbYuSOb0QtH2n3BKAsDSS9g+UlmxBENEvyDOiEuGCwvYpApmARxsg8VtZwWw0lmSWe39bZQ2q62KgeMTRI0VTQl3hnihWpwjt0hv18ID31evImaE=" }, { "description": "Three keys, multiple derivation paths, BIP329 content", @@ -47,8 +47,8 @@ ], "plaintext": "{\"type\":\"tx\",\"ref\":\"f91d0a8a78462bc59398f2c5d7a84fcff491c26ba54c4833478b202796c8aafd\",\"label\":\"Transaction\",\"origin\":\"wpkh([d34db33f/84'/0'/0'])\"}\n{\"type\":\"addr\",\"ref\":\"bc1q34aq5drpuwy3wgl9lhup9892qp6svr8ldzyy7c\",\"label\":\"Address\"}\n{\"type\":\"pubkey\",\"ref\":\"0283409659355b6d1cc3c32decd5d561abaac86c37a353b52895a5e6c196d6f448\",\"label\":\"Public Key\"}\n{\"type\":\"input\",\"ref\":\"f91d0a8a78462bc59398f2c5d7a84fcff491c26ba54c4833478b202796c8aafd:0\",\"label\":\"Input\"}\n{\"type\":\"output\",\"ref\":\"f91d0a8a78462bc59398f2c5d7a84fcff491c26ba54c4833478b202796c8aafd:1\",\"label\":\"Output\",\"spendable\":false}\n{\"type\":\"xpub\",\"ref\":\"xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8\",\"label\":\"Extended Public Key\"}\n{\"type\":\"tx\",\"ref\":\"f546156d9044844e02b181026a1a407abfca62e7ea1159f87bbeaa77b4286c74\",\"label\":\"Account #1 Transaction\",\"origin\":\"wpkh([d34db33f/84'/0'/1'])\"}", "nonce": "deadbeefcafebabe12345678", - "expected": "4249505858580102040000000080000001000000028000000303800000548000000080000000032424c7f03a4b1ec573f64738c2a61ac0a9480750f6a641ff8dd1e85acf5b8008331aabbcc51126eeeaf8f870c92bdae98a5688af3a1d9ce71004980b7f6af6e96e5f3aab8b6dfe2f8c09da023a29f797d8333736fb7b7c64958d0ff4109ba93a01deadbeefcafebabe12345678fd9c03f6ebb8e2e9c02c5194e453edd274ec677e0dea5f18cda3e00f7cc4e8c8d4821bda377728eb2f6d2f69eef72070a2a7bc01cc720bb989346102076d475cab2802f1e3766526d2c0bfd257a8e424045cd91356e8789458d06aa055fe2ed0c42fb338b43ae394ae3f9807e1840171965708c89e3b42e68dc4bf84c51bcc8738475e8325e07398753327c1afa6a96032cf73b9387c0f4cb6825adf383c8135b63394b1372fb2752c5297a595099d91c59f25ad6e0d136013ce64d67a53fc88861bf1f558fc2c775644fba1bba9efd23f562f6edb9a2cb476c40cc2ae3f006d3f839a9607271b6eed6f58efcf435eb0cf79c12b5f3c4160f8c3de8e9e311c7698090be2c8e2a3ef702daf88612179e21ee4ac401cab342f7a1d1c141eed8f1a7c60d6dd34324ed6bd07e03ae596d7c04350698ce4592660b841aadf5c2a372b0fc57539094bc0af80febc92aa10578c0b35efd164f4c94217d2e0de72461bdea40d881858eb4b16f1c361fa98cfe0fcbc83787c492238ea745a84265e907c8a07d98852fef62a2a360b75c8b700b24d503a0e54260a1a94e0a980d69aa76e34ba8c304f85e0e7f4cfa3cf3c0c4ac8ddad1548bf20dabd4b316ed53903701677e78d3cfd46980acfe482110be8be64a27ce1dd4d7502338d087e9b86b7ca6144fc81a2a7b806a4e397dfb8d8ad9ea54130d9b46d2cd9002e372094399078e0bce1af9f2dfb5a69a16ec88e53ec9c6f34d784596afcece4d8abd33e937d9ea4ddf170088270cc4f59f68b978368833dc7713b0351da5f690991c841f17c42e7b4d89c35a821e110c4b2a9a1f0cfebd14cfb39d938569614ee62bb488049c6b7ed636dd90cfb00170dd80f4a6e6c9a45a3bed0fa1340ecddb538bb888fdaaa1680d711d6f94297a9f7ed3401cecb25b6779b4ba5415a343a95597cb85b074d8e19def182d8581fb7b4bc716ba887af1bd51a10c699f6ddfdb5439c7eac02d9220a0417489a79bbc6da4d10325317a6630da9303c433f261e0d36f977cea8113c7e4581e5d27f6607be0f9f7058fd6730d64377b7d1e70f4858974896e3ae9fbde9fb6eb66be4d0c36544cf8cfb80166875f1672f5aa4991951248414a54457e3f3bea0a2953d27de6d0a299cc06471d9f331ace87937b96547e7bcfa7ae972fd9e08cfa69fae42fe786f1cb1d5ee0bc3bbd9277f38b290eb2033f39dc65bfc963c60d3f01d493ab7546cd72504303f68bd5e376d2b6a2dc59d4c3cfbef490d1cdcb73065f756620528bb0bd92301a26f53f0c1ae61962416c746d1b3b38fd202", - "expected_base64": "QklQWFhYAQIEAAAAAIAAAAEAAAACgAAAAwOAAABUgAAAAIAAAAADJCTH8DpLHsVz9kc4wqYawKlIB1D2pkH/jdHoWs9bgAgzGqu8xREm7ur4+HDJK9rpilaIrzodnOcQBJgLf2r26W5fOquLbf4vjAnaAjop95fYMzc2+3t8ZJWND/QQm6k6Ad6tvu/K/rq+EjRWeP2cA/bruOLpwCxRlORT7dJ07Gd+DepfGM2j4A98xOjI1IIb2jd3KOsvbS9p7vcgcKKnvAHMcgu5iTRhAgdtR1yrKALx43ZlJtLAv9JXqOQkBFzZE1boeJRY0GqgVf4u0MQvszi0OuOUrj+YB+GEAXGWVwjInjtC5o3Ev4TFG8yHOEdegyXgc5h1MyfBr6apYDLPc7k4fA9MtoJa3zg8gTW2M5SxNy+ydSxSl6WVCZ2RxZ8lrW4NE2ATzmTWelP8iIYb8fVY/Cx3VkT7obup79I/Vi9u25ostHbEDMKuPwBtP4OalgcnG27tb1jvz0NesM95wStfPEFg+MPejp4xHHaYCQviyOKj73Atr4hhIXniHuSsQByrNC96HRwUHu2PGnxg1t00Mk7WvQfgOuWW18BDUGmM5FkmYLhBqt9cKjcrD8V1OQlLwK+A/rySqhBXjAs179Fk9MlCF9Lg3nJGG96kDYgYWOtLFvHDYfqYz+D8vIN4fEkiOOp0WoQmXpB8igfZiFL+9ioqNgt1yLcAsk1QOg5UJgoalOCpgNaap240uowwT4Xg5/TPo888DErI3a0VSL8g2r1LMW7VOQNwFnfnjTz9RpgKz+SCEQvovmSifOHdTXUCM40IfpuGt8phRPyBoqe4BqTjl9+42K2epUEw2bRtLNkALjcglDmQeOC84a+fLftaaaFuyI5T7JxvNNeEWWr87OTYq9M+k32epN3xcAiCcMxPWfaLl4Nogz3HcTsDUdpfaQmRyEHxfELntNicNagh4RDEsqmh8M/r0Uz7Odk4VpYU7mK7SIBJxrftY23ZDPsAFw3YD0pubJpFo77Q+hNA7N21OLuIj9qqFoDXEdb5Qpep9+00Ac7LJbZ3m0ulQVo0OpVZfLhbB02OGd7xgthYH7e0vHFrqIevG9UaEMaZ9t39tUOcfqwC2SIKBBdImnm7xtpNEDJTF6ZjDakwPEM/Jh4NNvl3zqgRPH5FgeXSf2YHvg+fcFj9ZzDWQ3e30ecPSFiXSJbjrp+96ftutmvk0MNlRM+M+4AWaHXxZy9apJkZUSSEFKVEV+PzvqCilT0n3m0KKZzAZHHZ8zGs6Hk3uWVH57z6euly/Z4Iz6afrkL+eG8csdXuC8O72Sd/OLKQ6yAz853GW/yWPGDT8B1JOrdUbNclBDA/aL1eN20rai3FnUw8++9JDRzctzBl91ZiBSi7C9kjAaJvU/DBrmGWJBbHRtGzs4/SAg==" + "expected": "4249505858580102040000000080000001000000028000000303800000548000000080000000032424c7f03a4b1ec573f64738c2a61ac0a9480750f6a641ff8dd1e85acf5b8008331aabbcc51126eeeaf8f870c92bdae98a5688af3a1d9ce71004980b7f6af6e96e5f3aab8b6dfe2f8c09da023a29f797d8333736fb7b7c64958d0ff4109ba93a01deadbeefcafebabe12345678fd9f03f6ebb86442b72e0385bf19aa8436ec3f245da31b4892e7a40c6fc6e19888d34dda627622bd7a6a7439e2f6757bf9f4ea55982e08bed2666155583a1057ac2951f2b574642a82c7b3d65cfee12c5459d01702e92f9606d529ea13b06390cd22f367fa4cabd7943e980ae68c0d6bdd144485c0704afd8a81ecc890518598607752984ae0229f22373bcafdaebe6432cf73b94a650a6c95db05a13a6e906efc74d7ef713cf43d7c02dee1c556d9d19c8c36fd6b1d516116cd21c77f5aba889844bffe5cb030261b0df0e8f2adedd47b1d3578998f31f96c9f1783e072406432c3c5d864795d5dec7859a8c13a07efb17b933a04760632b783c59e8578552dc8404fb297a6b1e76a2ea9806b237ce21be4a0111ffa677a7d1f1c441fead94b7c30d18c37671a82ed07e163b296dcc141506bdeb559273ab446f3d30c7d617f00902036591bc2f196e6a6dce7505e814b6aa1a32bb4f55e169ec2d82b2f03adfd52f61a0afa105cb68835a884d5b2a5ead33138197d7cae7749862f0ecc2ddc078c8958a8a32d716607749dbc5be11b046e525721514894b7f6d78191a06f67b9da324e89b0e0f8cba89939041acdd4a94149e82284b8106728c32b4d3d567eeacd63b32dcc58f3fed01975b1e11aa02ef08607324f7cdb177e9bd4ee9c310db8d1fde3fc05b7e19e8fe489fb9ef0403a8fe16a77890c2f622bcf6ac62cb4e0e2a8c47ffb0d36f639c38952bf9f3936d688096df0e8ef8eaedb6e96749af0dca67256872b9b094fe5c5dac3618e7d983f564c07e55f695bc89e10ad3b5ff3b0d49431e877e25392a7adb089d1b4af4ea928827211cc5eb978e911c0198ff3bd3c298346ac1a514e8b74051256a279869dc2ee057bcdfad82cb1f7bdc19126859f39ddad58ef95858b0151ec9623950bc456910d633c2ca5487baf6a507a8d1980eee3a7773dbbb18e4e35b987ee23c55223d7e6dedadfa274cb2edd64a270693c032aab4c8af2aa7e5141436b804134f2776459716b5e043bb92880cf536a5e5391e5d83b5316fc33837114df6169bf5b04ee8e990d1a49cc02d1b5ec9fe5b3ab27f23bbb94876a529f88fa80436473a16a275aa4c41d5723851ef6455de4a2bdf7f7946b728c3c082acc9160708ef737f8bc7160b46b43bdeef979bb24fe9d0d95a4cea140bf637952fc95e70683e4974426799c86e63b66bed8c62cbfd70661d3fd1a4136ad1f2f9b685a7b3773ba1b64217e2064dac57c30e080495c1b8bb32c6ea55e750128bb0ad95119a74fdddfb803b28298ab427ae226fc5db23aeafe5b", + "expected_base64": "QklQWFhYAQIEAAAAAIAAAAEAAAACgAAAAwOAAABUgAAAAIAAAAADJCTH8DpLHsVz9kc4wqYawKlIB1D2pkH/jdHoWs9bgAgzGqu8xREm7ur4+HDJK9rpilaIrzodnOcQBJgLf2r26W5fOquLbf4vjAnaAjop95fYMzc2+3t8ZJWND/QQm6k6Ad6tvu/K/rq+EjRWeP2fA/bruGRCty4Dhb8ZqoQ27D8kXaMbSJLnpAxvxuGYiNNN2mJ2Ir16anQ54vZ1e/n06lWYLgi+0mZhVVg6EFesKVHytXRkKoLHs9Zc/uEsVFnQFwLpL5YG1SnqE7BjkM0i82f6TKvXlD6YCuaMDWvdFESFwHBK/YqB7MiQUYWYYHdSmErgIp8iNzvK/a6+ZDLPc7lKZQpsldsFoTpukG78dNfvcTz0PXwC3uHFVtnRnIw2/WsdUWEWzSHHf1q6iJhEv/5csDAmGw3w6PKt7dR7HTV4mY8x+WyfF4PgckBkMsPF2GR5XV3seFmowToH77F7kzoEdgYyt4PFnoV4VS3IQE+yl6ax52ouqYBrI3ziG+SgER/6Z3p9HxxEH+rZS3ww0Yw3ZxqC7QfhY7KW3MFBUGvetVknOrRG89MMfWF/AJAgNlkbwvGW5qbc51BegUtqoaMrtPVeFp7C2CsvA639UvYaCvoQXLaINaiE1bKl6tMxOBl9fK53SYYvDswt3AeMiViooy1xZgd0nbxb4RsEblJXIVFIlLf214GRoG9nudoyTomw4PjLqJk5BBrN1KlBSegihLgQZyjDK009Vn7qzWOzLcxY8/7QGXWx4RqgLvCGBzJPfNsXfpvU7pwxDbjR/eP8Bbfhno/kifue8EA6j+Fqd4kML2Irz2rGLLTg4qjEf/sNNvY5w4lSv585NtaICW3w6O+OrttulnSa8NymclaHK5sJT+XF2sNhjn2YP1ZMB+VfaVvInhCtO1/zsNSUMeh34lOSp62widG0r06pKIJyEcxeuXjpEcAZj/O9PCmDRqwaUU6LdAUSVqJ5hp3C7gV7zfrYLLH3vcGRJoWfOd2tWO+VhYsBUeyWI5ULxFaRDWM8LKVIe69qUHqNGYDu46d3Pbuxjk41uYfuI8VSI9fm3trfonTLLt1konBpPAMqq0yK8qp+UUFDa4BBNPJ3ZFlxa14EO7kogM9Tal5TkeXYO1MW/DODcRTfYWm/WwTujpkNGknMAtG17J/ls6sn8ju7lIdqUp+I+oBDZHOhaidapMQdVyOFHvZFXeSivff3lGtyjDwIKsyRYHCO9zf4vHFgtGtDve75ebsk/p0NlaTOoUC/Y3lS/JXnBoPkl0QmeZyG5jtmvtjGLL/XBmHT/RpBNq0fL5toWns3c7obZCF+IGTaxXww4IBJXBuLsyxupV51ASi7CtlRGadP3d+4A7KCmKtCeuIm/F2yOur+Ww==" }, { "description": "Single key, proprietary content (3 bytes)", @@ -61,7 +61,7 @@ "derivation_paths": [], "plaintext": "706c61696e74657874", "nonce": "000102030405060708090a0b", - "expected": "424950585858010001ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae0001000102030405060708090a0b2803da142accb6215cecfe50629224496c4d35cfc7ee64e906e77cc3398689748c325907c7d5dafef3", - "expected_base64": "QklQWFhYAQAB/zSzQR94Entxyi48xg0P1xNQ7lV8N9cfTYH7kTRhrgABAAECAwQFBgcICQoLKAPaFCrMtiFc7P5QYpIkSWxNNc/H7mTpBud8wzmGiXSMMlkHx9Xa/vM=" + "expected": "424950585858010001ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae0001000102030405060708090a0b2903da142accb6045beaab0565952b463f1f36cdc4ec6be60508154f5c503843c8d795954351d42469b1", + "expected_base64": "QklQWFhYAQAB/zSzQR94Entxyi48xg0P1xNQ7lV8N9cfTYH7kTRhrgABAAECAwQFBgcICQoLKQPaFCrMtgRb6qsFZZUrRj8fNs3E7GvmBQgVT1xQOEPI15WVQ1HUJGmx" } ] \ No newline at end of file From 72d8a9533f209d0f8e5e51223a2f7a17b635a01e Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Thu, 18 Jun 2026 00:11:49 -0400 Subject: [PATCH 04/12] bip-0138: use assigned BIP number 138 for magic and domain separation tags --- bip-0138.md | 8 ++-- bip-0138/test_vectors/encrypted_backup.json | 16 +++---- bip-0138/test_vectors/encryption_secret.json | 44 ++++++++++---------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/bip-0138.md b/bip-0138.md index 484989b1f8..e70ab3e7e7 100644 --- a/bip-0138.md +++ b/bip-0138.md @@ -88,8 +88,8 @@ Note: in the followings sections, the operator ⊕ refers to the bitwise XOR op in particular it supports single-signature descriptors ($n = 1$). Each $p_i$ is the x-only-normalized root public key of one *allowed* key expression (see [Descriptor key requirements](#descriptor-key-requirements)). -- Let $s$ = sha256(sha256("BIPXXX_DECRYPTION_SECRET") | sha256("BIPXXX_DECRYPTION_SECRET") | $p_1$ | $p_2$ | ... | $p_n$) -- Let $s_i$ = sha256(sha256("BIPXXX_INDIVIDUAL_SECRET") | sha256("BIPXXX_INDIVIDUAL_SECRET") | $p_i$) +- Let $s$ = sha256(sha256("BIP138_DECRYPTION_SECRET") | sha256("BIP138_DECRYPTION_SECRET") | $p_1$ | $p_2$ | ... | $p_n$) +- Let $s_i$ = sha256(sha256("BIP138_INDIVIDUAL_SECRET") | sha256("BIP138_INDIVIDUAL_SECRET") | $p_i$) - Let $c_i$ = $s$ ⊕ $s_i$ Because $s$ and $s_i$ use distinct domain-separation tags, $s \neq s_i$ and @@ -172,7 +172,7 @@ and integrity. In order to decrypt the payload of a backup, the owner of a certain public key p computes: -* let $s_i$ = sha256(sha256("BIPXXX_INDIVIDUAL_SECRET") ‖ sha256("BIPXXX_INDIVIDUAL_SECRET") ‖ $p$) +* let $s_i$ = sha256(sha256("BIP138_INDIVIDUAL_SECRET") ‖ sha256("BIP138_INDIVIDUAL_SECRET") ‖ $p$) * for each `individual_secret_i` generate `reconstructed_secret_i` = `individual_secret_i` ⊕ `si` * for each `reconstructed_secret_i` process $payload$ = @@ -190,7 +190,7 @@ The encrypted backup must be encoded as follows: #### Magic -`MAGIC`: 6 bytes which are ASCII/UTF-8 representation of **BIPXXX** (TBD). +`MAGIC`: 6 bytes which are ASCII/UTF-8 representation of **BIP138**. #### Version diff --git a/bip-0138/test_vectors/encrypted_backup.json b/bip-0138/test_vectors/encrypted_backup.json index 9ce95d6d2e..66b320c9d6 100644 --- a/bip-0138/test_vectors/encrypted_backup.json +++ b/bip-0138/test_vectors/encrypted_backup.json @@ -10,9 +10,9 @@ "derivation_paths": [], "plaintext": "00", "nonce": "a1b2c3d4e5f607080910a1b2", - "expected": "424950585858010001ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae0001a1b2c3d4e5f607080910a1b2161d8f44e9a6196e61ac587ad2a3243b7c26949d848121", + "expected": "424950313338010001c14d5bfeb7f9709e996c6696959107d4c57d367d2aee207d5361f116e3c4708b01a1b2c3d4e5f607080910a1b216a42cdae8b34bb573f5cd678ef6a25c29a214abbf52de", "trailing": "deadbeef00ff", - "expected_base64": "QklQWFhYAQAB/zSzQR94Entxyi48xg0P1xNQ7lV8N9cfTYH7kTRhrgABobLD1OX2BwgJEKGyFh2PROmmGW5hrFh60qMkO3wmlJ2EgSE=" + "expected_base64": "QklQMTM4AQABwU1b/rf5cJ6ZbGaWlZEH1MV9Nn0q7iB9U2HxFuPEcIsBobLD1OX2BwgJEKGyFqQs2uizS7Vz9c1njvaiXCmiFKu/Ut4=" }, { "description": "Two keys, 1 derivation paths, BIP380 content", @@ -28,8 +28,8 @@ ], "plaintext": "wsh(or_d(pk([9d69155f/48'/1'/0'/2']tpubDDxT9mkZzWwkKwpGT5fY6iiM9muYTPkTx6Eig8dpHR7TChuGGCWYAHVmpW1ciido5RiFWwjzYsF1GZHkEHg2nrYp3zNtx3QQRkznyLhQ77x/<0;1>/*),and_v(v:pkh([9d69155f/48'/1'/0'/2']tpubDDxT9mkZzWwkKwpGT5fY6iiM9muYTPkTx6Eig8dpHR7TChuGGCWYAHVmpW1ciido5RiFWwjzYsF1GZHkEHg2nrYp3zNtx3QQRkznyLhQ77x/<2;3>/*),older(52596))))#gx5f42wh", "nonce": "0102030405060708090a0b0c", - "expected": "42495058585801010480000030800000018000000080000002024900d4ef9021cb059b8fb35c6de9b6db91949a328527ede0645be237899100bd5e3eb8a36f7bf32e02810c14666476f2b28a15cd499c30f8f98e926639a0765c010102030405060708090a0b0cfd66012f51dbbc8d0b527938df6516c8d6dad47d1cef6afb73cd846a7c46b01c5c43da1948ad924b63f8117660b9ba04b7370e1e9108b40f73a10d447d46dc362dc28c5f609e29d41b9aa40dc1e8e17515f1806f3f920fbfa1cc66ad36d7115f83e2efba4a1055928333255c12fd5003982f57fc1c979c2fdf036b117a8cb45760c69f0bfed4955a44edb1551facb883ea6700288338e3f7d31ec69f00c2b06d00300e96c1fc3f31eb17c04ce0e6a296a3e669f066a34bd59678eb39d22b8d5366a5dd42e4142b597dbf911eeb691df4b4db4635464e86fdfc1d52b2bf5de521596fd2f41a7058b128b1260fa62181c5052e561602fee7022f573b90efd50191bf4e2683a5128ec2862703e1a4be848335fbbd5006966d8b9239bd10b47da7dc1280b03492f60f94966c4110d12fc833a212e182c2f629029980471b20f15b59c16c349664967b7f5b650daaeb62a078c4d1234553425de19e2856a708edd21bf5f080f7d5ebc899a1", - "expected_base64": "QklQWFhYAQEEgAAAMIAAAAGAAAAAgAAAAgJJANTvkCHLBZuPs1xt6bbbkZSaMoUn7eBkW+I3iZEAvV4+uKNve/MuAoEMFGZkdvKyihXNSZww+PmOkmY5oHZcAQECAwQFBgcICQoLDP1mAS9R27yNC1J5ON9lFsjW2tR9HO9q+3PNhGp8RrAcXEPaGUitkktj+BF2YLm6BLc3Dh6RCLQPc6ENRH1G3DYtwoxfYJ4p1BuapA3B6OF1FfGAbz+SD7+hzGatNtcRX4Pi77pKEFWSgzMlXBL9UAOYL1f8HJecL98DaxF6jLRXYMafC/7UlVpE7bFVH6y4g+pnACiDOOP30x7GnwDCsG0AMA6Wwfw/MesXwEzg5qKWo+Zp8GajS9WWeOs50iuNU2al3ULkFCtZfb+RHutpHfS020Y1Rk6G/fwdUrK/XeUhWW/S9BpwWLEosSYPpiGBxQUuVhYC/ucCL1c7kO/VAZG/TiaDpRKOwoYnA+GkvoSDNfu9UAaWbYuSOb0QtH2n3BKAsDSS9g+UlmxBENEvyDOiEuGCwvYpApmARxsg8VtZwWw0lmSWe39bZQ2q62KgeMTRI0VTQl3hnihWpwjt0hv18ID31evImaE=" + "expected": "4249503133380101048000003080000001800000008000000202b8c6ce74f81b0ffe7d7511824e75f95114f9b140e57bb570e5c5d807f0a5e96fb8e749fceb0dd84d20a75af4dbd6d585d89c54053f6313ac6592cbfe8c1bdd4f010102030405060708090a0b0cfd6601829ae3ce2f35059533a55d10fead962d645b08a53a6fad9da13e2aa270d4561f36602d92ba9af12ef4bb495fb8296a7f7ec1ddabef1d1b25cd7e93b8dc9d437dfcd282d24ab22aaa29292ceb463cb7560321cdcae6e537fafcbedbf59e75ccb15f3a930e132037b54d8bb9b675f5f979ed8c1e084b8d9e0216519bd8ab22825ab40868133ff0ec76b623d9341c51f96cbc97e61c753e4c12e5841b640fba3fc09864ac1b67f690447c6db5e960f2ca507cad5bfae71b2fef38cc0b68c34d7f956ca0cc59d54c2d53ff5a678b4e09ce5408f6ca723040ab42e889e77c6be3771fb38a0df881128466deaa8a84e3b7cbd0ddf4a000b03d63a8e2cf5f73310e1066d3b392dc45ad30bd664490641a6bd78d4008d44193b9ea3d9285029eaa309e80afff383dda3cff1df4df4b75a254eaaf8e0f0af86e90f40b78c9d98bd354eb6eb512b6b95d05d5f95c0ca56042cea52f76252d7f2e8a95ddc4e8bffe631b399a9d69ef80d56c", + "expected_base64": "QklQMTM4AQEEgAAAMIAAAAGAAAAAgAAAAgK4xs50+BsP/n11EYJOdflRFPmxQOV7tXDlxdgH8KXpb7jnSfzrDdhNIKda9NvW1YXYnFQFP2MTrGWSy/6MG91PAQECAwQFBgcICQoLDP1mAYKa484vNQWVM6VdEP6tli1kWwilOm+tnaE+KqJw1FYfNmAtkrqa8S70u0lfuClqf37B3avvHRslzX6TuNydQ3380oLSSrIqqikpLOtGPLdWAyHNyublN/r8vtv1nnXMsV86kw4TIDe1TYu5tnX1+XntjB4IS42eAhZRm9irIoJatAhoEz/w7Ha2I9k0HFH5bLyX5hx1PkwS5YQbZA+6P8CYZKwbZ/aQRHxttelg8spQfK1b+ucbL+84zAtow01/lWygzFnVTC1T/1pni04JzlQI9spyMECrQuiJ53xr43cfs4oN+IEShGbeqoqE47fL0N30oACwPWOo4s9fczEOEGbTs5LcRa0wvWZEkGQaa9eNQAjUQZO56j2ShQKeqjCegK//OD3aPP8d9N9LdaJU6q+ODwr4bpD0C3jJ2YvTVOtutRK2uV0F1flcDKVgQs6lL3YlLX8uipXdxOi//mMbOZqdae+A1Ww=" }, { "description": "Three keys, multiple derivation paths, BIP329 content", @@ -47,8 +47,8 @@ ], "plaintext": "{\"type\":\"tx\",\"ref\":\"f91d0a8a78462bc59398f2c5d7a84fcff491c26ba54c4833478b202796c8aafd\",\"label\":\"Transaction\",\"origin\":\"wpkh([d34db33f/84'/0'/0'])\"}\n{\"type\":\"addr\",\"ref\":\"bc1q34aq5drpuwy3wgl9lhup9892qp6svr8ldzyy7c\",\"label\":\"Address\"}\n{\"type\":\"pubkey\",\"ref\":\"0283409659355b6d1cc3c32decd5d561abaac86c37a353b52895a5e6c196d6f448\",\"label\":\"Public Key\"}\n{\"type\":\"input\",\"ref\":\"f91d0a8a78462bc59398f2c5d7a84fcff491c26ba54c4833478b202796c8aafd:0\",\"label\":\"Input\"}\n{\"type\":\"output\",\"ref\":\"f91d0a8a78462bc59398f2c5d7a84fcff491c26ba54c4833478b202796c8aafd:1\",\"label\":\"Output\",\"spendable\":false}\n{\"type\":\"xpub\",\"ref\":\"xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8\",\"label\":\"Extended Public Key\"}\n{\"type\":\"tx\",\"ref\":\"f546156d9044844e02b181026a1a407abfca62e7ea1159f87bbeaa77b4286c74\",\"label\":\"Account #1 Transaction\",\"origin\":\"wpkh([d34db33f/84'/0'/1'])\"}", "nonce": "deadbeefcafebabe12345678", - "expected": "4249505858580102040000000080000001000000028000000303800000548000000080000000032424c7f03a4b1ec573f64738c2a61ac0a9480750f6a641ff8dd1e85acf5b8008331aabbcc51126eeeaf8f870c92bdae98a5688af3a1d9ce71004980b7f6af6e96e5f3aab8b6dfe2f8c09da023a29f797d8333736fb7b7c64958d0ff4109ba93a01deadbeefcafebabe12345678fd9f03f6ebb86442b72e0385bf19aa8436ec3f245da31b4892e7a40c6fc6e19888d34dda627622bd7a6a7439e2f6757bf9f4ea55982e08bed2666155583a1057ac2951f2b574642a82c7b3d65cfee12c5459d01702e92f9606d529ea13b06390cd22f367fa4cabd7943e980ae68c0d6bdd144485c0704afd8a81ecc890518598607752984ae0229f22373bcafdaebe6432cf73b94a650a6c95db05a13a6e906efc74d7ef713cf43d7c02dee1c556d9d19c8c36fd6b1d516116cd21c77f5aba889844bffe5cb030261b0df0e8f2adedd47b1d3578998f31f96c9f1783e072406432c3c5d864795d5dec7859a8c13a07efb17b933a04760632b783c59e8578552dc8404fb297a6b1e76a2ea9806b237ce21be4a0111ffa677a7d1f1c441fead94b7c30d18c37671a82ed07e163b296dcc141506bdeb559273ab446f3d30c7d617f00902036591bc2f196e6a6dce7505e814b6aa1a32bb4f55e169ec2d82b2f03adfd52f61a0afa105cb68835a884d5b2a5ead33138197d7cae7749862f0ecc2ddc078c8958a8a32d716607749dbc5be11b046e525721514894b7f6d78191a06f67b9da324e89b0e0f8cba89939041acdd4a94149e82284b8106728c32b4d3d567eeacd63b32dcc58f3fed01975b1e11aa02ef08607324f7cdb177e9bd4ee9c310db8d1fde3fc05b7e19e8fe489fb9ef0403a8fe16a77890c2f622bcf6ac62cb4e0e2a8c47ffb0d36f639c38952bf9f3936d688096df0e8ef8eaedb6e96749af0dca67256872b9b094fe5c5dac3618e7d983f564c07e55f695bc89e10ad3b5ff3b0d49431e877e25392a7adb089d1b4af4ea928827211cc5eb978e911c0198ff3bd3c298346ac1a514e8b74051256a279869dc2ee057bcdfad82cb1f7bdc19126859f39ddad58ef95858b0151ec9623950bc456910d633c2ca5487baf6a507a8d1980eee3a7773dbbb18e4e35b987ee23c55223d7e6dedadfa274cb2edd64a270693c032aab4c8af2aa7e5141436b804134f2776459716b5e043bb92880cf536a5e5391e5d83b5316fc33837114df6169bf5b04ee8e990d1a49cc02d1b5ec9fe5b3ab27f23bbb94876a529f88fa80436473a16a275aa4c41d5723851ef6455de4a2bdf7f7946b728c3c082acc9160708ef737f8bc7160b46b43bdeef979bb24fe9d0d95a4cea140bf637952fc95e70683e4974426799c86e63b66bed8c62cbfd70661d3fd1a4136ad1f2f9b685a7b3773ba1b64217e2064dac57c30e080495c1b8bb32c6ea55e750128bb0ad95119a74fdddfb803b28298ab427ae226fc5db23aeafe5b", - "expected_base64": "QklQWFhYAQIEAAAAAIAAAAEAAAACgAAAAwOAAABUgAAAAIAAAAADJCTH8DpLHsVz9kc4wqYawKlIB1D2pkH/jdHoWs9bgAgzGqu8xREm7ur4+HDJK9rpilaIrzodnOcQBJgLf2r26W5fOquLbf4vjAnaAjop95fYMzc2+3t8ZJWND/QQm6k6Ad6tvu/K/rq+EjRWeP2fA/bruGRCty4Dhb8ZqoQ27D8kXaMbSJLnpAxvxuGYiNNN2mJ2Ir16anQ54vZ1e/n06lWYLgi+0mZhVVg6EFesKVHytXRkKoLHs9Zc/uEsVFnQFwLpL5YG1SnqE7BjkM0i82f6TKvXlD6YCuaMDWvdFESFwHBK/YqB7MiQUYWYYHdSmErgIp8iNzvK/a6+ZDLPc7lKZQpsldsFoTpukG78dNfvcTz0PXwC3uHFVtnRnIw2/WsdUWEWzSHHf1q6iJhEv/5csDAmGw3w6PKt7dR7HTV4mY8x+WyfF4PgckBkMsPF2GR5XV3seFmowToH77F7kzoEdgYyt4PFnoV4VS3IQE+yl6ax52ouqYBrI3ziG+SgER/6Z3p9HxxEH+rZS3ww0Yw3ZxqC7QfhY7KW3MFBUGvetVknOrRG89MMfWF/AJAgNlkbwvGW5qbc51BegUtqoaMrtPVeFp7C2CsvA639UvYaCvoQXLaINaiE1bKl6tMxOBl9fK53SYYvDswt3AeMiViooy1xZgd0nbxb4RsEblJXIVFIlLf214GRoG9nudoyTomw4PjLqJk5BBrN1KlBSegihLgQZyjDK009Vn7qzWOzLcxY8/7QGXWx4RqgLvCGBzJPfNsXfpvU7pwxDbjR/eP8Bbfhno/kifue8EA6j+Fqd4kML2Irz2rGLLTg4qjEf/sNNvY5w4lSv585NtaICW3w6O+OrttulnSa8NymclaHK5sJT+XF2sNhjn2YP1ZMB+VfaVvInhCtO1/zsNSUMeh34lOSp62widG0r06pKIJyEcxeuXjpEcAZj/O9PCmDRqwaUU6LdAUSVqJ5hp3C7gV7zfrYLLH3vcGRJoWfOd2tWO+VhYsBUeyWI5ULxFaRDWM8LKVIe69qUHqNGYDu46d3Pbuxjk41uYfuI8VSI9fm3trfonTLLt1konBpPAMqq0yK8qp+UUFDa4BBNPJ3ZFlxa14EO7kogM9Tal5TkeXYO1MW/DODcRTfYWm/WwTujpkNGknMAtG17J/ls6sn8ju7lIdqUp+I+oBDZHOhaidapMQdVyOFHvZFXeSivff3lGtyjDwIKsyRYHCO9zf4vHFgtGtDve75ebsk/p0NlaTOoUC/Y3lS/JXnBoPkl0QmeZyG5jtmvtjGLL/XBmHT/RpBNq0fL5toWns3c7obZCF+IGTaxXww4IBJXBuLsyxupV51ASi7CtlRGadP3d+4A7KCmKtCeuIm/F2yOur+Ww==" + "expected": "424950313338010204000000008000000100000002800000030380000054800000008000000003281aff33e4b8186ac4176427b59ec3c72af96bf6ecd1ad7ed1d746103d078a17283b78bbf7aecfd999c52f51203def13e69c8eb336c90ba2518055e941b9be37f6353d50c714c43f7b86794ee21e3490af33468ef30217dd93003413e23b4c1701deadbeefcafebabe12345678fd9f032b5e117a385bfc3c88c2eae4e2e4aeeaaff5c5ced44579c77cb67fbb6c12bdc113c1e2c9bb1029ec47f589311030efe4aa3924958aa53b737d5fdf0fc2272037ba9260303a07010ceaf38e40aec5d28318968e833511bdc6d4ab99cb1e51153f0571fd6c0e08b58a8b75bdb91c7fb94b16872ac5800c981f06d3c28fdf71a9382c08c74d2d0ffe9e20774e6c8bec95cd6713ec60ff2fa54d50a507e84448d91ba5fcaa8dd17ad19dbb962e4514a127d795d8cf82ced19d242a9777a9bd6f714c3deec247530f74c055410e6b42ae98de71259103cf14f0d5719ae2900675841c010c1e6c076a9be2ddf271e3281184dc8759063a4c1be8f2e3a57e6557b76228bf13e5d1cf6fc8726d6429cad74c84fbb15046abb12fe7f6f6e3856016dae37fff0a161cb9da34e814976ccc9b03a587900eb36cbd56049cdc9680816fe9c4a14838fa2a999bf4ad7fe5efa7d31c7164886d6eafa18fe40185bcc982768d0a3ca05e3450979e4140cacd834f8e6399048b59e6ab025964c2afcf6119b614c56755e5e37b6425ea3926dd9b9fe4cd6e127d6006abdb38b393437cb26cd8ccbda13825c90b857deab2dbaf759b14ffb0692e448ecbba9a3cdbac7b7661be2a8cec5a0b9df3bbe1a67014653e159c41c3b36974563b8392731f3dec68c16e4a644bad4236208876aba0d00bdd3cefac04c31b1e1673b91d0010f8ebe7070c07f8b00effa79b8e94fb1b9285904114e37d4e2987d9246a300958a9fbf1c2af1016edcec7b9e0fca80935652c3426e837a9ce018615d1f1127da307daca4dc8bc201f44b09c0adb52859f49cc625a5ecd31bbe513ea5c97dfb8f192cffd60864acc4c1a0a4f630190cbf1e1fe8201d8b7b2b4da7e8813f56e1d885f57700289ee4661928540607be79221137c1a79b8b4ab6150f1c9c4c6ca2367a673d5f7faa2cbcdbc1fd68c45acb33e7344e55a431c03ad03fb4442bd01b8b51cce71c7779fa2f63120bed1ed30ff35969cc2cb049b598a473b670012bd155e6efcad815a83cd76ea06eef14867cef22998bf39debadd78fface8cb6cb9ee3f02636683d69458f6ace058f232ef1d1d547c0073a82ba507a006df40f69d2a247b485ee6010cfbb58bbc6f0423287f475df21c2e23533a1653c48aac55b7a64e489850477482a08924c984700d5be68834455c17b8cae220f898679515735273d4d8e8a0c62735e859d7a7158db7f8e8d1d94e94dd9750c1bd8b5a89a8f67a1ba146201a3999b00350ae1467de39d984b56d4d62ec04bdf0cf05a241468b6a0b70e8ccbbe476ee", + "expected_base64": "QklQMTM4AQIEAAAAAIAAAAEAAAACgAAAAwOAAABUgAAAAIAAAAADKBr/M+S4GGrEF2QntZ7Dxyr5a/bs0a1+0ddGED0HihcoO3i7967P2ZnFL1EgPe8T5pyOszbJC6JRgFXpQbm+N/Y1PVDHFMQ/e4Z5TuIeNJCvM0aO8wIX3ZMANBPiO0wXAd6tvu/K/rq+EjRWeP2fAyteEXo4W/w8iMLq5OLkruqv9cXO1EV5x3y2f7tsEr3BE8HiybsQKexH9YkxEDDv5Ko5JJWKpTtzfV/fD8InIDe6kmAwOgcBDOrzjkCuxdKDGJaOgzURvcbUq5nLHlEVPwVx/WwOCLWKi3W9uRx/uUsWhyrFgAyYHwbTwo/fcak4LAjHTS0P/p4gd05si+yVzWcT7GD/L6VNUKUH6ERI2Rul/KqN0XrRnbuWLkUUoSfXldjPgs7RnSQql3epvW9xTD3uwkdTD3TAVUEOa0KumN5xJZEDzxTw1XGa4pAGdYQcAQwebAdqm+Ld8nHjKBGE3IdZBjpMG+jy46V+ZVe3Yii/E+XRz2/Icm1kKcrXTIT7sVBGq7Ev5/b244VgFtrjf/8KFhy52jToFJdszJsDpYeQDrNsvVYEnNyWgIFv6cShSDj6Kpmb9K1/5e+n0xxxZIhtbq+hj+QBhbzJgnaNCjygXjRQl55BQMrNg0+OY5kEi1nmqwJZZMKvz2EZthTFZ1Xl43tkJeo5Jt2bn+TNbhJ9YAar2zizk0N8smzYzL2hOCXJC4V96rLbr3WbFP+waS5Ejsu6mjzbrHt2Yb4qjOxaC53zu+GmcBRlPhWcQcOzaXRWO4OScx897GjBbkpkS61CNiCIdqug0AvdPO+sBMMbHhZzuR0AEPjr5wcMB/iwDv+nm46U+xuShZBBFON9TimH2SRqMAlYqfvxwq8QFu3Ox7ng/KgJNWUsNCboN6nOAYYV0fESfaMH2spNyLwgH0SwnArbUoWfScxiWl7NMbvlE+pcl9+48ZLP/WCGSsxMGgpPYwGQy/Hh/oIB2LeytNp+iBP1bh2IX1dwAonuRmGShUBge+eSIRN8Gnm4tKthUPHJxMbKI2emc9X3+qLLzbwf1oxFrLM+c0TlWkMcA60D+0RCvQG4tRzOccd3n6L2MSC+0e0w/zWWnMLLBJtZikc7ZwASvRVebvytgVqDzXbqBu7xSGfO8imYvzneut14/6zoy2y57j8CY2aD1pRY9qzgWPIy7x0dVHwAc6grpQegBt9A9p0qJHtIXuYBDPu1i7xvBCMof0dd8hwuI1M6FlPEiqxVt6ZOSJhQR3SCoIkkyYRwDVvmiDRFXBe4yuIg+JhnlRVzUnPU2Oigxic16FnXpxWNt/jo0dlOlN2XUMG9i1qJqPZ6G6FGIBo5mbADUK4UZ9452YS1bU1i7AS98M8FokFGi2oLcOjMu+R27g==" }, { "description": "Single key, proprietary content (3 bytes)", @@ -61,7 +61,7 @@ "derivation_paths": [], "plaintext": "706c61696e74657874", "nonce": "000102030405060708090a0b", - "expected": "424950585858010001ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae0001000102030405060708090a0b2903da142accb6045beaab0565952b463f1f36cdc4ec6be60508154f5c503843c8d795954351d42469b1", - "expected_base64": "QklQWFhYAQAB/zSzQR94Entxyi48xg0P1xNQ7lV8N9cfTYH7kTRhrgABAAECAwQFBgcICQoLKQPaFCrMtgRb6qsFZZUrRj8fNs3E7GvmBQgVT1xQOEPI15WVQ1HUJGmx" + "expected": "424950313338010001c14d5bfeb7f9709e996c6696959107d4c57d367d2aee207d5361f116e3c4708b01000102030405060708090a0b2988e0747028c10af011cba311ebabb3a094366a96ad747cd8e3edfc1474b356c2393e13ee9c5cd0aae5", + "expected_base64": "QklQMTM4AQABwU1b/rf5cJ6ZbGaWlZEH1MV9Nn0q7iB9U2HxFuPEcIsBAAECAwQFBgcICQoLKYjgdHAowQrwEcujEeurs6CUNmqWrXR82OPt/BR0s1bCOT4T7pxc0Krl" } ] \ No newline at end of file diff --git a/bip-0138/test_vectors/encryption_secret.json b/bip-0138/test_vectors/encryption_secret.json index a04b37af93..d2344b404d 100644 --- a/bip-0138/test_vectors/encryption_secret.json +++ b/bip-0138/test_vectors/encryption_secret.json @@ -4,9 +4,9 @@ "keys": [ "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443" ], - "decryption_secret": "a37acb446622cf11ffe44e1f17892d7b330b721b992513f680a52b128fb181b1", + "decryption_secret": "9628546fe8fbf82fb10ff692d82953fa2db546275be9ce1b00134aff1a8bacdd", "individual_secrets": [ - "ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae00" + "c14d5bfeb7f9709e996c6696959107d4c57d367d2aee207d5361f116e3c4708b" ] }, { @@ -15,10 +15,10 @@ "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443", "0384526253c27c7aef56c7b71a5cd25bebb66dddda437826defc5b2568bde81f07" ], - "decryption_secret": "154eaceae97b166f15a1d37fbc6d9477b1cf067c60352909a97f32b432412f0c", + "decryption_secret": "efa3c1e5a719874f5516818603cdad7ffc31c11a947c5b16b6b763ee09ea3539", "individual_secrets": [ - "5e3eb8a36f7bf32e02810c14666476f2b28a15cd499c30f8f98e926639a0765c", - "4900d4ef9021cb059b8fb35c6de9b6db91949a328527ede0645be237899100bd" + "b8e749fceb0dd84d20a75af4dbd6d585d89c54053f6313ac6592cbfe8c1bdd4f", + "b8c6ce74f81b0ffe7d7511824e75f95114f9b140e57bb570e5c5d807f0a5e96f" ] }, { @@ -28,11 +28,11 @@ "0384526253c27c7aef56c7b71a5cd25bebb66dddda437826defc5b2568bde81f07", "03c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5" ], - "decryption_secret": "6f54d3b9bc4bfb8464d6985318aff845aa0d14e1df0f580edd204888c4bad958", + "decryption_secret": "7f7ff0a2bbba90dbec74f423f82697e9c2311bac9dd6431882a5fdf9c4485641", "individual_secrets": [ - "2424c7f03a4b1ec573f64738c2a61ac0a9480750f6a641ff8dd1e85acf5b8008", - "6e5f3aab8b6dfe2f8c09da023a29f797d8333736fb7b7c64958d0ff4109ba93a", - "331aabbcc51126eeeaf8f870c92bdae98a5688af3a1d9ce71004980b7f6af6e9" + "283b78bbf7aecfd999c52f51203def13e69c8eb336c90ba2518055e941b9be37", + "f6353d50c714c43f7b86794ee21e3490af33468ef30217dd93003413e23b4c17", + "281aff33e4b8186ac4176427b59ec3c72af96bf6ecd1ad7ed1d746103d078a17" ] }, { @@ -42,11 +42,11 @@ "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443", "0384526253c27c7aef56c7b71a5cd25bebb66dddda437826defc5b2568bde81f07" ], - "decryption_secret": "6f54d3b9bc4bfb8464d6985318aff845aa0d14e1df0f580edd204888c4bad958", + "decryption_secret": "7f7ff0a2bbba90dbec74f423f82697e9c2311bac9dd6431882a5fdf9c4485641", "individual_secrets": [ - "2424c7f03a4b1ec573f64738c2a61ac0a9480750f6a641ff8dd1e85acf5b8008", - "6e5f3aab8b6dfe2f8c09da023a29f797d8333736fb7b7c64958d0ff4109ba93a", - "331aabbcc51126eeeaf8f870c92bdae98a5688af3a1d9ce71004980b7f6af6e9" + "283b78bbf7aecfd999c52f51203def13e69c8eb336c90ba2518055e941b9be37", + "f6353d50c714c43f7b86794ee21e3490af33468ef30217dd93003413e23b4c17", + "281aff33e4b8186ac4176427b59ec3c72af96bf6ecd1ad7ed1d746103d078a17" ] }, { @@ -56,11 +56,11 @@ "03c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5", "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443" ], - "decryption_secret": "6f54d3b9bc4bfb8464d6985318aff845aa0d14e1df0f580edd204888c4bad958", + "decryption_secret": "7f7ff0a2bbba90dbec74f423f82697e9c2311bac9dd6431882a5fdf9c4485641", "individual_secrets": [ - "2424c7f03a4b1ec573f64738c2a61ac0a9480750f6a641ff8dd1e85acf5b8008", - "6e5f3aab8b6dfe2f8c09da023a29f797d8333736fb7b7c64958d0ff4109ba93a", - "331aabbcc51126eeeaf8f870c92bdae98a5688af3a1d9ce71004980b7f6af6e9" + "283b78bbf7aecfd999c52f51203def13e69c8eb336c90ba2518055e941b9be37", + "f6353d50c714c43f7b86794ee21e3490af33468ef30217dd93003413e23b4c17", + "281aff33e4b8186ac4176427b59ec3c72af96bf6ecd1ad7ed1d746103d078a17" ] }, { @@ -69,10 +69,10 @@ "0384526253c27c7aef56c7b71a5cd25bebb66dddda437826defc5b2568bde81f07", "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443" ], - "decryption_secret": "154eaceae97b166f15a1d37fbc6d9477b1cf067c60352909a97f32b432412f0c", + "decryption_secret": "efa3c1e5a719874f5516818603cdad7ffc31c11a947c5b16b6b763ee09ea3539", "individual_secrets": [ - "5e3eb8a36f7bf32e02810c14666476f2b28a15cd499c30f8f98e926639a0765c", - "4900d4ef9021cb059b8fb35c6de9b6db91949a328527ede0645be237899100bd" + "b8e749fceb0dd84d20a75af4dbd6d585d89c54053f6313ac6592cbfe8c1bdd4f", + "b8c6ce74f81b0ffe7d7511824e75f95114f9b140e57bb570e5c5d807f0a5e96f" ] }, { @@ -81,9 +81,9 @@ "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443", "02e6642fd69bd211f93f7f1f36ca51a26a5290eb2dd1b0d8279a87bb0d480c8443" ], - "decryption_secret": "a37acb446622cf11ffe44e1f17892d7b330b721b992513f680a52b128fb181b1", + "decryption_secret": "9628546fe8fbf82fb10ff692d82953fa2db546275be9ce1b00134aff1a8bacdd", "individual_secrets": [ - "ff34b3411f78127b71ca2e3cc60d0fd71350ee557c37d71f4d81fb913461ae00" + "c14d5bfeb7f9709e996c6696959107d4c57d367d2aee207d5361f116e3c4708b" ] } ] \ No newline at end of file From b7ba2840a980ffde6831bc270fe804e041b1e638 Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Thu, 18 Jun 2026 03:02:17 -0400 Subject: [PATCH 05/12] bip-138: clarify CONTENT is a single TLV and forbid all-zero nonce --- bip-0138.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/bip-0138.md b/bip-0138.md index e70ab3e7e7..b88356b5af 100644 --- a/bip-0138.md +++ b/bip-0138.md @@ -167,6 +167,9 @@ and integrity. * let $nonce$ = random(96 bits) * let $ciphertext$ = encrypt($payload$, $secret$, $nonce$) +The $nonce$ MUST NOT be all zero. If the random source yields an all-zero nonce, +the encoder MUST generate a new one. + ### Decryption In order to decrypt the payload of a backup, the owner of a certain public key p @@ -309,6 +312,10 @@ it follows this format: `TYPE` (`LENGTH`) `DATA` +`CONTENT` is a single `TYPE (LENGTH) DATA` triple, one blob describing `PLAINTEXT`. +It is not a sequence of entries; it is immediately followed by the payload `LENGTH` +and `PLAINTEXT`. + `TYPE`: 1-byte unsigned integer identifying how to interpret `DATA`. | Value | Definition | @@ -332,16 +339,17 @@ For `TYPE` values defined above: For all `TYPE` values except `0x01`, parsers MUST reject `CONTENT` if `LENGTH` exceeds the remaining payload bytes. -Parsers MUST skip unknown `TYPE` values less than `0x80`, by consuming `LENGTH` bytes -of `DATA`. +For an unknown `TYPE` less than `0x80`, parsers MUST consume its `LENGTH` bytes of +`DATA`, treat the content type as unknown, and continue with the payload `LENGTH` +and `PLAINTEXT`. -For unknown `TYPE` values greater than or equal to `0x80`, parsers MUST stop parsing -`CONTENT`.[^type-upgrade] +For an unknown `TYPE` greater than or equal to `0x80`, parsers MUST reject the +payload.[^type-upgrade] [^type-upgrade]: **Why the 0x80 threshold?** - The `TYPE >= 0x80` rule means we're not stuck with the current TLV encoding. - It has a nice upgrade property: you can still encode backward compatible stuff - at the start. + The `TYPE >= 0x80` rule keeps the encoding upgradeable. A future version can + define a new content type at or above `0x80` that older parsers reject rather + than misread, while types below `0x80` stay backward compatible. #### Encrypted Payload @@ -349,7 +357,7 @@ For unknown `TYPE` values greater than or equal to `0x80`, parsers MUST stop par `NONCE` `LENGTH` `CIPHERTEXT` -`NONCE`: 12-byte (96-bit) nonce. +`NONCE`: 12-byte (96-bit) nonce. Parsers MUST reject a backup whose `NONCE` is all zero. `LENGTH`: variable-length integer representing ciphertext length. `CIPHERTEXT`: variable-length ciphertext. From 9e2a585a9ad2bc01d1114725f822953e1ae1ed81 Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Thu, 18 Jun 2026 03:44:25 -0400 Subject: [PATCH 06/12] bip-138: specify BIP380 descriptor backup content --- bip-0138.md | 56 +++++++++++++++++++ .../bip380_descriptor_backup.json | 33 +++++++++++ .../test_vectors/bip380_descriptor_backup.txt | 2 + 3 files changed, 91 insertions(+) create mode 100644 bip-0138/test_vectors/bip380_descriptor_backup.json create mode 100644 bip-0138/test_vectors/bip380_descriptor_backup.txt diff --git a/bip-0138.md b/bip-0138.md index b88356b5af..fc2d2872bf 100644 --- a/bip-0138.md +++ b/bip-0138.md @@ -351,6 +351,59 @@ payload.[^type-upgrade] define a new content type at or above `0x80` that older parsers reject rather than misread, while types below `0x80` stay backward compatible. +#### BIP380 Descriptor Backup Content + +When `CONTENT` is `TYPE = 0x01` with `DATA = 0x017c` (BIP380), `PLAINTEXT` +is UTF-8 encoded BIP380 descriptor backup content. It is either: + +- A text descriptor backup document. +- A JSON descriptor backup document, if the first character is `{`. + +Test vectors are in +[`bip380_descriptor_backup.txt`](./bip-0138/test_vectors/bip380_descriptor_backup.txt) +and +[`bip380_descriptor_backup.json`](./bip-0138/test_vectors/bip380_descriptor_backup.json). + +Descriptor strings MUST NOT contain private key material and SHOULD include a +checksum. + +##### Text Descriptor Backup Documents + +A text descriptor backup document contains one BIP380 output script descriptor +per line. Empty lines and lines starting with `#` MUST be ignored. Each +descriptor MUST use BIP389 multipath key expressions, where `/<0;1>` means +receive and change, respectively. + +##### JSON Descriptor Backup Documents + +The descriptor backup document is a JSON object with the following fields: + +- `version`: integer. This specification defines version `1`. +- `descriptor_sets`: array of descriptor set objects. + +Each descriptor set describes BIP380 output script descriptors belonging to one +logical account or script family. + +##### Descriptor Set Fields + +`descriptor` is a required string containing a BIP380 output script descriptor. + +For BIP389 multipath descriptors, `/<0;1>` means receive and change, +respectively. The `change_descriptor` field MUST NOT be used. + +For descriptors without BIP389 multipath key expressions, `descriptor` is the +receive descriptor and `change_descriptor` is the change descriptor. + +If optional boolean `archived` is `true`, importing wallets SHOULD NOT use the +descriptor set for new address generation. + +`range` is an optional two-element array `[start, end]`, inclusive, describing +the ranged derivation indexes covered by the descriptor set. + +`birth_time` is an optional integer Unix timestamp in seconds, indicating a +lower bound for when the descriptor set may have received funds. Importing +wallets MAY use this value as a scanning hint. + #### Encrypted Payload `ENCRYPTED_PAYLOAD` follows this format: @@ -407,6 +460,9 @@ contains test vectors for generation of encryption secret. contains test vectors for ciphertexts generated using CHACHA20-POLY1305. [encrypted_backup.json](./bip-0138/test_vectors/encrypted_backup.json) contains test vectors for generation of complete encrypted backup. +[bip380_descriptor_backup.txt](./bip-0138/test_vectors/bip380_descriptor_backup.txt) +and [bip380_descriptor_backup.json](./bip-0138/test_vectors/bip380_descriptor_backup.json) +contain test vectors for BIP380 descriptor backup documents. ## Acknowledgements diff --git a/bip-0138/test_vectors/bip380_descriptor_backup.json b/bip-0138/test_vectors/bip380_descriptor_backup.json new file mode 100644 index 0000000000..719d0e1187 --- /dev/null +++ b/bip-0138/test_vectors/bip380_descriptor_backup.json @@ -0,0 +1,33 @@ +[ + { + "description": "Descriptor with change descriptor", + "valid": true, + "document": { + "version": 1, + "descriptor_sets": [ + { + "archived": false, + "birth_time": 1710000000, + "range": [0, 999], + "descriptor": "wpkh([d34db33f/84h/1h/0h]tpubDC5FSnBiZDMmhiuCmWAYsLwgLYrrT9rAqvTySfuCCrgsWz8wxMXUS9Tb9iVMvcRbvFcAHGkMD5Kx8koh4GquNGNTfohfk7pgjhaPCdXpoba/0/*)", + "change_descriptor": "wpkh([d34db33f/84h/1h/0h]tpubDC5FSnBiZDMmhiuCmWAYsLwgLYrrT9rAqvTySfuCCrgsWz8wxMXUS9Tb9iVMvcRbvFcAHGkMD5Kx8koh4GquNGNTfohfk7pgjhaPCdXpoba/1/*)" + } + ] + } + }, + { + "description": "BIP389 multipath descriptor", + "valid": true, + "document": { + "version": 1, + "descriptor_sets": [ + { + "archived": false, + "birth_time": 1710000000, + "range": [0, 999], + "descriptor": "wpkh([d34db33f/84h/1h/0h]tpubDC5FSnBiZDMmhiuCmWAYsLwgLYrrT9rAqvTySfuCCrgsWz8wxMXUS9Tb9iVMvcRbvFcAHGkMD5Kx8koh4GquNGNTfohfk7pgjhaPCdXpoba/<0;1>/*)" + } + ] + } + } +] diff --git a/bip-0138/test_vectors/bip380_descriptor_backup.txt b/bip-0138/test_vectors/bip380_descriptor_backup.txt new file mode 100644 index 0000000000..4ce5adaa08 --- /dev/null +++ b/bip-0138/test_vectors/bip380_descriptor_backup.txt @@ -0,0 +1,2 @@ +# BIP380 descriptor backup text vector +wpkh([d34db33f/84h/1h/0h]tpubDC5FSnBiZDMmhiuCmWAYsLwgLYrrT9rAqvTySfuCCrgsWz8wxMXUS9Tb9iVMvcRbvFcAHGkMD5Kx8koh4GquNGNTfohfk7pgjhaPCdXpoba/<0;1>/*) From 810b4df73ef161e91b5ef10819e589e21e90b9ab Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Thu, 18 Jun 2026 04:38:58 -0400 Subject: [PATCH 07/12] bip-138: specify BIP388 wallet policy backup content --- bip-0138.md | 53 +++++++++++- bip-0138/test_vectors/bip388.json | 92 +++++++++++++++++++++ bip-0138/test_vectors/encrypted_backup.json | 17 ++++ 3 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 bip-0138/test_vectors/bip388.json diff --git a/bip-0138.md b/bip-0138.md index fc2d2872bf..38c50cc598 100644 --- a/bip-0138.md +++ b/bip-0138.md @@ -404,6 +404,54 @@ the ranged derivation indexes covered by the descriptor set. lower bound for when the descriptor set may have received funds. Importing wallets MAY use this value as a scanning hint. +#### BIP388 Wallet Policy Backup Content + +When `CONTENT` is `TYPE = 0x01` with `DATA = 0x0184` (BIP388), `PLAINTEXT` is a +UTF-8 JSON wallet policy backup document. A BIP388 wallet policy is a descriptor +template plus a vector of key information items, as defined in BIP388. + +Test vectors are in +[`bip388.json`](./bip-0138/test_vectors/bip388.json). + +The document is one of two forms: + +- A single policy, a JSON object `{ "keys": [...], "policy": "