@zkproofport-app/sdk 0.2.5 → 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 +21 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +81 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +81 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -21
- package/dist/index.mjs.map +1 -1
- package/dist/verifier.d.ts +17 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -70,8 +70,8 @@ const CIRCUIT_METADATA = {
|
|
|
70
70
|
oidc_domain_attestation: {
|
|
71
71
|
name: 'OIDC Domain',
|
|
72
72
|
description: 'Prove email domain affiliation via OIDC JWT',
|
|
73
|
-
publicInputsCount:
|
|
74
|
-
publicInputNames: ['pubkey_modulus_limbs', 'domain', 'scope', 'nullifier'],
|
|
73
|
+
publicInputsCount: 148,
|
|
74
|
+
publicInputNames: ['pubkey_modulus_limbs', 'domain', 'scope', 'nullifier', 'provider'],
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
77
|
/**
|
|
@@ -205,14 +205,15 @@ const COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT = {
|
|
|
205
205
|
NULLIFIER_END: 149,
|
|
206
206
|
};
|
|
207
207
|
/**
|
|
208
|
-
* OIDC Domain Attestation circuit public input layout (
|
|
209
|
-
* Defines the
|
|
208
|
+
* OIDC Domain Attestation circuit public input layout (field offsets).
|
|
209
|
+
* Defines the field positions in the flattened public inputs array (148 fields total).
|
|
210
210
|
*
|
|
211
|
-
*
|
|
212
|
-
* - pubkey_modulus_limbs:
|
|
213
|
-
* - domain
|
|
214
|
-
* - scope: 32
|
|
215
|
-
* - nullifier: 32
|
|
211
|
+
* Circuit public inputs (from main.nr):
|
|
212
|
+
* - pubkey_modulus_limbs: pub [u128; 18] → 18 fields (0–17)
|
|
213
|
+
* - domain: pub BoundedVec<u8, 64> → 1 len + 64 storage = 65 fields (18–82)
|
|
214
|
+
* - scope: pub [u8; 32] → 32 fields (83–114)
|
|
215
|
+
* - nullifier: pub [u8; 32] → 32 fields (115–146)
|
|
216
|
+
* - provider: pub u8 → 1 field (147)
|
|
216
217
|
*
|
|
217
218
|
* @example
|
|
218
219
|
* ```typescript
|
|
@@ -224,13 +225,19 @@ const COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT = {
|
|
|
224
225
|
*/
|
|
225
226
|
const OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT = {
|
|
226
227
|
PUBKEY_MODULUS_START: 0,
|
|
227
|
-
PUBKEY_MODULUS_END:
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
228
|
+
PUBKEY_MODULUS_END: 17,
|
|
229
|
+
DOMAIN_STORAGE_START: 18,
|
|
230
|
+
DOMAIN_STORAGE_END: 81,
|
|
231
|
+
DOMAIN_LEN: 82,
|
|
232
|
+
SCOPE_START: 83,
|
|
233
|
+
SCOPE_END: 114,
|
|
234
|
+
NULLIFIER_START: 115,
|
|
235
|
+
NULLIFIER_END: 146,
|
|
236
|
+
PROVIDER: 147,
|
|
237
|
+
/** @deprecated Use DOMAIN_STORAGE_START */
|
|
238
|
+
DOMAIN_START: 18,
|
|
239
|
+
/** @deprecated Use DOMAIN_LEN */
|
|
240
|
+
DOMAIN_END: 82,
|
|
234
241
|
};
|
|
235
242
|
|
|
236
243
|
/**
|
|
@@ -3828,8 +3835,8 @@ function extractScopeFromPublicInputs(publicInputsHex, circuit) {
|
|
|
3828
3835
|
end = 117;
|
|
3829
3836
|
}
|
|
3830
3837
|
else if (circuit === 'oidc_domain_attestation') {
|
|
3831
|
-
start =
|
|
3832
|
-
end =
|
|
3838
|
+
start = 83;
|
|
3839
|
+
end = 114;
|
|
3833
3840
|
}
|
|
3834
3841
|
else {
|
|
3835
3842
|
start = 64;
|
|
@@ -3865,8 +3872,8 @@ function extractNullifierFromPublicInputs(publicInputsHex, circuit) {
|
|
|
3865
3872
|
end = 149;
|
|
3866
3873
|
}
|
|
3867
3874
|
else if (circuit === 'oidc_domain_attestation') {
|
|
3868
|
-
start =
|
|
3869
|
-
end =
|
|
3875
|
+
start = 115;
|
|
3876
|
+
end = 146;
|
|
3870
3877
|
}
|
|
3871
3878
|
else {
|
|
3872
3879
|
start = 96;
|
|
@@ -3877,6 +3884,38 @@ function extractNullifierFromPublicInputs(publicInputsHex, circuit) {
|
|
|
3877
3884
|
const nullifierFields = publicInputsHex.slice(start, end + 1);
|
|
3878
3885
|
return reconstructBytes32FromFields(nullifierFields);
|
|
3879
3886
|
}
|
|
3887
|
+
/**
|
|
3888
|
+
* Extract domain string from OIDC Domain Attestation public inputs.
|
|
3889
|
+
*
|
|
3890
|
+
* The domain is stored as a Noir BoundedVec<u8, 64>, which serializes as
|
|
3891
|
+
* [storage[0..64], len]. Each storage element is a u8 value in a field element.
|
|
3892
|
+
*
|
|
3893
|
+
* @param publicInputsHex - Array of public input hex strings
|
|
3894
|
+
* @param circuit - Circuit identifier (must be 'oidc_domain_attestation')
|
|
3895
|
+
* @returns Domain as ASCII string, or null if circuit doesn't match or inputs are insufficient
|
|
3896
|
+
*
|
|
3897
|
+
* @example
|
|
3898
|
+
* ```typescript
|
|
3899
|
+
* const domain = extractDomainFromPublicInputs(publicInputs, 'oidc_domain_attestation');
|
|
3900
|
+
* console.log(domain); // 'example.com'
|
|
3901
|
+
* ```
|
|
3902
|
+
*/
|
|
3903
|
+
function extractDomainFromPublicInputs(publicInputsHex, circuit) {
|
|
3904
|
+
if (circuit !== 'oidc_domain_attestation')
|
|
3905
|
+
return null;
|
|
3906
|
+
const layout = OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT;
|
|
3907
|
+
if (publicInputsHex.length <= layout.DOMAIN_LEN)
|
|
3908
|
+
return null;
|
|
3909
|
+
const len = Number(BigInt(publicInputsHex[layout.DOMAIN_LEN]) & 0xffn);
|
|
3910
|
+
if (len === 0 || len > 64)
|
|
3911
|
+
return null;
|
|
3912
|
+
const storageFields = publicInputsHex.slice(layout.DOMAIN_STORAGE_START, layout.DOMAIN_STORAGE_START + len);
|
|
3913
|
+
const chars = storageFields.map(f => {
|
|
3914
|
+
const byte = Number(BigInt(f) & 0xffn);
|
|
3915
|
+
return String.fromCharCode(byte);
|
|
3916
|
+
});
|
|
3917
|
+
return chars.join('');
|
|
3918
|
+
}
|
|
3880
3919
|
/** @internal Reconstruct a bytes32 value from 32 individual field elements */
|
|
3881
3920
|
function reconstructBytes32FromFields(fields) {
|
|
3882
3921
|
if (fields.length !== 32) {
|
|
@@ -5054,6 +5093,27 @@ class ProofportSDK {
|
|
|
5054
5093
|
extractNullifier(publicInputs, circuit) {
|
|
5055
5094
|
return extractNullifierFromPublicInputs(publicInputs, circuit);
|
|
5056
5095
|
}
|
|
5096
|
+
/**
|
|
5097
|
+
* Extracts the domain string from OIDC Domain Attestation proof public inputs.
|
|
5098
|
+
*
|
|
5099
|
+
* Only works with 'oidc_domain_attestation' circuit. Returns null for other circuits.
|
|
5100
|
+
*
|
|
5101
|
+
* @param publicInputs - Array of hex-encoded field elements from proof result
|
|
5102
|
+
* @param circuit - Circuit type that produced the public inputs
|
|
5103
|
+
* @returns Domain as ASCII string (e.g., 'example.com'), or null if not applicable
|
|
5104
|
+
*
|
|
5105
|
+
* @example
|
|
5106
|
+
* ```typescript
|
|
5107
|
+
* const result = await sdk.waitForProof(relay.requestId);
|
|
5108
|
+
* if (result.status === 'completed') {
|
|
5109
|
+
* const domain = sdk.extractDomain(result.publicInputs, result.circuit);
|
|
5110
|
+
* console.log('Domain:', domain); // 'example.com'
|
|
5111
|
+
* }
|
|
5112
|
+
* ```
|
|
5113
|
+
*/
|
|
5114
|
+
extractDomain(publicInputs, circuit) {
|
|
5115
|
+
return extractDomainFromPublicInputs(publicInputs, circuit);
|
|
5116
|
+
}
|
|
5057
5117
|
}
|
|
5058
5118
|
/**
|
|
5059
5119
|
* Creates a proof request through the relay server.
|
|
@@ -5092,5 +5152,5 @@ ProofportSDK.WALLET_SIGNATURE_CIRCUITS = [
|
|
|
5092
5152
|
'coinbase_country_attestation',
|
|
5093
5153
|
];
|
|
5094
5154
|
|
|
5095
|
-
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, ProofportSDK, ProofportSDK as default, extractNullifierFromPublicInputs, extractScopeFromPublicInputs };
|
|
5155
|
+
export { COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT, COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT, OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT, ProofportSDK, ProofportSDK as default, extractDomainFromPublicInputs, extractNullifierFromPublicInputs, extractScopeFromPublicInputs };
|
|
5096
5156
|
//# sourceMappingURL=index.mjs.map
|