@iam-protocol/pulse-sdk 0.3.6 → 0.3.8

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
@@ -1362,7 +1362,8 @@ async function extractFeatures(data) {
1362
1362
  }
1363
1363
  const audioFeatures = await extractSpeakerFeatures(data.audio);
1364
1364
  const hasMotion = data.motion.length >= MIN_MOTION_SAMPLES;
1365
- const motionFeatures = hasMotion ? extractMotionFeatures(data.motion) : extractMouseDynamics(data.touch);
1365
+ const hasTouch = data.touch.length >= MIN_TOUCH_SAMPLES;
1366
+ const motionFeatures = hasMotion && hasTouch ? extractMouseDynamics(data.touch) : hasMotion ? extractMotionFeatures(data.motion) : extractMouseDynamics(data.touch);
1366
1367
  const touchFeatures = extractTouchFeatures(data.touch);
1367
1368
  return fuseFeatures(audioFeatures, motionFeatures, touchFeatures);
1368
1369
  }
@@ -1437,12 +1438,24 @@ async function processSensorData(sensorData, config, wallet, connection) {
1437
1438
  error: "wasmUrl and zkeyUrl must be configured for re-verification proof generation"
1438
1439
  };
1439
1440
  }
1440
- const { proof, publicSignals } = await generateProof(
1441
- circuitInput,
1442
- wasmPath,
1443
- zkeyPath
1444
- );
1445
- solanaProof = serializeProof(proof, publicSignals);
1441
+ try {
1442
+ const { proof, publicSignals } = await generateProof(
1443
+ circuitInput,
1444
+ wasmPath,
1445
+ zkeyPath
1446
+ );
1447
+ solanaProof = serializeProof(proof, publicSignals);
1448
+ } catch (proofErr) {
1449
+ const audioNZ = features.slice(0, 44).filter((v) => v !== 0).length;
1450
+ const motionNZ = features.slice(44, 98).filter((v) => v !== 0).length;
1451
+ const touchNZ = features.slice(98, 134).filter((v) => v !== 0).length;
1452
+ return {
1453
+ success: false,
1454
+ commitment: tbh.commitmentBytes,
1455
+ isFirstVerification: false,
1456
+ error: `Proof failed (distance=${distance}, audio=${audioNZ}/44, motion=${motionNZ}/54, touch=${touchNZ}/36): ${proofErr?.message ?? proofErr}`
1457
+ };
1458
+ }
1446
1459
  }
1447
1460
  let submission;
1448
1461
  if (wallet && connection) {