@zkproofport-app/sdk 0.2.6 → 0.2.7
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 +90 -3
- package/dist/ProofportSDK.d.ts +19 -0
- package/dist/constants.d.ts +7 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +61 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +61 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -4
- package/dist/index.mjs.map +1 -1
- package/dist/verifier.d.ts +17 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -231,14 +231,18 @@ const COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT = {
|
|
|
231
231
|
const OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT = {
|
|
232
232
|
PUBKEY_MODULUS_START: 0,
|
|
233
233
|
PUBKEY_MODULUS_END: 17,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
DOMAIN_STORAGE_START: 18,
|
|
235
|
+
DOMAIN_STORAGE_END: 81,
|
|
236
|
+
DOMAIN_LEN: 82,
|
|
237
237
|
SCOPE_START: 83,
|
|
238
238
|
SCOPE_END: 114,
|
|
239
239
|
NULLIFIER_START: 115,
|
|
240
240
|
NULLIFIER_END: 146,
|
|
241
241
|
PROVIDER: 147,
|
|
242
|
+
/** @deprecated Use DOMAIN_STORAGE_START */
|
|
243
|
+
DOMAIN_START: 18,
|
|
244
|
+
/** @deprecated Use DOMAIN_LEN */
|
|
245
|
+
DOMAIN_END: 82,
|
|
242
246
|
};
|
|
243
247
|
|
|
244
248
|
/**
|
|
@@ -1018,6 +1022,38 @@ function extractNullifierFromPublicInputs(publicInputsHex, circuit) {
|
|
|
1018
1022
|
const nullifierFields = publicInputsHex.slice(start, end + 1);
|
|
1019
1023
|
return reconstructBytes32FromFields(nullifierFields);
|
|
1020
1024
|
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Extract domain string from OIDC Domain Attestation public inputs.
|
|
1027
|
+
*
|
|
1028
|
+
* The domain is stored as a Noir BoundedVec<u8, 64>, which serializes as
|
|
1029
|
+
* [storage[0..64], len]. Each storage element is a u8 value in a field element.
|
|
1030
|
+
*
|
|
1031
|
+
* @param publicInputsHex - Array of public input hex strings
|
|
1032
|
+
* @param circuit - Circuit identifier (must be 'oidc_domain_attestation')
|
|
1033
|
+
* @returns Domain as ASCII string, or null if circuit doesn't match or inputs are insufficient
|
|
1034
|
+
*
|
|
1035
|
+
* @example
|
|
1036
|
+
* ```typescript
|
|
1037
|
+
* const domain = extractDomainFromPublicInputs(publicInputs, 'oidc_domain_attestation');
|
|
1038
|
+
* console.log(domain); // 'example.com'
|
|
1039
|
+
* ```
|
|
1040
|
+
*/
|
|
1041
|
+
function extractDomainFromPublicInputs(publicInputsHex, circuit) {
|
|
1042
|
+
if (circuit !== 'oidc_domain_attestation')
|
|
1043
|
+
return null;
|
|
1044
|
+
const layout = OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT;
|
|
1045
|
+
if (publicInputsHex.length <= layout.DOMAIN_LEN)
|
|
1046
|
+
return null;
|
|
1047
|
+
const len = Number(BigInt(publicInputsHex[layout.DOMAIN_LEN]) & 0xffn);
|
|
1048
|
+
if (len === 0 || len > 64)
|
|
1049
|
+
return null;
|
|
1050
|
+
const storageFields = publicInputsHex.slice(layout.DOMAIN_STORAGE_START, layout.DOMAIN_STORAGE_START + len);
|
|
1051
|
+
const chars = storageFields.map(f => {
|
|
1052
|
+
const byte = Number(BigInt(f) & 0xffn);
|
|
1053
|
+
return String.fromCharCode(byte);
|
|
1054
|
+
});
|
|
1055
|
+
return chars.join('');
|
|
1056
|
+
}
|
|
1021
1057
|
/** @internal Reconstruct a bytes32 value from 32 individual field elements */
|
|
1022
1058
|
function reconstructBytes32FromFields(fields) {
|
|
1023
1059
|
if (fields.length !== 32) {
|
|
@@ -2195,6 +2231,27 @@ class ProofportSDK {
|
|
|
2195
2231
|
extractNullifier(publicInputs, circuit) {
|
|
2196
2232
|
return extractNullifierFromPublicInputs(publicInputs, circuit);
|
|
2197
2233
|
}
|
|
2234
|
+
/**
|
|
2235
|
+
* Extracts the domain string from OIDC Domain Attestation proof public inputs.
|
|
2236
|
+
*
|
|
2237
|
+
* Only works with 'oidc_domain_attestation' circuit. Returns null for other circuits.
|
|
2238
|
+
*
|
|
2239
|
+
* @param publicInputs - Array of hex-encoded field elements from proof result
|
|
2240
|
+
* @param circuit - Circuit type that produced the public inputs
|
|
2241
|
+
* @returns Domain as ASCII string (e.g., 'example.com'), or null if not applicable
|
|
2242
|
+
*
|
|
2243
|
+
* @example
|
|
2244
|
+
* ```typescript
|
|
2245
|
+
* const result = await sdk.waitForProof(relay.requestId);
|
|
2246
|
+
* if (result.status === 'completed') {
|
|
2247
|
+
* const domain = sdk.extractDomain(result.publicInputs, result.circuit);
|
|
2248
|
+
* console.log('Domain:', domain); // 'example.com'
|
|
2249
|
+
* }
|
|
2250
|
+
* ```
|
|
2251
|
+
*/
|
|
2252
|
+
extractDomain(publicInputs, circuit) {
|
|
2253
|
+
return extractDomainFromPublicInputs(publicInputs, circuit);
|
|
2254
|
+
}
|
|
2198
2255
|
}
|
|
2199
2256
|
/**
|
|
2200
2257
|
* Creates a proof request through the relay server.
|
|
@@ -2238,6 +2295,7 @@ exports.COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT = COINBASE_COUNTRY_PUBLIC_INPUT_LAY
|
|
|
2238
2295
|
exports.OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT = OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT;
|
|
2239
2296
|
exports.ProofportSDK = ProofportSDK;
|
|
2240
2297
|
exports.default = ProofportSDK;
|
|
2298
|
+
exports.extractDomainFromPublicInputs = extractDomainFromPublicInputs;
|
|
2241
2299
|
exports.extractNullifierFromPublicInputs = extractNullifierFromPublicInputs;
|
|
2242
2300
|
exports.extractScopeFromPublicInputs = extractScopeFromPublicInputs;
|
|
2243
2301
|
//# sourceMappingURL=index.js.map
|