@bolyra/sdk 0.2.0 → 0.3.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.
Files changed (51) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +63 -0
  3. package/README.md +2 -2
  4. package/dist/delegation.d.ts +64 -16
  5. package/dist/delegation.d.ts.map +1 -1
  6. package/dist/delegation.js +200 -17
  7. package/dist/delegation.js.map +1 -1
  8. package/dist/errors.d.ts +12 -0
  9. package/dist/errors.d.ts.map +1 -1
  10. package/dist/errors.js +32 -1
  11. package/dist/errors.js.map +1 -1
  12. package/dist/handshake.d.ts +2 -0
  13. package/dist/handshake.d.ts.map +1 -1
  14. package/dist/handshake.js +55 -13
  15. package/dist/handshake.js.map +1 -1
  16. package/dist/identity.d.ts +24 -0
  17. package/dist/identity.d.ts.map +1 -1
  18. package/dist/identity.js +46 -0
  19. package/dist/identity.js.map +1 -1
  20. package/dist/index.d.ts +8 -3
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +26 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/model-binding.d.ts +113 -0
  25. package/dist/model-binding.d.ts.map +1 -0
  26. package/dist/model-binding.js +195 -0
  27. package/dist/model-binding.js.map +1 -0
  28. package/dist/offchain.d.ts +89 -0
  29. package/dist/offchain.d.ts.map +1 -0
  30. package/dist/offchain.js +300 -0
  31. package/dist/offchain.js.map +1 -0
  32. package/dist/prover.d.ts +21 -0
  33. package/dist/prover.d.ts.map +1 -0
  34. package/dist/prover.js +171 -0
  35. package/dist/prover.js.map +1 -0
  36. package/dist/types.d.ts +29 -0
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/utils.d.ts +4 -0
  39. package/dist/utils.d.ts.map +1 -1
  40. package/dist/utils.js +14 -0
  41. package/dist/utils.js.map +1 -1
  42. package/package.json +5 -3
  43. package/src/delegation.ts +268 -30
  44. package/src/errors.ts +46 -0
  45. package/src/handshake.ts +69 -20
  46. package/src/identity.ts +55 -1
  47. package/src/index.ts +29 -2
  48. package/src/offchain.ts +344 -0
  49. package/src/prover.ts +178 -0
  50. package/src/types.ts +32 -0
  51. package/src/utils.ts +23 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept and charge a
167
+ fee for the acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Viswanadha Pratap Kondoju
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,63 @@
1
+ Bolyra
2
+ Copyright 2026 Viswanadha Pratap Kondoju
3
+
4
+ This product includes software developed by Viswanadha Pratap Kondoju for the Bolyra
5
+ project (https://bolyra.ai).
6
+
7
+ ================================================================================
8
+ PATENT NOTICE
9
+ ================================================================================
10
+
11
+ The patent grant in Section 3 of the Apache License, Version 2.0 ("the
12
+ License") under which this software is distributed extends, without
13
+ limitation, to all patent claims owned or controlled by the Licensor that are
14
+ necessarily infringed by the Contribution alone or in combination with this
15
+ Work, including without limitation any claims that may issue from the
16
+ following patent applications and any continuations, continuations-in-part,
17
+ divisionals, reissues, reexaminations, foreign counterparts, or any other
18
+ applications claiming priority therefrom:
19
+
20
+ - U.S. Provisional Patent Application No. 64/043,898, filed April 20, 2026,
21
+ titled "Privacy-Preserving Mutual Authentication and Composable Delegation
22
+ Between Human and Artificial Intelligence Agent Identities Using
23
+ Zero-Knowledge Proofs with Scope Commitment Chain Linking."
24
+
25
+ The Licensor reserves the right to file additional patent applications
26
+ covering subject matter contained in or related to this Work. Any such
27
+ applications, if filed and prosecuted by the Licensor, will be subject to the
28
+ same patent grant under Section 3 of the License with respect to the version
29
+ of the Work distributed under the License.
30
+
31
+ The defensive termination provision of Section 3 of the License applies in
32
+ full: any patent license granted under the License terminates as of the date
33
+ that the licensee institutes patent litigation against the Licensor, the
34
+ Bolyra protocol, or any compliant implementation thereof.
35
+
36
+ ================================================================================
37
+ STANDARDS BODY INTENT
38
+ ================================================================================
39
+
40
+ The Licensor intends, but is not yet bound, to make a royalty-free (RF)
41
+ licensing declaration consistent with the IETF IPR disclosure rules (BCP 79)
42
+ and the W3C Patent Policy at such time as the Bolyra protocol is submitted to
43
+ a recognized standards body. This statement is forward-looking and does not
44
+ itself constitute an RF declaration to any particular standards
45
+ organization.
46
+
47
+ ================================================================================
48
+ TRADEMARK NOTICE
49
+ ================================================================================
50
+
51
+ "Bolyra" is a trademark of Viswanadha Pratap Kondoju. The Apache License does not grant
52
+ permission to use the trade name "Bolyra" or related marks except as required
53
+ for describing the origin of the Work and as permitted under the nominative
54
+ fair use policy set out in TRADEMARKS.md at the project root. See
55
+ TRADEMARKS.md for details on permitted and prohibited uses.
56
+
57
+ ================================================================================
58
+ THIRD-PARTY NOTICES
59
+ ================================================================================
60
+
61
+ This software depends on other open-source software. License information for
62
+ those dependencies is included in the corresponding package metadata
63
+ (package.json, node_modules/<dep>/LICENSE).
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @bolyra/sdk
2
2
 
3
- TypeScript SDK for **Bolyra (IdentityOS)** — mutual ZKP authentication for humans and AI agents.
3
+ TypeScript SDK for **Bolyra** — mutual ZKP authentication for humans and AI agents.
4
4
 
5
5
  > **New here?** Start with the [5-minute Quickstart](./QUICKSTART.md) — from `npm install` to on-chain verification.
6
6
 
@@ -73,4 +73,4 @@ Permissions use cumulative bit encoding — higher tiers imply lower ones:
73
73
 
74
74
  ## License
75
75
 
76
- MIT
76
+ Apache-2.0 — see [LICENSE](../LICENSE).
@@ -1,26 +1,74 @@
1
- import { DelegationResult, Proof, BolyraConfig, AgentCredential } from './types';
1
+ import { AgentCredential, BolyraConfig, DelegateeMerkleProof, DelegationResult, Proof } from './types';
2
+ import { ProverBackend } from './prover';
3
+ export interface DelegateInput {
4
+ /** The delegating agent's credential (provides modelHash, operator pubkey, scope, expiry). */
5
+ delegator: AgentCredential;
6
+ /** Operator's EdDSA private key — used to sign the delegation token.
7
+ * Same key that minted the delegator credential. */
8
+ delegatorOperatorPrivateKey: bigint | Buffer;
9
+ /** Identity commitment of the recipient (leaf in agentTree). */
10
+ delegateeCommitment: bigint;
11
+ /** Narrowed scope being granted. Must be a subset of delegator.permissionBitmask
12
+ * under the cumulative-bit rules. Circuit enforces; SDK pre-checks for a clean error. */
13
+ delegateeScope: bigint;
14
+ /** Expiry being granted. Must be <= delegator.expiryTimestamp. */
15
+ delegateeExpiry: bigint;
16
+ /** Scope commitment from the prior chain link.
17
+ * For hop 1, this is the agent's scopeCommitment output from the handshake.
18
+ * For hop N+1, this is the previous delegation's newScopeCommitment. */
19
+ previousScopeCommitment: bigint;
20
+ /** Session nonce. Must match the nonce of the originating handshake. */
21
+ sessionNonce: bigint;
22
+ /** Unix-seconds timestamp the proof is bound to. Must be within MAX_CLOCK_SKEW
23
+ * of block.timestamp at on-chain verification time (300s in IdentityRegistry).
24
+ * Defaults to floor(Date.now() / 1000). */
25
+ currentTimestamp?: bigint;
26
+ /** Optional Merkle inclusion proof for the delegatee in agentTree.
27
+ * Defaults to the single-leaf pattern (sufficient for tests and demos). */
28
+ delegateeMerkleProof?: DelegateeMerkleProof;
29
+ /** Informational hop index (0-indexed). Not consumed by the circuit;
30
+ * echoed in DelegationResult for caller bookkeeping. */
31
+ hopIndex?: number;
32
+ config?: BolyraConfig;
33
+ backend?: ProverBackend;
34
+ }
2
35
  /**
3
- * Delegate scoped permissions to another agent.
4
- * Currently a stub -- full implementation requires the delegation circuit zkey.
36
+ * Generate a Delegation proof.
5
37
  *
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
38
+ * Produces a Groth16 proof matching the Delegation circuit. The caller submits
39
+ * `{ proof, publicSignals }` to `IdentityRegistry.verifyDelegation()` along with
40
+ * the session nonce.
41
+ *
42
+ * Scope narrowing is one-way: the circuit (and contract) reject any delegatee
43
+ * scope that is not a subset of the delegator's, and any expiry past the
44
+ * delegator's. The cumulative-bit invariants (bit 4 ⇒ 2+3, bit 3 ⇒ 2) are
45
+ * enforced on the delegatee scope.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const { proof, result } = await delegate({
50
+ * delegator: parentCredential,
51
+ * delegatorOperatorPrivateKey: operatorSecret,
52
+ * delegateeCommitment: childCredential.commitment,
53
+ * delegateeScope: 0b00000011n, // read + write (narrower)
54
+ * delegateeExpiry: parentCredential.expiryTimestamp - 3600n,
55
+ * previousScopeCommitment: handshake.scopeCommitment,
56
+ * sessionNonce: handshake.sessionNonce,
57
+ * });
58
+ * ```
12
59
  */
13
- export declare function delegate(_delegator: AgentCredential, _delegatee: AgentCredential, _parentScopeCommitment: bigint, _hopIndex: number, _config?: BolyraConfig): Promise<{
60
+ export declare function delegate(input: DelegateInput): Promise<{
14
61
  proof: Proof;
15
62
  result: DelegationResult;
16
63
  }>;
17
64
  /**
18
- * Verify a delegation proof on-chain.
65
+ * Verify a delegation proof off-chain (snarkjs Groth16 verify).
19
66
  *
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
67
+ * For on-chain enforcement, submit `proof` and `proof.publicSignals` to
68
+ * `IdentityRegistry.verifyDelegation(proof, pubSignals, sessionNonce)` that
69
+ * call additionally enforces chain state, hop count, expiry binding, and
70
+ * nullifier replay. Off-chain verify here only confirms the proof itself is
71
+ * mathematically valid and that the publicSignals match the expected chain link.
24
72
  */
25
- export declare function verifyDelegation(_proof: Proof, _parentScopeCommitment: bigint, _config?: BolyraConfig): Promise<DelegationResult>;
73
+ export declare function verifyDelegation(proof: Proof, previousScopeCommitment: bigint, sessionNonce: bigint, currentTimestamp: bigint, config?: BolyraConfig): Promise<DelegationResult>;
26
74
  //# sourceMappingURL=delegation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"delegation.d.ts","sourceRoot":"","sources":["../src/delegation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,KAAK,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C;IAClB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC,CA0GrD;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,KAAK,EACZ,uBAAuB,EAAE,MAAM,EAC/B,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,EACxB,MAAM,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,gBAAgB,CAAC,CAgD3B"}
@@ -1,31 +1,214 @@
1
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
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.delegate = delegate;
4
37
  exports.verifyDelegation = verifyDelegation;
38
+ const snarkjs = __importStar(require("snarkjs"));
39
+ const path = __importStar(require("path"));
40
+ const fs = __importStar(require("fs"));
5
41
  const errors_1 = require("./errors");
42
+ const utils_1 = require("./utils");
43
+ const prover_1 = require("./prover");
44
+ const DEFAULT_CIRCUIT_DIR = process.env.BOLYRA_CIRCUITS_DIR ?? path.join(__dirname, '../../circuits/build');
45
+ /** Delegation circuit MAX_DEPTH constant (matches circuits/src/Delegation.circom). */
46
+ const DELEGATION_MAX_DEPTH = 20;
47
+ /** snarkjs publicSignals layout for the Delegation circuit (outputs first):
48
+ * [0] newScopeCommitment
49
+ * [1] delegationNullifier
50
+ * [2] delegateeMerkleRoot
51
+ * [3] previousScopeCommitment
52
+ * [4] sessionNonce
53
+ * [5] currentTimestamp
54
+ * This MUST match IdentityRegistry.verifyDelegation()'s pubSignals layout.
55
+ */
56
+ const PUBSIG_NEW_SCOPE = 0;
57
+ const PUBSIG_NULLIFIER = 1;
58
+ const PUBSIG_DELEGATEE_ROOT = 2;
59
+ const PUBSIG_PREV_SCOPE = 3;
60
+ const PUBSIG_SESSION_NONCE = 4;
61
+ const PUBSIG_CURRENT_TS = 5;
62
+ /** Build the single-leaf Merkle proof default (matches the conformance test pattern). */
63
+ function defaultMerkleProof() {
64
+ return {
65
+ length: 1,
66
+ index: 0,
67
+ siblings: new Array(DELEGATION_MAX_DEPTH).fill(0n),
68
+ };
69
+ }
6
70
  /**
7
- * Delegate scoped permissions to another agent.
8
- * Currently a stub -- full implementation requires the delegation circuit zkey.
71
+ * Generate a Delegation proof.
72
+ *
73
+ * Produces a Groth16 proof matching the Delegation circuit. The caller submits
74
+ * `{ proof, publicSignals }` to `IdentityRegistry.verifyDelegation()` along with
75
+ * the session nonce.
76
+ *
77
+ * Scope narrowing is one-way: the circuit (and contract) reject any delegatee
78
+ * scope that is not a subset of the delegator's, and any expiry past the
79
+ * delegator's. The cumulative-bit invariants (bit 4 ⇒ 2+3, bit 3 ⇒ 2) are
80
+ * enforced on the delegatee scope.
9
81
  *
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
82
+ * @example
83
+ * ```ts
84
+ * const { proof, result } = await delegate({
85
+ * delegator: parentCredential,
86
+ * delegatorOperatorPrivateKey: operatorSecret,
87
+ * delegateeCommitment: childCredential.commitment,
88
+ * delegateeScope: 0b00000011n, // read + write (narrower)
89
+ * delegateeExpiry: parentCredential.expiryTimestamp - 3600n,
90
+ * previousScopeCommitment: handshake.scopeCommitment,
91
+ * sessionNonce: handshake.sessionNonce,
92
+ * });
93
+ * ```
16
94
  */
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');
95
+ async function delegate(input) {
96
+ // Pre-flight scope check gives a clean error before paying for proof generation.
97
+ if ((input.delegateeScope & ~input.delegator.permissionBitmask) !== 0n) {
98
+ throw new errors_1.ScopeEscalationError(input.delegator.permissionBitmask, input.delegateeScope);
99
+ }
100
+ if (input.delegateeExpiry > input.delegator.expiryTimestamp) {
101
+ throw new errors_1.BolyraError(`Delegatee expiry (${input.delegateeExpiry}) exceeds delegator expiry (${input.delegator.expiryTimestamp}). Delegations may only narrow expiry, not extend it.`, 'EXPIRY_ESCALATION', {
102
+ delegateeExpiry: input.delegateeExpiry.toString(),
103
+ delegatorExpiry: input.delegator.expiryTimestamp.toString(),
104
+ });
105
+ }
106
+ // Sanity check: the previousScopeCommitment passed in must equal the
107
+ // identity-bound chain link Poseidon3(delegatorScope, delegatorCredCommitment,
108
+ // delegatorExpiry). The circuit will assert this; we precheck for a clean error.
109
+ // Ordered before artifact loading so CI environments without circuits still
110
+ // surface CHAIN_LINK_MISMATCH instead of CIRCUIT_ARTIFACT_NOT_FOUND.
111
+ const expectedPrev = await (0, utils_1.poseidon3)(input.delegator.permissionBitmask, input.delegator.commitment, input.delegator.expiryTimestamp);
112
+ if (expectedPrev !== input.previousScopeCommitment) {
113
+ throw new errors_1.BolyraError(`previousScopeCommitment does not match the delegator's identity-bound chain link. Got ${input.previousScopeCommitment}, expected ${expectedPrev} (= Poseidon3(scope, credCommitment, expiry) for this delegator). For hop 1, pass the agent's scopeCommitment output from proveHandshake.`, 'CHAIN_LINK_MISMATCH');
114
+ }
115
+ const circuitDir = input.config?.circuitDir ?? DEFAULT_CIRCUIT_DIR;
116
+ const backend = input.backend ?? 'auto';
117
+ const currentTimestamp = input.currentTimestamp ?? BigInt(Math.floor(Date.now() / 1000));
118
+ const merkleProof = input.delegateeMerkleProof ?? defaultMerkleProof();
119
+ if (merkleProof.siblings.length !== DELEGATION_MAX_DEPTH) {
120
+ throw new errors_1.BolyraError(`Delegatee Merkle proof must have exactly ${DELEGATION_MAX_DEPTH} siblings (got ${merkleProof.siblings.length}).`, 'INVALID_MERKLE_PROOF');
121
+ }
122
+ const wasmPath = path.join(circuitDir, 'Delegation_js/Delegation.wasm');
123
+ const zkeyPath = path.join(circuitDir, 'Delegation_final.zkey');
124
+ if (!fs.existsSync(wasmPath)) {
125
+ throw new errors_1.CircuitArtifactNotFoundError(wasmPath, 'wasm');
126
+ }
127
+ if (!fs.existsSync(zkeyPath)) {
128
+ throw new errors_1.CircuitArtifactNotFoundError(zkeyPath, 'zkey');
129
+ }
130
+ // The delegator signs the delegation token, binding this delegation to a
131
+ // specific recipient with specific scope+expiry.
132
+ // Token = Poseidon4(previousScopeCommitment, delegateeCommitment, delegateeScope, delegateeExpiry).
133
+ const tokenHash = await (0, utils_1.poseidon4)(input.previousScopeCommitment, input.delegateeCommitment, input.delegateeScope, input.delegateeExpiry);
134
+ const sig = await (0, utils_1.eddsaSign)(input.delegatorOperatorPrivateKey, tokenHash);
135
+ const witnessInput = {
136
+ delegatorScope: input.delegator.permissionBitmask.toString(),
137
+ delegateeScope: input.delegateeScope.toString(),
138
+ delegateeExpiry: input.delegateeExpiry.toString(),
139
+ delegatorExpiry: input.delegator.expiryTimestamp.toString(),
140
+ delegatorModelHash: input.delegator.modelHash.toString(),
141
+ delegatorPubkeyAx: input.delegator.operatorPublicKey.x.toString(),
142
+ delegatorPubkeyAy: input.delegator.operatorPublicKey.y.toString(),
143
+ sigR8x: sig.R8.x.toString(),
144
+ sigR8y: sig.R8.y.toString(),
145
+ sigS: sig.S.toString(),
146
+ delegatorCredCommitment: input.delegator.commitment.toString(),
147
+ delegateeCredCommitment: input.delegateeCommitment.toString(),
148
+ delegateeMerkleProofLength: merkleProof.length.toString(),
149
+ delegateeMerkleProofIndex: merkleProof.index.toString(),
150
+ delegateeMerkleProofSiblings: merkleProof.siblings.map((s) => s.toString()),
151
+ previousScopeCommitment: input.previousScopeCommitment.toString(),
152
+ sessionNonce: input.sessionNonce.toString(),
153
+ currentTimestamp: currentTimestamp.toString(),
154
+ };
155
+ let proof;
156
+ try {
157
+ proof = await (0, prover_1.proveGroth16)(witnessInput, wasmPath, zkeyPath, backend);
158
+ }
159
+ catch (err) {
160
+ throw new errors_1.ProofGenerationError('Delegation', err.message ?? String(err));
161
+ }
162
+ const result = {
163
+ newScopeCommitment: BigInt(proof.publicSignals[PUBSIG_NEW_SCOPE]),
164
+ delegationNullifier: BigInt(proof.publicSignals[PUBSIG_NULLIFIER]),
165
+ delegateeMerkleRoot: BigInt(proof.publicSignals[PUBSIG_DELEGATEE_ROOT]),
166
+ hopIndex: input.hopIndex ?? 0,
167
+ };
168
+ return { proof, result };
19
169
  }
20
170
  /**
21
- * Verify a delegation proof on-chain.
171
+ * Verify a delegation proof off-chain (snarkjs Groth16 verify).
22
172
  *
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
173
+ * For on-chain enforcement, submit `proof` and `proof.publicSignals` to
174
+ * `IdentityRegistry.verifyDelegation(proof, pubSignals, sessionNonce)` that
175
+ * call additionally enforces chain state, hop count, expiry binding, and
176
+ * nullifier replay. Off-chain verify here only confirms the proof itself is
177
+ * mathematically valid and that the publicSignals match the expected chain link.
27
178
  */
28
- async function verifyDelegation(_proof, _parentScopeCommitment, _config) {
29
- throw new errors_1.BolyraError('verifyDelegation() coming in @bolyra/sdk v0.3.', 'NOT_IMPLEMENTED');
179
+ async function verifyDelegation(proof, previousScopeCommitment, sessionNonce, currentTimestamp, config) {
180
+ if (!proof || !proof.proof || !Array.isArray(proof.publicSignals)) {
181
+ throw new errors_1.VerificationError('Invalid Delegation proof structure: expected { proof: object, publicSignals: string[] }.');
182
+ }
183
+ if (proof.publicSignals.length < 6) {
184
+ throw new errors_1.VerificationError(`Delegation proof has ${proof.publicSignals.length} public signals, expected 6.`);
185
+ }
186
+ // Bind the public signals to the expected chain context before trusting the proof.
187
+ if (BigInt(proof.publicSignals[PUBSIG_PREV_SCOPE]) !== previousScopeCommitment) {
188
+ throw new errors_1.VerificationError(`previousScopeCommitment mismatch: proof binds ${proof.publicSignals[PUBSIG_PREV_SCOPE]}, caller expected ${previousScopeCommitment}.`);
189
+ }
190
+ if (BigInt(proof.publicSignals[PUBSIG_SESSION_NONCE]) !== sessionNonce) {
191
+ throw new errors_1.VerificationError(`sessionNonce mismatch: proof binds ${proof.publicSignals[PUBSIG_SESSION_NONCE]}, caller expected ${sessionNonce}.`);
192
+ }
193
+ if (BigInt(proof.publicSignals[PUBSIG_CURRENT_TS]) !== currentTimestamp) {
194
+ throw new errors_1.VerificationError(`currentTimestamp mismatch: proof binds ${proof.publicSignals[PUBSIG_CURRENT_TS]}, caller expected ${currentTimestamp}.`);
195
+ }
196
+ const circuitDir = config?.circuitDir ?? DEFAULT_CIRCUIT_DIR;
197
+ const vkeyPath = path.join(circuitDir, 'Delegation_groth16_vkey.json');
198
+ if (!fs.existsSync(vkeyPath)) {
199
+ throw new errors_1.CircuitArtifactNotFoundError(vkeyPath, 'vkey');
200
+ }
201
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
202
+ const vkey = require(vkeyPath);
203
+ const valid = await snarkjs.groth16.verify(vkey, proof.publicSignals, proof.proof);
204
+ if (!valid) {
205
+ throw new errors_1.VerificationError('Delegation proof failed Groth16 verification.');
206
+ }
207
+ return {
208
+ newScopeCommitment: BigInt(proof.publicSignals[PUBSIG_NEW_SCOPE]),
209
+ delegationNullifier: BigInt(proof.publicSignals[PUBSIG_NULLIFIER]),
210
+ delegateeMerkleRoot: BigInt(proof.publicSignals[PUBSIG_DELEGATEE_ROOT]),
211
+ hopIndex: 0,
212
+ };
30
213
  }
31
214
  //# sourceMappingURL=delegation.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"delegation.js","sourceRoot":"","sources":["../src/delegation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,iBAAiB,CAAC,qBAAqB,gBAAgB,GAAG,CACzH,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,EAAE,UAAU,IAAI,mBAAmB,CAAC;IAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,8BAA8B,CAAC,CAAC;IACvE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,qCAA4B,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IACD,8DAA8D;IAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE/B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACnF,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,0BAAiB,CAAC,+CAA+C,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO;QACL,kBAAkB,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QACjE,mBAAmB,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAClE,mBAAmB,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;QACvE,QAAQ,EAAE,CAAC;KACZ,CAAC;AACJ,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -21,4 +21,16 @@ export declare class ScopeEscalationError extends BolyraError {
21
21
  export declare class StaleProofError extends BolyraError {
22
22
  constructor(rootType: 'human' | 'agent');
23
23
  }
24
+ export declare class InvalidSecretError extends BolyraError {
25
+ constructor(reason: string);
26
+ }
27
+ export declare class CircuitArtifactNotFoundError extends ProofGenerationError {
28
+ constructor(artifactPath: string, artifactType: 'wasm' | 'zkey' | 'vkey');
29
+ }
30
+ export declare class MerkleTreeError extends BolyraError {
31
+ constructor(reason: string, details?: Record<string, unknown>);
32
+ }
33
+ export declare class ConfigurationError extends BolyraError {
34
+ constructor(field: string, reason: string);
35
+ }
24
36
  //# sourceMappingURL=errors.d.ts.map