@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.js CHANGED
@@ -1441,7 +1441,8 @@ async function extractFeatures(data) {
1441
1441
  }
1442
1442
  const audioFeatures = await extractSpeakerFeatures(data.audio);
1443
1443
  const hasMotion = data.motion.length >= MIN_MOTION_SAMPLES;
1444
- const motionFeatures = hasMotion ? extractMotionFeatures(data.motion) : extractMouseDynamics(data.touch);
1444
+ const hasTouch = data.touch.length >= MIN_TOUCH_SAMPLES;
1445
+ const motionFeatures = hasMotion && hasTouch ? extractMouseDynamics(data.touch) : hasMotion ? extractMotionFeatures(data.motion) : extractMouseDynamics(data.touch);
1445
1446
  const touchFeatures = extractTouchFeatures(data.touch);
1446
1447
  return fuseFeatures(audioFeatures, motionFeatures, touchFeatures);
1447
1448
  }
@@ -1516,12 +1517,24 @@ async function processSensorData(sensorData, config, wallet, connection) {
1516
1517
  error: "wasmUrl and zkeyUrl must be configured for re-verification proof generation"
1517
1518
  };
1518
1519
  }
1519
- const { proof, publicSignals } = await generateProof(
1520
- circuitInput,
1521
- wasmPath,
1522
- zkeyPath
1523
- );
1524
- solanaProof = serializeProof(proof, publicSignals);
1520
+ try {
1521
+ const { proof, publicSignals } = await generateProof(
1522
+ circuitInput,
1523
+ wasmPath,
1524
+ zkeyPath
1525
+ );
1526
+ solanaProof = serializeProof(proof, publicSignals);
1527
+ } catch (proofErr) {
1528
+ const audioNZ = features.slice(0, 44).filter((v) => v !== 0).length;
1529
+ const motionNZ = features.slice(44, 98).filter((v) => v !== 0).length;
1530
+ const touchNZ = features.slice(98, 134).filter((v) => v !== 0).length;
1531
+ return {
1532
+ success: false,
1533
+ commitment: tbh.commitmentBytes,
1534
+ isFirstVerification: false,
1535
+ error: `Proof failed (distance=${distance}, audio=${audioNZ}/44, motion=${motionNZ}/54, touch=${touchNZ}/36): ${proofErr?.message ?? proofErr}`
1536
+ };
1537
+ }
1525
1538
  }
1526
1539
  let submission;
1527
1540
  if (wallet && connection) {