@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/dist/index.mjs CHANGED
@@ -226,14 +226,18 @@ const COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT = {
226
226
  const OIDC_DOMAIN_ATTESTATION_PUBLIC_INPUT_LAYOUT = {
227
227
  PUBKEY_MODULUS_START: 0,
228
228
  PUBKEY_MODULUS_END: 17,
229
- DOMAIN_LEN: 18,
230
- DOMAIN_START: 19,
231
- DOMAIN_END: 82,
229
+ DOMAIN_STORAGE_START: 18,
230
+ DOMAIN_STORAGE_END: 81,
231
+ DOMAIN_LEN: 82,
232
232
  SCOPE_START: 83,
233
233
  SCOPE_END: 114,
234
234
  NULLIFIER_START: 115,
235
235
  NULLIFIER_END: 146,
236
236
  PROVIDER: 147,
237
+ /** @deprecated Use DOMAIN_STORAGE_START */
238
+ DOMAIN_START: 18,
239
+ /** @deprecated Use DOMAIN_LEN */
240
+ DOMAIN_END: 82,
237
241
  };
238
242
 
239
243
  /**
@@ -3880,6 +3884,38 @@ function extractNullifierFromPublicInputs(publicInputsHex, circuit) {
3880
3884
  const nullifierFields = publicInputsHex.slice(start, end + 1);
3881
3885
  return reconstructBytes32FromFields(nullifierFields);
3882
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
+ }
3883
3919
  /** @internal Reconstruct a bytes32 value from 32 individual field elements */
3884
3920
  function reconstructBytes32FromFields(fields) {
3885
3921
  if (fields.length !== 32) {
@@ -5057,6 +5093,27 @@ class ProofportSDK {
5057
5093
  extractNullifier(publicInputs, circuit) {
5058
5094
  return extractNullifierFromPublicInputs(publicInputs, circuit);
5059
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
+ }
5060
5117
  }
5061
5118
  /**
5062
5119
  * Creates a proof request through the relay server.
@@ -5095,5 +5152,5 @@ ProofportSDK.WALLET_SIGNATURE_CIRCUITS = [
5095
5152
  'coinbase_country_attestation',
5096
5153
  ];
5097
5154
 
5098
- 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 };
5099
5156
  //# sourceMappingURL=index.mjs.map