Skip to content

Commit a2a0103

Browse files
committed
feat: Transition to device-native cryptographically secure random generator
1 parent 4ea293c commit a2a0103

3 files changed

Lines changed: 13 additions & 30 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
OpenRando is an open-source, web-based alternative to Randonautica that generates unique, random real-world coordinates for you to explore.
44

5-
By leveraging true quantum random numbers from the Australian National University (ANU) and applying Kernel Density Estimation (KDE), the application calculates concentrated areas of probability ("attractors") to break your daily routine and send you on an adventure. 🥾🌲✨
5+
By leveraging your device's native Cryptographically Secure Random Number Generator and applying Kernel Density Estimation (KDE), the application calculates concentrated areas of probability ("attractors") to break your daily routine and send you on an adventure. 🥾🌲✨
66

77
### 👉 [Launch the App](https://realjck.github.io/OpenRando/)
88

@@ -11,7 +11,7 @@ By leveraging true quantum random numbers from the Australian National Universit
1111
**Features:**
1212
- Set your starting location via GPS or by clicking on the map.
1313
- Choose a search radius between 500m and 5km.
14-
- Generate quantum-backed destination points.
14+
- Generate unpredictable true-random destination points.
1515
- Open the generated coordinates directly in Google Maps.
1616

1717
Built with React, Leaflet, and Tailwind CSS.

src/App.tsx

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,6 @@ export default function App() {
7373
const [loading, setLoading] = useState(false);
7474
const [error, setError] = useState<string | null>(null);
7575
const [showInfo, setShowInfo] = useState(false);
76-
const [cooldown, setCooldown] = useState(0);
77-
78-
useEffect(() => {
79-
let timer: ReturnType<typeof setInterval>;
80-
if (cooldown > 0) {
81-
timer = setInterval(() => {
82-
setCooldown(prev => prev - 1);
83-
}, 1000);
84-
}
85-
return () => {
86-
if (timer) clearInterval(timer);
87-
};
88-
}, [cooldown]);
8976

9077
// Get user location on mount
9178
useEffect(() => {
@@ -116,10 +103,9 @@ export default function App() {
116103
const quantumNumbers = await fetchQuantumNumbers();
117104
const result = calculateAttractor(startPos[0], startPos[1], radius, quantumNumbers);
118105
setAttractor(result);
119-
setCooldown(120);
120106
} catch (err) {
121107
console.error("Generation error:", err);
122-
setError("Error during quantum generation. Please try again.");
108+
setError("Error during generation. Please try again.");
123109
} finally {
124110
setLoading(false);
125111
}
@@ -255,22 +241,22 @@ export default function App() {
255241

256242
<button
257243
onClick={handleGenerate}
258-
disabled={loading || cooldown > 0}
244+
disabled={loading}
259245
className={`w-full py-4 rounded-2xl font-bold text-lg flex items-center justify-center gap-3 transition-all ${
260-
loading || cooldown > 0
246+
loading
261247
? 'bg-zinc-800 text-zinc-500 cursor-not-allowed'
262248
: 'bg-white text-black hover:bg-zinc-200 active:scale-[0.98]'
263249
}`}
264250
>
265251
{loading ? (
266252
<>
267253
<RefreshCw className="w-6 h-6 animate-spin" />
268-
Quantum Calculation...
254+
Calculating...
269255
</>
270256
) : (
271257
<>
272258
<RefreshCw className="w-6 h-6" />
273-
{cooldown > 0 ? `Generate Attractor (${cooldown}s)` : 'Generate Attractor'}
259+
Generate Attractor
274260
</>
275261
)}
276262
</button>
@@ -302,7 +288,7 @@ export default function App() {
302288
<h2 className="text-2xl font-bold text-white mb-4">About OpenRando</h2>
303289
<div className="space-y-4 text-zinc-400 text-sm leading-relaxed">
304290
<p>
305-
OpenRando uses quantum random numbers generated by the Australian National University (ANU) to create unique destination points.
291+
OpenRando uses your device's native Cryptographically Secure Random Number Generator to create unique destination points.
306292
</p>
307293
<p>
308294
The principle is to break your daily routine by sending you to areas of high "vibration", calculated by a Kernel Density Estimation (KDE) on 512 quantum points.

src/services/quantumService.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Logic for calculating quantum attractors using ANU QRNG API and Silverman KDE.
2+
* Logic for calculating attractors using local CSPRNG and Silverman KDE.
33
*/
44

55
export interface Point {
@@ -20,15 +20,12 @@ const EARTH_RADIUS = 6371; // km
2020
const ONE_DEGREE = (EARTH_RADIUS * 2 * Math.PI) / 360 * 1000;
2121

2222
/**
23-
* Fetches quantum random numbers from ANU API.
23+
* Generates random numbers using the browser's native CSPRNG.
2424
*/
2525
export async function fetchQuantumNumbers(length: number = 1024): Promise<number[]> {
26-
const response = await fetch(`https://qrng.anu.edu.au/API/jsonI.php?length=${length}&type=uint16`);
27-
if (!response.ok) {
28-
throw new Error("Failed to fetch quantum numbers from ANU API");
29-
}
30-
const data = await response.json();
31-
return data.data;
26+
const array = new Uint16Array(length);
27+
globalThis.crypto.getRandomValues(array);
28+
return Array.from(array);
3229
}
3330

3431
/**

0 commit comments

Comments
 (0)