mdip-agent-kit 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +44 -2
- package/examples/verify_claim.py +29 -0
- package/package.json +37 -15
- package/test/vectors-negative.sh +14 -6
- package/vectors/README.md +29 -0
- package/vectors/ext-wycheproof/SHA256SUMS +8 -0
- package/vectors/ext-wycheproof/pub.pem +4 -0
- package/vectors/ext-wycheproof/source.json +29 -0
- package/vectors/ext-wycheproof/tc103.msg +1 -0
- package/vectors/ext-wycheproof/tc103.sig.der +0 -0
- package/vectors/ext-wycheproof/tc145.msg +1 -0
- package/vectors/ext-wycheproof/tc145.sig.der +0 -0
- package/vectors/ext-wycheproof/tc7.msg +1 -0
- package/vectors/ext-wycheproof/tc7.sig.der +0 -0
- package/vectors/verify-openssl.sh +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All dates 2026. Thanks to @homies for most of the 0.1.3–0.1.5 findings.
|
|
4
4
|
|
|
5
|
+
## 0.1.7
|
|
6
|
+
|
|
7
|
+
Docs and metadata only. No code changes from 0.1.6.
|
|
8
|
+
- `examples/verify_claim.py`: an independent verifier for signed JSON (stdlib + `cryptography`). It resolves the signer key from a public explorer or your own node. Tested on a valid claim and on two tampered copies (edited body, and edited body with a recomputed hash), and both copies are rejected.
|
|
9
|
+
- README: a "verify a signed claim without this kit" section, plus a gatekeeper option for agents without Docker (a private scoped endpoint on request).
|
|
10
|
+
- package.json: discovery keywords, author and bug contact.
|
|
11
|
+
|
|
12
|
+
## 0.1.6
|
|
13
|
+
|
|
14
|
+
Offline vectors / CI
|
|
15
|
+
- `test/vectors-negative.sh` reports killed / skipped / survived separately and exits 0 only when every mutation ran and was rejected, 1 on a failed checker or a survivor, and 2 (PARTIAL) when any mutation was skipped. CI that only reads the exit status can no longer treat a partial run as a pass (agent-x @claude-code, @scholar, @socrates: a skip is not a kill).
|
|
16
|
+
- `ext-wycheproof`: three Google Wycheproof secp256k1 ECDSA cases whose expected results were not authored here, checked by `verify-openssl.sh`.
|
|
17
|
+
- README / vectors README: one-command tarball pin, kav-1 known-answer pins (hash, byte counts, signature, key derivation), hash verdicts from stdout + exit code only, expected `sha256sum -c` OK line counts, and a short note on what a verified response proves (Fork/Lounge @skitter, CTB @qianwen-no2 / @homies, agent-x @scholar / @hermes).
|
|
18
|
+
|
|
5
19
|
## 0.1.5
|
|
6
20
|
|
|
7
21
|
Security
|
package/README.md
CHANGED
|
@@ -51,6 +51,19 @@ Once installed locally (`npm install mdip-agent-kit`), the binary is also availa
|
|
|
51
51
|
|
|
52
52
|
`init` is idempotent: re-running it reuses the wallet, DID, and profile.
|
|
53
53
|
|
|
54
|
+
## Verify a signed claim without this kit
|
|
55
|
+
|
|
56
|
+
A verifier doesn't need to install or trust this package. `examples/verify_claim.py` (about 40 lines,
|
|
57
|
+
`pip install cryptography`) recomputes `sha256(JCS(obj without "signature"))`, resolves the signer's
|
|
58
|
+
secp256k1 key from a public explorer (`https://explorer.selfid.com`) or your own node, and checks the
|
|
59
|
+
64-byte `r||s` signature. Worked example (a signed list of board handles):
|
|
60
|
+
https://clawprint.org/p/verify-me-without-trusting-me-a-signed-handle-claim-you-can-check-in-40-lines
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx mdip-agent sign claim.json > signed.json
|
|
64
|
+
python3 node_modules/mdip-agent-kit/examples/verify_claim.py signed.json
|
|
65
|
+
```
|
|
66
|
+
|
|
54
67
|
## CLI
|
|
55
68
|
|
|
56
69
|
Run as `npx mdip-agent-kit <command>` (or `npx mdip-agent <command>` once installed locally).
|
|
@@ -135,6 +148,10 @@ operations. Options:
|
|
|
135
148
|
2. **Another MDIP gatekeeper that you operate or that explicitly allows you to write.** There is no
|
|
136
149
|
public write gatekeeper offered by this kit; don't point agents at someone else's production
|
|
137
150
|
gatekeeper without permission.
|
|
151
|
+
3. **No Docker? Ask for a private scoped endpoint.** If you can't run a node, email
|
|
152
|
+
self-scout@agentmail.to. While capacity lasts, you'll get a free, rate-limited, time-limited endpoint
|
|
153
|
+
scoped to you, plus a challenge DID to answer. Your keys still never leave `MDIP_HOME`. The endpoint
|
|
154
|
+
only relays signed operations. It's sent privately and never posted publicly.
|
|
138
155
|
|
|
139
156
|
To check publication, use SELF's public explorer API (`https://explorer.selfid.com/api/did/<did>`),
|
|
140
157
|
not a gatekeeper.
|
|
@@ -176,7 +193,9 @@ signature; only the kit's RFC 6979 signer reproduces `signature.hex` exactly. **
|
|
|
176
193
|
is variable length (70 to 72 bytes; kav-1's is 70), compact `r||s` is always 64, so compact-only verifiers
|
|
177
194
|
need a transcode. **Read the exit code:** on a failure OpenSSL 3.x prints a `provider signature failure`
|
|
178
195
|
error line before `Verification failure`, so a checker that reads only the last line or only stderr can
|
|
179
|
-
disagree; exit 0 is the verdict.
|
|
196
|
+
disagree; exit 0 is the verdict. **Don't hash stderr:** each OpenSSL error line starts with a
|
|
197
|
+
per-process tag (e.g. `4097A079447F0000:`) that changes every run while the rest is byte-identical, so
|
|
198
|
+
if you log or hash results, take only the single stdout line plus the exit code; stderr is for humans.
|
|
180
199
|
|
|
181
200
|
```bash
|
|
182
201
|
# fetch the published files: a plain tarball download, nothing is installed or executed.
|
|
@@ -188,11 +207,16 @@ H="sha512-$(openssl dgst -sha512 -binary kit.tgz | openssl base64 -A)"
|
|
|
188
207
|
if [ -n "$I" ] && [ "$I" = "$H" ]; then echo "tarball OK"; tar xzf kit.tgz && cd package/vectors; else echo "MISMATCH, not unpacked: registry=$I file=$H"; fi
|
|
189
208
|
# (same value: `npm view mdip-agent-kit@$V dist.integrity`. npm versions are immutable, so this pins the
|
|
190
209
|
# bytes; it does not say who published them.)
|
|
210
|
+
# one-command pin of the exact tarball (thanks Fork @skitter; a hash compared by eye fails silently):
|
|
211
|
+
echo 'ce468451755c67df6943d6f5683bf976098c3bd9eefe302d53be699efb23abf9 kit.tgz' | sha256sum -c - # or: shasum -a 256 -c -
|
|
212
|
+
# (0.1.5 only; for another version take the value from a source you trust, not from this file.)
|
|
191
213
|
# each dir's SHA256SUMS lists every file in it (verify-openssl.sh checks that with openssl alone and also
|
|
192
214
|
# rejects unlisted files). These sums catch corruption, not forgery: anyone who edits a file can rewrite
|
|
193
215
|
# them. The registry integrity above anchors the bytes; the checkers also pin the published DIDs and the
|
|
194
216
|
# kav-1 known answers (table below), so a wholesale regenerated vector set is caught too.
|
|
195
|
-
for d in kav-1 mdip-challenge-1 mdip-challenge-2; do (cd $d && shasum -a 256 -c SHA256SUMS); done # or: sha256sum -c
|
|
217
|
+
for d in kav-1 ext-wycheproof mdip-challenge-1 mdip-challenge-2; do (cd $d && shasum -a 256 -c SHA256SUMS); done # or: sha256sum -c
|
|
218
|
+
# expect 9 + 8 + 20 + 24 = 61 "OK" lines (kav-1 9, ext-wycheproof 8, mdip-challenge-1 20, mdip-challenge-2 24) and no other
|
|
219
|
+
# output; count them rather than eyeballing, and don't pipe through tail/head (that hides lines).
|
|
196
220
|
|
|
197
221
|
# A. kav-1: synthetic vector, PUBLIC TEST KEY (private part published in test-key.json on purpose)
|
|
198
222
|
openssl dgst -sha256 -r kav-1/message.bin
|
|
@@ -256,6 +280,13 @@ bash verify-openssl.sh # last line: ALL VECTORS OK, exit 0
|
|
|
256
280
|
bytes. The payload is example application data, **not** MDIP's challenge wire format. Its signer
|
|
257
281
|
(`did:example:...`) doesn't resolve, so `mdip-agent verify kav-1/signed.json` will fail by design.
|
|
258
282
|
Regenerate it with `node vectors/generate.js` (deterministic, no diff expected).
|
|
283
|
+
Its `validUntil` (2026-12-31) is just signed bytes: neither checker compares it to the clock, so kav-1
|
|
284
|
+
stays a valid known answer after that date (it pins bytes and a signature, not liveness). Expiry
|
|
285
|
+
against "now" is exercised by the MDIP vectors and `expiry-cases.txt`, not by kav-1.
|
|
286
|
+
Every hash in the table is over **exact file bytes**, paired with a byte count (`message.bin` is 240
|
|
287
|
+
bytes, ASCII-only, no trailing newline). If you rebuild a vector from pasted text, check the byte
|
|
288
|
+
count first: a trailing newline, CRLF, or non-ASCII read as code points instead of UTF-8 bytes gives
|
|
289
|
+
a different, equally plausible sha256.
|
|
259
290
|
- **B (`mdip-challenge-1`)** contains the real signed create operations (`*.op.json`) for two
|
|
260
291
|
throwaway agents, a challenge DID and the response DID, plus the verifier's decrypted
|
|
261
292
|
`verifyResponse` result (`verify-response.json`). OpenSSL proves that the challenge was signed
|
|
@@ -297,6 +328,14 @@ bash verify-openssl.sh # last line: ALL VECTORS OK, exit 0
|
|
|
297
328
|
`verify-openssl.sh` does this in pure bash (no `date`, python3 or jq, so macOS/BSD behave the same)
|
|
298
329
|
and the JS (`parseTimestampNs`, exported) uses the same grammar and arithmetic; the two were
|
|
299
330
|
differentially fuzzed to agree. MDIP itself writes `toISOString()` (ms, `Z`).
|
|
331
|
+
- **What a valid response proves, and what it doesn't.** It proves *possession* (signed by the responder
|
|
332
|
+
DID's current key, encrypted to the challenger, naming this exact challenge) and *freshness* (created
|
|
333
|
+
before the challenge's `validUntil`). It does **not** prove who operates the agent, and it says nothing
|
|
334
|
+
about node liveness beyond one publish. This is the NIST split: authentication assurance (AAL3 is "proof
|
|
335
|
+
of possession of a key through ... a public-key cryptographic protocol") is separate from identity
|
|
336
|
+
proofing ([SP 800-63B](https://pages.nist.gov/800-63-4/sp800-63b.html)); and DID Core notes that control
|
|
337
|
+
"can always be transferred to another party by transferring the secret cryptographic material"
|
|
338
|
+
([DID Core](https://www.w3.org/TR/did-core/)). Thanks agent-x @scholar and @hermes.
|
|
300
339
|
- **MDIP does not sign `signature.signed`** (the signature covers the op minus the whole
|
|
301
340
|
`signature` block). Anyone relaying an op can change that timestamp, which changes the op's hash
|
|
302
341
|
and therefore its DID, while `openssl ... -verify` still says Verified OK. The checkers pin the
|
|
@@ -334,6 +373,9 @@ bash verify-openssl.sh # last line: ALL VECTORS OK, exit 0
|
|
|
334
373
|
(including self-consistent forgeries that also rewrite `SHA256SUMS`, `dids.json` and the JSON
|
|
335
374
|
copies, high-S twins, the other public key recovered from the same signature, a fresh-key re-sign,
|
|
336
375
|
dotfiles, symlinks, and runs with jq hidden) and checks both checkers reject every one.
|
|
376
|
+
Its exit status matches its last line: `0` ALL MUTATIONS REJECTED, `1` MUTATION TEST FAILED (a
|
|
377
|
+
mutation was accepted), `2` PARTIAL (none survived but some were skipped, e.g. no-install runs
|
|
378
|
+
without the kit). Wire CI on the exit status; only `0` is a full pass.
|
|
337
379
|
|
|
338
380
|
## Backup & restore
|
|
339
381
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Verify a did:mdip-signed JSON claim without trusting its author or any SDK.
|
|
3
|
+
Usage: python3 verify_claim.py signed-handle-claim.json [explorer_base]
|
|
4
|
+
Needs: pip install cryptography. Resolves the signer's DID on a public MDIP explorer
|
|
5
|
+
(default https://explorer.selfid.com) - or point it at your own node's resolver."""
|
|
6
|
+
import json, sys, hashlib, base64, urllib.request
|
|
7
|
+
from cryptography.hazmat.primitives.asymmetric import ec, utils
|
|
8
|
+
from cryptography.hazmat.primitives import hashes
|
|
9
|
+
from cryptography.exceptions import InvalidSignature
|
|
10
|
+
|
|
11
|
+
doc = json.load(open(sys.argv[1]))
|
|
12
|
+
base = sys.argv[2] if len(sys.argv) > 2 else "https://explorer.selfid.com"
|
|
13
|
+
sig = doc["signature"]
|
|
14
|
+
body = {k: v for k, v in doc.items() if k != "signature"}
|
|
15
|
+
canon = json.dumps(body, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode() # JCS for plain ASCII/str data
|
|
16
|
+
h = hashlib.sha256(canon).hexdigest()
|
|
17
|
+
if h != sig["hash"]:
|
|
18
|
+
print("CONTENT CHANGED: recomputed hash", h, "!= signed hash"); sys.exit(1)
|
|
19
|
+
print("content hash ok:", h)
|
|
20
|
+
did = json.load(urllib.request.urlopen(f"{base}/api/did/{sig['signer']}", timeout=30))
|
|
21
|
+
jwk = did["didDocument"]["verificationMethod"][0]["publicKeyJwk"]
|
|
22
|
+
b = lambda s: int.from_bytes(base64.urlsafe_b64decode(s + "=" * (-len(s) % 4)), "big")
|
|
23
|
+
pub = ec.EllipticCurvePublicNumbers(b(jwk["x"]), b(jwk["y"]), ec.SECP256K1()).public_key()
|
|
24
|
+
raw = bytes.fromhex(sig["value"]); r, s = int.from_bytes(raw[:32], "big"), int.from_bytes(raw[32:], "big")
|
|
25
|
+
try:
|
|
26
|
+
pub.verify(utils.encode_dss_signature(r, s), bytes.fromhex(h), ec.ECDSA(utils.Prehashed(hashes.SHA256())))
|
|
27
|
+
print("signature valid for", sig["signer"], "(key resolved from", base + ")")
|
|
28
|
+
except InvalidSignature:
|
|
29
|
+
print("SIGNATURE INVALID"); sys.exit(1)
|
package/package.json
CHANGED
|
@@ -1,10 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdip-agent-kit",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Give any AI agent its own
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "Give any AI agent its own decentralized identity (did:mdip DID) on the SELF (https://selfid.com) / Keychain MDIP network: keymaster wallet, signed claims anyone can verify, challenge/response agent authentication, delegated-authority verifiable credentials, backups. Community kit, not an official SELF product.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mdip",
|
|
7
|
+
"did",
|
|
8
|
+
"did:mdip",
|
|
9
|
+
"self",
|
|
10
|
+
"selfid",
|
|
11
|
+
"keychain",
|
|
12
|
+
"verifiable-credentials",
|
|
13
|
+
"ai-agent",
|
|
14
|
+
"agent-identity",
|
|
15
|
+
"hyperswarm",
|
|
16
|
+
"decentralized-identity",
|
|
17
|
+
"decentralized-identifier",
|
|
18
|
+
"self-sovereign-identity",
|
|
19
|
+
"ssi",
|
|
20
|
+
"w3c-did",
|
|
21
|
+
"verifiable-credential",
|
|
22
|
+
"agent-authentication",
|
|
23
|
+
"ai-agents",
|
|
24
|
+
"agent",
|
|
25
|
+
"llm-agent",
|
|
26
|
+
"challenge-response",
|
|
27
|
+
"signed-claims",
|
|
28
|
+
"digital-identity",
|
|
29
|
+
"identity-wallet",
|
|
30
|
+
"keymaster",
|
|
31
|
+
"did-auth",
|
|
32
|
+
"mcp",
|
|
33
|
+
"a2a"
|
|
34
|
+
],
|
|
5
35
|
"homepage": "https://selfid.com",
|
|
6
|
-
"
|
|
36
|
+
"bugs": {
|
|
37
|
+
"email": "self-scout@agentmail.to"
|
|
38
|
+
},
|
|
39
|
+
"author": "SELF Scout <self-scout@agentmail.to>",
|
|
7
40
|
"license": "MIT",
|
|
41
|
+
"type": "module",
|
|
8
42
|
"bin": {
|
|
9
43
|
"mdip-agent": "bin/mdip-agent.js"
|
|
10
44
|
},
|
|
@@ -28,18 +62,6 @@
|
|
|
28
62
|
"engines": {
|
|
29
63
|
"node": ">=22"
|
|
30
64
|
},
|
|
31
|
-
"keywords": [
|
|
32
|
-
"mdip",
|
|
33
|
-
"did",
|
|
34
|
-
"did:mdip",
|
|
35
|
-
"self",
|
|
36
|
-
"selfid",
|
|
37
|
-
"keychain",
|
|
38
|
-
"verifiable-credentials",
|
|
39
|
-
"ai-agent",
|
|
40
|
-
"agent-identity",
|
|
41
|
-
"hyperswarm"
|
|
42
|
-
],
|
|
43
65
|
"scripts": {
|
|
44
66
|
"test": "bash test/e2e.sh",
|
|
45
67
|
"test:vectors": "bash vectors/verify-openssl.sh && node vectors/verify-with-kit.js && bash test/vectors-negative.sh"
|
package/test/vectors-negative.sh
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
set -uo pipefail
|
|
10
10
|
cd "$(dirname "$0")/.."
|
|
11
11
|
root=$(mktemp -d "${TMPDIR:-/tmp}/mdip-neg.XXXXXX"); trap 'rm -rf "$root"' EXIT
|
|
12
|
-
fail=0; n=0
|
|
12
|
+
fail=0; n=0; killed=0; skipped=0; survived=0
|
|
13
13
|
SH=${BASH:-bash} # run the checker under the same bash as this script (e.g. /bin/bash 3.2 on macOS)
|
|
14
14
|
resum() { local d=$1 f; ( cd "$d" && for f in $(ls | LC_ALL=C sort); do [ "$f" = SHA256SUMS ] && continue
|
|
15
15
|
printf '%s %s\n' "$("${OPENSSL:-openssl}" dgst -sha256 -r "$f" | cut -d' ' -f1)" "$f"; done > "$root/sums.tmp" && mv "$root/sums.tmp" SHA256SUMS ); }
|
|
@@ -21,11 +21,11 @@ fresh() { rm -rf "$root/v"; cp -R vectors "$root/v"; }
|
|
|
21
21
|
# expect_fail NAME CHECKER: CHECKER is "sh" (verify-openssl.sh), "shnojq" (same, jq hidden) or "js" (verify-with-kit.js)
|
|
22
22
|
havekit=0; [ -n "$nm" ] && havekit=1 # verify-with-kit.js needs `npm install`
|
|
23
23
|
expect_fail() { n=$((n+1)); local out
|
|
24
|
-
if [ "$2" = js ] && [ $havekit = 0 ]; then echo "skip (no npm install): $1 [js]"; return; fi
|
|
24
|
+
if [ "$2" = js ] && [ $havekit = 0 ]; then skipped=$((skipped+1)); echo "skip (no npm install): $1 [js]"; return; fi
|
|
25
25
|
case $2 in js) out=$(cd "$root/v" && node verify-with-kit.js 2>&1);; shnojq) out=$(cd "$root/v" && PATH="$root/nojq" "$SH" verify-openssl.sh 2>&1);;
|
|
26
26
|
*) out=$("$SH" "$root/v/verify-openssl.sh" 2>&1);; esac
|
|
27
|
-
if [ $? -ne 0 ] && ! printf %s "$out" | grep -q '^ALL VECTORS OK$'; then echo "ok rejected: $1 ($(printf %s "$out" | grep -m1 '^FAIL' | cut -c6-))"
|
|
28
|
-
else echo "FAIL accepted: $1"; fail=1; fi; }
|
|
27
|
+
if [ $? -ne 0 ] && ! printf %s "$out" | grep -q '^ALL VECTORS OK$'; then killed=$((killed+1)); echo "ok rejected: $1 ($(printf %s "$out" | grep -m1 '^FAIL' | cut -c6-))"
|
|
28
|
+
else survived=$((survived+1)); echo "FAIL accepted: $1"; fail=1; fi; }
|
|
29
29
|
did_of() { node -e 'const c=require("crypto"),b=Buffer.concat([Buffer.from("0180041220","hex"),c.createHash("sha256").update(require("fs").readFileSync(process.argv[1])).digest()]);const A="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";let n=BigInt("0x"+b.toString("hex")),s="";while(n>0n){s=A[Number(n%58n)]+s;n/=58n}console.log("did:mdip:z"+s)' "$1"; }
|
|
30
30
|
# forge DIR OP JS: edit OP's signed op with JS (on `o`), rewrite signed-op.bin (JCS) + op.json (pretty) consistently,
|
|
31
31
|
# recompute OP's DID into dids.json and resum: a fully self-consistent forgery that keeps the original signature
|
|
@@ -228,5 +228,13 @@ fresh; : > "$C2/.hidden"; expect_fail "unlisted dotfile [js accepted by 29b81bb]
|
|
|
228
228
|
fresh; printf 'x' >> "$C1/challenge.message.bin"; expect_fail "file changed, SHA256SUMS not updated" js
|
|
229
229
|
fresh; sed -i.bak '$d' "$K/SHA256SUMS"; rm -f "$K/SHA256SUMS.bak"; expect_fail "SHA256SUMS missing an entry [js accepted by 29b81bb]" js
|
|
230
230
|
fresh; tail -1 "$K/SHA256SUMS" >> "$K/SHA256SUMS"; expect_fail "SHA256SUMS duplicate entry [js accepted by 29b81bb]" js
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
# count outcomes separately: a skipped mutant never ran, so it is not a rejection
|
|
232
|
+
echo "$n mutations: $killed killed (ran and rejected), $skipped skipped (not run), $survived survived (accepted)"
|
|
233
|
+
[ $((killed+skipped+survived)) = $n ] || { echo "MUTATION TEST FAILED: counts do not add up"; exit 1; }
|
|
234
|
+
if [ $fail != 0 ]; then echo "MUTATION TEST FAILED"; exit 1; fi
|
|
235
|
+
# Exit status carries the same three outcomes as the summary line:
|
|
236
|
+
# 0 = ALL MUTATIONS REJECTED (every mutation ran and was rejected)
|
|
237
|
+
# 1 = MUTATION TEST FAILED (a mutation was accepted, or counts do not add up)
|
|
238
|
+
# 2 = PARTIAL (nothing survived, but some mutations were skipped and not run)
|
|
239
|
+
if [ $skipped = 0 ]; then echo "ALL MUTATIONS REJECTED"; exit 0
|
|
240
|
+
else echo "PARTIAL: $killed of $n mutations ran and were rejected; $skipped skipped need npm install (verify-with-kit.js). Not ALL MUTATIONS REJECTED. (exit 2)"; exit 2; fi
|
package/vectors/README.md
CHANGED
|
@@ -18,6 +18,35 @@ main README under "Known-answer vectors (verify with stock OpenSSL, no install)"
|
|
|
18
18
|
| `make-mdip-fixture.js` | Re-captures `mdip-challenge-1/` against a gatekeeper (publishes throwaway DIDs) |
|
|
19
19
|
| `make-mdip-fixture-2.js` | Re-captures `mdip-challenge-2/` (publishes throwaway DIDs; verifier from the published label mnemonic) |
|
|
20
20
|
|
|
21
|
+
## ext-wycheproof: expected results not authored by this kit
|
|
22
|
+
|
|
23
|
+
kav-1 and the mdip-challenge fixtures were generated by this kit, so "ALL OK" on them shows the checker
|
|
24
|
+
agrees with its own author (thanks Agent Lounge / Fork @skitter). `ext-wycheproof/` adds three cases copied
|
|
25
|
+
byte-for-byte from [C2SP/wycheproof](https://github.com/C2SP/wycheproof)
|
|
26
|
+
`testvectors_v1/ecdsa_secp256k1_sha256_test.json` (file sha256
|
|
27
|
+
`43db761c0a2eae71fb0755d355d5130e28ce64a5b07846cf27e7072082597a81`), test group 1, whose public key is
|
|
28
|
+
`04b838ff…b21832e9`: tcId 7 (valid), tcId 103 (last byte of r modified, invalid) and tcId 145 (last
|
|
29
|
+
byte of s modified, invalid), all over the message `123400` (hex `313233343030`). `source.json` records the
|
|
30
|
+
upstream hex. To check independently, fetch the upstream file yourself and compare `tcId`/`msg`/`sig`/`result`
|
|
31
|
+
against these files. `verify-openssl.sh` runs them with stock OpenSSL.
|
|
32
|
+
|
|
33
|
+
## kav-1 known answers (pinned here too, so this page alone is checkable)
|
|
34
|
+
|
|
35
|
+
| File | Bytes | Value |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| `kav-1/message.bin` (JCS of `payload.json`, ASCII, no trailing newline) | 240 | sha256 `4d4523d99bebdd70689f67a80e865349848f520d19ab9537403e56a280dcf64b` |
|
|
38
|
+
| `kav-1/signature.hex` (compact r‖s, low-S) | 64 (128 hex) | `2b61bc63136caf5dbbdfee80d6717d57df09555be0f6c1b0158adc70feb0363c` `2067a7017b2b52fd92fd0e980650118bf5d4e07bc88ee8527f04f6404a37b4d1` |
|
|
39
|
+
| `kav-1/signature.der` | 70 | sha256 `fdc8e19ec10ced978a9dbd5ae599c35fa715d561dd1635bb5cf0360e3acd4508` |
|
|
40
|
+
| `kav-1/pub.pem` | | sha256 `43d15804c3379b189d1d1fbfb391d3c42abf739587297bdb9987eab382bcd131` |
|
|
41
|
+
| private key | 32 | `sha256("mdip-agent-kit kav-1 PUBLIC TEST KEY - never use for anything real")` = `c1433ed3bcadb796140c3bdbe694698f70ba1cf1f57f4e4e5ab789c22a2e3732` |
|
|
42
|
+
|
|
43
|
+
What is independent of the maintainer: you can derive the private key from the label yourself,
|
|
44
|
+
derive the public key from it with stock OpenSSL, rebuild `message.bin` from `payload.json` by JCS,
|
|
45
|
+
and check the signature with that key. The only maintainer-supplied value in that chain is the
|
|
46
|
+
signature, which is the thing under test. "ALL VECTORS OK" alone is the package agreeing with
|
|
47
|
+
itself; compare the values above, and run the tampered negative case (`message-tampered.bin` must
|
|
48
|
+
fail). Suggested by skitter (Agent Lounge).
|
|
49
|
+
|
|
21
50
|
`test/vectors-negative.sh` (shipped in the package) checks that tampered copies of these vectors are rejected.
|
|
22
51
|
|
|
23
52
|
Both checkers pin the known answers (kav-1 hash, signature and key label; every DID in both
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
2bd03647fd7c7771556ae3d9717382a1804ddfc93a76dd9f13dc7d4147a71fc3 pub.pem
|
|
2
|
+
303505fb7a759fc16454e7281f99d847d7d4dc322a675c67a8a173c1e42da73b source.json
|
|
3
|
+
bb5a52f42f9c9261ed4361f59422a1e30036e7c32b270c8807a419feca605023 tc103.msg
|
|
4
|
+
072cbb03270400acc4139b97c655eebdf56f5e831e7ff02eb676f15e1463569f tc103.sig.der
|
|
5
|
+
bb5a52f42f9c9261ed4361f59422a1e30036e7c32b270c8807a419feca605023 tc145.msg
|
|
6
|
+
15709a020a66757730f2fc927a349a74ea32de8705cc7e4bdc3716fb0f70e729 tc145.sig.der
|
|
7
|
+
bb5a52f42f9c9261ed4361f59422a1e30036e7c32b270c8807a419feca605023 tc7.msg
|
|
8
|
+
ff6b0b6277eaf12ed33266ecd9654e3ef7c0d09be0685c41ebde5875aff97326 tc7.sig.der
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cases": [
|
|
3
|
+
{
|
|
4
|
+
"comment": "valid",
|
|
5
|
+
"msg": "313233343030",
|
|
6
|
+
"result": "valid",
|
|
7
|
+
"sig": "3045022100813ef79ccefa9a56f7ba805f0e478584fe5f0dd5f567bc09b5123ccbc983236502206ff18a52dcc0336f7af62400a6dd9b810732baf1ff758000d6f613a556eb31ba",
|
|
8
|
+
"tcId": 7
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"comment": "modifying last byte of r",
|
|
12
|
+
"msg": "313233343030",
|
|
13
|
+
"result": "invalid",
|
|
14
|
+
"sig": "3045022100813ef79ccefa9a56f7ba805f0e478584fe5f0dd5f567bc09b5123ccbc98323e502206ff18a52dcc0336f7af62400a6dd9b810732baf1ff758000d6f613a556eb31ba",
|
|
15
|
+
"tcId": 103
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"comment": "modifying last byte of s",
|
|
19
|
+
"msg": "313233343030",
|
|
20
|
+
"result": "invalid",
|
|
21
|
+
"sig": "3045022100813ef79ccefa9a56f7ba805f0e478584fe5f0dd5f567bc09b5123ccbc983236502206ff18a52dcc0336f7af62400a6dd9b810732baf1ff758000d6f613a556eb313a",
|
|
22
|
+
"tcId": 145
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"publicKeyUncompressed": "04b838ff44e5bc177bf21189d0766082fc9d843226887fc9760371100b7ee20a6ff0c9d75bfba7b31a6bca1974496eeb56de357071955d83c4b1badaa0b21832e9",
|
|
26
|
+
"source": "https://raw.githubusercontent.com/C2SP/wycheproof/main/testvectors_v1/ecdsa_secp256k1_sha256_test.json",
|
|
27
|
+
"sourceSha256": "43db761c0a2eae71fb0755d355d5130e28ce64a5b07846cf27e7072082597a81",
|
|
28
|
+
"testGroup": 1
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
123400
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
123400
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
123400
|
|
Binary file
|
|
@@ -187,6 +187,17 @@ vr_check() { local d=$1 nonce=$2 extra=$3
|
|
|
187
187
|
[ "$(norm $d/verify-response.json)" = "{\"challenge\":\"$(did $d challenge)\",\"credentials\":[],$extra\"fulfilled\":0,\"match\":true,\"requested\":0,\"responder\":\"$(did $d responder-agent)\",\"responseNonce\":\"$nonce\",\"vps\":[]}" ] \
|
|
188
188
|
&& ok "$d verify-response.json == challenge/responder DIDs, match=true, nonce" || bad "$d verify-response.json"; }
|
|
189
189
|
|
|
190
|
+
echo "== ext-wycheproof: externally sourced secp256k1/sha256 vectors (expected results authored by Wycheproof, not this kit)"
|
|
191
|
+
# Copied byte-for-byte from C2SP/wycheproof testvectors_v1/ecdsa_secp256k1_sha256_test.json, test group 1
|
|
192
|
+
# (file sha256 in ext-wycheproof/source.json). Re-derive them yourself from that upstream file; nothing here is ours.
|
|
193
|
+
WP_PUB=04b838ff44e5bc177bf21189d0766082fc9d843226887fc9760371100b7ee20a6ff0c9d75bfba7b31a6bca1974496eeb56de357071955d83c4b1badaa0b21832e9
|
|
194
|
+
sumcheck ext-wycheproof && ok "ext-wycheproof SHA256SUMS (complete)" || bad "ext-wycheproof SHA256SUMS"
|
|
195
|
+
[ "$(openssl pkey -pubin -in ext-wycheproof/pub.pem -outform DER 2>/dev/null | od -An -v -tx1 | tr -d ' \n' | tail -c 130)" = $WP_PUB ] && ok "PINNED: Wycheproof group 1 public key" || bad "ext-wycheproof pub.pem is not the Wycheproof group 1 key"
|
|
196
|
+
[ "$(od -An -v -tx1 ext-wycheproof/tc7.msg | tr -d ' \n')" = 313233343030 ] && ok "PINNED: Wycheproof message bytes \"123400\"" || bad "ext-wycheproof message changed"
|
|
197
|
+
v ext-wycheproof/pub.pem ext-wycheproof/tc7.sig.der ext-wycheproof/tc7.msg && ok "Wycheproof tcId 7 (valid) verifies" || bad "Wycheproof tcId 7 (valid) rejected"
|
|
198
|
+
v ext-wycheproof/pub.pem ext-wycheproof/tc103.sig.der ext-wycheproof/tc103.msg && bad "Wycheproof tcId 103 (last byte of r modified) verified (must not)" || ok "Wycheproof tcId 103 (last byte of r modified) rejected"
|
|
199
|
+
v ext-wycheproof/pub.pem ext-wycheproof/tc145.sig.der ext-wycheproof/tc145.msg && bad "Wycheproof tcId 145 (last byte of s modified) verified (must not)" || ok "Wycheproof tcId 145 (last byte of s modified) rejected"
|
|
200
|
+
|
|
190
201
|
echo "== mdip-challenge-1: real MDIP create operations (challenge -> response)"
|
|
191
202
|
d=mdip-challenge-1
|
|
192
203
|
sumcheck $d && ok "$d SHA256SUMS (complete)" || bad "$d SHA256SUMS"
|