@opaquecash/psr-core 0.1.0 → 0.2.1

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.
@@ -0,0 +1,66 @@
1
+ /**
2
+ * PSR V2 attestation codecs — chain-neutral (the attestation engine has the same encoding on
3
+ * Ethereum and Solana). Covers uid computation, attestation-data field encode/decode, and the
4
+ * `0xB2` announce-metadata marker that lets a recipient's scanner match a V2 attestation.
5
+ *
6
+ * Ported from `ethereum/frontend/src/lib/{attestationV2,psr}.ts` (UI-only zod schemas and display
7
+ * helpers intentionally dropped).
8
+ */
9
+ import { type Address, type Hex } from "viem";
10
+ import type { FieldDef } from "./schema.js";
11
+ /** All-zero bytes32 (no reference uid). */
12
+ export declare const ZERO_BYTES32: Hex;
13
+ /** Minimal field descriptor accepted by the data codecs. */
14
+ export type AttestationField = Pick<FieldDef, "name" | "type"> | {
15
+ name: string;
16
+ type: string;
17
+ };
18
+ /** A decoded V2 attestation record (chain-neutral view). */
19
+ export interface AttestationV2 {
20
+ /** Stable id (== uid). */
21
+ address: string;
22
+ /** uid = sha256(schema_id || issuer || stealth_address_hash || block). */
23
+ uid: string;
24
+ /** schema id as 0x-hex. */
25
+ schemaId: string;
26
+ /** Issuer wallet/address. */
27
+ issuer: string;
28
+ /** Privacy-preserving stealth-address hash (bytes32 0x-hex). */
29
+ stealthAddressHash: string;
30
+ /** Encoded attestation data as 0x-hex. */
31
+ dataHex: string;
32
+ /** Block/slot when created. */
33
+ createdAt: number;
34
+ /** 0 = no expiry. */
35
+ expirationSlot: number;
36
+ /** 0 = not revoked. */
37
+ revocationSlot: number;
38
+ /** Reference uid (zeros = none). */
39
+ refUid: string;
40
+ }
41
+ /**
42
+ * `uid = sha256(abi.encodePacked(schemaId, issuer, stealthAddressHash, blockNumber))`,
43
+ * matching the attestation engine's `computeUid` on-chain.
44
+ */
45
+ export declare function computeUid(schemaId: Hex, issuer: Address, stealthAddressHash: Hex, blockNumber: bigint): Hex;
46
+ /** Encode field values: per field a 4-byte LE length prefix followed by UTF-8 bytes. */
47
+ export declare function encodeAttestationData(fieldValues: Record<string, string>, fieldDefs: readonly AttestationField[]): Hex;
48
+ /** Decode attestation data back into a field-value map. */
49
+ export declare function decodeAttestationData(dataHex: Hex | string, fieldDefs: readonly AttestationField[]): Record<string, string>;
50
+ /**
51
+ * Build the `announce` metadata for a V2 attestation:
52
+ * `viewTag(1) || 0xB2 || schemaId(32) || issuer(32) || uid(32) || nonce(32)` (130 bytes).
53
+ * The recipient's scanner matches it with their viewing key.
54
+ */
55
+ export declare function encodeV2AttestationMetadata(args: {
56
+ viewTag: number;
57
+ schemaId: Hex;
58
+ issuer: Address;
59
+ uid: Hex;
60
+ nonce: Hex;
61
+ }): Hex;
62
+ /** A fresh 32-byte nonce as 0x-hex (uses Web Crypto, available in Node 18+ and browsers). */
63
+ export declare function randomNonce(): Hex;
64
+ /** True if a uid is all-zero (no reference). */
65
+ export declare function isZeroUid(uid: string): boolean;
66
+ //# sourceMappingURL=attestation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attestation.d.ts","sourceRoot":"","sources":["../src/attestation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAQL,KAAK,OAAO,EACZ,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,2CAA2C;AAC3C,eAAO,MAAM,YAAY,EAA+B,GAAG,CAAC;AAE5D,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhG,4DAA4D;AAC5D,MAAM,WAAW,aAAa;IAC5B,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,GAAG,EAA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 * PSR V2 attestation codecs — chain-neutral (the attestation engine has the same encoding on
3
+ * Ethereum and Solana). Covers uid computation, attestation-data field encode/decode, and the
4
+ * `0xB2` announce-metadata marker that lets a recipient's scanner match a V2 attestation.
5
+ *
6
+ * Ported from `ethereum/frontend/src/lib/{attestationV2,psr}.ts` (UI-only zod schemas and display
7
+ * helpers intentionally dropped).
8
+ */
9
+ import { bytesToHex, concatHex, encodePacked, hexToBytes, numberToHex, pad, sha256, } from "viem";
10
+ /** All-zero bytes32 (no reference uid). */
11
+ export const ZERO_BYTES32 = ("0x" + "00".repeat(32));
12
+ /**
13
+ * `uid = sha256(abi.encodePacked(schemaId, issuer, stealthAddressHash, blockNumber))`,
14
+ * matching the attestation engine's `computeUid` on-chain.
15
+ */
16
+ export function computeUid(schemaId, issuer, stealthAddressHash, blockNumber) {
17
+ return sha256(encodePacked(["bytes32", "address", "bytes32", "uint256"], [schemaId, issuer, stealthAddressHash, blockNumber]));
18
+ }
19
+ /** Encode field values: per field a 4-byte LE length prefix followed by UTF-8 bytes. */
20
+ export function encodeAttestationData(fieldValues, fieldDefs) {
21
+ const enc = new TextEncoder();
22
+ const parts = [];
23
+ for (const field of fieldDefs) {
24
+ const encoded = enc.encode(fieldValues[field.name] ?? "");
25
+ const lenBuf = new Uint8Array(4);
26
+ new DataView(lenBuf.buffer).setUint32(0, encoded.length, true);
27
+ parts.push(lenBuf, encoded);
28
+ }
29
+ const total = parts.reduce((acc, p) => acc + p.length, 0);
30
+ const out = new Uint8Array(total);
31
+ let offset = 0;
32
+ for (const part of parts) {
33
+ out.set(part, offset);
34
+ offset += part.length;
35
+ }
36
+ return bytesToHex(out);
37
+ }
38
+ /** Decode attestation data back into a field-value map. */
39
+ export function decodeAttestationData(dataHex, fieldDefs) {
40
+ const hx = (dataHex.startsWith("0x") ? dataHex : `0x${dataHex}`);
41
+ const bytes = hexToBytes(hx);
42
+ const dec = new TextDecoder();
43
+ const result = {};
44
+ let offset = 0;
45
+ for (const field of fieldDefs) {
46
+ if (offset + 4 > bytes.length)
47
+ break;
48
+ const len = new DataView(bytes.buffer, bytes.byteOffset + offset, 4).getUint32(0, true);
49
+ offset += 4;
50
+ if (offset + len > bytes.length)
51
+ break;
52
+ result[field.name] = dec.decode(bytes.slice(offset, offset + len));
53
+ offset += len;
54
+ }
55
+ return result;
56
+ }
57
+ /**
58
+ * Build the `announce` metadata for a V2 attestation:
59
+ * `viewTag(1) || 0xB2 || schemaId(32) || issuer(32) || uid(32) || nonce(32)` (130 bytes).
60
+ * The recipient's scanner matches it with their viewing key.
61
+ */
62
+ export function encodeV2AttestationMetadata(args) {
63
+ return concatHex([
64
+ numberToHex(args.viewTag & 0xff, { size: 1 }),
65
+ "0xb2",
66
+ args.schemaId,
67
+ pad(args.issuer, { size: 32 }),
68
+ args.uid,
69
+ args.nonce,
70
+ ]);
71
+ }
72
+ /** A fresh 32-byte nonce as 0x-hex (uses Web Crypto, available in Node 18+ and browsers). */
73
+ export function randomNonce() {
74
+ const b = new Uint8Array(32);
75
+ crypto.getRandomValues(b);
76
+ return bytesToHex(b);
77
+ }
78
+ /** True if a uid is all-zero (no reference). */
79
+ export function isZeroUid(uid) {
80
+ return uid.replace(/^0x/, "").replace(/0/g, "") === "";
81
+ }
82
+ //# sourceMappingURL=attestation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attestation.js","sourceRoot":"","sources":["../src/attestation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,WAAW,EACX,GAAG,EACH,MAAM,GAGP,MAAM,MAAM,CAAC;AAGd,2CAA2C;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAQ,CAAC;AA6B5D;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,QAAa,EACb,MAAe,EACf,kBAAuB,EACvB,WAAmB;IAEnB,OAA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B,IAAI,CAAC,GAAG;QACR,IAAI,CAAC,KAAK;KACX,CAAC,CAAC;AACL,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,WAAW;IACzB,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC7B,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC1B,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC;AACzD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -7,7 +7,9 @@
7
7
  */
8
8
  export { PSR_CIRCUIT_VERSION } from "./scope.js";
9
9
  export { buildActionScope, externalNullifierFromScope } from "./scope.js";
10
- export type { Attestation, DiscoveredTrait, MerkleRootMeta, ProofData, } from "./types.js";
10
+ export type { Attestation, AttestationIdentifier, DiscoveredTrait, MerkleRootMeta, ProofData, V2Attestation, V2MerkleLeafPreimage, } from "./types.js";
11
11
  export { PsrError, ProofError, RootExpiredError, NullifierUsedError, } from "./errors.js";
12
- export { attestationsToDiscoveredTraits } from "./traits.js";
12
+ export { attestationsToDiscoveredTraits, v2AttestationsToDiscoveredTraits, } from "./traits.js";
13
+ export { type FieldType, type FieldDef, type SchemaV2, SCHEMA_VERSION, ZERO_ADDRESS, parseFieldDefs, fieldDefsToString, computeSchemaId, packSchemaIdToField, } from "./schema.js";
14
+ export { type AttestationField, type AttestationV2, ZERO_BYTES32, computeUid, encodeAttestationData, decodeAttestationData, encodeV2AttestationMetadata, randomNonce, isZeroUid, } from "./attestation.js";
13
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAE1E,YAAY,EACV,WAAW,EACX,eAAe,EACf,cAAc,EACd,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAE1E,YAAY,EACV,WAAW,EACX,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,cAAc,EACd,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,YAAY,EACZ,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,WAAW,EACX,SAAS,GACV,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -8,5 +8,8 @@
8
8
  export { PSR_CIRCUIT_VERSION } from "./scope.js";
9
9
  export { buildActionScope, externalNullifierFromScope } from "./scope.js";
10
10
  export { PsrError, ProofError, RootExpiredError, NullifierUsedError, } from "./errors.js";
11
- export { attestationsToDiscoveredTraits } from "./traits.js";
11
+ export { attestationsToDiscoveredTraits, v2AttestationsToDiscoveredTraits, } from "./traits.js";
12
+ // PSR V2 schema + attestation codecs (chain-neutral).
13
+ export { SCHEMA_VERSION, ZERO_ADDRESS, parseFieldDefs, fieldDefsToString, computeSchemaId, packSchemaIdToField, } from "./schema.js";
14
+ export { ZERO_BYTES32, computeUid, encodeAttestationData, decodeAttestationData, encodeV2AttestationMetadata, randomNonce, isZeroUid, } from "./attestation.js";
12
15
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAS1E,OAAO,EACL,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAY1E,OAAO,EACL,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,aAAa,CAAC;AAErB,sDAAsD;AACtD,OAAO,EAIL,cAAc,EACd,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,YAAY,EACZ,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,WAAW,EACX,SAAS,GACV,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * PSR V2 schema codecs — chain-neutral. A schema defines an attestation class and controls who
3
+ * may issue it. Ported from `ethereum/frontend/src/lib/schema.ts` (zod schemas dropped).
4
+ */
5
+ import { type Address, type Hex } from "viem";
6
+ export type FieldType = "bool" | "u8" | "u16" | "u32" | "u64" | "string" | "pubkey";
7
+ export interface FieldDef {
8
+ id: string;
9
+ name: string;
10
+ type: FieldType;
11
+ }
12
+ /** A decoded V2 schema record (chain-neutral view). */
13
+ export interface SchemaV2 {
14
+ /** Stable id (== schemaId). */
15
+ address: string;
16
+ /** schemaId = sha256(authority || name || version) as 0x-hex (bytes32). */
17
+ schemaId: string;
18
+ /** Wallet that created the schema. */
19
+ authority: string;
20
+ /** Optional resolver (zero address = none). */
21
+ resolver: string;
22
+ /** Whether attestations can be revoked. */
23
+ revocable: boolean;
24
+ /** Display name. */
25
+ name: string;
26
+ /** ABI-style field definitions, e.g. "bool passed, u64 score". */
27
+ fieldDefinitions: string;
28
+ /** Schema version (always 1 currently). */
29
+ version: number;
30
+ /** Authorized delegate addresses. */
31
+ delegates: string[];
32
+ /** Block/slot when registered. */
33
+ createdAt: number;
34
+ /** 0 = no expiry. */
35
+ schemaExpirySlot: number;
36
+ /** Whether the schema has been deprecated. */
37
+ deprecated: boolean;
38
+ }
39
+ export declare const SCHEMA_VERSION = 1;
40
+ export declare const ZERO_ADDRESS: Address;
41
+ /** Parse a `fieldDefinitions` string ("bool passed, u64 score") into {@link FieldDef}s. */
42
+ export declare function parseFieldDefs(fieldDefs: string): FieldDef[];
43
+ /** Convert {@link FieldDef}s back to the canonical ABI string. */
44
+ export declare function fieldDefsToString(fields: readonly FieldDef[]): string;
45
+ /**
46
+ * `schemaId = sha256(abi.encodePacked(authority, bytes(name), version))`, byte-for-byte matching
47
+ * the schema registry's `computeSchemaId` on-chain.
48
+ */
49
+ export declare function computeSchemaId(authority: Address, name: string, version?: number): Hex;
50
+ /** Normalize a schemaId hex to the `0x`-prefixed field input the V2 circuit expects. */
51
+ export declare function packSchemaIdToField(schemaId: string): string;
52
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAwB,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAEpE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEpF,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,uDAAuD;AACvD,MAAM,WAAW,QAAQ;IACvB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,gBAAgB,EAAE,MAAM,CAAC;IACzB,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,8CAA8C;IAC9C,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,YAAY,EAAmD,OAAO,CAAC;AAEpF,2FAA2F;AAC3F,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE,CAS5D;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CAKrE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,OAAO,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAuB,GAC/B,GAAG,CAEL;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5D"}
package/dist/schema.js ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * PSR V2 schema codecs — chain-neutral. A schema defines an attestation class and controls who
3
+ * may issue it. Ported from `ethereum/frontend/src/lib/schema.ts` (zod schemas dropped).
4
+ */
5
+ import { encodePacked, sha256 } from "viem";
6
+ export const SCHEMA_VERSION = 1;
7
+ export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
8
+ /** Parse a `fieldDefinitions` string ("bool passed, u64 score") into {@link FieldDef}s. */
9
+ export function parseFieldDefs(fieldDefs) {
10
+ if (!fieldDefs.trim())
11
+ return [];
12
+ return fieldDefs.split(",").map((part, i) => {
13
+ const trimmed = part.trim();
14
+ const spaceIdx = trimmed.indexOf(" ");
15
+ const type = (spaceIdx === -1 ? "string" : trimmed.slice(0, spaceIdx));
16
+ const name = spaceIdx === -1 ? trimmed : trimmed.slice(spaceIdx + 1);
17
+ return { id: String(i), name: name.trim(), type: type.trim() };
18
+ });
19
+ }
20
+ /** Convert {@link FieldDef}s back to the canonical ABI string. */
21
+ export function fieldDefsToString(fields) {
22
+ return fields
23
+ .filter((f) => f.name.trim())
24
+ .map((f) => `${f.type} ${f.name.trim()}`)
25
+ .join(", ");
26
+ }
27
+ /**
28
+ * `schemaId = sha256(abi.encodePacked(authority, bytes(name), version))`, byte-for-byte matching
29
+ * the schema registry's `computeSchemaId` on-chain.
30
+ */
31
+ export function computeSchemaId(authority, name, version = SCHEMA_VERSION) {
32
+ return sha256(encodePacked(["address", "string", "uint8"], [authority, name, version]));
33
+ }
34
+ /** Normalize a schemaId hex to the `0x`-prefixed field input the V2 circuit expects. */
35
+ export function packSchemaIdToField(schemaId) {
36
+ return schemaId.startsWith("0x") ? schemaId : "0x" + schemaId;
37
+ }
38
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,EAA0B,MAAM,MAAM,CAAC;AAsCpE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,YAAY,GAAG,4CAAuD,CAAC;AAEpF,2FAA2F;AAC3F,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC;IACjC,OAAO,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAc,CAAC;QACpF,MAAM,IAAI,GAAG,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;QACrE,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAe,EAAE,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,MAA2B;IAC3D,OAAO,MAAM;SACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC5B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;SACxC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,SAAkB,EAClB,IAAY,EACZ,UAAkB,cAAc;IAEhC,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1F,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,QAAQ,CAAC;AAChE,CAAC"}
package/dist/traits.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Attestation, DiscoveredTrait } from "./types.js";
1
+ import type { Attestation, DiscoveredTrait, V2Attestation } from "./types.js";
2
2
  /**
3
3
  * Convert raw WASM/JSON {@link Attestation} rows into {@link DiscoveredTrait}.
4
4
  *
@@ -6,4 +6,11 @@ import type { Attestation, DiscoveredTrait } from "./types.js";
6
6
  * @param nowMs - Optional clock override (defaults to `Date.now()`).
7
7
  */
8
8
  export declare function attestationsToDiscoveredTraits(rows: Attestation[], nowMs?: number): DiscoveredTrait[];
9
+ /**
10
+ * Convert raw V2 WASM scanner rows into {@link DiscoveredTrait}.
11
+ *
12
+ * V2 uses the schema id as the public circuit identifier, so the resulting
13
+ * `attestationId` may be a hex string rather than a V1-safe JavaScript number.
14
+ */
15
+ export declare function v2AttestationsToDiscoveredTraits(rows: V2Attestation[], nowMs?: number): DiscoveredTrait[];
9
16
  //# sourceMappingURL=traits.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"traits.d.ts","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,WAAW,EAAE,EACnB,KAAK,GAAE,MAAmB,GACzB,eAAe,EAAE,CASnB"}
1
+ {"version":3,"file":"traits.d.ts","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAEX,eAAe,EACf,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,WAAW,EAAE,EACnB,KAAK,GAAE,MAAmB,GACzB,eAAe,EAAE,CASnB;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,aAAa,EAAE,EACrB,KAAK,GAAE,MAAmB,GACzB,eAAe,EAAE,CA4BnB"}
package/dist/traits.js CHANGED
@@ -14,4 +14,54 @@ export function attestationsToDiscoveredTraits(rows, nowMs = Date.now()) {
14
14
  ephemeralPubkey: a.ephemeral_pubkey,
15
15
  }));
16
16
  }
17
+ /**
18
+ * Convert raw V2 WASM scanner rows into {@link DiscoveredTrait}.
19
+ *
20
+ * V2 uses the schema id as the public circuit identifier, so the resulting
21
+ * `attestationId` may be a hex string rather than a V1-safe JavaScript number.
22
+ */
23
+ export function v2AttestationsToDiscoveredTraits(rows, nowMs = Date.now()) {
24
+ return rows.map((a) => {
25
+ const schemaId = ensure0x(a.schema_id);
26
+ const preimage = a.merkle_leaf_preimage;
27
+ return {
28
+ attestationId: fieldIdentifier(preimage.schema_id_field),
29
+ stealthAddress: a.stealth_address,
30
+ txHash: a.tx_hash,
31
+ blockNumber: a.slot,
32
+ discoveredAt: nowMs,
33
+ ephemeralPubkey: a.ephemeral_pubkey,
34
+ schemaId,
35
+ schemaName: a.schema_name ?? null,
36
+ issuer: ensure0x(a.issuer),
37
+ attestationUid: ensure0x(a.attestation_uid),
38
+ dataHex: ensure0x(a.data_hex),
39
+ nonce: ensure0x(a.nonce),
40
+ merkleLeafPreimage: {
41
+ stealthPkField: preimage.stealth_pk_field,
42
+ schemaIdField: preimage.schema_id_field,
43
+ issuerPkX: preimage.issuer_pk_x,
44
+ traitDataHash: preimage.trait_data_hash,
45
+ nonceField: preimage.nonce_field,
46
+ },
47
+ isValid: a.is_valid,
48
+ issuerAuthorized: a.issuer_authorized,
49
+ };
50
+ });
51
+ }
52
+ function ensure0x(value) {
53
+ if (!value)
54
+ return "0x";
55
+ return value.startsWith("0x") ? value : `0x${value}`;
56
+ }
57
+ function fieldIdentifier(value) {
58
+ const normalized = ensure0x(value);
59
+ try {
60
+ const n = BigInt(normalized);
61
+ return n <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(n) : normalized;
62
+ }
63
+ catch {
64
+ return value;
65
+ }
66
+ }
17
67
  //# sourceMappingURL=traits.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"traits.js","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAC5C,IAAmB,EACnB,QAAgB,IAAI,CAAC,GAAG,EAAE;IAE1B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,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ED
@@ -1,4 +1,6 @@
1
1
  import type { Hex } from "viem";
2
+ /** Public identifier used by the reputation circuit. V1 uses a u64 number; V2 uses schema_id. */
3
+ export type AttestationIdentifier = number | string;
2
4
  /**
3
5
  * Issuer attestation embedded in announcement metadata and discovered by the WASM scanner.
4
6
  */
@@ -19,7 +21,7 @@ export interface Attestation {
19
21
  */
20
22
  export interface DiscoveredTrait {
21
23
  /** Numeric attestation id (matches circuit public input). */
22
- attestationId: number;
24
+ attestationId: AttestationIdentifier;
23
25
  /** One-time stealth address. */
24
26
  stealthAddress: string;
25
27
  /** Announcement transaction hash. */
@@ -29,6 +31,53 @@ export interface DiscoveredTrait {
29
31
  discoveredAt: number;
30
32
  /** Ephemeral pubkey from the announcement (compressed bytes). */
31
33
  ephemeralPubkey?: number[];
34
+ /** V2 schema id, when discovered from a schema-bound attestation announcement. */
35
+ schemaId?: string;
36
+ /** Optional schema display name from the registry snapshot. */
37
+ schemaName?: string | null;
38
+ /** V2 issuer identity encoded as 32-byte hex. */
39
+ issuer?: string;
40
+ /** V2 attestation UID as bytes32 hex. */
41
+ attestationUid?: string;
42
+ /** Encoded V2 attestation payload, if available. */
43
+ dataHex?: string;
44
+ /** V2 leaf nonce as bytes32 hex. */
45
+ nonce?: string;
46
+ /** V2 leaf preimage fields needed by the prover. */
47
+ merkleLeafPreimage?: V2MerkleLeafPreimage;
48
+ /** Scanner-side validity and authorization checks. */
49
+ isValid?: boolean;
50
+ issuerAuthorized?: boolean;
51
+ }
52
+ /** V2 leaf preimage fields emitted by the Rust scanner. */
53
+ export interface V2MerkleLeafPreimage {
54
+ stealthPkField: string;
55
+ schemaIdField: string;
56
+ issuerPkX: string;
57
+ traitDataHash: string;
58
+ nonceField: string;
59
+ }
60
+ /** Raw JSON row emitted by `scan_attestations_v2_wasm`. */
61
+ export interface V2Attestation {
62
+ readonly stealth_address: string;
63
+ readonly schema_id: string;
64
+ readonly schema_name?: string | null;
65
+ readonly issuer: string;
66
+ readonly attestation_uid: string;
67
+ readonly data_hex: string;
68
+ readonly nonce: string;
69
+ readonly merkle_leaf_preimage: {
70
+ readonly stealth_pk_field: string;
71
+ readonly schema_id_field: string;
72
+ readonly issuer_pk_x: string;
73
+ readonly trait_data_hash: string;
74
+ readonly nonce_field: string;
75
+ };
76
+ readonly tx_hash: string;
77
+ readonly slot: number;
78
+ readonly ephemeral_pubkey: number[];
79
+ readonly is_valid: boolean;
80
+ readonly issuer_authorized: boolean;
32
81
  }
33
82
  /**
34
83
  * Metadata about an on-chain Merkle root (for indexers or `OpaqueReputationVerifier` history).
@@ -44,6 +93,8 @@ export interface MerkleRootMeta {
44
93
  }
45
94
  /**
46
95
  * Groth16 proof bundle compatible with {@link submitVerifyReputation} in `@opaquecash/psr-chain`.
96
+ *
97
+ * V2 public signals: `[merkle_root, attestation_id, external_nullifier, nullifier_hash]`.
47
98
  */
48
99
  export interface ProofData {
49
100
  proof: {
@@ -52,7 +103,8 @@ export interface ProofData {
52
103
  pi_c: string[];
53
104
  };
54
105
  publicSignals: string[];
106
+ /** V2 `nullifier_hash` (`publicSignals[3]` = `Poseidon(stealth_pk, external_nullifier)`). */
55
107
  nullifier: string;
56
- attestationId: number;
108
+ attestationId: AttestationIdentifier;
57
109
  }
58
110
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,yDAAyD;IACzD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,mDAAmD;IACnD,QAAQ,CAAC,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EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,qBAAqB,CAAC;CACtC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opaquecash/psr-core",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Programmable Stealth Reputation types, scoping, and error taxonomy",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,5 +21,15 @@
21
21
  "dependencies": {
22
22
  "viem": "^2.21.0"
23
23
  },
24
- "sideEffects": false
24
+ "sideEffects": false,
25
+ "license": "Apache-2.0",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/opaquecash/sdk.git",
29
+ "directory": "packages/psr-core"
30
+ },
31
+ "homepage": "https://docs.opaque.cash",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ }
25
35
  }