@0xpolygonid/js-sdk 1.29.2 → 1.29.4
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 +9 -19
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +9 -19
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/iden3comm/handlers/common.js +1 -18
- package/dist/node/cjs/iden3comm/handlers/contract-request.js +8 -1
- package/dist/node/esm/iden3comm/handlers/common.js +3 -20
- package/dist/node/esm/iden3comm/handlers/contract-request.js +8 -1
- package/dist/types/iden3comm/types/protocol/contract-request.d.ts +1 -0
- package/package.json +1 -1
|
@@ -112,9 +112,6 @@ const processProofAuth = async (to, proofService, opts) => {
|
|
|
112
112
|
if (!opts.senderAddress) {
|
|
113
113
|
throw new Error('Sender address is not provided');
|
|
114
114
|
}
|
|
115
|
-
if (!opts.zkpResponses || opts.zkpResponses.length === 0) {
|
|
116
|
-
throw new Error('ZKP responses are not provided');
|
|
117
|
-
}
|
|
118
115
|
const challengeAuth = (0, exports.calcChallengeAuthV2)(opts.senderAddress, opts.zkpResponses);
|
|
119
116
|
const zkpRes = await proofService.generateAuthProof(circuitId, to, { challenge: challengeAuth });
|
|
120
117
|
return {
|
|
@@ -157,21 +154,7 @@ const processProofResponse = (zkProof) => {
|
|
|
157
154
|
}
|
|
158
155
|
const preparedZkpProof = (0, common_1.prepareZkpProof)(zkProof.proof);
|
|
159
156
|
const zkProofEncoded = (0, common_1.packZkpProof)(inputs, preparedZkpProof.a, preparedZkpProof.b, preparedZkpProof.c);
|
|
160
|
-
const
|
|
161
|
-
if (zkProof.vp) {
|
|
162
|
-
for (const key in zkProof.vp.verifiableCredential.credentialSubject) {
|
|
163
|
-
if (key === '@type') {
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
const metadataValue = js_crypto_1.poseidon.hashBytes(utils_1.byteEncoder.encode(JSON.stringify(zkProof.vp.verifiableCredential.credentialSubject[key])));
|
|
167
|
-
const bytesValue = utils_1.byteEncoder.encode(metadataValue.toString());
|
|
168
|
-
metadataArr.push({
|
|
169
|
-
key,
|
|
170
|
-
value: bytesValue
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
const metadata = metadataArr.length ? (0, exports.packMetadatas)(metadataArr) : emptyBytes;
|
|
157
|
+
const metadata = emptyBytes;
|
|
175
158
|
return { requestId, zkProofEncoded, metadata };
|
|
176
159
|
};
|
|
177
160
|
exports.processProofResponse = processProofResponse;
|
|
@@ -83,6 +83,8 @@ class ContractRequestHandler extends message_handler_1.AbstractMessageHandler {
|
|
|
83
83
|
for (const [txHash, zkpResponses] of txHashZkpResponsesMap) {
|
|
84
84
|
response.set(txHash, { responses: zkpResponses });
|
|
85
85
|
}
|
|
86
|
+
// set txHash of the first response
|
|
87
|
+
message.body.transaction_data.txHash = txHashZkpResponsesMap.keys().next().value;
|
|
86
88
|
return response;
|
|
87
89
|
}
|
|
88
90
|
case storage_1.FunctionSignatures.SubmitZKPResponseV1: {
|
|
@@ -91,6 +93,8 @@ class ContractRequestHandler extends message_handler_1.AbstractMessageHandler {
|
|
|
91
93
|
for (const [txHash, zkpResponse] of txHashZkpResponseMap) {
|
|
92
94
|
response.set(txHash, { responses: [zkpResponse] });
|
|
93
95
|
}
|
|
96
|
+
// set txHash of the first response
|
|
97
|
+
message.body.transaction_data.txHash = txHashZkpResponseMap.keys().next().value;
|
|
94
98
|
return response;
|
|
95
99
|
}
|
|
96
100
|
case storage_1.FunctionSignatures.SubmitResponse: {
|
|
@@ -110,7 +114,10 @@ class ContractRequestHandler extends message_handler_1.AbstractMessageHandler {
|
|
|
110
114
|
senderAddress: await ethSigner.getAddress(),
|
|
111
115
|
zkpResponses: zkpResponses
|
|
112
116
|
});
|
|
113
|
-
return
|
|
117
|
+
// we return txHash because responsesMap could be empty if there are no queries in scope
|
|
118
|
+
const txHashZkpResponsesMap = await this._zkpVerifier.submitResponse(ethSigner, message.body.transaction_data, zkpResponses, authProof);
|
|
119
|
+
message.body.transaction_data.txHash = txHashZkpResponsesMap.keys().next().value;
|
|
120
|
+
return txHashZkpResponsesMap;
|
|
114
121
|
}
|
|
115
122
|
default:
|
|
116
123
|
throw new Error(`Not supported method id. Only '${storage_1.FunctionSignatures.SubmitZKPResponseV1}, ${storage_1.FunctionSignatures.SubmitZKPResponseV2} and ${storage_1.FunctionSignatures.SubmitResponse} are supported.'`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getRandomBytes
|
|
1
|
+
import { getRandomBytes } from '@iden3/js-crypto';
|
|
2
2
|
import { AuthMethod } from '../types';
|
|
3
|
-
import {
|
|
3
|
+
import { mergeObjects } from '../../utils';
|
|
4
4
|
import { getUnixTimestamp } from '@iden3/js-iden3-core';
|
|
5
5
|
import { AcceptJwsAlgorithms, defaultAcceptProfile, MediaType } from '../constants';
|
|
6
6
|
import { ethers } from 'ethers';
|
|
@@ -108,9 +108,6 @@ export const processProofAuth = async (to, proofService, opts) => {
|
|
|
108
108
|
if (!opts.senderAddress) {
|
|
109
109
|
throw new Error('Sender address is not provided');
|
|
110
110
|
}
|
|
111
|
-
if (!opts.zkpResponses || opts.zkpResponses.length === 0) {
|
|
112
|
-
throw new Error('ZKP responses are not provided');
|
|
113
|
-
}
|
|
114
111
|
const challengeAuth = calcChallengeAuthV2(opts.senderAddress, opts.zkpResponses);
|
|
115
112
|
const zkpRes = await proofService.generateAuthProof(circuitId, to, { challenge: challengeAuth });
|
|
116
113
|
return {
|
|
@@ -152,21 +149,7 @@ export const processProofResponse = (zkProof) => {
|
|
|
152
149
|
}
|
|
153
150
|
const preparedZkpProof = prepareZkpProof(zkProof.proof);
|
|
154
151
|
const zkProofEncoded = packZkpProof(inputs, preparedZkpProof.a, preparedZkpProof.b, preparedZkpProof.c);
|
|
155
|
-
const
|
|
156
|
-
if (zkProof.vp) {
|
|
157
|
-
for (const key in zkProof.vp.verifiableCredential.credentialSubject) {
|
|
158
|
-
if (key === '@type') {
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
const metadataValue = poseidon.hashBytes(byteEncoder.encode(JSON.stringify(zkProof.vp.verifiableCredential.credentialSubject[key])));
|
|
162
|
-
const bytesValue = byteEncoder.encode(metadataValue.toString());
|
|
163
|
-
metadataArr.push({
|
|
164
|
-
key,
|
|
165
|
-
value: bytesValue
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
const metadata = metadataArr.length ? packMetadatas(metadataArr) : emptyBytes;
|
|
152
|
+
const metadata = emptyBytes;
|
|
170
153
|
return { requestId, zkProofEncoded, metadata };
|
|
171
154
|
};
|
|
172
155
|
/**
|
|
@@ -80,6 +80,8 @@ export class ContractRequestHandler extends AbstractMessageHandler {
|
|
|
80
80
|
for (const [txHash, zkpResponses] of txHashZkpResponsesMap) {
|
|
81
81
|
response.set(txHash, { responses: zkpResponses });
|
|
82
82
|
}
|
|
83
|
+
// set txHash of the first response
|
|
84
|
+
message.body.transaction_data.txHash = txHashZkpResponsesMap.keys().next().value;
|
|
83
85
|
return response;
|
|
84
86
|
}
|
|
85
87
|
case FunctionSignatures.SubmitZKPResponseV1: {
|
|
@@ -88,6 +90,8 @@ export class ContractRequestHandler extends AbstractMessageHandler {
|
|
|
88
90
|
for (const [txHash, zkpResponse] of txHashZkpResponseMap) {
|
|
89
91
|
response.set(txHash, { responses: [zkpResponse] });
|
|
90
92
|
}
|
|
93
|
+
// set txHash of the first response
|
|
94
|
+
message.body.transaction_data.txHash = txHashZkpResponseMap.keys().next().value;
|
|
91
95
|
return response;
|
|
92
96
|
}
|
|
93
97
|
case FunctionSignatures.SubmitResponse: {
|
|
@@ -107,7 +111,10 @@ export class ContractRequestHandler extends AbstractMessageHandler {
|
|
|
107
111
|
senderAddress: await ethSigner.getAddress(),
|
|
108
112
|
zkpResponses: zkpResponses
|
|
109
113
|
});
|
|
110
|
-
return
|
|
114
|
+
// we return txHash because responsesMap could be empty if there are no queries in scope
|
|
115
|
+
const txHashZkpResponsesMap = await this._zkpVerifier.submitResponse(ethSigner, message.body.transaction_data, zkpResponses, authProof);
|
|
116
|
+
message.body.transaction_data.txHash = txHashZkpResponsesMap.keys().next().value;
|
|
117
|
+
return txHashZkpResponsesMap;
|
|
111
118
|
}
|
|
112
119
|
default:
|
|
113
120
|
throw new Error(`Not supported method id. Only '${FunctionSignatures.SubmitZKPResponseV1}, ${FunctionSignatures.SubmitZKPResponseV2} and ${FunctionSignatures.SubmitResponse} are supported.'`);
|