561b656d9465

fix Mayan decoder cy offset — diamond horizontal midpoint is 1 module above code center; shift rune.cy by modulePx before passing to sampleModuleGrid

time
2026-05-01 15:46 UTC · 5 months ago
machine
koh2
parent
3c4de4d66983
3 files manifest.firefox.json+1 −1manifest.json+1 −1src/crypto/mayan.ts+7 −12
manifest.firefox.json+1 −1
@@ -1,7 +1,7 @@11 {22   "manifest_version": 3,33   "name": "Peach",4-  "version": "2.22.0",4+  "version": "2.23.0",55   "description": "Zero-knowledge password manager",66   "browser_specific_settings": {77     "gecko": {

view file

manifest.json+1 −1
@@ -1,7 +1,7 @@11 {22   "manifest_version": 3,33   "name": "Peach",4-  "version": "2.22.0",4+  "version": "2.23.0",55   "description": "Zero-knowledge password manager",66   "action": {77     "default_popup": "src/popup/index.html",

view file

src/crypto/mayan.ts+7 −12
@@ -469,18 +469,13 @@469469   // Cluster by (cx, size) proximity and pick the strongest cluster.470470   const best = candidates.reduce((a, b) => (a.size > b.size ? a : b));471471 472-  // Refine cy by scanning vertically through the diamond's horizontal axis.473-  let cyTop = best.cy;474-  while (cyTop > 0 && binary[cyTop][best.cx]) cyTop--;475-  let cyBot = best.cy;476-  while (477-    cyBot < H - 1 &&478-    (binary[cyBot][best.cx] ||479-      (best.cx > 0 && binary[cyBot][best.cx - 1]) ||480-      (best.cx < W - 1 && binary[cyBot][best.cx + 1]))481-  ) cyBot++;482-  const cy = Math.floor((cyTop + cyBot) / 2);483-  return { cx: best.cx, cy, size: best.size };472+  // best.cy is the scan row where the widest dark-light-dark was found, which473+  // is the diamond's horizontal midpoint (the LEFT/RIGHT vertex row). This row474+  // is always 1 module above the code-grid center (drawOthalan places the475+  // vertices at centerRow-1). Shift down 1 module so sampleModuleGrid uses476+  // the correct center reference.477+  const modulePx = Math.round(best.size / 23);478+  return { cx: best.cx, cy: best.cy + modulePx, size: best.size };484479 }485480 486481 function estimateModuleSize(

view file