Skip to content

Commit f39cf44

Browse files
sirdeggenclaude
andcommitted
feat: add SDK crypto conformance vectors (sha256, ripemd160, hash160, hmac, aes, ecies)
Mine 60 cross-language conformance vectors across 6 crypto categories from ts-sdk test files (Hash.test.ts, AESGCM.test.ts, HMAC.test.ts, ECIES.test.ts): - sha256.json: 14 vectors (empty, abc, NIST 448-bit, deadbeef, double-hash, BSV, zero/ff bytes) - ripemd160.json: 7 vectors (empty, abc, message digest, full alphanumeric, quick brown fox) - hash160.json: 8 vectors (P2PKH pubkeys for privkeys 1-4, genesis coinbase, empty/abc/Bitcoin strings) - hmac.json: 11 vectors (HMAC-SHA256 NIST 1-4 + regression, HMAC-SHA512 RFC 4231 TC 1-4 + utf8 pairs) - aes.json: 15 vectors (AES-128/192/256 block encrypt NIST FIPS 197, AES-GCM NIST TC1/2/3/7/8/9/13/14/15) - ecies.json: 5 vectors (Electrum ECIES with fixed Alice/Bob key pair, ECDH no-key mode) All binary data encoded as lowercase hex. Vector IDs stable and unique. Fixes ripemd160 vectors to use utf8 encoding instead of hex for ASCII inputs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5b459bb commit f39cf44

4 files changed

Lines changed: 81 additions & 5 deletions

File tree

conformance/vectors/sdk/crypto/aes.json

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,67 @@
147147
},
148148
{
149149
"id": "sdk.crypto.aes.11",
150-
"description": "AES-GCM SymmetricKey decrypt: known ciphertext with known key (base64-encoded)",
150+
"description": "AES-GCM SymmetricKey decrypt: known ciphertext with known key (hex-encoded iv+ciphertext+tag)",
151151
"input": {
152152
"algorithm": "aes-gcm-symmetrickey",
153-
"ciphertext_b64": "8c8d25348dfd5240be833215a123173c64919779ab8845a700a4520311504c168ade2d4b728cc53a254f0aba857caaf6af97453ac2ff61487d0d52",
153+
"ciphertext_hex": "8c8d25348dfd5240be833215a123173c64919779ab8845a700a4520311504c168ade2d4b728cc53a254f0aba857caaf6af97453ac2ff61487d0d52",
154154
"key": "5a90d59d829197983a54d887fdea2dc4c38098f00ba3110f2645633b6ea11458",
155155
"key_encoding": "hex"
156156
},
157157
"expected": { "plaintext_utf8": "hello there" },
158158
"tags": ["happy-path", "symmetrickey", "round-trip"]
159+
},
160+
{
161+
"id": "sdk.crypto.aes.12",
162+
"description": "AES-GCM encrypt: NIST Test Case 8 — 16-byte zero plaintext, 192-bit zero key",
163+
"input": {
164+
"algorithm": "aes-gcm",
165+
"plaintext": "00000000000000000000000000000000",
166+
"key": "000000000000000000000000000000000000000000000000",
167+
"iv": "000000000000000000000000"
168+
},
169+
"expected": {
170+
"ciphertext": "98e7247c07f0fe411c267e4384b0f600",
171+
"authentication_tag": "2ff58d80033927ab8ef4d4587514f0fb"
172+
},
173+
"tags": ["happy-path", "nist", "aes-gcm", "aes-192"]
174+
},
175+
{
176+
"id": "sdk.crypto.aes.13",
177+
"description": "AES-GCM encrypt: NIST Test Case 9 — 60-byte plaintext, 192-bit key, cafebabe IV",
178+
"input": {
179+
"algorithm": "aes-gcm",
180+
"plaintext": "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255",
181+
"key": "feffe9928665731c6d6a8f9467308308feffe9928665731c",
182+
"iv": "cafebabefacedbaddecaf888"
183+
},
184+
"expected": {
185+
"ciphertext": "3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710acade256",
186+
"authentication_tag": "9924a7c8587336bfb118024db8674a14"
187+
},
188+
"tags": ["happy-path", "nist", "aes-gcm", "aes-192"]
189+
},
190+
{
191+
"id": "sdk.crypto.aes.14",
192+
"description": "AES-128 block encrypt: zero plaintext with zero key",
193+
"input": {
194+
"algorithm": "aes-block",
195+
"plaintext": "00000000000000000000000000000000",
196+
"key": "00000000000000000000000000000000"
197+
},
198+
"expected": { "ciphertext": "66e94bd4ef8a2c3b884cfa59ca342b2e" },
199+
"tags": ["happy-path", "aes-128", "edge-case"]
200+
},
201+
{
202+
"id": "sdk.crypto.aes.15",
203+
"description": "AES-128 block encrypt: zero plaintext with sequential key 00..0f",
204+
"input": {
205+
"algorithm": "aes-block",
206+
"plaintext": "00000000000000000000000000000000",
207+
"key": "000102030405060708090a0b0c0d0e0f"
208+
},
209+
"expected": { "ciphertext": "c6a13b37878f5b826f4f8162a1c8d879" },
210+
"tags": ["happy-path", "aes-128"]
159211
}
160212
]
161213
}

conformance/vectors/sdk/crypto/hash160.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@
6767
"input": { "message": "Bitcoin", "encoding": "utf8" },
6868
"expected": { "hash160": "024f9137e731852f3570492545d6efb85cbcdf49" },
6969
"tags": ["happy-path"]
70+
},
71+
{
72+
"id": "sdk.crypto.hash160.8",
73+
"description": "Hash160 of compressed pubkey for privkey=4",
74+
"input": {
75+
"pubkey": "02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13",
76+
"encoding": "hex"
77+
},
78+
"expected": { "hash160": "c42e7ef92fdb603af844d064faad95db9bcdfd3d" },
79+
"tags": ["happy-path", "p2pkh"]
7080
}
7181
]
7282
}

conformance/vectors/sdk/crypto/ripemd160.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
},
3131
{
3232
"id": "sdk.crypto.ripemd160.4",
33-
"description": "RIPEMD-160 of 448-bit ASCII string",
34-
"input": { "message": "6162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f7071", "encoding": "hex" },
33+
"description": "RIPEMD-160 of 448-bit ASCII string 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'",
34+
"input": { "message": "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "encoding": "utf8" },
3535
"expected": { "hash": "12a053384a9c0c88e405a06c27dcf49ada62eb2b" },
3636
"tags": ["happy-path"]
3737
},
3838
{
3939
"id": "sdk.crypto.ripemd160.5",
4040
"description": "RIPEMD-160 of full alphanumeric ASCII string (A-Z a-z 0-9)",
41-
"input": { "message": "4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a30313233343536373839", "encoding": "hex" },
41+
"input": { "message": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "encoding": "utf8" },
4242
"expected": { "hash": "b0e20b6e3116640286ed3a87a5713079b21f5189" },
4343
"tags": ["happy-path"]
4444
},

conformance/vectors/sdk/crypto/sha256.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@
9090
"input": { "message": "0000000000000000", "encoding": "hex" },
9191
"expected": { "hash": "af5570f5a1810b7af78caf4bc70a660f0df51e42baf91d4de5b2328de0e83dfc" },
9292
"tags": ["happy-path", "binary", "edge-case"]
93+
},
94+
{
95+
"id": "sdk.crypto.sha256.13",
96+
"description": "SHA-256 of ASCII string 'BSV'",
97+
"input": { "message": "BSV", "encoding": "utf8" },
98+
"expected": { "hash": "6c080e27dedb22dd1850901075c94cfc2c0c5c7d762ff4070871260a71263ad4" },
99+
"tags": ["happy-path"]
100+
},
101+
{
102+
"id": "sdk.crypto.sha256.14",
103+
"description": "SHA-256 of 16 0xff bytes",
104+
"input": { "message": "ffffffffffffffffffffffffffffffff", "encoding": "hex" },
105+
"expected": { "hash": "5ac6a5945f16500911219129984ba8b387a06f24fe383ce4e81a73294065461b" },
106+
"tags": ["happy-path", "binary", "edge-case"]
93107
}
94108
]
95109
}

0 commit comments

Comments
 (0)