@bolyra/sdk 0.2.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 ADDED
@@ -0,0 +1,76 @@
1
+ # @bolyra/sdk
2
+
3
+ TypeScript SDK for **Bolyra (IdentityOS)** — mutual ZKP authentication for humans and AI agents.
4
+
5
+ > **New here?** Start with the [5-minute Quickstart](./QUICKSTART.md) — from `npm install` to on-chain verification.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @bolyra/sdk
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import {
17
+ createHumanIdentity,
18
+ createAgentCredential,
19
+ Permission,
20
+ proveHandshake,
21
+ verifyHandshake,
22
+ } from '@bolyra/sdk';
23
+
24
+ // 1. Create identities
25
+ const human = await createHumanIdentity(123456789n);
26
+ const agent = await createAgentCredential(
27
+ 12345n,
28
+ operatorPrivateKey,
29
+ [Permission.READ_DATA, Permission.WRITE_DATA],
30
+ BigInt(Math.floor(Date.now() / 1000) + 86400),
31
+ );
32
+
33
+ // 2. Generate mutual handshake proofs (parallel, ~16s)
34
+ const { humanProof, agentProof, nonce } = await proveHandshake(human, agent);
35
+
36
+ // 3. Verify locally
37
+ const result = await verifyHandshake(humanProof, agentProof, nonce);
38
+ console.log('Verified:', result.verified); // true
39
+ console.log('Human nullifier:', result.humanNullifier);
40
+ console.log('Agent scope commitment:', result.scopeCommitment);
41
+
42
+ // 4. Submit to chain (via ethers.js)
43
+ // await registry.verifyHandshake(humanProof, agentProof, nonce);
44
+ ```
45
+
46
+ ## Permissions
47
+
48
+ Permissions use cumulative bit encoding — higher tiers imply lower ones:
49
+
50
+ | Bit | Permission | Notes |
51
+ |-----|---------------------|--------------------------|
52
+ | 0 | `READ_DATA` | |
53
+ | 1 | `WRITE_DATA` | |
54
+ | 2 | `FINANCIAL_SMALL` | < $100 |
55
+ | 3 | `FINANCIAL_MEDIUM` | < $10,000 (implies bit 2)|
56
+ | 4 | `FINANCIAL_UNLIMITED`| Unlimited (implies 2+3) |
57
+ | 5 | `SIGN_ON_BEHALF` | |
58
+ | 6 | `SUB_DELEGATE` | |
59
+ | 7 | `ACCESS_PII` | |
60
+
61
+ ## API Status
62
+
63
+ | Function | Status |
64
+ |-------------------------------|--------|
65
+ | `createHumanIdentity()` | v0.1 |
66
+ | `createAgentCredential()` | v0.1 |
67
+ | `permissionsToBitmask()` | v0.1 |
68
+ | `validateCumulativeBitEncoding()` | v0.1 |
69
+ | `proveHandshake()` | v0.2 |
70
+ | `verifyHandshake()` | v0.2 |
71
+ | `delegate()` | v0.3 (stub) |
72
+ | `verifyDelegation()` | v0.3 (stub) |
73
+
74
+ ## License
75
+
76
+ MIT
@@ -0,0 +1,26 @@
1
+ import { DelegationResult, Proof, BolyraConfig, AgentCredential } from './types';
2
+ /**
3
+ * Delegate scoped permissions to another agent.
4
+ * Currently a stub -- full implementation requires the delegation circuit zkey.
5
+ *
6
+ * @param delegator - The delegating agent's credential
7
+ * @param delegatee - The receiving agent's credential
8
+ * @param parentScopeCommitment - Scope commitment from the parent handshake or delegation
9
+ * @param hopIndex - Current hop index in the delegation chain (0-indexed)
10
+ * @param config - SDK configuration
11
+ * @returns Delegation proof ready for on-chain verification
12
+ */
13
+ export declare function delegate(_delegator: AgentCredential, _delegatee: AgentCredential, _parentScopeCommitment: bigint, _hopIndex: number, _config?: BolyraConfig): Promise<{
14
+ proof: Proof;
15
+ result: DelegationResult;
16
+ }>;
17
+ /**
18
+ * Verify a delegation proof on-chain.
19
+ *
20
+ * @param proof - The delegation ZK proof
21
+ * @param parentScopeCommitment - Expected parent scope commitment
22
+ * @param config - SDK configuration
23
+ * @returns DelegationResult with new scope commitment and hop index
24
+ */
25
+ export declare function verifyDelegation(_proof: Proof, _parentScopeCommitment: bigint, _config?: BolyraConfig): Promise<DelegationResult>;
26
+ //# sourceMappingURL=delegation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.d.ts","sourceRoot":"","sources":["../src/delegation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAC5B,UAAU,EAAE,eAAe,EAC3B,UAAU,EAAE,eAAe,EAC3B,sBAAsB,EAAE,MAAM,EAC9B,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC,CAKrD;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,KAAK,EACb,sBAAsB,EAAE,MAAM,EAC9B,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAK3B"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.delegate = delegate;
4
+ exports.verifyDelegation = verifyDelegation;
5
+ const errors_1 = require("./errors");
6
+ /**
7
+ * Delegate scoped permissions to another agent.
8
+ * Currently a stub -- full implementation requires the delegation circuit zkey.
9
+ *
10
+ * @param delegator - The delegating agent's credential
11
+ * @param delegatee - The receiving agent's credential
12
+ * @param parentScopeCommitment - Scope commitment from the parent handshake or delegation
13
+ * @param hopIndex - Current hop index in the delegation chain (0-indexed)
14
+ * @param config - SDK configuration
15
+ * @returns Delegation proof ready for on-chain verification
16
+ */
17
+ async function delegate(_delegator, _delegatee, _parentScopeCommitment, _hopIndex, _config) {
18
+ throw new errors_1.BolyraError('delegate() coming in @bolyra/sdk v0.3 — delegation circuit integration.', 'NOT_IMPLEMENTED');
19
+ }
20
+ /**
21
+ * Verify a delegation proof on-chain.
22
+ *
23
+ * @param proof - The delegation ZK proof
24
+ * @param parentScopeCommitment - Expected parent scope commitment
25
+ * @param config - SDK configuration
26
+ * @returns DelegationResult with new scope commitment and hop index
27
+ */
28
+ async function verifyDelegation(_proof, _parentScopeCommitment, _config) {
29
+ throw new errors_1.BolyraError('verifyDelegation() coming in @bolyra/sdk v0.3.', 'NOT_IMPLEMENTED');
30
+ }
31
+ //# sourceMappingURL=delegation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.js","sourceRoot":"","sources":["../src/delegation.ts"],"names":[],"mappings":";;AAcA,4BAWC;AAUD,4CASC;AA5CD,qCAAuC;AAGvC;;;;;;;;;;GAUG;AACI,KAAK,UAAU,QAAQ,CAC5B,UAA2B,EAC3B,UAA2B,EAC3B,sBAA8B,EAC9B,SAAiB,EACjB,OAAsB;IAEtB,MAAM,IAAI,oBAAW,CACnB,yEAAyE,EACzE,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,gBAAgB,CACpC,MAAa,EACb,sBAA8B,EAC9B,OAAsB;IAEtB,MAAM,IAAI,oBAAW,CACnB,gDAAgD,EAChD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ export declare class BolyraError extends Error {
2
+ code: string;
3
+ details?: Record<string, unknown> | undefined;
4
+ constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
5
+ }
6
+ export declare class ProofGenerationError extends BolyraError {
7
+ constructor(circuit: string, reason: string);
8
+ }
9
+ export declare class VerificationError extends BolyraError {
10
+ constructor(reason: string);
11
+ }
12
+ export declare class InvalidPermissionError extends BolyraError {
13
+ constructor(message: string);
14
+ }
15
+ export declare class ExpiredCredentialError extends BolyraError {
16
+ constructor(expiryTimestamp: bigint);
17
+ }
18
+ export declare class ScopeEscalationError extends BolyraError {
19
+ constructor(delegatorScope: bigint, requestedScope: bigint);
20
+ }
21
+ export declare class StaleProofError extends BolyraError {
22
+ constructor(rootType: 'human' | 'agent');
23
+ }
24
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;IAG3B,IAAI,EAAE,MAAM;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAFxC,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAK3C;AAED,qBAAa,oBAAqB,SAAQ,WAAW;gBACvC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAO5C;AAED,qBAAa,iBAAkB,SAAQ,WAAW;gBACpC,MAAM,EAAE,MAAM;CAO3B;AAED,qBAAa,sBAAuB,SAAQ,WAAW;gBACzC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,sBAAuB,SAAQ,WAAW;gBACzC,eAAe,EAAE,MAAM;CAOpC;AAED,qBAAa,oBAAqB,SAAQ,WAAW;gBACvC,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;CAU3D;AAED,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,QAAQ,EAAE,OAAO,GAAG,OAAO;CAOxC"}
package/dist/errors.js ADDED
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StaleProofError = exports.ScopeEscalationError = exports.ExpiredCredentialError = exports.InvalidPermissionError = exports.VerificationError = exports.ProofGenerationError = exports.BolyraError = void 0;
4
+ class BolyraError extends Error {
5
+ code;
6
+ details;
7
+ constructor(message, code, details) {
8
+ super(message);
9
+ this.code = code;
10
+ this.details = details;
11
+ this.name = 'BolyraError';
12
+ }
13
+ }
14
+ exports.BolyraError = BolyraError;
15
+ class ProofGenerationError extends BolyraError {
16
+ constructor(circuit, reason) {
17
+ super(`Failed to generate ${circuit} proof: ${reason}`, 'PROOF_GENERATION_FAILED', { circuit, reason });
18
+ }
19
+ }
20
+ exports.ProofGenerationError = ProofGenerationError;
21
+ class VerificationError extends BolyraError {
22
+ constructor(reason) {
23
+ super(`On-chain verification failed: ${reason}`, 'VERIFICATION_FAILED', { reason });
24
+ }
25
+ }
26
+ exports.VerificationError = VerificationError;
27
+ class InvalidPermissionError extends BolyraError {
28
+ constructor(message) {
29
+ super(message, 'INVALID_PERMISSION');
30
+ }
31
+ }
32
+ exports.InvalidPermissionError = InvalidPermissionError;
33
+ class ExpiredCredentialError extends BolyraError {
34
+ constructor(expiryTimestamp) {
35
+ super(`Agent credential expired at ${expiryTimestamp}`, 'CREDENTIAL_EXPIRED', { expiryTimestamp: expiryTimestamp.toString() });
36
+ }
37
+ }
38
+ exports.ExpiredCredentialError = ExpiredCredentialError;
39
+ class ScopeEscalationError extends BolyraError {
40
+ constructor(delegatorScope, requestedScope) {
41
+ super(`Delegation scope escalation: delegatee scope (${requestedScope}) is not a subset of delegator scope (${delegatorScope})`, 'SCOPE_ESCALATION', {
42
+ delegatorScope: delegatorScope.toString(),
43
+ requestedScope: requestedScope.toString(),
44
+ });
45
+ }
46
+ }
47
+ exports.ScopeEscalationError = ScopeEscalationError;
48
+ class StaleProofError extends BolyraError {
49
+ constructor(rootType) {
50
+ super(`${rootType} Merkle root is stale — the tree was updated after proof generation. Regenerate the proof.`, 'STALE_MERKLE_ROOT', { rootType });
51
+ }
52
+ }
53
+ exports.StaleProofError = StaleProofError;
54
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAY,SAAQ,KAAK;IAG3B;IACA;IAHT,YACE,OAAe,EACR,IAAY,EACZ,OAAiC;QAExC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAA0B;QAGxC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AATD,kCASC;AAED,M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utual handshake proof (human + agent).
4
+ * Both proofs can be generated in parallel for wall-clock optimization.
5
+ *
6
+ * @param human - The human's identity (secret + publicKey + commitment)
7
+ * @param agent - The agent's credential (signed by operator)
8
+ * @param options - Optional scope, nonce override, and SDK config
9
+ * @returns Both proofs and the session nonce
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const { humanProof, agentProof, nonce } = await proveHandshake(
14
+ * humanIdentity,
15
+ * agentCredential,
16
+ * { scope: 1n }
17
+ * );
18
+ * // Submit both proofs to IdentityRegistry.verifyHandshake()
19
+ * ```
20
+ */
21
+ export declare function proveHandshake(human: HumanIdentity, agent: AgentCredential, options?: {
22
+ scope?: bigint;
23
+ nonce?: bigint;
24
+ config?: BolyraConfig;
25
+ }): Promise<{
26
+ humanProof: Proof;
27
+ agentProof: Proof;
28
+ nonce: bigint;
29
+ }>;
30
+ /**
31
+ * Verify a handshake result (check proof validity without on-chain submission).
32
+ * For on-chain verification, submit proofs to IdentityRegistry.verifyHandshake().
33
+ *
34
+ * @param humanProof - The human's ZK proof
35
+ * @param agentProof - The agent's ZK proof
36
+ * @param nonce - The session nonce used during proof generation
37
+ * @param config - SDK configuration (circuitDir for vkey paths)
38
+ * @returns HandshakeResult with nullifiers and verification status
39
+ */
40
+ export declare function verifyHandshake(humanProof: Proof, agentProof: Proof, nonce: bigint, config?: BolyraConfig): Promise<HandshakeResult>;
41
+ //# sourceMappingURL=handshake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../src/handshake.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,KAAK,EACL,YAAY,EACb,MAAM,SAAS,CAAC;AAMjB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,eAAe,EACtB,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GACA,OAAO,CAAC;IAAE,UAAU,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAYlE;AAyFD;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,KAAK,EACjB,UAAU,EAAE,KAAK,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,eAAe,CAAC,CA4B1B"}
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.proveHandshake = proveHandshake;
37
+ exports.verifyHandshake = verifyHandshake;
38
+ const snarkjs = __importStar(require("snarkjs"));
39
+ const path = __importStar(require("path"));
40
+ const errors_1 = require("./errors");
41
+ // Default paths to circuit artifacts (relative to package root)
42
+ const DEFAULT_CIRCUIT_DIR = path.join(__dirname, '../../circuits/build');
43
+ /**
44
+ * Generate a mutual handshake proof (human + agent).
45
+ * Both proofs can be generated in parallel for wall-clock optimization.
46
+ *
47
+ * @param human - The human's identity (secret + publicKey + commitment)
48
+ * @param agent - The agent's credential (signed by operator)
49
+ * @param options - Optional scope, nonce override, and SDK config
50
+ * @returns Both proofs and the session nonce
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const { humanProof, agentProof, nonce } = await proveHandshake(
55
+ * humanIdentity,
56
+ * agentCredential,
57
+ * { scope: 1n }
58
+ * );
59
+ * // Submit both proofs to IdentityRegistry.verifyHandshake()
60
+ * ```
61
+ */
62
+ async function proveHandshake(human, agent, options) {
63
+ const scope = options?.scope ?? 1n;
64
+ const nonce = options?.nonce ?? BigInt(Date.now());
65
+ const circuitDir = options?.config?.circuitDir ?? DEFAULT_CIRCUIT_DIR;
66
+ // Generate both proofs in parallel
67
+ const [humanProof, agentProof] = await Promise.all([
68
+ generateHumanProof(human, scope, nonce, circuitDir),
69
+ generateAgentProof(agent, nonce, circuitDir),
70
+ ]);
71
+ return { humanProof, agentProof, nonce };
72
+ }
73
+ async function generateHumanProof(human, scope, nonce, circuitDir) {
74
+ const wasmPath = path.join(circuitDir, 'HumanUniqueness_js/HumanUniqueness.wasm');
75
+ const zkeyPath = path.join(circuitDir, 'HumanUniqueness_final.zkey');
76
+ // Build Merkle proof inputs (single leaf: depth 0, padded to 20)
77
+ const siblings = new Array(20).fill('0');
78
+ const input = {
79
+ secret: human.secret.toString(),
80
+ merkleProofLength: '0', // depth 0 for single-leaf tree
81
+ merkleProofIndex: '0',
82
+ merkleProofSiblings: siblings,
83
+ scope: scope.toString(),
84
+ sessionNonce: nonce.toString(),
85
+ };
86
+ try {
87
+ const { proof, publicSignals } = await snarkjs.groth16.fullProve(input, wasmPath, zkeyPath);
88
+ return { proof, publicSignals };
89
+ }
90
+ catch (err) {
91
+ throw new errors_1.ProofGenerationError('HumanUniqueness', err.message ?? String(err));
92
+ }
93
+ }
94
+ async function generateAgentProof(agent, nonce, circuitDir) {
95
+ const wasmPath = path.join(circuitDir, 'AgentPolicy_js/AgentPolicy.wasm');
96
+ const zkeyPath = path.join(circuitDir, 'AgentPolicy_plonk.zkey');
97
+ const currentTimestamp = BigInt(Math.floor(Date.now() / 1000));
98
+ const requiredScopeMask = 0n; // no required scope for basic handshake
99
+ const siblings = new Array(20).fill('0');
100
+ const input = {
101
+ modelHash: agent.modelHash.toString(),
102
+ operatorPubkeyAx: agent.operatorPublicKey.x.toString(),
103
+ operatorPubkeyAy: agent.operatorPublicKey.y.toString(),
104
+ permissionBitmask: agent.permissionBitmask.toString(),
105
+ expiryTimestamp: agent.expiryTimestamp.toString(),
106
+ sigR8x: agent.signature.R8.x.toString(),
107
+ sigR8y: agent.signature.R8.y.toString(),
108
+ sigS: agent.signature.S.toString(),
109
+ merkleProofLength: '0',
110
+ merkleProofIndex: '0',
111
+ merkleProofSiblings: siblings,
112
+ requiredScopeMask: requiredScopeMask.toString(),
113
+ currentTimestamp: currentTimestamp.toString(),
114
+ sessionNonce: nonce.toString(),
115
+ };
116
+ try {
117
+ const { proof, publicSignals } = await snarkjs.plonk.fullProve(input, wasmPath, zkeyPath);
118
+ return { proof, publicSignals };
119
+ }
120
+ catch (err) {
121
+ throw new errors_1.ProofGenerationError('AgentPolicy', err.message ?? String(err));
122
+ }
123
+ }
124
+ /**
125
+ * Verify a handshake result (check proof validity without on-chain submission).
126
+ * For on-chain verification, submit proofs to IdentityRegistry.verifyHandshake().
127
+ *
128
+ * @param humanProof - The human's ZK proof
129
+ * @param agentProof - The agent's ZK proof
130
+ * @param nonce - The session nonce used during proof generation
131
+ * @param config - SDK configuration (circuitDir for vkey paths)
132
+ * @returns HandshakeResult with nullifiers and verification status
133
+ */
134
+ async function verifyHandshake(humanProof, agentProof, nonce, config) {
135
+ const circuitDir = config?.circuitDir ?? DEFAULT_CIRCUIT_DIR;
136
+ // Verify human proof (Groth16)
137
+ const humanVkeyPath = path.join(circuitDir, 'HumanUniqueness_vkey.json');
138
+ const humanVkey = require(humanVkeyPath);
139
+ const humanValid = await snarkjs.groth16.verify(humanVkey, humanProof.publicSignals, humanProof.proof);
140
+ // Verify agent proof (PLONK)
141
+ const agentVkeyPath = path.join(circuitDir, 'AgentPolicy_vkey.json');
142
+ const agentVkey = require(agentVkeyPath);
143
+ const agentValid = await snarkjs.plonk.verify(agentVkey, agentProof.publicSignals, agentProof.proof);
144
+ return {
145
+ humanNullifier: BigInt(humanProof.publicSignals[1]),
146
+ agentNullifier: BigInt(agentProof.publicSignals[1]),
147
+ sessionNonce: nonce,
148
+ scopeCommitment: BigInt(agentProof.publicSignals[2]),
149
+ verified: humanValid && agentValid,
150
+ };
151
+ }
152
+ //# sourceMappingURL=handshake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake.js","sourceRoot":"","sources":["../src/handshake.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,wCAoBC;AAmGD,0CAiCC;AAzLD,iDAAmC;AACnC,2CAA6B;AAQ7B,qCAAgD;AAEhD,gEAAgE;AAChE,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;AAEzE;;;;;;;;;;;;;;;;;;GAkBG;AACI,KAAK,UAAU,cAAc,CAClC,KAAoB,EACpB,KAAsB,EACtB,OAIC;IAED,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG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,CAAC,MAAM,CAC3C,SAAS,EACT,UAAU,CAAC,aAAa,EACxB,UAAU,CAAC,KAAK,CACjB,CAAC;IAEF,OAAO;QACL,cAAc,EAAE,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACnD,cAAc,EAAE,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACnD,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACpD,QAAQ,EAAE,UAAU,IAAI,UAAU;KACnC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { HumanIdentity, AgentCredential, Permission } from './types';
2
+ /**
3
+ * Create a human identity (EdDSA keypair + commitment).
4
+ * Compatible with Semaphore v4 identity scheme.
5
+ *
6
+ * @param secret - A secret value (random bigint or derived from a seed phrase).
7
+ * KEEP THIS PRIVATE — it is the human's authentication key.
8
+ * @returns HumanIdentity with secret, publicKey, and commitment
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const identity = await createHumanIdentity(BigInt(crypto.getRandomValues(new Uint8Array(32)).reduce((a, b) => a * 256n + BigInt(b), 0n)));
13
+ * console.log(identity.commitment); // Poseidon2(Ax, Ay) — enroll this in humanTree
14
+ * ```
15
+ */
16
+ export declare function createHumanIdentity(secret: bigint): Promise<HumanIdentity>;
17
+ /**
18
+ * Create an AI agent credential signed by the operator.
19
+ *
20
+ * @param modelHash - Hash of the model identifier (e.g., sha256("gpt-4o"))
21
+ * @param operatorPrivateKey - Operator's EdDSA private key (signs the credential)
22
+ * @param permissions - Array of Permission flags (cumulative encoding enforced)
23
+ * @param expiryTimestamp - Unix timestamp when the credential expires
24
+ * @returns AgentCredential with all fields + operator signature + commitment
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const credential = await createAgentCredential(
29
+ * hashModel("gpt-4o"),
30
+ * operatorKey,
31
+ * [Permission.READ_DATA, Permission.WRITE_DATA, Permission.FINANCIAL_SMALL],
32
+ * BigInt(Math.floor(Date.now() / 1000) + 86400) // +1 day
33
+ * );
34
+ * console.log(credential.commitment); // enroll this in agentTree
35
+ * ```
36
+ */
37
+ export declare function createAgentCredential(modelHash: bigint, operatorPrivateKey: bigint | Buffer, permissions: Permission[], expiryTimestamp: bigint): Promise<AgentCredential>;
38
+ /** Convert an array of Permission flags to a 64-bit bitmask */
39
+ export declare function permissionsToBitmask(permissions: Permission[]): bigint;
40
+ /** Validate cumulative bit encoding: bit 4 implies 2+3, bit 3 implies 2 */
41
+ export declare function validateCumulativeBitEncoding(bitmask: bigint): void;
42
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIrE;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,CAAC,CAMxB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,GAAG,MAAM,EACnC,WAAW,EAAE,UAAU,EAAE,EACzB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,CAAC,CA4B1B;AAED,+DAA+D;AAC/D,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,CAMtE;AAED,2EAA2E;AAC3E,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAoBnE"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createHumanIdentity = createHumanIdentity;
4
+ exports.createAgentCredential = createAgentCredential;
5
+ exports.permissionsToBitmask = permissionsToBitmask;
6
+ exports.validateCumulativeBitEncoding = validateCumulativeBitEncoding;
7
+ const utils_1 = require("./utils");
8
+ const errors_1 = require("./errors");
9
+ /**
10
+ * Create a human identity (EdDSA keypair + commitment).
11
+ * Compatible with Semaphore v4 identity scheme.
12
+ *
13
+ * @param secret - A secret value (random bigint or derived from a seed phrase).
14
+ * KEEP THIS PRIVATE — it is the human's authentication key.
15
+ * @returns HumanIdentity with secret, publicKey, and commitment
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const identity = await createHumanIdentity(BigInt(crypto.getRandomValues(new Uint8Array(32)).reduce((a, b) => a * 256n + BigInt(b), 0n)));
20
+ * console.log(identity.commitment); // Poseidon2(Ax, Ay) — enroll this in humanTree
21
+ * ```
22
+ */
23
+ async function createHumanIdentity(secret) {
24
+ // HumanUniqueness circuit uses BabyPbk (direct scalar multiply),
25
+ // NOT EdDSA prv2pub. Use derivePublicKeyScalar here.
26
+ const publicKey = await (0, utils_1.derivePublicKeyScalar)(secret);
27
+ const commitment = await (0, utils_1.poseidon2)(publicKey.x, publicKey.y);
28
+ return { secret, publicKey, commitment };
29
+ }
30
+ /**
31
+ * Create an AI agent credential signed by the operator.
32
+ *
33
+ * @param modelHash - Hash of the model identifier (e.g., sha256("gpt-4o"))
34
+ * @param operatorPrivateKey - Operator's EdDSA private key (signs the credential)
35
+ * @param permissions - Array of Permission flags (cumulative encoding enforced)
36
+ * @param expiryTimestamp - Unix timestamp when the credential expires
37
+ * @returns AgentCredential with all fields + operator signature + commitment
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const credential = await createAgentCredential(
42
+ * hashModel("gpt-4o"),
43
+ * operatorKey,
44
+ * [Permission.READ_DATA, Permission.WRITE_DATA, Permission.FINANCIAL_SMALL],
45
+ * BigInt(Math.floor(Date.now() / 1000) + 86400) // +1 day
46
+ * );
47
+ * console.log(credential.commitment); // enroll this in agentTree
48
+ * ```
49
+ */
50
+ async function createAgentCredential(modelHash, operatorPrivateKey, permissions, expiryTimestamp) {
51
+ const bitmask = permissionsToBitmask(permissions);
52
+ validateCumulativeBitEncoding(bitmask);
53
+ const operatorPublicKey = await (0, utils_1.derivePublicKey)(typeof operatorPrivateKey === 'bigint'
54
+ ? operatorPrivateKey
55
+ : BigInt('0x' + operatorPrivateKey.toString('hex')));
56
+ const commitment = await (0, utils_1.poseidon5)(modelHash, operatorPublicKey.x, operatorPublicKey.y, bitmask, expiryTimestamp);
57
+ const signature = await (0, utils_1.eddsaSign)(operatorPrivateKey, commitment);
58
+ return {
59
+ modelHash,
60
+ operatorPublicKey,
61
+ permissionBitmask: bitmask,
62
+ expiryTimestamp,
63
+ signature,
64
+ commitment,
65
+ };
66
+ }
67
+ /** Convert an array of Permission flags to a 64-bit bitmask */
68
+ function permissionsToBitmask(permissions) {
69
+ let bitmask = 0n;
70
+ for (const p of permissions) {
71
+ bitmask |= 1n << BigInt(p);
72
+ }
73
+ return bitmask;
74
+ }
75
+ /** Validate cumulative bit encoding: bit 4 implies 2+3, bit 3 implies 2 */
76
+ function validateCumulativeBitEncoding(bitmask) {
77
+ const bit2 = (bitmask >> 2n) & 1n;
78
+ const bit3 = (bitmask >> 3n) & 1n;
79
+ const bit4 = (bitmask >> 4n) & 1n;
80
+ if (bit4 && !bit3) {
81
+ throw new errors_1.InvalidPermissionError('FINANCIAL_UNLIMITED (bit 4) requires FINANCIAL_MEDIUM (bit 3)');
82
+ }
83
+ if (bit4 && !bit2) {
84
+ throw new errors_1.InvalidPermissionError('FINANCIAL_UNLIMITED (bit 4) requires FINANCIAL_SMALL (bit 2)');
85
+ }
86
+ if (bit3 && !bit2) {
87
+ throw new errors_1.InvalidPermissionError('FINANCIAL_MEDIUM (bit 3) requires FINANCIAL_SMALL (bit 2)');
88
+ }
89
+ }
90
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":";;AAkBA,kDAQC;AAsBD,sDAiCC;AAGD,oDAMC;AA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jB,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5B,OAAO,IAAI,EAAE,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,2EAA2E;AAC3E,SAAgB,6BAA6B,CAAC,OAAe;IAC3D,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC;IAElC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,+BAAsB,CAC9B,+DAA+D,CAChE,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,+BAAsB,CAC9B,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,+BAAsB,CAC9B,2DAA2D,CAC5D,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type { HumanIdentity, AgentCredential, HandshakeResult, DelegationResult, Proof, BolyraConfig, } from './types';
2
+ export { Permission } from './types';
3
+ export { createHumanIdentity, createAgentCredential, permissionsToBitmask, validateCumulativeBitEncoding, } from './identity';
4
+ export { proveHandshake, verifyHandshake } from './handshake';
5
+ export { delegate, verifyDelegation } from './delegation';
6
+ export { BolyraError, ProofGenerationError, VerificationError, InvalidPermissionError, ExpiredCredentialError, ScopeEscalationError, StaleProofError, } from './errors';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,aAAa,EACb,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,KAAK,EACL,YAAY,GACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,GAChB,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StaleProofError = exports.ScopeEscalationError = exports.ExpiredCredentialError = exports.InvalidPermissionError = exports.VerificationError = exports.ProofGenerationError = exports.BolyraError = exports.verifyDelegation = exports.delegate = exports.verifyHandshake = exports.proveHandshake = exports.validateCumulativeBitEncoding = exports.permissionsToBitmask = exports.createAgentCredential = exports.createHumanIdentity = exports.Permission = void 0;
4
+ // Permission enum
5
+ var types_1 = require("./types");
6
+ Object.defineProperty(exports, "Permission", { enumerable: true, get: function () { return types_1.Permission; } });
7
+ // Identity creation
8
+ var identity_1 = require("./identity");
9
+ Object.defineProperty(exports, "createHumanIdentity", { enumerable: true, get: function () { return identity_1.createHumanIdentity; } });
10
+ Object.defineProperty(exports, "createAgentCredential", { enumerable: true, get: function () { return identity_1.createAgentCredential; } });
11
+ Object.defineProperty(exports, "permissionsToBitmask", { enumerable: true, get: function () { return identity_1.permissionsToBitmask; } });
12
+ Object.defineProperty(exports, "validateCumulativeBitEncoding", { enumerable: true, get: function () { return identity_1.validateCumulativeBitEncoding; } });
13
+ // Handshake (v0.2 — real proof generation via snarkjs)
14
+ var handshake_1 = require("./handshake");
15
+ Object.defineProperty(exports, "proveHandshake", { enumerable: true, get: function () { return handshake_1.proveHandshake; } });
16
+ Object.defineProperty(exports, "verifyHandshake", { enumerable: true, get: function () { return handshake_1.verifyHandshake; } });
17
+ // Delegation (stubs — coming in v0.3)
18
+ var delegation_1 = require("./delegation");
19
+ Object.defineProperty(exports, "delegate", { enumerable: true, get: function () { return delegation_1.delegate; } });
20
+ Object.defineProperty(exports, "verifyDelegation", { enumerable: true, get: function () { return delegation_1.verifyDelegation; } });
21
+ // Errors
22
+ var errors_1 = require("./errors");
23
+ Object.defineProperty(exports, "BolyraError", { enumerable: true, get: function () { return errors_1.BolyraError; } });
24
+ Object.defineProperty(exports, "ProofGenerationError", { enumerable: true, get: function () { return errors_1.ProofGenerationError; } });
25
+ Object.defineProperty(exports, "VerificationError", { enumerable: true, get: function () { return errors_1.VerificationError; } });
26
+ Object.defineProperty(exports, "InvalidPermissionError", { enumerable: true, get: function () { return errors_1.InvalidPermissionError; } });
27
+ Object.defineProperty(exports, "ExpiredCredentialError", { enumerable: true, get: function () { return errors_1.ExpiredCredentialError; } });
28
+ Object.defineProperty(exports, "ScopeEscalationError", { enumerable: true, get: function () { return errors_1.ScopeEscalationError; } });
29
+ Object.defineProperty(exports, "StaleProofError", { enumerable: true, get: function () { return errors_1.StaleProofError; } });
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAUA,kBAAkB;AAClB,iCAAqC;AAA5B,mGAAA,UAAU,OAAA;AAEnB,oBAAoB;AACpB,uCAKoB;AAJlB,+GAAA,mBAAmB,OAAA;AACnB,iHAAA,qBAAqB,OAAA;AACrB,gHAAA,oBAAoB,OAAA;AACpB,yHAAA,6BAA6B,OAAA;AAG/B,uDAAuD;AACvD,yCAA8D;AAArD,2GAAA,cAAc,OAAA;AAAE,4GAAA,eAAe,OAAA;AAExC,sCAAsC;AACtC,2CAA0D;AAAjD,sGAAA,QAAQ,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAEnC,SAAS;AACT,mCAQkB;AAPhB,qGAAA,WAAW,OAAA;AACX,8GAAA,oBAAoB,OAAA;AACpB,2GAAA,iBAAiB,OAAA;AACjB,gHAAA,sBAAsB,OAAA;AACtB,gHAAA,sBAAsB,OAAA;AACtB,8GAAA,oBAAoB,OAAA;AACpB,yGAAA,eAAe,OAAA"}