@zkproofport-ai/sdk 0.2.10 → 0.2.11
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 +232 -18
- package/dist/arcWallet.d.ts +50 -0
- package/dist/arcWallet.d.ts.map +1 -0
- package/dist/arcWallet.js +158 -0
- package/dist/arcWallet.js.map +1 -0
- package/dist/attestation.d.ts +5 -1
- package/dist/attestation.d.ts.map +1 -1
- package/dist/attestation.js +21 -2
- package/dist/attestation.js.map +1 -1
- package/dist/cdp.d.ts +162 -0
- package/dist/cdp.d.ts.map +1 -0
- package/dist/cdp.js +78 -0
- package/dist/cdp.js.map +1 -0
- package/dist/circuits.d.ts +121 -0
- package/dist/circuits.d.ts.map +1 -0
- package/dist/circuits.js +129 -0
- package/dist/circuits.js.map +1 -0
- package/dist/constants.d.ts +8 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +19 -4
- package/dist/constants.js.map +1 -1
- package/dist/delegation.d.ts +102 -0
- package/dist/delegation.d.ts.map +1 -0
- package/dist/delegation.js +121 -0
- package/dist/delegation.js.map +1 -0
- package/dist/extract.d.ts +46 -12
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +92 -30
- package/dist/extract.js.map +1 -1
- package/dist/flow.d.ts +13 -0
- package/dist/flow.d.ts.map +1 -1
- package/dist/flow.js +88 -3
- package/dist/flow.js.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/dist/inputs.d.ts +12 -0
- package/dist/inputs.d.ts.map +1 -1
- package/dist/inputs.js +13 -2
- package/dist/inputs.js.map +1 -1
- package/dist/nanopayment.d.ts +71 -0
- package/dist/nanopayment.d.ts.map +1 -0
- package/dist/nanopayment.js +77 -0
- package/dist/nanopayment.js.map +1 -0
- package/dist/payment.d.ts +73 -0
- package/dist/payment.d.ts.map +1 -0
- package/dist/payment.js +167 -0
- package/dist/payment.js.map +1 -0
- package/dist/prove.d.ts +7 -0
- package/dist/prove.d.ts.map +1 -1
- package/dist/prove.js +2 -0
- package/dist/prove.js.map +1 -1
- package/dist/typedAction.d.ts +3 -0
- package/dist/typedAction.d.ts.map +1 -0
- package/dist/typedAction.js +50 -0
- package/dist/typedAction.js.map +1 -0
- package/dist/types.d.ts +146 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +9 -6
- package/dist/types.js.map +1 -1
- package/dist/usdc.d.ts +63 -0
- package/dist/usdc.d.ts.map +1 -0
- package/dist/usdc.js +78 -0
- package/dist/usdc.js.map +1 -0
- package/dist/wallets.d.ts +96 -0
- package/dist/wallets.d.ts.map +1 -0
- package/dist/wallets.js +214 -0
- package/dist/wallets.js.map +1 -0
- package/package.json +40 -3
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegating a credential from one wallet to another.
|
|
3
|
+
*
|
|
4
|
+
* ## The problem this solves
|
|
5
|
+
*
|
|
6
|
+
* A wallet holds a Coinbase KYC attestation — call it A. A service wants proof
|
|
7
|
+
* of that KYC before it will let anyone stake. But A is the wallet whose
|
|
8
|
+
* on-chain history is worth hiding: revealing it links the KYC to everything
|
|
9
|
+
* else A has ever done.
|
|
10
|
+
*
|
|
11
|
+
* So A never appears. A signs a statement naming a second wallet, B, and the
|
|
12
|
+
* proof carries the hash of that statement. The service checks the proof, reads
|
|
13
|
+
* B out of the statement, and lets B act — while A stays behind the proof.
|
|
14
|
+
*
|
|
15
|
+
* ## Why this is an ordinary action and not a new mechanism
|
|
16
|
+
*
|
|
17
|
+
* `arc_eligibility` already proves "the wallet holding this KYC authorised ONE
|
|
18
|
+
* EIP-712 action". A delegation IS such an action: its fields name who is being
|
|
19
|
+
* delegated to, what they may do, and until when. Nothing in the circuit
|
|
20
|
+
* changes — only the structure being signed.
|
|
21
|
+
*
|
|
22
|
+
* That also means the delegation is bound to the proof: a proof made for one
|
|
23
|
+
* delegation verifies for no other, because the action's hash is a public
|
|
24
|
+
* input. Lifting the proof onto a different B is not possible.
|
|
25
|
+
*
|
|
26
|
+
* ## What the verifier must do
|
|
27
|
+
*
|
|
28
|
+
* Reading B out of the action is not enough. The service MUST rebuild the
|
|
29
|
+
* action's hash from the delegation it was shown and compare it with the
|
|
30
|
+
* proof's public input — otherwise anyone could present a valid proof
|
|
31
|
+
* alongside a delegation naming a wallet of their choosing.
|
|
32
|
+
* `delegationMatchesProof` is that check.
|
|
33
|
+
*/
|
|
34
|
+
import type { TypedAction } from './types.js';
|
|
35
|
+
/** What a delegation says. Every field is signed and none may be inferred. */
|
|
36
|
+
export interface Delegation {
|
|
37
|
+
/** The wallet being given the credential's benefit. */
|
|
38
|
+
delegate: string;
|
|
39
|
+
/** What the delegate may do, e.g. 'stake'. Free text the service defines. */
|
|
40
|
+
action: string;
|
|
41
|
+
/** Unix seconds. A delegation without an end is not offered. */
|
|
42
|
+
expiresAt: number;
|
|
43
|
+
/** Makes this delegation single-use, so it cannot be replayed. */
|
|
44
|
+
nonce: string;
|
|
45
|
+
}
|
|
46
|
+
/** The EIP-712 type of a delegation, and the name its wallet renders. */
|
|
47
|
+
export declare const DELEGATION_PRIMARY_TYPE = "CredentialDelegation";
|
|
48
|
+
export declare const DELEGATION_TYPES: {
|
|
49
|
+
readonly CredentialDelegation: readonly [{
|
|
50
|
+
readonly name: "delegate";
|
|
51
|
+
readonly type: "address";
|
|
52
|
+
}, {
|
|
53
|
+
readonly name: "action";
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
}, {
|
|
56
|
+
readonly name: "expiresAt";
|
|
57
|
+
readonly type: "uint256";
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: "nonce";
|
|
60
|
+
readonly type: "string";
|
|
61
|
+
}];
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Build the action that A signs to delegate to B.
|
|
65
|
+
*
|
|
66
|
+
* `domain` names the service the delegation is for, so a delegation issued to
|
|
67
|
+
* one service cannot be presented at another: the domain separator is part of
|
|
68
|
+
* what the proof binds.
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildDelegationAction(params: {
|
|
71
|
+
delegation: Delegation;
|
|
72
|
+
domain: {
|
|
73
|
+
name: string;
|
|
74
|
+
version: string;
|
|
75
|
+
chainId: number;
|
|
76
|
+
verifyingContract: string;
|
|
77
|
+
};
|
|
78
|
+
}): TypedAction;
|
|
79
|
+
/** The 32 bytes a proof carries for this action: EIP-712's hashStruct. */
|
|
80
|
+
export declare function delegationActionHash(action: TypedAction): string;
|
|
81
|
+
/** The 32 bytes a proof carries for the service this delegation is for. */
|
|
82
|
+
export declare function delegationDomainSeparator(action: TypedAction): string;
|
|
83
|
+
/**
|
|
84
|
+
* Whether a proof was made for exactly this delegation.
|
|
85
|
+
*
|
|
86
|
+
* The reason to call this rather than trust the delegation shown alongside the
|
|
87
|
+
* proof: a proof is public once presented, and anything that reads the
|
|
88
|
+
* delegate out of an unverified structure can be handed a proof plus a
|
|
89
|
+
* delegation naming somebody else.
|
|
90
|
+
*/
|
|
91
|
+
export declare function delegationMatchesProof(params: {
|
|
92
|
+
action: TypedAction;
|
|
93
|
+
/** The proof's `domain_separator` public input. */
|
|
94
|
+
domainSeparator: string;
|
|
95
|
+
/** The proof's `action_hash` public input. */
|
|
96
|
+
actionHash: string;
|
|
97
|
+
/** Unix seconds. An expired delegation is refused even when the proof is sound. */
|
|
98
|
+
now?: number;
|
|
99
|
+
}): string | null;
|
|
100
|
+
/** The wallet a checked delegation names. Throws rather than return a guess. */
|
|
101
|
+
export declare function delegateOf(action: TypedAction): string;
|
|
102
|
+
//# sourceMappingURL=delegation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation.d.ts","sourceRoot":"","sources":["../src/delegation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,8EAA8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
+
* A wallet holds a Coinbase KYC attestation — call it A. A service wants proof
|
|
7
|
+
* of that KYC before it will let anyone stake. But A is the wallet whose
|
|
8
|
+
* on-chain history is worth hiding: revealing it links the KYC to everything
|
|
9
|
+
* else A has ever done.
|
|
10
|
+
*
|
|
11
|
+
* So A never appears. A signs a statement naming a second wallet, B, and the
|
|
12
|
+
* proof carries the hash of that statement. The service checks the proof, reads
|
|
13
|
+
* B out of the statement, and lets B act — while A stays behind the proof.
|
|
14
|
+
*
|
|
15
|
+
* ## Why this is an ordinary action and not a new mechanism
|
|
16
|
+
*
|
|
17
|
+
* `arc_eligibility` already proves "the wallet holding this KYC authorised ONE
|
|
18
|
+
* EIP-712 action". A delegation IS such an action: its fields name who is being
|
|
19
|
+
* delegated to, what they may do, and until when. Nothing in the circuit
|
|
20
|
+
* changes — only the structure being signed.
|
|
21
|
+
*
|
|
22
|
+
* That also means the delegation is bound to the proof: a proof made for one
|
|
23
|
+
* delegation verifies for no other, because the action's hash is a public
|
|
24
|
+
* input. Lifting the proof onto a different B is not possible.
|
|
25
|
+
*
|
|
26
|
+
* ## What the verifier must do
|
|
27
|
+
*
|
|
28
|
+
* Reading B out of the action is not enough. The service MUST rebuild the
|
|
29
|
+
* action's hash from the delegation it was shown and compare it with the
|
|
30
|
+
* proof's public input — otherwise anyone could present a valid proof
|
|
31
|
+
* alongside a delegation naming a wallet of their choosing.
|
|
32
|
+
* `delegationMatchesProof` is that check.
|
|
33
|
+
*/
|
|
34
|
+
import { ethers } from 'ethers';
|
|
35
|
+
const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
36
|
+
/** The EIP-712 type of a delegation, and the name its wallet renders. */
|
|
37
|
+
export const DELEGATION_PRIMARY_TYPE = 'CredentialDelegation';
|
|
38
|
+
export const DELEGATION_TYPES = {
|
|
39
|
+
[DELEGATION_PRIMARY_TYPE]: [
|
|
40
|
+
{ name: 'delegate', type: 'address' },
|
|
41
|
+
{ name: 'action', type: 'string' },
|
|
42
|
+
{ name: 'expiresAt', type: 'uint256' },
|
|
43
|
+
{ name: 'nonce', type: 'string' },
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Build the action that A signs to delegate to B.
|
|
48
|
+
*
|
|
49
|
+
* `domain` names the service the delegation is for, so a delegation issued to
|
|
50
|
+
* one service cannot be presented at another: the domain separator is part of
|
|
51
|
+
* what the proof binds.
|
|
52
|
+
*/
|
|
53
|
+
export function buildDelegationAction(params) {
|
|
54
|
+
const { delegation, domain } = params;
|
|
55
|
+
if (!ADDRESS.test(delegation.delegate)) {
|
|
56
|
+
throw new Error(`delegate must be an address, got '${delegation.delegate}'.`);
|
|
57
|
+
}
|
|
58
|
+
if (!delegation.action.trim()) {
|
|
59
|
+
throw new Error('A delegation must say what the delegate may do; `action` was empty.');
|
|
60
|
+
}
|
|
61
|
+
if (!Number.isInteger(delegation.expiresAt) || delegation.expiresAt <= 0) {
|
|
62
|
+
throw new Error('expiresAt must be a Unix time in seconds. A delegation without an end is not offered.');
|
|
63
|
+
}
|
|
64
|
+
if (!delegation.nonce.trim()) {
|
|
65
|
+
throw new Error('A delegation needs a nonce, or the same signature can be replayed.');
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
domain,
|
|
69
|
+
types: DELEGATION_TYPES,
|
|
70
|
+
primaryType: DELEGATION_PRIMARY_TYPE,
|
|
71
|
+
message: {
|
|
72
|
+
delegate: delegation.delegate,
|
|
73
|
+
action: delegation.action,
|
|
74
|
+
expiresAt: delegation.expiresAt,
|
|
75
|
+
nonce: delegation.nonce,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** The 32 bytes a proof carries for this action: EIP-712's hashStruct. */
|
|
80
|
+
export function delegationActionHash(action) {
|
|
81
|
+
return ethers.TypedDataEncoder.hashStruct(action.primaryType, action.types, action.message);
|
|
82
|
+
}
|
|
83
|
+
/** The 32 bytes a proof carries for the service this delegation is for. */
|
|
84
|
+
export function delegationDomainSeparator(action) {
|
|
85
|
+
return ethers.TypedDataEncoder.hashDomain(action.domain);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Whether a proof was made for exactly this delegation.
|
|
89
|
+
*
|
|
90
|
+
* The reason to call this rather than trust the delegation shown alongside the
|
|
91
|
+
* proof: a proof is public once presented, and anything that reads the
|
|
92
|
+
* delegate out of an unverified structure can be handed a proof plus a
|
|
93
|
+
* delegation naming somebody else.
|
|
94
|
+
*/
|
|
95
|
+
export function delegationMatchesProof(params) {
|
|
96
|
+
const { action, domainSeparator, actionHash } = params;
|
|
97
|
+
const now = params.now ?? Math.floor(Date.now() / 1000);
|
|
98
|
+
if (action.primaryType !== DELEGATION_PRIMARY_TYPE) {
|
|
99
|
+
return `This action is a '${action.primaryType}', not a ${DELEGATION_PRIMARY_TYPE}. It authorises something, but not a delegation.`;
|
|
100
|
+
}
|
|
101
|
+
if (delegationDomainSeparator(action).toLowerCase() !== domainSeparator.toLowerCase()) {
|
|
102
|
+
return 'The proof was made for a different service: its domain separator does not match this delegation.';
|
|
103
|
+
}
|
|
104
|
+
if (delegationActionHash(action).toLowerCase() !== actionHash.toLowerCase()) {
|
|
105
|
+
return 'The proof was made for a different delegation: its action hash does not match the one shown.';
|
|
106
|
+
}
|
|
107
|
+
const expiresAt = Number(action.message.expiresAt);
|
|
108
|
+
if (!Number.isFinite(expiresAt) || expiresAt <= now) {
|
|
109
|
+
return `This delegation expired at ${expiresAt}, and it is now ${now}.`;
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
/** The wallet a checked delegation names. Throws rather than return a guess. */
|
|
114
|
+
export function delegateOf(action) {
|
|
115
|
+
const delegate = action.message.delegate;
|
|
116
|
+
if (typeof delegate !== 'string' || !ADDRESS.test(delegate)) {
|
|
117
|
+
return (() => { throw new Error(`This action names no delegate address: got '${String(delegate)}'.`); })();
|
|
118
|
+
}
|
|
119
|
+
return delegate;
|
|
120
|
+
}
|
|
121
|
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,EAAE,CAAC;QACtF,OAAO,kGAAkG,CAAC;IAC5G,CAAC;IACD,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC;QAC5E,OAAO,8FAA8F,CAAC;IACxG,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,GAAG,EAAE,CAAC;QACpD,OAAO,8BAA8B,SAAS,mBAAmB,GAAG,GAAG,CAAC;IAC1E,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,UAAU,CAAC,MAAmB;IAC5C,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;IACzC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5D,OAAO,CAAC,GAAG,EAAE,GAAG,MAAM,IAAI,KAAK,CAAC,+CAA+C,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7G,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/extract.d.ts
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Extract structured data from ZK proof publicInputs.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* ## The caller says which circuit; this module never guesses
|
|
5
|
+
*
|
|
6
|
+
* Every function here takes the circuit id explicitly. There used to be a
|
|
7
|
+
* `detectCircuit(fieldCount)` that inferred the circuit from the *number* of
|
|
8
|
+
* public inputs (128 → coinbase, 150 → country, 148 → oidc, anything else →
|
|
9
|
+
* coinbase). It is gone. Field count is a size, not an identity: nothing
|
|
10
|
+
* guarantees two circuits have different counts, and when they collide the
|
|
11
|
+
* inference returns whichever branch is written first, silently, with no error.
|
|
12
|
+
* A wrong answer here is a wrong nullifier, which is a correctness bug in
|
|
13
|
+
* uniqueness and double-spend checks rather than a cosmetic one.
|
|
14
|
+
*
|
|
15
|
+
* The circuit is always available at the call site — it is in the prove request
|
|
16
|
+
* and comes back in the prove response — so requiring it costs nothing and a
|
|
17
|
+
* missing one now returns `null` ("I don't know") instead of a confident guess.
|
|
18
|
+
*
|
|
19
|
+
* ## Public-input layouts are this repo's knowledge
|
|
20
|
+
*
|
|
21
|
+
* The index ranges below are per-circuit facts that proofport-ai owns; the
|
|
22
|
+
* customer SDK has no layout data. Only the *identifiers* come from
|
|
23
|
+
* `./circuits.js` (mirroring `@zkproofport-app/sdk/circuits`).
|
|
5
24
|
*
|
|
6
25
|
* coinbase_attestation (128 fields):
|
|
7
26
|
* Index 0-31: signal_hash (32 bytes)
|
|
@@ -25,29 +44,44 @@
|
|
|
25
44
|
* Index 115-146: nullifier (32 bytes)
|
|
26
45
|
* Index 147: provider (u8)
|
|
27
46
|
*/
|
|
47
|
+
import type { CircuitId } from './types.js';
|
|
28
48
|
/**
|
|
29
49
|
* Extract scope from proof publicInputs.
|
|
30
|
-
* Auto-detects circuit from field count.
|
|
31
50
|
*
|
|
32
51
|
* @param publicInputs - Single hex string of concatenated public inputs
|
|
33
|
-
* @param circuit -
|
|
34
|
-
*
|
|
52
|
+
* @param circuit - Canonical circuit id the proof was generated for. Required:
|
|
53
|
+
* the layout cannot be inferred from the data, and this function will not
|
|
54
|
+
* guess. JavaScript callers that omit it get `null`.
|
|
55
|
+
* @returns The scope as a 0x-prefixed hex string, or `null` when the circuit is
|
|
56
|
+
* unknown or the input is too short for its layout.
|
|
35
57
|
*/
|
|
36
|
-
export declare function extractScopeFromPublicInputs(publicInputs: string, circuit
|
|
58
|
+
export declare function extractScopeFromPublicInputs(publicInputs: string, circuit: CircuitId): string | null;
|
|
37
59
|
/**
|
|
38
60
|
* Extract nullifier from proof publicInputs.
|
|
39
|
-
* Auto-detects circuit from field count.
|
|
40
61
|
*
|
|
41
62
|
* @param publicInputs - Single hex string of concatenated public inputs
|
|
42
|
-
* @param circuit -
|
|
43
|
-
*
|
|
63
|
+
* @param circuit - Canonical circuit id the proof was generated for. Required:
|
|
64
|
+
* the layout cannot be inferred from the data, and this function will not
|
|
65
|
+
* guess. JavaScript callers that omit it get `null`.
|
|
66
|
+
* @returns The nullifier as a 0x-prefixed hex string, or `null` when the circuit
|
|
67
|
+
* is unknown or the input is too short for its layout.
|
|
44
68
|
*/
|
|
45
|
-
export declare function extractNullifierFromPublicInputs(publicInputs: string, circuit
|
|
69
|
+
export declare function extractNullifierFromPublicInputs(publicInputs: string, circuit: CircuitId): string | null;
|
|
46
70
|
/**
|
|
47
|
-
* Extract domain from
|
|
71
|
+
* Extract the email domain from proof publicInputs.
|
|
72
|
+
*
|
|
73
|
+
* Only `oidc_domain_attestation` carries a domain. The circuit is a parameter
|
|
74
|
+
* for the same reason as above: this function used to assume OIDC and read
|
|
75
|
+
* indices 18..81 out of whatever it was handed, so a 128-field coinbase proof
|
|
76
|
+
* (length 128, comfortably past its `< 83` guard) produced a plausible-looking
|
|
77
|
+
* string built from unrelated attestation bytes.
|
|
48
78
|
*
|
|
49
79
|
* @param publicInputs - Single hex string of concatenated public inputs
|
|
50
|
-
* @
|
|
80
|
+
* @param circuit - Canonical circuit id the proof was generated for. Required
|
|
81
|
+
* for the same reason as the other extractors: a default would be a guess,
|
|
82
|
+
* and the compiler catching a wrong call site beats a wrong domain at runtime.
|
|
83
|
+
* @returns The domain string, or `null` when the circuit carries no domain or
|
|
84
|
+
* extraction fails.
|
|
51
85
|
*/
|
|
52
|
-
export declare function extractDomainFromPublicInputs(publicInputs: string): string | null;
|
|
86
|
+
export declare function extractDomainFromPublicInputs(publicInputs: string, circuit: CircuitId): string | null;
|
|
53
87
|
//# sourceMappingURL=extract.d.ts.map
|
package/dist/extract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAyE5C;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,SAAS,GACjB,MAAM,GAAG,IAAI,CAWf;AAED;;;;;;;;;GASG;AACH,wBAAgB,gCAAgC,CAC9C,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,SAAS,GACjB,MAAM,GAAG,IAAI,CAWf;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,SAAS,GACjB,MAAM,GAAG,IAAI,CAwBf"}
|
package/dist/extract.js
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Extract structured data from ZK proof publicInputs.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* ## The caller says which circuit; this module never guesses
|
|
5
|
+
*
|
|
6
|
+
* Every function here takes the circuit id explicitly. There used to be a
|
|
7
|
+
* `detectCircuit(fieldCount)` that inferred the circuit from the *number* of
|
|
8
|
+
* public inputs (128 → coinbase, 150 → country, 148 → oidc, anything else →
|
|
9
|
+
* coinbase). It is gone. Field count is a size, not an identity: nothing
|
|
10
|
+
* guarantees two circuits have different counts, and when they collide the
|
|
11
|
+
* inference returns whichever branch is written first, silently, with no error.
|
|
12
|
+
* A wrong answer here is a wrong nullifier, which is a correctness bug in
|
|
13
|
+
* uniqueness and double-spend checks rather than a cosmetic one.
|
|
14
|
+
*
|
|
15
|
+
* The circuit is always available at the call site — it is in the prove request
|
|
16
|
+
* and comes back in the prove response — so requiring it costs nothing and a
|
|
17
|
+
* missing one now returns `null` ("I don't know") instead of a confident guess.
|
|
18
|
+
*
|
|
19
|
+
* ## Public-input layouts are this repo's knowledge
|
|
20
|
+
*
|
|
21
|
+
* The index ranges below are per-circuit facts that proofport-ai owns; the
|
|
22
|
+
* customer SDK has no layout data. Only the *identifiers* come from
|
|
23
|
+
* `./circuits.js` (mirroring `@zkproofport-app/sdk/circuits`).
|
|
5
24
|
*
|
|
6
25
|
* coinbase_attestation (128 fields):
|
|
7
26
|
* Index 0-31: signal_hash (32 bytes)
|
|
@@ -25,21 +44,40 @@
|
|
|
25
44
|
* Index 115-146: nullifier (32 bytes)
|
|
26
45
|
* Index 147: provider (u8)
|
|
27
46
|
*/
|
|
28
|
-
|
|
47
|
+
import { CIRCUIT_IDS } from './circuits.js';
|
|
48
|
+
/**
|
|
49
|
+
* Public-input layout for every circuit proofport-ai can prove.
|
|
50
|
+
*
|
|
51
|
+
* Keyed by the canonical identifiers, so a rename in the customer SDK is a
|
|
52
|
+
* compile error here rather than a lookup that quietly misses.
|
|
53
|
+
*/
|
|
29
54
|
const LAYOUTS = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
55
|
+
[CIRCUIT_IDS.COINBASE_ATTESTATION]: { scope: [64, 95], nullifier: [96, 127] },
|
|
56
|
+
[CIRCUIT_IDS.COINBASE_COUNTRY_ATTESTATION]: { scope: [86, 117], nullifier: [118, 149] },
|
|
57
|
+
[CIRCUIT_IDS.OIDC_DOMAIN_ATTESTATION]: {
|
|
58
|
+
scope: [83, 114],
|
|
59
|
+
nullifier: [115, 146],
|
|
60
|
+
domainStorage: 18,
|
|
61
|
+
domainLen: 82,
|
|
62
|
+
},
|
|
63
|
+
// Read off the compiled ABI, not counted by hand:
|
|
64
|
+
// signal_hash 0-31, domain_separator 32-63, action_hash 64-95,
|
|
65
|
+
// signer_list_merkle_root 96-127, scope 128-159, nullifier 160-191.
|
|
66
|
+
// The two extra 32-byte fields before the Merkle root are what pushes scope
|
|
67
|
+
// and nullifier 64 fields past where they sit in coinbase_attestation.
|
|
68
|
+
[CIRCUIT_IDS.ARC_ELIGIBILITY]: { scope: [128, 159], nullifier: [160, 191] },
|
|
33
69
|
};
|
|
34
70
|
/**
|
|
35
|
-
*
|
|
71
|
+
* Look up the public-input layout for a circuit.
|
|
72
|
+
*
|
|
73
|
+
* Returns `null` for anything without a known layout — including a canonical
|
|
74
|
+
* identifier this server cannot prove, such as `mdl_kr_age`. It never falls
|
|
75
|
+
* back to another circuit's byte ranges.
|
|
36
76
|
*/
|
|
37
|
-
function
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
return 'coinbase_country_attestation';
|
|
42
|
-
return 'coinbase_attestation';
|
|
77
|
+
function getLayout(circuit) {
|
|
78
|
+
if (typeof circuit !== 'string')
|
|
79
|
+
return null;
|
|
80
|
+
return LAYOUTS[circuit] ?? null;
|
|
43
81
|
}
|
|
44
82
|
/**
|
|
45
83
|
* Split a concatenated hex string into 32-byte (64 hex char) fields.
|
|
@@ -65,17 +103,20 @@ function extractBytes32(fields, start, end) {
|
|
|
65
103
|
}
|
|
66
104
|
/**
|
|
67
105
|
* Extract scope from proof publicInputs.
|
|
68
|
-
* Auto-detects circuit from field count.
|
|
69
106
|
*
|
|
70
107
|
* @param publicInputs - Single hex string of concatenated public inputs
|
|
71
|
-
* @param circuit -
|
|
72
|
-
*
|
|
108
|
+
* @param circuit - Canonical circuit id the proof was generated for. Required:
|
|
109
|
+
* the layout cannot be inferred from the data, and this function will not
|
|
110
|
+
* guess. JavaScript callers that omit it get `null`.
|
|
111
|
+
* @returns The scope as a 0x-prefixed hex string, or `null` when the circuit is
|
|
112
|
+
* unknown or the input is too short for its layout.
|
|
73
113
|
*/
|
|
74
114
|
export function extractScopeFromPublicInputs(publicInputs, circuit) {
|
|
75
115
|
try {
|
|
116
|
+
const layout = getLayout(circuit);
|
|
117
|
+
if (!layout)
|
|
118
|
+
return null;
|
|
76
119
|
const fields = splitFields(publicInputs);
|
|
77
|
-
const ct = circuit || detectCircuit(fields.length);
|
|
78
|
-
const layout = LAYOUTS[ct] || LAYOUTS.coinbase_attestation;
|
|
79
120
|
const [start, end] = layout.scope;
|
|
80
121
|
if (fields.length <= end)
|
|
81
122
|
return null;
|
|
@@ -87,17 +128,20 @@ export function extractScopeFromPublicInputs(publicInputs, circuit) {
|
|
|
87
128
|
}
|
|
88
129
|
/**
|
|
89
130
|
* Extract nullifier from proof publicInputs.
|
|
90
|
-
* Auto-detects circuit from field count.
|
|
91
131
|
*
|
|
92
132
|
* @param publicInputs - Single hex string of concatenated public inputs
|
|
93
|
-
* @param circuit -
|
|
94
|
-
*
|
|
133
|
+
* @param circuit - Canonical circuit id the proof was generated for. Required:
|
|
134
|
+
* the layout cannot be inferred from the data, and this function will not
|
|
135
|
+
* guess. JavaScript callers that omit it get `null`.
|
|
136
|
+
* @returns The nullifier as a 0x-prefixed hex string, or `null` when the circuit
|
|
137
|
+
* is unknown or the input is too short for its layout.
|
|
95
138
|
*/
|
|
96
139
|
export function extractNullifierFromPublicInputs(publicInputs, circuit) {
|
|
97
140
|
try {
|
|
141
|
+
const layout = getLayout(circuit);
|
|
142
|
+
if (!layout)
|
|
143
|
+
return null;
|
|
98
144
|
const fields = splitFields(publicInputs);
|
|
99
|
-
const ct = circuit || detectCircuit(fields.length);
|
|
100
|
-
const layout = LAYOUTS[ct] || LAYOUTS.coinbase_attestation;
|
|
101
145
|
const [start, end] = layout.nullifier;
|
|
102
146
|
if (fields.length <= end)
|
|
103
147
|
return null;
|
|
@@ -108,22 +152,40 @@ export function extractNullifierFromPublicInputs(publicInputs, circuit) {
|
|
|
108
152
|
}
|
|
109
153
|
}
|
|
110
154
|
/**
|
|
111
|
-
* Extract domain from
|
|
155
|
+
* Extract the email domain from proof publicInputs.
|
|
156
|
+
*
|
|
157
|
+
* Only `oidc_domain_attestation` carries a domain. The circuit is a parameter
|
|
158
|
+
* for the same reason as above: this function used to assume OIDC and read
|
|
159
|
+
* indices 18..81 out of whatever it was handed, so a 128-field coinbase proof
|
|
160
|
+
* (length 128, comfortably past its `< 83` guard) produced a plausible-looking
|
|
161
|
+
* string built from unrelated attestation bytes.
|
|
112
162
|
*
|
|
113
163
|
* @param publicInputs - Single hex string of concatenated public inputs
|
|
114
|
-
* @
|
|
164
|
+
* @param circuit - Canonical circuit id the proof was generated for. Required
|
|
165
|
+
* for the same reason as the other extractors: a default would be a guess,
|
|
166
|
+
* and the compiler catching a wrong call site beats a wrong domain at runtime.
|
|
167
|
+
* @returns The domain string, or `null` when the circuit carries no domain or
|
|
168
|
+
* extraction fails.
|
|
115
169
|
*/
|
|
116
|
-
export function extractDomainFromPublicInputs(publicInputs) {
|
|
170
|
+
export function extractDomainFromPublicInputs(publicInputs, circuit) {
|
|
117
171
|
try {
|
|
172
|
+
const layout = getLayout(circuit);
|
|
173
|
+
if (!layout)
|
|
174
|
+
return null;
|
|
175
|
+
const { domainStorage, domainLen } = layout;
|
|
176
|
+
if (domainStorage === undefined || domainLen === undefined)
|
|
177
|
+
return null;
|
|
118
178
|
const fields = splitFields(publicInputs);
|
|
119
|
-
if (fields.length
|
|
179
|
+
if (fields.length <= domainLen)
|
|
180
|
+
return null;
|
|
181
|
+
const length = Number(BigInt(fields[domainLen]));
|
|
182
|
+
if (length <= 0 || length > 64)
|
|
120
183
|
return null;
|
|
121
|
-
|
|
122
|
-
if (domainLen <= 0 || domainLen > 64)
|
|
184
|
+
if (fields.length < domainStorage + length)
|
|
123
185
|
return null;
|
|
124
186
|
const chars = [];
|
|
125
|
-
for (let i = 0; i <
|
|
126
|
-
const byte = Number(BigInt(fields[
|
|
187
|
+
for (let i = 0; i < length; i++) {
|
|
188
|
+
const byte = Number(BigInt(fields[domainStorage + i]) & 0xffn);
|
|
127
189
|
chars.push(String.fromCharCode(byte));
|
|
128
190
|
}
|
|
129
191
|
return chars.join('');
|
package/dist/extract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAe5C;;;;;GAKG;AACH,MAAM,OAAO,GAAyC;IACpD,CAAC,WAAW,CAAC,oBAAoB,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE;IAC7E,CAAC,WAAW,CAAC,4BAA4B,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;IACvF,CAAC,WAAW,CAAC,uBAAuB,CAAC,EAAE;QACrC,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC;QAChB,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;QACrB,aAAa,EAAE,EAAE;QACjB,SAAS,EAAE,EAAE;KACd;IACD,kDAAkD;IAClD,iEAAiE;IACjE,sEAAsE;IACtE,4EAA4E;IAC5E,uEAAuE;IACvE,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;CAC5E,CAAC;AAEF;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,OAAgB;IACjC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC7C,OAAQ,OAAyD,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;AACrF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,MAAM,CAAC,MAAM,IAAI,SAAS;YAAE,OAAO,IAAI,CAAC;QAE5C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,EAAE;YAAE,OAAO,IAAI,CAAC;QAC5C,IAAI,MAAM,CAAC,MAAM,GAAG,aAAa,GAAG,MAAM;YAAE,OAAO,IAAI,CAAC;QAExD,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;YAC/D,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/flow.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ClientConfig, ProofParams, ProofResult, StepResult } from './types.js';
|
|
2
2
|
import type { ProofportSigner } from './signer.js';
|
|
3
|
+
import type { PaymentWallet } from './types.js';
|
|
3
4
|
export interface FlowCallbacks {
|
|
4
5
|
onStep?: (step: StepResult) => void;
|
|
5
6
|
}
|
|
@@ -19,5 +20,17 @@ export interface FlowCallbacks {
|
|
|
19
20
|
*/
|
|
20
21
|
export declare function generateProof(config: ClientConfig, signers: {
|
|
21
22
|
attestation: ProofportSigner;
|
|
23
|
+
/**
|
|
24
|
+
* The wallet that pays, when the service charges. A different wallet from
|
|
25
|
+
* `attestation` and deliberately so: the attestation wallet is fixed by
|
|
26
|
+
* the EAS attestation bound to it, while the paying wallet is whichever
|
|
27
|
+
* one holds USDC. Forcing them to be the same would mean the wallet that
|
|
28
|
+
* passed KYC also has to be funded on the paying chain.
|
|
29
|
+
*
|
|
30
|
+
* Omitting it is fine against a service with payment disabled. Against one
|
|
31
|
+
* that charges, the 402 is returned as an error naming the chains offered,
|
|
32
|
+
* rather than a proof request that hangs.
|
|
33
|
+
*/
|
|
34
|
+
payment?: PaymentWallet;
|
|
22
35
|
}, params: ProofParams, callbacks?: FlowCallbacks): Promise<ProofResult>;
|
|
23
36
|
//# sourceMappingURL=flow.d.ts.map
|
package/dist/flow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAEZ,WAAW,EACX,WAAW,EACX,UAAU,EACX,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAEZ,WAAW,EACX,WAAW,EACX,UAAU,EACX,MAAM,YAAY,CAAC;AAQpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKhD,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CACrC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE;IACP,WAAW,EAAE,eAAe,CAAC;IAC7B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,EACD,MAAM,EAAE,WAAW,EACnB,SAAS,CAAC,EAAE,aAAa,GACxB,OAAO,CAAC,WAAW,CAAC,CAgMtB"}
|