@agenticprimitives/attestations 0.0.0-alpha.10

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Agentic Trust Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @agenticprimitives/attestations
2
+
3
+ **Agent reputation needs public, revocable claims pinned to a persistent identity — not to a key that rotates away.** When an agent's track record lives on chain, three things must be true: the subject is an address that survives credential recovery, the claim cannot be anchored against a different subject by replaying a signature, and a "joint" claim genuinely carries both parties' consent. This package is the SDK for `AttestationRegistry.sol`, the single on-chain registry where those guarantees are enforced — bilateral consent is verified on chain from both party signatures, not assumed from a stored reference.
4
+
5
+ It is EAS-aligned where alignment helps (UID model, schema IDs, refUID chaining) and deliberately stricter where EAS is loose: one registry, credential types as discriminators rather than per-type contracts, and no issuer-unilateral revocation entrypoint at all.
6
+
7
+ > Part of [agenticprimitives](../../README.md) — the trust substrate for the agent economy: one canonical Smart Agent identity with custody, delegation, naming, credentials, and audit evidence designed as one system.
8
+
9
+ ## What ships today
10
+
11
+ The W1 foundational slice — the cryptographic spine the contract and downstream packages already rely on:
12
+
13
+ - **`CREDENTIAL_TYPE`** — keccak discriminators for `Association`, `Evidence`, `Outcome`, `Validation`, `TrustUpdate`, `JointAgreement`, `PaymentReceipt` (one registry, many types — [ADR-0024](../../docs/architecture/decisions/0024-intent-coordination-substrate.md) Decision 2).
14
+ - **`computeAttestationUid(...)`** — recomputes the on-chain UID per `AttestationRegistry._computeUid`.
15
+ - **`JOINT_CONSENT_TYPEHASH` + `jointConsentDigest(...)`** — the digest BOTH parties sign to consent to a joint agreement. `assertJointAgreement` recomputes it on chain and verifies both signatures (ERC-1271 / ECDSA); a stored consent reference is not consent (RW1-1, [ADR-0027](../../docs/architecture/decisions/0027-canonical-authority-binding.md)). `chainId` and the registry address are bound, so consent cannot be replayed cross-chain (ATT-3).
16
+ - **`JOINT_ISSUER_TYPEHASH` + `jointIssuerDigest(...)`** — the issuer signs parties, schema, credential type/hash, agreement commitment, chain, and registry — never a bare hash (ATT-1).
17
+ - **`ASSOCIATION_ATTESTATION_TYPEHASH` + `associationAttestationDigest(...)`** — binds the subject, so a known credential hash cannot be anchored against someone else (SC-2).
18
+ - **Request payload shapes** — `AssociationAttestationRequest`, `JointAgreementAttestationRequest`, matching the contract ABI.
19
+
20
+ Every typehash above MUST byte-equal its `AttestationRegistry.sol` constant — enforced by the cross-stack `check:eip712-typehash-equality` CI gate.
21
+
22
+ Planned for later waves per the [W1 implementation wave plan](../../docs/architecture/w1-implementation-wave-plan.md): assertion builders (`buildAssociationAssertion`, `buildJointAgreementAssertion`), the `AttestationClient` read client, and revocation encoders (holder-only / either-party / validator-only per type).
23
+
24
+ ## How it's different
25
+
26
+ Against EAS and Verax, three concrete deltas:
27
+
28
+ 1. **Contracts and SDK are one artifact.** The EIP-712 typehashes in this package are CI-locked to the Solidity constants. In EAS-style stacks the client SDK and the chain are separate codebases that drift; here drift fails the build.
29
+ 2. **Bilateral consent is verified, not asserted.** A joint attestation requires both parties' signatures over a digest the contract recomputes. There is no resolver/module hook where consent semantics can be customized away ([ADR-0023](../../docs/architecture/decisions/0023-attestation-registry-eas-aligned-bilateral-consent.md), D2).
30
+ 3. **No `issuerRevoke`.** Holders revoke their own associations; joint agreements revoke by either party; issuer revocation is off-chain via StatusList2021 (D-18). An issuer cannot unilaterally erase a subject's record.
31
+
32
+ The credential bodies themselves are W3C VCs from [`verifiable-credentials`](../verifiable-credentials) (type-only dependency); only their canonical hashes touch the chain. Vault-resident bodies stay private unless explicitly opted into public assertion (D-46).
33
+
34
+ ## Status
35
+
36
+ **Foundational (W1) — code shipped; not production enforcement.** The digest math, typehashes, and payload shapes above are real and gate-checked; the full builder/client surface lands in Wave 4 per the [wave plan](../../docs/architecture/w1-implementation-wave-plan.md). See [AUDIT.md](./AUDIT.md).
37
+
38
+ > Testnet/pilot-ready. Production launch is gated on the public checklist in the root README — including third-party contract audit and governance key rotation. Track every security finding live in [`docs/audits/findings.yaml`](../../docs/audits/findings.yaml).
39
+
40
+ **Owns spine layers:** 12–15.
41
+ **Authoritative spec:** [`specs/242-trust-credentials-and-public-assertions.md`](../../specs/242-trust-credentials-and-public-assertions.md) — see `spec.md` for the symlink. Bounded surface: `CLAUDE.md` + `capability.manifest.json`.
42
+
43
+ ## Build
44
+
45
+ ```bash
46
+ pnpm --filter @agenticprimitives/attestations typecheck
47
+ pnpm --filter @agenticprimitives/attestations test
48
+ pnpm --filter @agenticprimitives/attestations build
49
+ ```
@@ -0,0 +1,133 @@
1
+ /**
2
+ * @agenticprimitives/attestations — AttestationRegistry SDK + credential types
3
+ * (Layers 12–15 of the spine).
4
+ *
5
+ * Authoritative spec: specs/242-trust-credentials-and-public-assertions.md
6
+ * Architecture-of-record: ADR-0023
7
+ */
8
+ import type { Address, Hex } from '@agenticprimitives/types';
9
+ export declare const PACKAGE_NAME = "@agenticprimitives/attestations";
10
+ export declare const PACKAGE_STATUS: "w1-foundational";
11
+ export declare const SPEC_REF = "specs/242-trust-credentials-and-public-assertions.md";
12
+ export type Hex32 = `0x${string}`;
13
+ /** ADR-0024 Decision 2 — substrate credential-type discriminators. */
14
+ export declare const CREDENTIAL_TYPE: {
15
+ readonly Association: `0x${string}`;
16
+ readonly Evidence: `0x${string}`;
17
+ readonly Outcome: `0x${string}`;
18
+ readonly Validation: `0x${string}`;
19
+ readonly TrustUpdate: `0x${string}`;
20
+ readonly JointAgreement: `0x${string}`;
21
+ readonly PaymentReceipt: `0x${string}`;
22
+ };
23
+ /** Recomputes the on-chain UID per AttestationRegistry._computeUid. */
24
+ export declare function computeAttestationUid(args: {
25
+ subject: Address;
26
+ party2: Address;
27
+ issuer: Address;
28
+ credentialType: Hex32;
29
+ credentialHash: Hex32;
30
+ refUID: Hex32;
31
+ salt: bigint;
32
+ }): Hex32;
33
+ /**
34
+ * RW1-1 (ADR-0027) — canonical joint-agreement consent typehash. MUST byte-equal
35
+ * `AttestationRegistry.JOINT_CONSENT_TYPEHASH`; enforced by the cross-stack
36
+ * typehash-equality gate (`check:eip712-typehash-equality`).
37
+ */
38
+ export declare const JOINT_CONSENT_TYPEHASH: Hex32;
39
+ /**
40
+ * Recompute the consent digest each party signs to consent to a joint agreement
41
+ * (RW1-1). Equals the contract's `keccak256(abi.encode(JOINT_CONSENT_TYPEHASH,
42
+ * party1, party2, agreementCommitment, credentialHash, chainId, verifyingContract))`.
43
+ * `assertJointAgreement` recomputes the same digest on-chain and verifies BOTH party
44
+ * signatures (ERC-1271 / ECDSA) against it — a stored or supplied consent reference is
45
+ * not consent. ATT-3: `chainId` + the registry address are bound (anti cross-chain/replay).
46
+ */
47
+ export declare function jointConsentDigest(args: {
48
+ party1: Address;
49
+ party2: Address;
50
+ agreementCommitment: Hex32;
51
+ credentialHash: Hex32;
52
+ chainId: bigint;
53
+ verifyingContract: Address;
54
+ }): Hex32;
55
+ /**
56
+ * ATT-1 (audit 2026-06-10) — canonical issuer typehash for a JOINT-agreement attestation. MUST
57
+ * byte-equal `AttestationRegistry.JOINT_ISSUER_TYPEHASH`; locked by the cross-stack typehash-equality
58
+ * gate. The issuer no longer signs a bare `credentialHash` (the SC-2 bug class, which survived on the
59
+ * joint path) — it binds the parties, schema, credential type/hash, the agreement commitment, chain,
60
+ * and the registry address.
61
+ */
62
+ export declare const JOINT_ISSUER_TYPEHASH: Hex32;
63
+ /**
64
+ * Recompute the digest the issuer signs for a joint-agreement attestation (ATT-1). Equals the
65
+ * contract's `keccak256(abi.encode(JOINT_ISSUER_TYPEHASH, party1, party2, issuer, schemaId,
66
+ * credentialType, credentialHash, agreementCommitment, chainId, verifyingContract))`.
67
+ * `assertJointAgreement` recomputes the same digest on chain — so a leaked issuer signature can't be
68
+ * replayed against different parties/schema/chain. `agreementCommitment` is the request's `refUID`.
69
+ */
70
+ export declare function jointIssuerDigest(args: {
71
+ party1: Address;
72
+ party2: Address;
73
+ issuer: Address;
74
+ schemaId: Hex32;
75
+ credentialType: Hex32;
76
+ credentialHash: Hex32;
77
+ agreementCommitment: Hex32;
78
+ chainId: bigint;
79
+ verifyingContract: Address;
80
+ }): Hex32;
81
+ /**
82
+ * SC-2 (audit 2026-06-09) — canonical issuer-attestation typehash for a unilateral association.
83
+ * MUST byte-equal `AttestationRegistry.ASSOCIATION_ATTESTATION_TYPEHASH`; locked by the cross-stack
84
+ * typehash-equality gate.
85
+ */
86
+ export declare const ASSOCIATION_ATTESTATION_TYPEHASH: Hex32;
87
+ /**
88
+ * Recompute the digest the issuer signs for a unilateral association (SC-2). Equals the contract's
89
+ * `keccak256(abi.encode(ASSOCIATION_ATTESTATION_TYPEHASH, subject, issuer, schemaId, credentialType,
90
+ * credentialHash, chainId, verifyingContract))`. `assertAssociation` recomputes the same digest on
91
+ * chain — binding the SUBJECT so a known credentialHash can't be anchored against a different subject.
92
+ */
93
+ export declare function associationAttestationDigest(args: {
94
+ subject: Address;
95
+ issuer: Address;
96
+ schemaId: Hex32;
97
+ credentialType: Hex32;
98
+ credentialHash: Hex32;
99
+ chainId: bigint;
100
+ verifyingContract: Address;
101
+ }): Hex32;
102
+ /** Payload shape for `AttestationRegistry.assertAssociation(...)`. */
103
+ export interface AssociationAttestationRequest {
104
+ schemaId: Hex32;
105
+ credentialType: Hex32;
106
+ credentialHash: Hex32;
107
+ offchainCredentialStatusList: Hex32;
108
+ subject: Address;
109
+ issuer: Address;
110
+ issuerSignature: Hex;
111
+ salt: bigint;
112
+ }
113
+ /** Payload shape for `AttestationRegistry.assertJointAgreement(...)`.
114
+ * RW1-1 (ADR-0027): consent is VERIFIED on-chain from two party signatures over
115
+ * the recomputed {@link jointConsentDigest}; `bilateralConsentRef` is ignored by
116
+ * the contract (kept in the ABI tuple — pass `bytes32(0)`). */
117
+ export interface JointAgreementAttestationRequest {
118
+ schemaId: Hex32;
119
+ credentialType: Hex32;
120
+ credentialHash: Hex32;
121
+ refUID: Hex32;
122
+ offchainCredentialStatusList: Hex32;
123
+ party1: Address;
124
+ party2: Address;
125
+ issuer: Address;
126
+ issuerSignature: Hex;
127
+ /** party1's consent signature over {@link jointConsentDigest} (ERC-1271 / ECDSA). */
128
+ party1Signature: Hex;
129
+ /** party2's consent signature over {@link jointConsentDigest} (ERC-1271 / ECDSA). */
130
+ party2Signature: Hex;
131
+ salt: bigint;
132
+ }
133
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE7D,eAAO,MAAM,YAAY,oCAAoC,CAAC;AAC9D,eAAO,MAAM,cAAc,EAAG,iBAA0B,CAAC;AACzD,eAAO,MAAM,QAAQ,yDAAyD,CAAC;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;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC;IAChB,cAAc,EAAE,KAAK,CAAC;IACtB,cAAc,EAAE,KAAK,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;CAC5B,GAAG,KAAK,CAcR;AAyBD,sEAAsE;AACtE,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,KAAK,CAAC;IAChB,cAAc,EAAE,KAAK,CAAC;IACtB,cAAc,EAAE,KAAK,CAAC;IACtB,4BAA4B,EAAE,KAAK,CAAC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,GAAG,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;gEAGgE;AAChE,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,KAAK,CAAC;IAChB,cAAc,EAAE,KAAK,CAAC;IACtB,cAAc,EAAE,KAAK,CAAC;IACtB,MAAM,EAAE,KAAK,CAAC;IACd,4BAA4B,EAAE,KAAK,CAAC;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,GAAG,CAAC;IACrB,qFAAqF;IACrF,eAAe,EAAE,GAAG,CAAC;IACrB,qFAAqF;IACrF,eAAe,EAAE,GAAG,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd"}
package/dist/index.js ADDED
@@ -0,0 +1,160 @@
1
+ /**
2
+ * @agenticprimitives/attestations — AttestationRegistry SDK + credential types
3
+ * (Layers 12–15 of the spine).
4
+ *
5
+ * Authoritative spec: specs/242-trust-credentials-and-public-assertions.md
6
+ * Architecture-of-record: ADR-0023
7
+ */
8
+ import { keccak_256 } from '@noble/hashes/sha3.js';
9
+ import { utf8ToBytes } from '@noble/hashes/utils.js';
10
+ export const PACKAGE_NAME = '@agenticprimitives/attestations';
11
+ export const PACKAGE_STATUS = 'w1-foundational';
12
+ export const SPEC_REF = 'specs/242-trust-credentials-and-public-assertions.md';
13
+ function hashName(name) {
14
+ const digest = keccak_256(utf8ToBytes(name));
15
+ let hex = '0x';
16
+ for (const v of digest)
17
+ hex += v.toString(16).padStart(2, '0');
18
+ return hex;
19
+ }
20
+ /** ADR-0024 Decision 2 — substrate credential-type discriminators. */
21
+ export const CREDENTIAL_TYPE = {
22
+ Association: hashName('AssociationCredential'),
23
+ Evidence: hashName('EvidenceCredential'),
24
+ Outcome: hashName('OutcomeCredential'),
25
+ Validation: hashName('ValidationCredential'),
26
+ TrustUpdate: hashName('TrustUpdate'),
27
+ JointAgreement: hashName('JointAgreementAttestation'),
28
+ PaymentReceipt: hashName('PaymentReceipt'),
29
+ };
30
+ /** Recomputes the on-chain UID per AttestationRegistry._computeUid. */
31
+ export function computeAttestationUid(args) {
32
+ const buf = new Uint8Array(7 * 32);
33
+ writeAddress(buf, 0, args.subject);
34
+ writeAddress(buf, 32, args.party2);
35
+ writeAddress(buf, 64, args.issuer);
36
+ writeHex32(buf, 96, args.credentialType);
37
+ writeHex32(buf, 128, args.credentialHash);
38
+ writeHex32(buf, 160, args.refUID);
39
+ writeUint256(buf, 192, args.salt);
40
+ const digest = keccak_256(buf);
41
+ let hex = '0x';
42
+ for (const v of digest)
43
+ hex += v.toString(16).padStart(2, '0');
44
+ return hex;
45
+ }
46
+ /**
47
+ * RW1-1 (ADR-0027) — canonical joint-agreement consent typehash. MUST byte-equal
48
+ * `AttestationRegistry.JOINT_CONSENT_TYPEHASH`; enforced by the cross-stack
49
+ * typehash-equality gate (`check:eip712-typehash-equality`).
50
+ */
51
+ export const JOINT_CONSENT_TYPEHASH = hashName(
52
+ // ATT-3 (audit 2026-06-10): bind chainId + verifyingContract so a party's consent signature can't
53
+ // be replayed cross-chain or on a redeployed registry.
54
+ 'JointAgreementConsent(address party1,address party2,bytes32 agreementCommitment,bytes32 credentialHash,uint256 chainId,address verifyingContract)');
55
+ /**
56
+ * Recompute the consent digest each party signs to consent to a joint agreement
57
+ * (RW1-1). Equals the contract's `keccak256(abi.encode(JOINT_CONSENT_TYPEHASH,
58
+ * party1, party2, agreementCommitment, credentialHash, chainId, verifyingContract))`.
59
+ * `assertJointAgreement` recomputes the same digest on-chain and verifies BOTH party
60
+ * signatures (ERC-1271 / ECDSA) against it — a stored or supplied consent reference is
61
+ * not consent. ATT-3: `chainId` + the registry address are bound (anti cross-chain/replay).
62
+ */
63
+ export function jointConsentDigest(args) {
64
+ const buf = new Uint8Array(7 * 32);
65
+ writeHex32(buf, 0, JOINT_CONSENT_TYPEHASH);
66
+ writeAddress(buf, 32, args.party1);
67
+ writeAddress(buf, 64, args.party2);
68
+ writeHex32(buf, 96, args.agreementCommitment);
69
+ writeHex32(buf, 128, args.credentialHash);
70
+ writeUint256(buf, 160, args.chainId);
71
+ writeAddress(buf, 192, args.verifyingContract);
72
+ const digest = keccak_256(buf);
73
+ let hex = '0x';
74
+ for (const v of digest)
75
+ hex += v.toString(16).padStart(2, '0');
76
+ return hex;
77
+ }
78
+ /**
79
+ * ATT-1 (audit 2026-06-10) — canonical issuer typehash for a JOINT-agreement attestation. MUST
80
+ * byte-equal `AttestationRegistry.JOINT_ISSUER_TYPEHASH`; locked by the cross-stack typehash-equality
81
+ * gate. The issuer no longer signs a bare `credentialHash` (the SC-2 bug class, which survived on the
82
+ * joint path) — it binds the parties, schema, credential type/hash, the agreement commitment, chain,
83
+ * and the registry address.
84
+ */
85
+ export const JOINT_ISSUER_TYPEHASH = hashName('JointAgreementIssuerAttestation(address party1,address party2,address issuer,bytes32 schemaId,bytes32 credentialType,bytes32 credentialHash,bytes32 agreementCommitment,uint256 chainId,address verifyingContract)');
86
+ /**
87
+ * Recompute the digest the issuer signs for a joint-agreement attestation (ATT-1). Equals the
88
+ * contract's `keccak256(abi.encode(JOINT_ISSUER_TYPEHASH, party1, party2, issuer, schemaId,
89
+ * credentialType, credentialHash, agreementCommitment, chainId, verifyingContract))`.
90
+ * `assertJointAgreement` recomputes the same digest on chain — so a leaked issuer signature can't be
91
+ * replayed against different parties/schema/chain. `agreementCommitment` is the request's `refUID`.
92
+ */
93
+ export function jointIssuerDigest(args) {
94
+ const buf = new Uint8Array(10 * 32);
95
+ writeHex32(buf, 0, JOINT_ISSUER_TYPEHASH);
96
+ writeAddress(buf, 32, args.party1);
97
+ writeAddress(buf, 64, args.party2);
98
+ writeAddress(buf, 96, args.issuer);
99
+ writeHex32(buf, 128, args.schemaId);
100
+ writeHex32(buf, 160, args.credentialType);
101
+ writeHex32(buf, 192, args.credentialHash);
102
+ writeHex32(buf, 224, args.agreementCommitment);
103
+ writeUint256(buf, 256, args.chainId);
104
+ writeAddress(buf, 288, args.verifyingContract);
105
+ const digest = keccak_256(buf);
106
+ let hex = '0x';
107
+ for (const v of digest)
108
+ hex += v.toString(16).padStart(2, '0');
109
+ return hex;
110
+ }
111
+ /**
112
+ * SC-2 (audit 2026-06-09) — canonical issuer-attestation typehash for a unilateral association.
113
+ * MUST byte-equal `AttestationRegistry.ASSOCIATION_ATTESTATION_TYPEHASH`; locked by the cross-stack
114
+ * typehash-equality gate.
115
+ */
116
+ export const ASSOCIATION_ATTESTATION_TYPEHASH = hashName('AssociationAttestation(address subject,address issuer,bytes32 schemaId,bytes32 credentialType,bytes32 credentialHash,uint256 chainId,address verifyingContract)');
117
+ /**
118
+ * Recompute the digest the issuer signs for a unilateral association (SC-2). Equals the contract's
119
+ * `keccak256(abi.encode(ASSOCIATION_ATTESTATION_TYPEHASH, subject, issuer, schemaId, credentialType,
120
+ * credentialHash, chainId, verifyingContract))`. `assertAssociation` recomputes the same digest on
121
+ * chain — binding the SUBJECT so a known credentialHash can't be anchored against a different subject.
122
+ */
123
+ export function associationAttestationDigest(args) {
124
+ const buf = new Uint8Array(8 * 32);
125
+ writeHex32(buf, 0, ASSOCIATION_ATTESTATION_TYPEHASH);
126
+ writeAddress(buf, 32, args.subject);
127
+ writeAddress(buf, 64, args.issuer);
128
+ writeHex32(buf, 96, args.schemaId);
129
+ writeHex32(buf, 128, args.credentialType);
130
+ writeHex32(buf, 160, args.credentialHash);
131
+ writeUint256(buf, 192, args.chainId);
132
+ writeAddress(buf, 224, args.verifyingContract);
133
+ const digest = keccak_256(buf);
134
+ let hex = '0x';
135
+ for (const v of digest)
136
+ hex += v.toString(16).padStart(2, '0');
137
+ return hex;
138
+ }
139
+ function writeAddress(buf, offset, addr) {
140
+ const clean = addr.toLowerCase().replace(/^0x/, '');
141
+ if (clean.length !== 40)
142
+ throw new Error(`bad address length: ${addr}`);
143
+ for (let i = 0; i < 20; i++) {
144
+ buf[offset + 12 + i] = parseInt(clean.substring(i * 2, i * 2 + 2), 16);
145
+ }
146
+ }
147
+ function writeHex32(buf, offset, h) {
148
+ const clean = h.toLowerCase().replace(/^0x/, '').padStart(64, '0');
149
+ for (let i = 0; i < 32; i++) {
150
+ buf[offset + i] = parseInt(clean.substring(i * 2, i * 2 + 2), 16);
151
+ }
152
+ }
153
+ function writeUint256(buf, offset, n) {
154
+ let value = n;
155
+ for (let i = 31; i >= 0; i--) {
156
+ buf[offset + i] = Number(value & 0xffn);
157
+ value = value >> 8n;
158
+ }
159
+ }
160
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,MAAM,CAAC,MAAM,YAAY,GAAG,iCAAiC,CAAC;AAC9D,MAAM,CAAC,MAAM,cAAc,GAAG,iBAA0B,CAAC;AACzD,MAAM,CAAC,MAAM,QAAQ,GAAG,sDAAsD,CAAC;AAI/E,SAAS,QAAQ,CAA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AC;QACxC,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;IACtB,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@agenticprimitives/attestations",
3
+ "version": "0.0.0-alpha.10",
4
+ "description": "AttestationRegistry SDK — EAS-aligned with bilateral consent. Owns Association + JointAgreement + Evidence + Outcome + Validation + TrustUpdate credential types asserted into a single on-chain registry per ADR-0023.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
9
+ "directory": "packages/attestations"
10
+ },
11
+ "homepage": "https://github.com/agentictrustlabs/agenticprimitives/tree/master/packages/attestations",
12
+ "bugs": {
13
+ "url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
14
+ },
15
+ "type": "module",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "LICENSE",
26
+ "dist",
27
+ "spec.md",
28
+ "README.md"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "peerDependencies": {
34
+ "viem": "^2.52.2"
35
+ },
36
+ "dependencies": {
37
+ "@noble/hashes": "^2.2.0",
38
+ "@agenticprimitives/delegation": "1.0.0-alpha.14",
39
+ "@agenticprimitives/types": "1.0.0-alpha.14",
40
+ "@agenticprimitives/verifiable-credentials": "0.0.0-alpha.11"
41
+ },
42
+ "devDependencies": {
43
+ "vitest": "^4.1.8",
44
+ "viem": "^2.52.2"
45
+ },
46
+ "keywords": [
47
+ "agentic",
48
+ "primitives",
49
+ "attestations"
50
+ ],
51
+ "scripts": {
52
+ "build": "tsc -p tsconfig.build.json",
53
+ "typecheck": "tsc -p tsconfig.json --noEmit",
54
+ "test": "vitest run",
55
+ "test:unit": "vitest run test/unit --passWithNoTests",
56
+ "test:watch": "vitest",
57
+ "clean": "rm -rf dist"
58
+ }
59
+ }
package/spec.md ADDED
@@ -0,0 +1,5 @@
1
+ # Spec pointer
2
+
3
+ Canonical spec: [`../../specs/242-*.md`](../../specs/)
4
+
5
+ Owning layers (per [coordination-substrate.md](../../docs/architecture/coordination-substrate.md)): layers-12-15.