-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
343 lines (310 loc) · 12.4 KB
/
Copy pathindex.html
File metadata and controls
343 lines (310 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!DOCTYPE html>
<html lang="en">
<head>
<script>document.documentElement.dataset.theme=localStorage.getItem('il-theme')||'dark';</script>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/>
<title>touch biometric — invisible layer</title>
<meta name="theme-color" content="#0f172a"/>
<link rel="stylesheet" href="../../../assets/css/base.css"/>
<link rel="stylesheet" href="../../../assets/css/experiment.css"/>
<style>/* experiment-specific styles */
.touch-canvas-wrap {
width: 100%;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
overflow: hidden;
position: relative;
touch-action: none;
user-select: none;
-webkit-user-select: none;
cursor: crosshair;
}
.touch-canvas-wrap canvas { width: 100%; display: block; }
.touch-prompt {
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
font-family: var(--font-mono);
font-size: 0.68rem;
letter-spacing: 0.16em;
text-transform: uppercase;
color: var(--dim);
pointer-events: none;
transition: opacity 0.4s;
}
.touch-label {
position: absolute;
top: 8px; left: 12px;
font-family: var(--font-mono);
font-size: 0.58rem;
letter-spacing: 0.1em;
text-transform: uppercase;
color: var(--dim);
pointer-events: none;
}
.touch-log {
width: 100%;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 6px;
max-height: 120px;
overflow-y: auto;
padding: 6px 0;
}
.touch-log-row {
display: flex;
gap: 8px;
padding: 4px 14px;
font-family: var(--font-mono);
font-size: 0.62rem;
color: var(--dim);
border-bottom: 1px solid var(--border);
line-height: 1.4;
}
.touch-log-row:last-child { border-bottom: none; }
.touch-log-row .tl-n { color: var(--cyan); width: 22px; flex-shrink: 0; }
.touch-log-row .tl-xy { color: var(--text); width: 110px; flex-shrink: 0; }
.touch-log-row .tl-r { color: var(--purple); width: 60px; flex-shrink: 0; }
.touch-log-row .tl-f { flex: 1; }
.force-note {
font-family: var(--font-mono);
font-size: 0.62rem;
color: var(--amber);
padding: 4px 0;
}
</style>
</head>
<body>
<div class="exp-shell">
<header class="exp-header">
<div class="exp-header-left">
<div class="exp-breadcrumb">
<a href="../../../" data-i18n="exp.back">invisible layer</a> / <strong>touch-biometric</strong>
</div>
</div>
<button class="exp-theme-btn" onclick="(function(){var T=['dark','light','hc'],d=document.documentElement,c=d.dataset.theme||'dark',n=T[(T.indexOf(c)+1)%3];d.dataset.theme=n;localStorage.setItem('il-theme',n)})()" aria-label="toggle theme">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>
</button>
<button class="exp-lang-btn" id="lang-btn" onclick="IL_I18N.toggle()">DE</button>
<a class="exp-close" href="../../../">✕</a>
</header>
<div class="exp-body">
<div class="exp-stage">
<div class="exp-intro">
<div class="exp-label" data-i18n="exp.touch-biometric.label">experiment 35 · touch events · no permissions</div>
<div class="exp-title" data-i18n="exp.touch-biometric.title">your fingertip<br>is a signature.</div>
<div class="exp-desc" data-i18n="exp.touch-biometric.desc">
Every touch carries a physical signature: the size of your fingertip, the pressure you apply,
and the angle of contact. The Touch API exposes all of this — radius, force, rotation —
without any permission prompt.
</div>
</div>
<div class="shock" data-i18n="exp.touch-biometric.shock">
<strong>The physical size, pressure, and angle of your finger on glass is biometrically unique.</strong>
Combined with typing rhythm, it identifies you to authentication systems — without any password.
Mobile banking apps already use touch biometrics as a continuous background authentication layer.
</div>
<div class="stat-row">
<div class="stat-cell">
<span class="stat-val" id="stat-touches">0</span>
<span class="stat-lbl" data-i18n="exp.touch-biometric.stat.touches">touches</span>
</div>
<div class="stat-cell">
<span class="stat-val" id="stat-radius">—</span>
<span class="stat-lbl" data-i18n="exp.touch-biometric.stat.radius">avg radius px</span>
</div>
<div class="stat-cell">
<span class="stat-val" id="stat-force">—</span>
<span class="stat-lbl" data-i18n="exp.touch-biometric.stat.force">force support</span>
</div>
</div>
<div class="touch-canvas-wrap" id="touch-wrap" style="height:300px"
ontouchstart="handleTouchStart(event)"
ontouchmove="handleTouchMove(event)"
ontouchend="handleTouchEnd(event)">
<canvas id="touch-canvas"></canvas>
<div class="touch-label" data-i18n="exp.touch-biometric.canvas-label">touch fingerprint canvas</div>
<div class="touch-prompt" id="touch-prompt" data-i18n="exp.touch-biometric.prompt">touch anywhere</div>
</div>
<div id="force-note" class="force-note" style="display:none" data-i18n="exp.touch-biometric.force-note">
force = 0 on all touches — this device does not expose pressure data
</div>
<div class="touch-log" id="touch-log">
<div style="color:var(--dim);font-size:0.62rem;font-family:var(--font-mono);text-align:center;padding:14px 0" data-i18n="exp.touch-biometric.log-empty">no touches recorded yet</div>
</div>
<button class="exp-btn ghost" onclick="clearTouch()" style="align-self:flex-start" data-i18n="exp.touch-biometric.clear">clear canvas</button>
<div class="exp-info">
<details>
<summary data-i18n="exp.touch-biometric.summary">▶ the biometrics of a touch</summary>
<p>The browser's <code>TouchEvent</code> API exposes far more than just X/Y coordinates. Each touch point includes:</p>
<ul>
<li><strong>radiusX / radiusY</strong> — the elliptical contact area of your fingertip in CSS pixels</li>
<li><strong>rotationAngle</strong> — the angle of the ellipse (how tilted your finger is)</li>
<li><strong>force</strong> — pressure from 0.0 (lightest) to 1.0 (maximum), on supported hardware</li>
</ul>
<p>Your fingertip size is determined by the width of your distal phalanx — typically 8–20mm. This varies by person and is stable over time. Combined with how hard you tap and your natural tilt angle, it forms a biometric signature that is independent of which finger you use.</p>
<p>Most Android devices do not expose force data (it returns 0). Apple devices with 3D Touch (iPhone 6s–11) or Haptic Touch expose partial force data. The radius and rotation data are available on almost all touch screens.</p>
<p>This data is accessible to any webpage you visit on a touch device — no permission required.</p>
</details>
</div>
</div>
</div>
</div>
<script>
(function(){
'use strict';
var touchCanvas = document.getElementById('touch-canvas');
var ctx = touchCanvas.getContext('2d');
var dpr = window.devicePixelRatio || 1;
var touchCount = 0;
var radiusSamples = [];
var forceAlwaysZero = true;
var forceEverNonZero = false;
var touchLog = [];
var rings = [];
var rafId = null;
function resizeCanvas() {
var wrap = touchCanvas.parentElement;
var r = wrap.getBoundingClientRect();
touchCanvas.width = Math.round(r.width * dpr);
touchCanvas.height = Math.round(r.height * dpr);
}
resizeCanvas();
window.addEventListener('resize', resizeCanvas);
function drawRings() {
var W = touchCanvas.width;
var H = touchCanvas.height;
ctx.clearRect(0, 0, W, H);
var now = Date.now();
rings = rings.filter(function(ring) { return now - ring.time < 1800; });
rings.forEach(function(ring) {
var age = (now - ring.time) / 1800;
var alpha = (1 - age) * 0.8;
var scale = 1 + age * 1.6;
var x = ring.x * dpr;
var y = ring.y * dpr;
var r = ring.radius * dpr;
var force = ring.force;
var color = force > 0.4 ? '#f87171' : force > 0.0001 ? '#f59e0b' : '#22d3ee';
// fill
ctx.save();
ctx.globalAlpha = alpha * 0.18;
ctx.fillStyle = color;
ctx.beginPath();
ctx.ellipse(x, y, r, r, 0, 0, Math.PI * 2);
ctx.fill();
ctx.restore();
// expanding ring
ctx.save();
ctx.globalAlpha = alpha * 0.7;
ctx.strokeStyle = color;
ctx.lineWidth = 1.5 * dpr;
ctx.beginPath();
ctx.ellipse(x, y, r * scale, r * scale, ring.rotation || 0, 0, Math.PI * 2);
ctx.stroke();
ctx.restore();
// center dot
ctx.save();
ctx.globalAlpha = alpha;
ctx.fillStyle = '#22d3ee';
ctx.beginPath();
ctx.arc(x, y, 2 * dpr, 0, Math.PI * 2);
ctx.fill();
ctx.restore();
});
rafId = requestAnimationFrame(drawRings);
}
rafId = requestAnimationFrame(drawRings);
function recordTouch(t, wrap) {
var rect = wrap.getBoundingClientRect();
var rx = t.radiusX || 0;
var ry = t.radiusY || 0;
var r = Math.max(rx, ry, 15);
var force = t.force || 0;
var rotation = (t.rotationAngle || 0) * Math.PI / 180;
var x = t.clientX - rect.left;
var y = t.clientY - rect.top;
rings.push({ x: x, y: y, radius: r, force: force, rotation: rotation, time: Date.now() });
touchCount++;
radiusSamples.push(r);
if (force > 0.001) {
forceEverNonZero = true;
forceAlwaysZero = false;
}
// update stats
document.getElementById('stat-touches').textContent = touchCount;
var avgR = radiusSamples.reduce(function(a, b){ return a + b; }, 0) / radiusSamples.length;
document.getElementById('stat-radius').textContent = avgR.toFixed(1);
document.getElementById('stat-force').textContent = forceEverNonZero ? 'yes' : 'no';
// show force note if all zeros after 3+ touches
if (touchCount >= 3 && forceAlwaysZero) {
document.getElementById('force-note').style.display = 'block';
}
// log entry
touchLog.unshift({
n: touchCount,
x: Math.round(x),
y: Math.round(y),
r: r.toFixed(1),
force: forceEverNonZero ? force.toFixed(2) : (force === 0 ? '0.00' : force.toFixed(2)),
rot: Math.round(t.rotationAngle || 0)
});
if (touchLog.length > 30) touchLog.pop();
renderLog();
document.getElementById('touch-prompt').style.opacity = '0';
}
function renderLog() {
var log = document.getElementById('touch-log');
if (touchLog.length === 0) {
log.innerHTML = '<div style="color:var(--dim);font-size:0.62rem;font-family:var(--font-mono);text-align:center;padding:14px 0">no touches recorded yet</div>';
return;
}
var html = '';
touchLog.slice(0, 20).forEach(function(entry) {
html += '<div class="touch-log-row">'
+ '<span class="tl-n">#' + entry.n + '</span>'
+ '<span class="tl-xy">x:' + entry.x + ' y:' + entry.y + '</span>'
+ '<span class="tl-r">r:' + entry.r + 'px</span>'
+ '<span class="tl-f">f:' + entry.force + ' ang:' + entry.rot + '°</span>'
+ '</div>';
});
log.innerHTML = html;
}
window.handleTouchStart = function(e) {
e.preventDefault();
var wrap = document.getElementById('touch-wrap');
for (var i = 0; i < e.changedTouches.length; i++) {
recordTouch(e.changedTouches[i], wrap);
}
};
window.handleTouchMove = function(e) {
e.preventDefault();
var wrap = document.getElementById('touch-wrap');
for (var i = 0; i < e.changedTouches.length; i++) {
recordTouch(e.changedTouches[i], wrap);
}
};
window.handleTouchEnd = function(e) {
e.preventDefault();
};
window.clearTouch = function() {
touchCount = 0;
radiusSamples = [];
forceAlwaysZero = true;
forceEverNonZero = false;
touchLog = [];
rings = [];
document.getElementById('stat-touches').textContent = '0';
document.getElementById('stat-radius').textContent = '—';
document.getElementById('stat-force').textContent = '—';
document.getElementById('touch-prompt').style.opacity = '1';
document.getElementById('force-note').style.display = 'none';
renderLog();
};
})();
</script>
<script src="../../../assets/js/i18n.js?v=4"></script>
</body>
</html>