@0xpolygonid/js-sdk 1.24.1 → 1.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/esm/index.js +138 -702
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +136 -701
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/circuits/auth-v2.js +6 -0
- package/dist/node/cjs/iden3comm/handlers/contract-request.js +7 -1
- package/dist/node/cjs/iden3comm/handlers/payment.js +27 -46
- package/dist/node/cjs/iden3comm/utils/contract-request.utils.js +59 -0
- package/dist/node/cjs/iden3comm/utils/index.js +1 -0
- package/dist/node/cjs/proof/proof-service.js +6 -0
- package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +56 -47
- package/dist/node/cjs/utils/did-helper.js +8 -3
- package/dist/node/cjs/verifiable/constants.js +1 -2
- package/dist/node/esm/circuits/auth-v2.js +6 -0
- package/dist/node/esm/iden3comm/handlers/contract-request.js +7 -1
- package/dist/node/esm/iden3comm/handlers/payment.js +28 -46
- package/dist/node/esm/iden3comm/utils/contract-request.utils.js +54 -0
- package/dist/node/esm/iden3comm/utils/index.js +1 -0
- package/dist/node/esm/proof/proof-service.js +6 -0
- package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +58 -49
- package/dist/node/esm/utils/did-helper.js +8 -3
- package/dist/node/esm/verifiable/constants.js +1 -2
- package/dist/types/circuits/auth-v2.d.ts +3 -2
- package/dist/types/iden3comm/handlers/payment.d.ts +5 -9
- package/dist/types/iden3comm/types/protocol/payment.d.ts +6 -5
- package/dist/types/iden3comm/utils/contract-request.utils.d.ts +20 -0
- package/dist/types/iden3comm/utils/index.d.ts +1 -0
- package/dist/types/proof/proof-service.d.ts +10 -0
- package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts +2 -0
- package/dist/types/verifiable/constants.d.ts +2 -3
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { keccak256 } from 'ethers';
|
|
2
|
+
import { byteEncoder, hexToBytes, isEthereumIdentity } from '../../utils';
|
|
3
|
+
import { CircuitId } from '../../circuits';
|
|
4
|
+
import { Hex } from '@iden3/js-crypto';
|
|
5
|
+
/**
|
|
6
|
+
* @beta
|
|
7
|
+
* Retrieves the request ID from circuit string.
|
|
8
|
+
* CircuitId.AuthV2 - 940499666
|
|
9
|
+
* @returns The request ID.
|
|
10
|
+
*/
|
|
11
|
+
export function calculateRequestIdForCircuit(circuitId) {
|
|
12
|
+
const circuitHash = keccak256(byteEncoder.encode(circuitId));
|
|
13
|
+
const dataView = new DataView(Hex.decodeString(circuitHash.replace('0x', '')).buffer);
|
|
14
|
+
const id = dataView.getUint32(0);
|
|
15
|
+
return id;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Prepares the zero-knowledge proof response for the AuthV2 circuit.
|
|
19
|
+
* @beta
|
|
20
|
+
* @param address - The address associated with the request.
|
|
21
|
+
* @param senderDid - The sender's decentralized identifier (DID).
|
|
22
|
+
* @param proofService - The proof service used to generate the proof.
|
|
23
|
+
* @returns A promise that resolves to an array of ZeroKnowledgeProofResponse objects.
|
|
24
|
+
*/
|
|
25
|
+
export async function prepareAuthV2ZeroKnowledgeResponse(address, senderDid, proofService) {
|
|
26
|
+
const circuitId = CircuitId.AuthV2;
|
|
27
|
+
// this is now hardcoded calculated value for 'authV2' that can be changed in the future.
|
|
28
|
+
const id = 940499666;
|
|
29
|
+
if (isEthereumIdentity(senderDid)) {
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
circuitId,
|
|
33
|
+
id,
|
|
34
|
+
pub_signals: [],
|
|
35
|
+
proof: {
|
|
36
|
+
pi_a: [],
|
|
37
|
+
pi_b: [],
|
|
38
|
+
pi_c: [],
|
|
39
|
+
protocol: 'groth16'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
const hash = Uint8Array.from([...hexToBytes(address), ...new Uint8Array(12)]).reverse();
|
|
45
|
+
const { proof, pub_signals } = await proofService.generateAuthV2Proof(hash, senderDid);
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
circuitId,
|
|
49
|
+
id,
|
|
50
|
+
pub_signals,
|
|
51
|
+
proof
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
}
|
|
@@ -213,6 +213,12 @@ export class ProofService {
|
|
|
213
213
|
authInputs.gistProof = gistProof;
|
|
214
214
|
return authInputs.inputsMarshal();
|
|
215
215
|
}
|
|
216
|
+
/** {@inheritdoc IProofService.generateAuthV2Proof} */
|
|
217
|
+
async generateAuthV2Proof(challenge, did) {
|
|
218
|
+
const authInputs = await this.generateAuthV2Inputs(challenge, did, CircuitId.AuthV2);
|
|
219
|
+
const zkProof = await this._prover.generate(authInputs, CircuitId.AuthV2);
|
|
220
|
+
return zkProof;
|
|
221
|
+
}
|
|
216
222
|
async verifyState(circuitId, pubSignals, opts = {
|
|
217
223
|
acceptedStateTransitionDelay: PROTOCOL_CONSTANTS.DEFAULT_AUTH_VERIFY_DELAY
|
|
218
224
|
}) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { JsonRpcProvider, Contract, ethers } from 'ethers';
|
|
2
2
|
import abi from './abi/ZkpVerifier.json';
|
|
3
3
|
import { TransactionService } from '../../blockchain';
|
|
4
|
-
import { DID } from '@iden3/js-iden3-core';
|
|
5
|
-
import { AtomicQueryMTPV2OnChainPubSignals, AtomicQuerySigV2OnChainPubSignals, AtomicQueryV3OnChainPubSignals, CircuitId } from '../../circuits';
|
|
4
|
+
import { chainIDfromDID, DID, Id } from '@iden3/js-iden3-core';
|
|
5
|
+
import { AtomicQueryMTPV2OnChainPubSignals, AtomicQuerySigV2OnChainPubSignals, AtomicQueryV3OnChainPubSignals, AuthV2PubSignals, CircuitId } from '../../circuits';
|
|
6
6
|
import { byteEncoder, DIDDocumentSignature, resolveDidDocument } from '../../utils';
|
|
7
7
|
import { poseidon } from '@iden3/js-crypto';
|
|
8
|
+
import { Hash } from '@iden3/js-merkletree';
|
|
8
9
|
const maxGasLimit = 10000000n;
|
|
9
10
|
/**
|
|
10
11
|
* Supported function signature for SubmitZKPResponse
|
|
@@ -151,54 +152,60 @@ export class OnChainZKPVerifier {
|
|
|
151
152
|
const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
|
|
152
153
|
return new Map().set(txnHash, zkProofResponses);
|
|
153
154
|
}
|
|
155
|
+
static getCrossChainResolvers(source, txDataChainId, type, didResolverUrl) {
|
|
156
|
+
return [
|
|
157
|
+
...new Set(source.map((info) => JSON.stringify({
|
|
158
|
+
id: info.id.string(),
|
|
159
|
+
[type]: type === 'gist' ? info.root?.string() : info.state?.string()
|
|
160
|
+
})))
|
|
161
|
+
].reduce((acc, s) => {
|
|
162
|
+
const info = JSON.parse(s);
|
|
163
|
+
const id = Id.fromString(info.id);
|
|
164
|
+
const chainId = chainIDfromDID(DID.parseFromId(id));
|
|
165
|
+
if (txDataChainId === chainId) {
|
|
166
|
+
return acc;
|
|
167
|
+
}
|
|
168
|
+
const promise = this.resolveDidDocumentEip712MessageAndSignature(DID.parseFromId(Id.fromString(info.id)), didResolverUrl, {
|
|
169
|
+
[type]: Hash.fromString(info[type])
|
|
170
|
+
});
|
|
171
|
+
return [...acc, promise];
|
|
172
|
+
}, []);
|
|
173
|
+
}
|
|
154
174
|
static async prepareTxArgsSubmitV2(resolverUrl, txData, zkProofResponses) {
|
|
155
175
|
if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV2) {
|
|
156
176
|
throw new Error(`submit cross chain doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV2}' is supported.`);
|
|
157
177
|
}
|
|
158
|
-
const
|
|
159
|
-
const
|
|
178
|
+
const gistUpdates = [];
|
|
179
|
+
const stateUpdates = [];
|
|
160
180
|
const payload = [];
|
|
161
|
-
|
|
162
|
-
const gistUpdateResolutionsPending = [];
|
|
163
|
-
const stateUpdateResolutionsPending = [];
|
|
181
|
+
const emptyBytes = '0x';
|
|
164
182
|
for (const zkProof of zkProofResponses) {
|
|
165
|
-
const
|
|
166
|
-
const
|
|
167
|
-
if (!this._supportedCircuits.includes(
|
|
183
|
+
const { id: requestId, pub_signals: inputs } = zkProof;
|
|
184
|
+
const proofCircuitId = zkProof.circuitId;
|
|
185
|
+
if (!this._supportedCircuits.includes(proofCircuitId)) {
|
|
168
186
|
throw new Error(`Circuit ${zkProof.circuitId} not supported by OnChainZKPVerifier`);
|
|
169
187
|
}
|
|
188
|
+
if (inputs.length === 0) {
|
|
189
|
+
payload.push({
|
|
190
|
+
requestId: requestId,
|
|
191
|
+
zkProof: emptyBytes,
|
|
192
|
+
data: emptyBytes
|
|
193
|
+
});
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
170
196
|
const zkProofEncoded = this.packZkpProof(inputs, zkProof.proof.pi_a.slice(0, 2), [
|
|
171
197
|
[zkProof.proof.pi_b[0][1], zkProof.proof.pi_b[0][0]],
|
|
172
198
|
[zkProof.proof.pi_b[1][1], zkProof.proof.pi_b[1][0]]
|
|
173
199
|
], zkProof.proof.pi_c.slice(0, 2));
|
|
174
|
-
const stateInfo = this.getOnChainGistRootStatePubSignals(
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (gistResolutionPending) {
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
gistUpdateResolutionsPending.push(JSON.stringify(gist));
|
|
182
|
-
gistUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(DID.parseFromId(gist.id), resolverUrl, {
|
|
183
|
-
gist: gist.root
|
|
184
|
-
}));
|
|
185
|
-
}
|
|
186
|
-
const stateUpdateResolutions = [];
|
|
187
|
-
for (const state of stateInfo.states) {
|
|
188
|
-
const stateResolutionPending = stateUpdateResolutionsPending.find((s) => s == JSON.stringify(state));
|
|
189
|
-
if (stateResolutionPending) {
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
stateUpdateResolutionsPending.push(JSON.stringify(state));
|
|
193
|
-
stateUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(DID.parseFromId(state.id), resolverUrl, {
|
|
194
|
-
state: state.state
|
|
195
|
-
}));
|
|
196
|
-
}
|
|
200
|
+
const stateInfo = this.getOnChainGistRootStatePubSignals(proofCircuitId, inputs);
|
|
201
|
+
const chainId = txData.chain_id;
|
|
202
|
+
const gistUpdateResolutions = this.getCrossChainResolvers(stateInfo.gists, chainId, 'gist', resolverUrl);
|
|
203
|
+
const stateUpdateResolutions = this.getCrossChainResolvers(stateInfo.states, chainId, 'state', resolverUrl);
|
|
197
204
|
if (gistUpdateResolutions.length > 0) {
|
|
198
|
-
|
|
205
|
+
gistUpdates.push(...(await Promise.all(gistUpdateResolutions)));
|
|
199
206
|
}
|
|
200
207
|
if (stateUpdateResolutions.length > 0) {
|
|
201
|
-
|
|
208
|
+
stateUpdates.push(...(await Promise.all(stateUpdateResolutions)));
|
|
202
209
|
}
|
|
203
210
|
const metadataArr = [];
|
|
204
211
|
if (zkProof.vp) {
|
|
@@ -214,14 +221,16 @@ export class OnChainZKPVerifier {
|
|
|
214
221
|
});
|
|
215
222
|
}
|
|
216
223
|
}
|
|
217
|
-
const metadata = metadataArr.length ? this.packMetadatas(metadataArr) :
|
|
224
|
+
const metadata = metadataArr.length ? this.packMetadatas(metadataArr) : emptyBytes;
|
|
218
225
|
payload.push({
|
|
219
|
-
requestId:
|
|
226
|
+
requestId: requestId,
|
|
220
227
|
zkProof: zkProofEncoded,
|
|
221
228
|
data: metadata
|
|
222
229
|
});
|
|
223
230
|
}
|
|
224
|
-
const crossChainProofs =
|
|
231
|
+
const crossChainProofs = gistUpdates.length || stateUpdates.length
|
|
232
|
+
? this.packCrossChainProofs(gistUpdates, stateUpdates)
|
|
233
|
+
: emptyBytes;
|
|
225
234
|
return [payload, crossChainProofs];
|
|
226
235
|
}
|
|
227
236
|
async prepareTxArgsSubmitV2(txData, zkProofResponses) {
|
|
@@ -279,18 +288,11 @@ export class OnChainZKPVerifier {
|
|
|
279
288
|
return new ethers.AbiCoder().encode(['tuple(' + 'string key,' + 'bytes value' + ')[]'], [metas]);
|
|
280
289
|
}
|
|
281
290
|
static getOnChainGistRootStatePubSignals(onChainCircuitId, inputs) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
atomicQueryPubSignals = new AtomicQueryMTPV2OnChainPubSignals();
|
|
286
|
-
break;
|
|
287
|
-
case CircuitId.AtomicQuerySigV2OnChain:
|
|
288
|
-
atomicQueryPubSignals = new AtomicQuerySigV2OnChainPubSignals();
|
|
289
|
-
break;
|
|
290
|
-
case CircuitId.AtomicQueryV3OnChain:
|
|
291
|
-
atomicQueryPubSignals = new AtomicQueryV3OnChainPubSignals();
|
|
292
|
-
break;
|
|
291
|
+
const PubSignals = this._supportedCircuitsPubSignalsMap[onChainCircuitId];
|
|
292
|
+
if (!PubSignals) {
|
|
293
|
+
throw new Error(`Circuit ${onChainCircuitId} not supported by OnChainZKPVerifier`);
|
|
293
294
|
}
|
|
295
|
+
const atomicQueryPubSignals = new PubSignals();
|
|
294
296
|
const encodedInputs = byteEncoder.encode(JSON.stringify(inputs));
|
|
295
297
|
atomicQueryPubSignals.pubSignalsUnmarshal(encodedInputs);
|
|
296
298
|
return atomicQueryPubSignals.getStatesInfo();
|
|
@@ -332,7 +334,14 @@ export class OnChainZKPVerifier {
|
|
|
332
334
|
* supported circuits
|
|
333
335
|
*/
|
|
334
336
|
OnChainZKPVerifier._supportedCircuits = [
|
|
337
|
+
CircuitId.AuthV2,
|
|
335
338
|
CircuitId.AtomicQueryMTPV2OnChain,
|
|
336
339
|
CircuitId.AtomicQuerySigV2OnChain,
|
|
337
340
|
CircuitId.AtomicQueryV3OnChain
|
|
338
341
|
];
|
|
342
|
+
OnChainZKPVerifier._supportedCircuitsPubSignalsMap = {
|
|
343
|
+
[CircuitId.AtomicQueryMTPV2OnChain]: AtomicQueryMTPV2OnChainPubSignals,
|
|
344
|
+
[CircuitId.AtomicQuerySigV2OnChain]: AtomicQuerySigV2OnChainPubSignals,
|
|
345
|
+
[CircuitId.AtomicQueryV3OnChain]: AtomicQueryV3OnChainPubSignals,
|
|
346
|
+
[CircuitId.AuthV2]: AuthV2PubSignals
|
|
347
|
+
};
|
|
@@ -97,9 +97,14 @@ export const resolveDidDocument = async (did, resolverUrl, opts) => {
|
|
|
97
97
|
if (opts?.gist) {
|
|
98
98
|
url += `${url.includes('?') ? '&' : '?'}gist=${opts.gist.hex()}`;
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
try {
|
|
101
|
+
const resp = await fetch(url);
|
|
102
|
+
const data = await resp.json();
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
throw new Error(`Failed to resolve DID document for ${did} ${e}`);
|
|
107
|
+
}
|
|
103
108
|
};
|
|
104
109
|
export const buildDIDFromEthPubKey = (didType, pubKeyEth) => {
|
|
105
110
|
// Use Keccak-256 hash function to get public key hash
|
|
@@ -146,6 +146,7 @@ export var SupportedPaymentProofType;
|
|
|
146
146
|
/**
|
|
147
147
|
* Media types for Payment supported currencies
|
|
148
148
|
* @beta
|
|
149
|
+
* @deprecated
|
|
149
150
|
* @enum {string}
|
|
150
151
|
*/
|
|
151
152
|
export var SupportedCurrencies;
|
|
@@ -155,8 +156,6 @@ export var SupportedCurrencies;
|
|
|
155
156
|
SupportedCurrencies["ETH_GWEI"] = "ETHGWEI";
|
|
156
157
|
SupportedCurrencies["MATIC"] = "MATIC";
|
|
157
158
|
SupportedCurrencies["POL"] = "POL";
|
|
158
|
-
SupportedCurrencies["USDT"] = "USDT";
|
|
159
|
-
SupportedCurrencies["USDC"] = "USDC";
|
|
160
159
|
})(SupportedCurrencies || (SupportedCurrencies = {}));
|
|
161
160
|
/**
|
|
162
161
|
* Supported features for payment-request
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hash, Proof } from '@iden3/js-merkletree';
|
|
2
2
|
import { Claim, Id } from '@iden3/js-iden3-core';
|
|
3
3
|
import { GISTProof, TreeState } from './models';
|
|
4
|
-
import { BaseConfig } from './common';
|
|
4
|
+
import { BaseConfig, IStateInfoPubSignals, StatesInfo } from './common';
|
|
5
5
|
import { Signature } from '@iden3/js-crypto';
|
|
6
6
|
/**
|
|
7
7
|
* Auth v2 circuit representation
|
|
@@ -30,7 +30,7 @@ export declare class AuthV2Inputs extends BaseConfig {
|
|
|
30
30
|
* @public
|
|
31
31
|
* @class AuthV2PubSignals
|
|
32
32
|
*/
|
|
33
|
-
export declare class AuthV2PubSignals {
|
|
33
|
+
export declare class AuthV2PubSignals implements IStateInfoPubSignals {
|
|
34
34
|
userID: Id;
|
|
35
35
|
challenge: bigint;
|
|
36
36
|
GISTRoot: Hash;
|
|
@@ -41,4 +41,5 @@ export declare class AuthV2PubSignals {
|
|
|
41
41
|
* @returns AuthV2PubSignals
|
|
42
42
|
*/
|
|
43
43
|
pubSignalsUnmarshal(data: Uint8Array): AuthV2PubSignals;
|
|
44
|
+
getStatesInfo(): StatesInfo;
|
|
44
45
|
}
|
|
@@ -2,7 +2,6 @@ import { BasicMessage, IPackageManager, PackerParams } from '../types';
|
|
|
2
2
|
import { DID } from '@iden3/js-iden3-core';
|
|
3
3
|
import { AbstractMessageHandler, BasicHandlerOptions, IProtocolMessageHandler } from './message-handler';
|
|
4
4
|
import { Iden3PaymentRailsERC20RequestV1, Iden3PaymentRailsRequestV1, MultiChainPaymentConfig, PaymentMessage, PaymentRequestInfo, PaymentRequestMessage, PaymentRequestTypeUnion, PaymentTypeUnion } from '../types/protocol/payment';
|
|
5
|
-
import { PaymentFeatures, PaymentRequestDataType, SupportedCurrencies } from '../../verifiable';
|
|
6
5
|
import { Signer } from 'ethers';
|
|
7
6
|
import { Resolvable } from 'did-resolver';
|
|
8
7
|
/** @beta PaymentRequestCreationOptions represents payment-request creation options */
|
|
@@ -24,7 +23,6 @@ export type PaymentCreationOptions = {
|
|
|
24
23
|
*/
|
|
25
24
|
export declare function createPaymentRequest(sender: DID, receiver: DID, agent: string, payments: PaymentRequestInfo[], opts?: PaymentRequestCreationOptions): PaymentRequestMessage;
|
|
26
25
|
export declare function verifyEIP712TypedData(data: Iden3PaymentRailsRequestV1 | Iden3PaymentRailsERC20RequestV1, resolver: Resolvable): Promise<string>;
|
|
27
|
-
export declare function convertPaymentAmount(amount: string, currency: SupportedCurrencies): Promise<bigint>;
|
|
28
26
|
/**
|
|
29
27
|
* @beta
|
|
30
28
|
* PaymentRailsInfo represents payment info for payment rails
|
|
@@ -35,20 +33,18 @@ export type PaymentRailsInfo = {
|
|
|
35
33
|
context: string;
|
|
36
34
|
}[];
|
|
37
35
|
description?: string;
|
|
38
|
-
|
|
36
|
+
options: PaymentRailsOptionInfo[];
|
|
39
37
|
};
|
|
40
38
|
/**
|
|
41
39
|
* @beta
|
|
42
|
-
*
|
|
40
|
+
* PaymentRailsOptionInfo represents option info for payment rails
|
|
43
41
|
*/
|
|
44
|
-
export type
|
|
42
|
+
export type PaymentRailsOptionInfo = {
|
|
43
|
+
optionId: string;
|
|
44
|
+
chainId: string;
|
|
45
45
|
nonce: bigint;
|
|
46
46
|
amount: string;
|
|
47
|
-
currency: SupportedCurrencies | string;
|
|
48
|
-
chainId: string;
|
|
49
47
|
expirationDate?: Date;
|
|
50
|
-
features?: PaymentFeatures[];
|
|
51
|
-
type: PaymentRequestDataType.Iden3PaymentRailsRequestV1 | PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1;
|
|
52
48
|
};
|
|
53
49
|
/**
|
|
54
50
|
* @beta
|
|
@@ -36,7 +36,6 @@ export type Iden3PaymentRailsRequestV1 = {
|
|
|
36
36
|
'@context': string | (string | object)[];
|
|
37
37
|
recipient: string;
|
|
38
38
|
amount: string;
|
|
39
|
-
currency: SupportedCurrencies | string;
|
|
40
39
|
expirationDate: string;
|
|
41
40
|
nonce: string;
|
|
42
41
|
metadata: string;
|
|
@@ -106,11 +105,13 @@ export type Iden3PaymentRailsERC20V1 = {
|
|
|
106
105
|
/** @beta MultiChainPaymentConfig is struct that represents payments contracts information for different chains */
|
|
107
106
|
export type MultiChainPaymentConfig = {
|
|
108
107
|
chainId: string;
|
|
109
|
-
|
|
108
|
+
paymentRails: string;
|
|
110
109
|
recipient: string;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
options: {
|
|
111
|
+
id: string;
|
|
112
|
+
type: PaymentRequestDataType.Iden3PaymentRailsRequestV1 | PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1;
|
|
113
|
+
contractAddress?: string;
|
|
114
|
+
features?: PaymentFeatures[];
|
|
114
115
|
}[];
|
|
115
116
|
};
|
|
116
117
|
/**
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CircuitId } from '../../circuits';
|
|
2
|
+
import { DID } from '@iden3/js-iden3-core';
|
|
3
|
+
import { IProofService } from '../../proof';
|
|
4
|
+
import { ZeroKnowledgeProofResponse } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* @beta
|
|
7
|
+
* Retrieves the request ID from circuit string.
|
|
8
|
+
* CircuitId.AuthV2 - 940499666
|
|
9
|
+
* @returns The request ID.
|
|
10
|
+
*/
|
|
11
|
+
export declare function calculateRequestIdForCircuit(circuitId: CircuitId): number;
|
|
12
|
+
/**
|
|
13
|
+
* Prepares the zero-knowledge proof response for the AuthV2 circuit.
|
|
14
|
+
* @beta
|
|
15
|
+
* @param address - The address associated with the request.
|
|
16
|
+
* @param senderDid - The sender's decentralized identifier (DID).
|
|
17
|
+
* @param proofService - The proof service used to generate the proof.
|
|
18
|
+
* @returns A promise that resolves to an array of ZeroKnowledgeProofResponse objects.
|
|
19
|
+
*/
|
|
20
|
+
export declare function prepareAuthV2ZeroKnowledgeResponse(address: string, senderDid: DID, proofService: IProofService): Promise<ZeroKnowledgeProofResponse[]>;
|
|
@@ -73,6 +73,14 @@ export interface IProofService {
|
|
|
73
73
|
* @returns `Promise<Uint8Array>`
|
|
74
74
|
*/
|
|
75
75
|
generateAuthV2Inputs(hash: Uint8Array, did: DID, circuitId: CircuitId): Promise<Uint8Array>;
|
|
76
|
+
/**
|
|
77
|
+
* generates auth inputs
|
|
78
|
+
*
|
|
79
|
+
* @param {Uint8Array} hash - challenge that will be signed
|
|
80
|
+
* @param {DID} did - identity that will generate a proof
|
|
81
|
+
* @returns `Promise<ZKProof>`
|
|
82
|
+
*/
|
|
83
|
+
generateAuthV2Proof(hash: Uint8Array, did: DID): Promise<ZKProof>;
|
|
76
84
|
/**
|
|
77
85
|
* state verification function
|
|
78
86
|
*
|
|
@@ -138,6 +146,8 @@ export declare class ProofService implements IProofService {
|
|
|
138
146
|
private loadLdContext;
|
|
139
147
|
/** {@inheritdoc IProofService.generateAuthV2Inputs} */
|
|
140
148
|
generateAuthV2Inputs(hash: Uint8Array, did: DID, circuitId: CircuitId): Promise<Uint8Array>;
|
|
149
|
+
/** {@inheritdoc IProofService.generateAuthV2Proof} */
|
|
150
|
+
generateAuthV2Proof(challenge: Uint8Array, did: DID): Promise<ZKProof>;
|
|
141
151
|
verifyState(circuitId: string, pubSignals: string[], opts?: StateVerificationOpts): Promise<boolean>;
|
|
142
152
|
findCredentialByProofQuery(did: DID, query: ProofQuery): Promise<{
|
|
143
153
|
cred: W3CCredential;
|
|
@@ -35,6 +35,7 @@ export declare class OnChainZKPVerifier implements IOnChainZKPVerifier {
|
|
|
35
35
|
* supported circuits
|
|
36
36
|
*/
|
|
37
37
|
private static readonly _supportedCircuits;
|
|
38
|
+
private static readonly _supportedCircuitsPubSignalsMap;
|
|
38
39
|
/**
|
|
39
40
|
*
|
|
40
41
|
* Creates an instance of OnChainZKPVerifier.
|
|
@@ -55,6 +56,7 @@ export declare class OnChainZKPVerifier implements IOnChainZKPVerifier {
|
|
|
55
56
|
* {@inheritDoc IOnChainZKPVerifier.submitZKPResponseV2}
|
|
56
57
|
*/
|
|
57
58
|
submitZKPResponseV2(ethSigner: Signer, txData: ContractInvokeTransactionData, zkProofResponses: ZeroKnowledgeProofResponse[]): Promise<Map<string, ZeroKnowledgeProofResponse[]>>;
|
|
59
|
+
private static getCrossChainResolvers;
|
|
58
60
|
static prepareTxArgsSubmitV2(resolverUrl: string, txData: ContractInvokeTransactionData, zkProofResponses: ZeroKnowledgeProofResponse[]): Promise<JsonDocumentObjectValue[]>;
|
|
59
61
|
prepareTxArgsSubmitV2(txData: ContractInvokeTransactionData, zkProofResponses: ZeroKnowledgeProofResponse[]): Promise<JsonDocumentObjectValue[]>;
|
|
60
62
|
private static packZkpProof;
|
|
@@ -117,6 +117,7 @@ export declare enum SupportedPaymentProofType {
|
|
|
117
117
|
/**
|
|
118
118
|
* Media types for Payment supported currencies
|
|
119
119
|
* @beta
|
|
120
|
+
* @deprecated
|
|
120
121
|
* @enum {string}
|
|
121
122
|
*/
|
|
122
123
|
export declare enum SupportedCurrencies {
|
|
@@ -124,9 +125,7 @@ export declare enum SupportedCurrencies {
|
|
|
124
125
|
ETH_WEI = "ETHWEI",
|
|
125
126
|
ETH_GWEI = "ETHGWEI",
|
|
126
127
|
MATIC = "MATIC",
|
|
127
|
-
POL = "POL"
|
|
128
|
-
USDT = "USDT",
|
|
129
|
-
USDC = "USDC"
|
|
128
|
+
POL = "POL"
|
|
130
129
|
}
|
|
131
130
|
/**
|
|
132
131
|
* Supported features for payment-request
|