LightRiderInc commited on
Commit
2ea4dbd
·
verified ·
1 Parent(s): 1c3ecf1

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +41 -45
  2. app.py +27 -37
README.md CHANGED
@@ -1,45 +1,41 @@
1
- ---
2
- title: Light Rider Quantum Entropy
3
- emoji: ⚛️
4
- colorFrom: red
5
- colorTo: yellow
6
- sdk: gradio
7
- sdk_version: 6.30.0
8
- app_file: app.py
9
- pinned: false
10
- license: apache-2.0
11
- short_description: Entropy from named quantum sources, with signed receipts
12
- ---
13
-
14
- # Light Rider Quantum Entropy
15
-
16
- Draw random bytes from **named quantum sources** (quantum random number generators
17
- and quantum processors). Every draw comes with a **receipt signed by the Light Rider
18
- Entropy Management Service (EMS)**: it records which source produced the bytes, how
19
- they were health-checked and when. The app verifies the receipt's Ed25519 signature
20
- against EMS's published key and shows the result.
21
-
22
- This is an alternative entropy source with verifiable provenance. It is not a claim
23
- that quantum randomness is better than a good classical generator. If a source can't
24
- serve, you'll see why. Nothing is ever substituted, and nothing is generated locally.
25
-
26
- ## Use it from your code
27
-
28
- ```python
29
- import lightrider as lr # pip install lightrider (1.6.0+), export LR_API_KEY=lr_live_...
30
- r = lr.entropy.get(16, source="anu") # or sources=["anu", "cisco"]
31
- print(r.hex, r.request_id, r.sources)
32
- assert lr.entropy.verify(r.receipt)
33
- seed = lr.entropy.seed(64) # int seed for numpy / torch
34
- ```
35
-
36
- Get your Light Rider API key from Light Rider Cloud (Settings → API Keys). It is a
37
- full-access account key: keep it out of public code and store it as a Space secret.
38
-
39
- ## Space configuration
40
-
41
- Secrets: `LR_API_KEY` (demo account key), `LR_ENTROPY_BASE_URL`, and
42
- `LR_VERCEL_BYPASS` (only while pointing at a protected preview deployment).
43
-
44
- Optional variables: `DEMO_PER_VISITOR_DAILY` (default 5), `DEMO_GLOBAL_DAILY`
45
- (default 200), `LR_PUBLIC_SITE_URL`, `LR_CLOUD_KEYS_URL`.
 
1
+ ---
2
+ title: Light Rider Quantum Entropy
3
+ emoji: ⚛️
4
+ colorFrom: red
5
+ colorTo: yellow
6
+ sdk: gradio
7
+ sdk_version: 6.30.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: apache-2.0
11
+ short_description: Quantum random bytes with signed, verifiable receipts
12
+ ---
13
+
14
+ # Light Rider Quantum Entropy
15
+
16
+ Draw random bytes from a named quantum source: a quantum random number generator or a quantum
17
+ processor. Every draw comes with a receipt, signed by Light Rider, that records which source
18
+ produced the bytes and when. The app checks the signature and shows you the result.
19
+
20
+ It's an alternative entropy source you can verify, not a claim that quantum randomness beats a
21
+ good classical generator. If a source can't serve, the app says so; no other source is used in
22
+ its place.
23
+
24
+ ## Use it from your code
25
+
26
+ ```bash
27
+ pip install lightrider
28
+ export LR_API_KEY=lr_live_... # your Light Rider API key
29
+ ```
30
+
31
+ ```python
32
+ import lightrider as lr
33
+
34
+ r = lr.entropy.get(16, source="anu") # 16 bytes from the ANU quantum RNG
35
+ print(r.hex, r.sources, r.request_id)
36
+ assert lr.entropy.verify(r.receipt) # the receipt is genuine
37
+ ```
38
+
39
+ Create your API key at [entropy.lightriderinc.com/developers](https://entropy.lightriderinc.com/developers),
40
+ which also documents the HTTP API. The key gives full access to your account, so keep it out of
41
+ public code.
 
 
 
 
app.py CHANGED
@@ -1,21 +1,17 @@
1
  """Light Rider Quantum Entropy: Hugging Face Space demo.
2
 
3
- Draws entropy from a named quantum source through the Light Rider Entropy
4
- developer API and shows the EMS-signed receipt, verified with Ed25519.
5
 
6
- Space secrets (never printed):
7
- LR_API_KEY Light Rider API key of the demo account (pays for draws)
8
- LR_ENTROPY_BASE_URL entropy site to call (dev for now)
9
- LR_VERCEL_BYPASS x-vercel-protection-bypass, sent only when set
10
 
11
  Optional variables:
12
  DEMO_PER_VISITOR_DAILY draws per visitor per UTC day (default 5)
13
  DEMO_GLOBAL_DAILY draws for the whole Space per UTC day (default 200)
14
- LR_PUBLIC_SITE_URL public entropy site for links (default production)
15
- LR_CLOUD_KEYS_URL Light Rider Cloud API Keys page
16
 
17
- Strict by design: if a source can't serve, the visitor sees why. Nothing is
18
- ever substituted and this app never generates randomness locally.
19
  """
20
 
21
  from __future__ import annotations
@@ -33,11 +29,10 @@ from lightrider.entropy import api as lre
33
  MIN_BYTES, MAX_BYTES = 16, 512
34
  PER_VISITOR_DAILY = int(os.environ.get("DEMO_PER_VISITOR_DAILY", "5"))
35
  GLOBAL_DAILY = int(os.environ.get("DEMO_GLOBAL_DAILY", "200"))
36
- PUBLIC_SITE = os.environ.get("LR_PUBLIC_SITE_URL", "https://entropy.lightriderinc.com").rstrip("/")
37
- CLOUD_KEYS_URL = os.environ.get("LR_CLOUD_KEYS_URL", "https://cloud.lightriderinc.com/settings/keys")
38
  BRAND = "#ef3b39"
39
 
40
- # Reads LR_API_KEY, LR_ENTROPY_BASE_URL and LR_VERCEL_BYPASS from the environment.
41
  client = lre.EntropyAPI(max_retries=1, timeout=60)
42
 
43
 
@@ -166,10 +161,10 @@ def _friendly(err: lre.EntropyAPIError, what: str) -> str:
166
  def _badge(ok: bool) -> str:
167
  if ok:
168
  return (
169
- '<div class="lr-badge lr-ok">✔ Verified: the Ed25519 signature matches the EMS public key, '
170
- "so this receipt is exactly what EMS signed.</div>"
171
  )
172
- return '<div class="lr-badge lr-bad">✘ Not verified: the signature did not check out against the EMS public key.</div>'
173
 
174
 
175
  def generate(mode: str, source_id: str | None, custom_ids: list[str] | None, n_bytes: float, request: gr.Request | None = None):
@@ -229,42 +224,37 @@ def toggle_mode(mode: str):
229
  INTRO = f"""
230
  # Light Rider Quantum Entropy
231
 
232
- Random bytes from **named quantum sources** (quantum random number generators and quantum processors),
233
- each with a **receipt signed by the Light Rider Entropy Management Service (EMS)**. The receipt says which
234
- source produced the bytes, how they were checked and when. Anyone can verify its Ed25519 signature.
235
 
236
- This is an alternative entropy source with verifiable provenance. It isn't a claim that quantum randomness is
237
- better than a good classical generator. If a source can't serve, you'll see why: nothing is ever substituted,
238
- and nothing here is generated locally.
239
 
240
- <small>Demo: up to {PER_VISITOR_DAILY} draws per visitor per day. Bytes are shown once and never stored.</small>
241
  """
242
 
243
  CODE = f"""
244
  ### Draw entropy from your own code
245
 
246
  ```bash
247
- pip install lightrider # the entropy client ships in lightrider 1.6.0 (coming to PyPI soon)
248
- export LR_API_KEY=lr_live_... # your Light Rider API key
249
  ```
250
 
251
  ```python
252
  import lightrider as lr
253
 
254
- r = lr.entropy.get(16, source="anu") # or sources=["anu", "cisco"]
255
- print(r.hex, r.request_id, r.sources)
256
- assert lr.entropy.verify(r.receipt) # Ed25519 against EMS's published key
257
- seed = lr.entropy.seed(64) # int seed for numpy / torch
258
  ```
259
 
260
- - **Sources** by short name: `anu`, `cisco`, `qispace`, `rigetti`, `iqm`, `iqm-qec` (or the full id);
261
- `lr.entropy.sources()` lists what's ready now. Receipts always record the full id.
262
- - **Get your key:** [Light Rider Cloud → API Keys]({CLOUD_KEYS_URL}). It is your account's full-access key, so keep it
263
- out of public code and Spaces (store it as a Space secret).
264
- - **Docs and the HTTP API:** [{PUBLIC_SITE}/developers]({PUBLIC_SITE}/developers)
265
- - **Price:** 1 token (one Light Rider credit, $0.01) per 256 bytes. Single source or a custom pool of 2 to 8
266
- sources, up to 4096 bytes per call.
267
- - **Strict:** if the source can't serve, you get `SourceEmptyError`, never a substitute.
268
  """
269
 
270
  CSS = f"""
 
1
  """Light Rider Quantum Entropy: Hugging Face Space demo.
2
 
3
+ Draws random bytes from a named quantum source with the lightrider SDK and
4
+ shows the signed receipt, verified with Ed25519.
5
 
6
+ Secret:
7
+ LR_API_KEY Light Rider API key that pays for the demo's draws
 
 
8
 
9
  Optional variables:
10
  DEMO_PER_VISITOR_DAILY draws per visitor per UTC day (default 5)
11
  DEMO_GLOBAL_DAILY draws for the whole Space per UTC day (default 200)
 
 
12
 
13
+ If a source can't serve, the visitor sees why. No other source is used in its
14
+ place, and this app never generates randomness itself.
15
  """
16
 
17
  from __future__ import annotations
 
29
  MIN_BYTES, MAX_BYTES = 16, 512
30
  PER_VISITOR_DAILY = int(os.environ.get("DEMO_PER_VISITOR_DAILY", "5"))
31
  GLOBAL_DAILY = int(os.environ.get("DEMO_GLOBAL_DAILY", "200"))
32
+ PUBLIC_SITE = "https://entropy.lightriderinc.com"
 
33
  BRAND = "#ef3b39"
34
 
35
+ # Reads LR_API_KEY from the environment.
36
  client = lre.EntropyAPI(max_retries=1, timeout=60)
37
 
38
 
 
161
  def _badge(ok: bool) -> str:
162
  if ok:
163
  return (
164
+ '<div class="lr-badge lr-ok">✔ Verified: this receipt is signed by Light Rider and hasn\'t been '
165
+ "changed.</div>"
166
  )
167
+ return '<div class="lr-badge lr-bad">✘ Not verified: the receipt\'s signature didn\'t match Light Rider\'s public key.</div>'
168
 
169
 
170
  def generate(mode: str, source_id: str | None, custom_ids: list[str] | None, n_bytes: float, request: gr.Request | None = None):
 
224
  INTRO = f"""
225
  # Light Rider Quantum Entropy
226
 
227
+ Draw random bytes from a named quantum source: a quantum random number generator or a quantum processor.
228
+ Every draw comes with a receipt, signed by Light Rider, that records which source produced the bytes and when.
229
+ The app checks the signature for you.
230
 
231
+ It's an alternative entropy source you can verify, not a claim that quantum randomness beats a good classical
232
+ generator. If a source can't serve, you'll see why; no other source is used in its place.
 
233
 
234
+ <small>Up to {PER_VISITOR_DAILY} draws per visitor per day. Your bytes are shown once and never stored.</small>
235
  """
236
 
237
  CODE = f"""
238
  ### Draw entropy from your own code
239
 
240
  ```bash
241
+ pip install lightrider
242
+ export LR_API_KEY=lr_live_... # your Light Rider API key
243
  ```
244
 
245
  ```python
246
  import lightrider as lr
247
 
248
+ r = lr.entropy.get(16, source="anu") # 16 bytes from the ANU quantum RNG
249
+ print(r.hex, r.sources, r.request_id)
250
+ assert lr.entropy.verify(r.receipt) # the receipt is genuine
 
251
  ```
252
 
253
+ - **API key:** create one at [{PUBLIC_SITE}/developers]({PUBLIC_SITE}/developers), which also documents the
254
+ HTTP API. The key gives full access to your account, so keep it out of public code.
255
+ - **Sources:** use a short name (`anu`, `cisco`, `qispace`, `rigetti`, `iqm`, `iqm-qec`) or the full id.
256
+ `lr.entropy.sources()` lists what's available right now. `sources=["anu", "cisco"]` blends 2 to 8 sources.
257
+ - **Price:** 1 credit ($0.01) per 256 bytes, up to 4096 bytes per call. A draw that fails isn't charged.
 
 
 
258
  """
259
 
260
  CSS = f"""