Skip to content

Commit 40249b2

Browse files
committed
fix: leading 0s issue
1 parent 8d9a487 commit 40249b2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

frontend/src/lib/zk-proof.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,13 @@ export async function generateZKProof(
114114
const expectedCode =
115115
BigInt(poseidon.F.toString(totpHash)) % BigInt(1000000);
116116

117-
if (expectedCode.toString() !== totpCode.toString()) {
117+
// Ensure both codes are padded to 6 digits for comparison
118+
const expectedCodeStr = expectedCode.toString().padStart(6, "0");
119+
const totpCodeStr = totpCode.padStart(6, "0");
120+
121+
if (expectedCodeStr !== totpCodeStr) {
118122
throw new Error(
119-
`TOTP code mismatch. Expected: ${expectedCode}, Got: ${totpCode}`,
123+
`TOTP code mismatch. Expected: ${expectedCodeStr}, Got: ${totpCodeStr}`,
120124
);
121125
}
122126

0 commit comments

Comments
 (0)