xoonya 2.6.0 → 2.7.0
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/RELEASE_NOTES.md +11 -0
- package/lib/release_history.js +13 -0
- package/package.json +2 -1
- package/scripts/registry_cli.js +157 -0
- package/scripts/verify_all.js +558 -0
- package/scripts/verify_examples.js +19 -0
- package/scripts/verify_integrations.js +170 -0
- package/scripts/verify_release_candidate.js +87 -0
- package/scripts/verify_service.js +2825 -0
- package/scripts/verify_tooling.js +1228 -0
- package/scripts/verify_vectors.js +164 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const assert = require("assert");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const sdk = require("..");
|
|
7
|
+
|
|
8
|
+
const conformanceVectors = JSON.parse(
|
|
9
|
+
fs.readFileSync(path.resolve(__dirname, "..", "vectors", "conformance-vectors.json"), "utf8")
|
|
10
|
+
);
|
|
11
|
+
const adversarialVectors = JSON.parse(
|
|
12
|
+
fs.readFileSync(path.resolve(__dirname, "..", "vectors", "adversarial-vectors.json"), "utf8")
|
|
13
|
+
);
|
|
14
|
+
const nativeAtomVectors = JSON.parse(
|
|
15
|
+
fs.readFileSync(path.resolve(__dirname, "..", "vectors", "native-atom-vectors.json"), "utf8")
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
function unique(values) {
|
|
19
|
+
return Array.from(new Set(values.filter(Boolean))).sort();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function runVectorVerification() {
|
|
23
|
+
assert.strictEqual(conformanceVectors.version, "proof-conformance-v1", "conformance vector version mismatch");
|
|
24
|
+
assert.strictEqual(adversarialVectors.version, "proof-adversarial-v1", "adversarial vector version mismatch");
|
|
25
|
+
assert.strictEqual(nativeAtomVectors.version, "xoonya-native-atom-vectors-v1", "native atom vector version mismatch");
|
|
26
|
+
|
|
27
|
+
const conformanceResults = [];
|
|
28
|
+
for (const vector of conformanceVectors.vectors) {
|
|
29
|
+
const eventCommitment = sdk.hashEvent(vector.event);
|
|
30
|
+
assert.strictEqual(eventCommitment, vector.expected.event_commitment, `${vector.id} event commitment mismatch`);
|
|
31
|
+
|
|
32
|
+
const receipt = sdk.emitReceipt(vector.event, vector.receipt_options || {});
|
|
33
|
+
assert.deepStrictEqual(receipt, vector.expected.receipt, `${vector.id} receipt mismatch`);
|
|
34
|
+
|
|
35
|
+
const bundle = sdk.buildProofBundle({
|
|
36
|
+
ceb: vector.event,
|
|
37
|
+
receipt,
|
|
38
|
+
anchors: Array.isArray(vector.anchors) ? vector.anchors : undefined
|
|
39
|
+
});
|
|
40
|
+
assert.strictEqual(bundle.version, vector.expected.proof_bundle_version, `${vector.id} proof bundle version mismatch`);
|
|
41
|
+
const verification = sdk.verifyProofBundle(bundle);
|
|
42
|
+
assert.strictEqual(verification.valid, true, `${vector.id} proof bundle should verify`);
|
|
43
|
+
conformanceResults.push({
|
|
44
|
+
id: vector.id,
|
|
45
|
+
verification_method: verification.verification_method,
|
|
46
|
+
verification_state: verification.verification_state
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const adversarialResults = [];
|
|
51
|
+
for (const vector of adversarialVectors.vectors) {
|
|
52
|
+
if (vector.kind === "canonicalize_event_error") {
|
|
53
|
+
assert.throws(
|
|
54
|
+
() => sdk.canonicalizeEvent(vector.event),
|
|
55
|
+
(error) => error && error.message === vector.expected_reason,
|
|
56
|
+
`${vector.id} should throw expected reason`
|
|
57
|
+
);
|
|
58
|
+
adversarialResults.push({
|
|
59
|
+
id: vector.id,
|
|
60
|
+
kind: vector.kind,
|
|
61
|
+
reason: vector.expected_reason
|
|
62
|
+
});
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (vector.kind === "verify_bundle_reason") {
|
|
66
|
+
const result = sdk.verifyProofBundle(vector.bundle);
|
|
67
|
+
assert.strictEqual(result.valid, false, `${vector.id} should fail`);
|
|
68
|
+
assert.strictEqual(result.reason, vector.expected_reason, `${vector.id} failure reason mismatch`);
|
|
69
|
+
adversarialResults.push({
|
|
70
|
+
id: vector.id,
|
|
71
|
+
kind: vector.kind,
|
|
72
|
+
reason: result.reason
|
|
73
|
+
});
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`${vector.id} has unsupported vector kind`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const nativeAtomResults = [];
|
|
80
|
+
const nativeAtomPayload = Buffer.from(nativeAtomVectors.payload_ascii, "utf8");
|
|
81
|
+
for (const vector of nativeAtomVectors.vectors) {
|
|
82
|
+
const parsed = sdk.parseXoonyaNativeAtom(vector.atom_hex);
|
|
83
|
+
assert.strictEqual(parsed.atom_version, vector.atom_version, `${vector.id} atom version mismatch`);
|
|
84
|
+
assert.strictEqual(parsed.byte_length, vector.byte_length, `${vector.id} byte length mismatch`);
|
|
85
|
+
assert.strictEqual(parsed.agent_id, vector.agent_id, `${vector.id} agent id mismatch`);
|
|
86
|
+
assert.strictEqual(parsed.payload_hash_sha256, vector.payload_hash_sha256, `${vector.id} payload hash mismatch`);
|
|
87
|
+
const hasPayload = vector.payload_hash_sha256 !== "00".repeat(32);
|
|
88
|
+
const verification = sdk.verifyXoonyaNativeAtom(vector.atom_hex, {
|
|
89
|
+
identity_material_hex: nativeAtomVectors.identity_material_hex,
|
|
90
|
+
...(hasPayload ? { payload_bytes: nativeAtomPayload } : {})
|
|
91
|
+
});
|
|
92
|
+
assert.strictEqual(verification.valid, true, `${vector.id} should verify`);
|
|
93
|
+
assert.strictEqual(verification.error_code, null, `${vector.id} should not have error code`);
|
|
94
|
+
nativeAtomResults.push({
|
|
95
|
+
id: vector.id,
|
|
96
|
+
atom_version: vector.atom_version,
|
|
97
|
+
byte_length: vector.byte_length
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const nativeAtomAdversarialResults = [];
|
|
102
|
+
for (const vector of nativeAtomVectors.adversarial) {
|
|
103
|
+
const verification = sdk.verifyXoonyaNativeAtom(vector.atom_hex, {
|
|
104
|
+
identity_material_hex: vector.identity_material_hex || nativeAtomVectors.identity_material_hex,
|
|
105
|
+
...(vector.payload_ascii ? { payload_bytes: Buffer.from(vector.payload_ascii, "utf8") } : {})
|
|
106
|
+
});
|
|
107
|
+
assert.strictEqual(verification.valid, false, `${vector.id} should fail`);
|
|
108
|
+
assert.strictEqual(verification.reason, vector.expected_reason, `${vector.id} failure reason mismatch`);
|
|
109
|
+
assert.strictEqual(verification.error_code, vector.expected_error_code, `${vector.id} error code mismatch`);
|
|
110
|
+
nativeAtomAdversarialResults.push({
|
|
111
|
+
id: vector.id,
|
|
112
|
+
reason: verification.reason,
|
|
113
|
+
error_code: verification.error_code
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
ok: true,
|
|
119
|
+
product: "xoonya",
|
|
120
|
+
suite: "proof-conformance-and-adversarial-vectors",
|
|
121
|
+
conformance_version: conformanceVectors.version,
|
|
122
|
+
adversarial_version: adversarialVectors.version,
|
|
123
|
+
conformance_count: conformanceResults.length,
|
|
124
|
+
adversarial_count: adversarialResults.length,
|
|
125
|
+
native_atom_vector_count: nativeAtomResults.length,
|
|
126
|
+
native_atom_adversarial_count: nativeAtomAdversarialResults.length,
|
|
127
|
+
verification_methods: unique(conformanceResults.map((result) => result.verification_method)),
|
|
128
|
+
adversarial_reasons: unique(adversarialResults.map((result) => result.reason)),
|
|
129
|
+
native_atom_error_codes: unique(nativeAtomAdversarialResults.map((result) => result.error_code)),
|
|
130
|
+
conformance_results: conformanceResults,
|
|
131
|
+
adversarial_results: adversarialResults,
|
|
132
|
+
native_atom_results: nativeAtomResults,
|
|
133
|
+
native_atom_adversarial_results: nativeAtomAdversarialResults
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function main() {
|
|
138
|
+
const json = process.argv.includes("--json");
|
|
139
|
+
const summary = runVectorVerification();
|
|
140
|
+
if (json) {
|
|
141
|
+
process.stdout.write(`${JSON.stringify(summary, null, 2)}\n`);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
process.stdout.write(
|
|
145
|
+
[
|
|
146
|
+
"xoonya verify:vectors passed",
|
|
147
|
+
`conformance vectors: ${summary.conformance_count}`,
|
|
148
|
+
`adversarial vectors: ${summary.adversarial_count}`,
|
|
149
|
+
`native atom vectors: ${summary.native_atom_vector_count}`,
|
|
150
|
+
`native atom adversarial vectors: ${summary.native_atom_adversarial_count}`,
|
|
151
|
+
`verification methods: ${summary.verification_methods.join(", ")}`,
|
|
152
|
+
`adversarial reasons: ${summary.adversarial_reasons.join(", ")}`,
|
|
153
|
+
`native atom error codes: ${summary.native_atom_error_codes.join(", ")}`
|
|
154
|
+
].join("\n") + "\n"
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (require.main === module) {
|
|
159
|
+
main();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
module.exports = {
|
|
163
|
+
runVectorVerification
|
|
164
|
+
};
|