@333eco/origin-verify 0.2.0 → 0.4.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/README.md +15 -0
- package/index.mjs +47 -2
- package/package.json +1 -1
- package/trust.mjs +5 -0
package/README.md
CHANGED
|
@@ -32,6 +32,21 @@ Four states. Each stands alone and none implies another.
|
|
|
32
32
|
|
|
33
33
|
**What a record does not say:** who imagined the work, or that one person holds one account. Without a signer's reveal it says *the operator witnessed this claim at this time and cannot later remove it*. With the reveal, *a passkey whose public key is given here signed exactly this claim*.
|
|
34
34
|
|
|
35
|
+
**Version-3 records** name their press, inside the log's signature: `press: { key: "passkey" }`, or for a key held by the B-PoH app
|
|
36
|
+
`{ key: "b-poh", unlock, shown }` (how it was unlocked; whose screen showed the words). A revealed press must carry the origin its
|
|
37
|
+
press allows: a press made in the app's own screen (`shown: "app"`) one of the trust file's `appOrigins` — none is listed yet, so such
|
|
38
|
+
a reveal is refused until the app ships — and every other press sign.333.eco's, including an app key pressed through the phone's
|
|
39
|
+
passkey sheet, whose origin the browser writes. Version-2 records read exactly as before.
|
|
40
|
+
|
|
41
|
+
**Key statements and revocations** (b-poh-statements §5, §6.1). A press made with a B-PoH app key may travel with a *key statement*:
|
|
42
|
+
what sign.333.eco found, when the key was enrolled, about where the key lives and what unlocks it, signed by the key statement key
|
|
43
|
+
(the trust file's `keyStatementKeys`, never a record key). `checkKeyStatement(statement, entry, opening, trust, revocations)`, called
|
|
44
|
+
after `checkReveal` passed, answers for that press: `covered: true` (no revocation reaches the press's minute), `covered: false` with
|
|
45
|
+
both dates of the revocation that reaches it, or `covered: null` when the log was not read (never read as covered). It returns
|
|
46
|
+
`declared` apart from `attested`: a declared field is the app's word, and `sensorsPresent` lists sensors the phone HAS, never which one
|
|
47
|
+
unlocks the key. `findRevocations(get, size, trust)` reads the log's `revoke` entries; a holder's revocation reveals through
|
|
48
|
+
`checkReveal` like a record. None of it says who held the phone.
|
|
49
|
+
|
|
35
50
|
## Finding a file after its metadata is gone
|
|
36
51
|
|
|
37
52
|
| field | what it is | survives |
|
package/index.mjs
CHANGED
|
@@ -158,12 +158,20 @@ export async function checkReveal(entry, opening, trust) {
|
|
|
158
158
|
if (toB64u(commitment) !== entry.assertionCommitment) return fail("the opening does not match the record's commitment");
|
|
159
159
|
const challenge = entry.t === "record"
|
|
160
160
|
? sha256(utf8("b-origin/claim/v1\0"), raw.nonce, sha256(utf8(canonical(entry.claim))))
|
|
161
|
-
: entry.t === "withdraw" ? sha256(utf8("b-origin/withdraw/v1\0"), raw.nonce, u64(entry.target))
|
|
161
|
+
: entry.t === "withdraw" ? sha256(utf8("b-origin/withdraw/v1\0"), raw.nonce, u64(entry.target))
|
|
162
|
+
// A holder's revocation (b-poh-statements §5): one passkey press bound to EVERY key the entry names, in order, and the date.
|
|
163
|
+
: entry.t === "revoke" && entry.by === "holder" && Array.isArray(entry.keys) && typeof entry.compromised === "string"
|
|
164
|
+
? sha256(utf8("b-origin/revoke/v1\0"), raw.nonce, u32(entry.keys.length), ...entry.keys.map((k) => lp(b64u(String(k)))), lp(utf8(entry.compromised))) : null;
|
|
162
165
|
if (!challenge) return fail("nothing to reveal in this entry");
|
|
163
166
|
if (toB64u(challenge) !== entry.claimCommitment) return fail("the challenge does not bind this claim");
|
|
164
167
|
let cd;
|
|
165
168
|
try { cd = JSON.parse(text(raw.clientDataJSON)); } catch { return fail("bad client data"); }
|
|
166
|
-
|
|
169
|
+
// Version 3: the record names its press, inside the log's signature. A press made in the B-PoH app's own screen (shown "app")
|
|
170
|
+
// carries an app origin the trust file must list; every other press carries sign.333.eco's — a passkey, every version-2 record,
|
|
171
|
+
// and an app key pressed through the phone's passkey sheet (shown "site"), whose origin the browser writes.
|
|
172
|
+
const appPress = entry.v >= 3 && entry.press?.key === "b-poh" && entry.press?.shown === "app";
|
|
173
|
+
const originOk = appPress ? Array.isArray(trust.appOrigins) && trust.appOrigins.includes(cd.origin) : cd.origin === trust.webOrigin;
|
|
174
|
+
if (cd.type !== "webauthn.get" || !originOk || cd.challenge !== entry.claimCommitment) return fail("the assertion was made elsewhere or for something else");
|
|
167
175
|
const auth = raw.authenticatorData;
|
|
168
176
|
if (auth.length < 37 || !eq(auth.subarray(0, 32), sha256(utf8(trust.rpId)))) return fail("the assertion names another site");
|
|
169
177
|
if ((auth[32] & 0x05) !== 0x05) return fail("the passkey's owner was not present and verified");
|
|
@@ -172,6 +180,43 @@ export async function checkReveal(entry, opening, trust) {
|
|
|
172
180
|
if (!good) return fail("the passkey's signature does not verify");
|
|
173
181
|
return { ok: true, passkeyPublicKey: opening.credentialPublicKey };
|
|
174
182
|
}
|
|
183
|
+
// ── key statements and revocations (b-poh-statements §5, §6.1) ────────────────────────────────────────────────────────────────
|
|
184
|
+
/** A key ID: the SHA-256 of the COSE public key a proof's opening carries (`credentialPublicKey`, base64url-decoded). */
|
|
185
|
+
export const keyIdOf = (cosePublicKey) => toB64u(sha256(cosePublicKey));
|
|
186
|
+
/** Every revocation among these entries whose witness signature verifies. ⛔ Read the log to its latest checkpoint first (auditLog). */
|
|
187
|
+
export async function revocationsIn(entries, trust) {
|
|
188
|
+
const out = [];
|
|
189
|
+
for (const e of entries) if (e?.t === "revoke" && Array.isArray(e.keys) && typeof e.compromised === "string" && (await checkWitnessSignature(e, trust))) out.push(e);
|
|
190
|
+
return out;
|
|
191
|
+
}
|
|
192
|
+
export async function findRevocations(get, size, trust) { return revocationsIn((await readEntries(get, size)).map((b) => JSON.parse(text(b))), trust); }
|
|
193
|
+
/**
|
|
194
|
+
* What a key statement lets a checker say about ONE b-poh press (§6.1, §9.5). Call it after `checkReveal(entry, opening)` passed.
|
|
195
|
+
* `revocations`: from findRevocations; `null` when the log could not be read → `covered: null`, never read as covered.
|
|
196
|
+
* The answer is about the KEY when the press was made, never about who held the phone (§1); `declared` is the app's word and is
|
|
197
|
+
* returned apart from `attested`, never as attested.
|
|
198
|
+
*/
|
|
199
|
+
export async function checkKeyStatement(statement, entry, opening, trust, revocations) {
|
|
200
|
+
const fail = (why) => ({ ok: false, why });
|
|
201
|
+
if (!statement || statement.t !== "key" || statement.v !== 1 || typeof statement.sig !== "string") return fail("not a key statement");
|
|
202
|
+
const spki = trust.keyStatementKeys?.[statement.kid];
|
|
203
|
+
if (!spki) return fail("the key statement's key is not one the trust file lists for key statements");
|
|
204
|
+
const { sig, ...rest } = statement;
|
|
205
|
+
let good = false;
|
|
206
|
+
try { good = await crypto.subtle.verify({ name: "ECDSA", hash: "SHA-256" }, await importP256(b64(spki)), b64u(sig), concat(utf8("b-origin/key/v1\0"), utf8(canonical(rest)))); } catch { good = false; }
|
|
207
|
+
if (!good) return fail("the key statement's signature does not verify");
|
|
208
|
+
if (statement.key !== keyIdOf(b64u(String(opening?.credentialPublicKey ?? "")))) return fail("a key statement that doesn't belong to this press");
|
|
209
|
+
if (!(entry?.v >= 3 && entry.press?.key === "b-poh")) return fail("this record was not pressed with a B-PoH app key");
|
|
210
|
+
if (entry.press.unlock !== statement.attested?.unlock) return fail("the record's unlock is not one this key allows");
|
|
211
|
+
if (!(Date.parse(statement.checked) <= Date.parse(entry.witnessedAt))) return fail("the key statement is dated after the press");
|
|
212
|
+
const base = { ok: true, key: statement.key, checked: statement.checked, attested: statement.attested, declared: statement.declared };
|
|
213
|
+
if (!Array.isArray(revocations)) return { ...base, covered: null, why: "the key couldn't be checked just now: the log was not read to its latest checkpoint" };
|
|
214
|
+
const hits = revocations.filter((r) => r.keys.includes(statement.key) && Date.parse(r.compromised) <= Date.parse(entry.witnessedAt))
|
|
215
|
+
.sort((a, b) => Date.parse(a.compromised) - Date.parse(b.compromised));
|
|
216
|
+
if (hits.length) return { ...base, covered: false, revoked: { compromised: hits[0].compromised, known: hits[0].witnessedAt, by: hits[0].by, index: hits[0].index } };
|
|
217
|
+
return { ...base, covered: true };
|
|
218
|
+
}
|
|
219
|
+
|
|
175
220
|
/** SPEC §6.4: which of these entries carry this person's tag. Anything here they did not make is a forgery to report. */
|
|
176
221
|
export function findMine(tagKey, entries) {
|
|
177
222
|
const key = b64u(tagKey), out = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@333eco/origin-verify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Checks a B-Origin record with no help from its operator: signatures, its place in the public log, witness cosignatures, RFC 3161 tokens, OpenTimestamps proofs against Bitcoin, and a signer's reveal. Browser or Node, no runtime dependencies.",
|
|
5
5
|
"license": "CC0-1.0 OR Apache-2.0",
|
|
6
6
|
"author": "Thon Ly",
|
package/trust.mjs
CHANGED
|
@@ -5,6 +5,11 @@ export default {
|
|
|
5
5
|
"recordKeys": {
|
|
6
6
|
"k1-1": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEBJbkbZoh6NVkspuIZKGXnOs25DxF331TbbGqhK1j2rtsWIZI5x6Ze+jo4mc3kNcqnJFnpUGlOoVu0zexPo0WzQ=="
|
|
7
7
|
},
|
|
8
|
+
// K12, the key statement key (b-poh-statements §6.1): created 2026-11-26 (sign.333.eco KEYS.md Ceremony 3), SPKI SHA-256 b7612d5c…48b0.
|
|
9
|
+
// ⛔ Apart from recordKeys on purpose: a record key never signs a key statement, and this key never signs a log entry.
|
|
10
|
+
"keyStatementKeys": {
|
|
11
|
+
"k12-1": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEgFEqWgp0FhU+uOphnSUK3+CvM5jr8Iem/Z8jB64cpQFUQe/CuA5ZfsjRKPYxOFS0bOXKqE15eg0BUXyEfgq+lg=="
|
|
12
|
+
},
|
|
8
13
|
"rpId": "sign.333.eco",
|
|
9
14
|
"webOrigin": "https://sign.333.eco",
|
|
10
15
|
// The Witness Network's TESTING list (2026-11-04). These witnesses may reset or disappear, so they are named and NOT counted: no witnessQuorum, so `witnessed` stays false.
|