From bf6759facd8a4a4ae707c7b538f288a223d7cc68 Mon Sep 17 00:00:00 2001 From: alanhkarp Date: Mon, 17 Jun 2024 09:41:31 -0700 Subject: [PATCH] Use simpler formula for modulo bias because it's easier to understand and does not substantively affect the result. --- src/ssp.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ssp.js b/src/ssp.js index 9a98331..ec3a852 100644 --- a/src/ssp.js +++ b/src/ssp.js @@ -285,8 +285,7 @@ let SitePasswordWeb = ((function (self) { } if (which === "sitepw") { // Adjust site password for modulus bias - let m = alphabetSize - let statisticalDistance = Math.abs((256 % m)**2 - (m - 256 % m)**2)/(2*256*m); + let statisticalDistance = (256%alphabetSize)/256; // Upper bound on statistical distance guesses = Math.floor(guesses*(1 - statisticalDistance)); } return guesses;