infiniteviolets commited on
Commit
18689fe
·
verified ·
1 Parent(s): 77ad1e5

Revert empty-key change

Browse files
Files changed (2) hide show
  1. app.py +3 -9
  2. sentence_encode.py +2 -7
app.py CHANGED
@@ -115,11 +115,8 @@ def encode(message, topic, key, attempts):
115
  return "", (f"Message is {len(message)} characters; the cap is "
116
  f"{MAX_MESSAGE_CHARS} so a single run stays inside a "
117
  f"reasonable slice of your daily GPU quota.")
118
- # An empty key is allowed and means no key: the fixed base alphabet, which
119
- # the site's decoder also uses for an empty key field. The key is passed on
120
- # untrimmed because the browser decoder does not trim either, so " " is a
121
- # real key on both sides and they cannot disagree about it.
122
- key = key or None
123
 
124
  bits = pc.compress_to_bits(message)
125
  prompt = se.build_prompt(TOK, (topic or "the sea").strip(), think=False)
@@ -152,8 +149,6 @@ def encode(message, topic, key, attempts):
152
  + f" | {dt:.0f}s", flush=True)
153
  note = ("Verified: this text decodes back to your message." if ok else
154
  "This run did not verify. Try again, or raise Attempts.")
155
- if ok and key is None:
156
- note += " No key was set, so anyone can decode it."
157
  return text.strip(), note
158
 
159
 
@@ -174,8 +169,7 @@ with gr.Blocks(title="Garfield-Naruto Encoder") as demo:
174
  placeholder="Enter your secret message here.")
175
  topic = gr.Textbox(label="Topic",
176
  placeholder="Choose a topic for the LLM slop.")
177
- key_in = gr.Textbox(label="Key",
178
- placeholder="Pick a secret key (optional).",
179
  type="password")
180
  attempts = gr.Number(label="Attempts", value=6, minimum=1, maximum=10,
181
  precision=0)
 
115
  return "", (f"Message is {len(message)} characters; the cap is "
116
  f"{MAX_MESSAGE_CHARS} so a single run stays inside a "
117
  f"reasonable slice of your daily GPU quota.")
118
+ if not (key or "").strip():
119
+ return "", "A key is required. The same key is needed to decode."
 
 
 
120
 
121
  bits = pc.compress_to_bits(message)
122
  prompt = se.build_prompt(TOK, (topic or "the sea").strip(), think=False)
 
149
  + f" | {dt:.0f}s", flush=True)
150
  note = ("Verified: this text decodes back to your message." if ok else
151
  "This run did not verify. Try again, or raise Attempts.")
 
 
152
  return text.strip(), note
153
 
154
 
 
169
  placeholder="Enter your secret message here.")
170
  topic = gr.Textbox(label="Topic",
171
  placeholder="Choose a topic for the LLM slop.")
172
+ key_in = gr.Textbox(label="Key", placeholder="Pick a secret key.",
 
173
  type="password")
174
  attempts = gr.Number(label="Attempts", value=6, minimum=1, maximum=10,
175
  precision=0)
sentence_encode.py CHANGED
@@ -280,11 +280,7 @@ def _letter_roles(key, pos: int) -> np.ndarray:
280
  text each letter lands in each role about equally. A greedy pass in the keyed
281
  order fills the currently lightest role, keeping each role ~1/3 of letter
282
  frequency for fluency. key=None returns the fixed base assignment."""
283
- # An empty key means no key, exactly as in the browser decoder (script.js
284
- # letterRoles: null, undefined and '' all return the base alphabet). Hashing
285
- # '' as a real key instead meant text encoded with a blank key field could not
286
- # be decoded on the site. No trimming on either side: " " is a real key.
287
- if not key:
288
  return _BASE_ROLE
289
  sums = [0.0, 0.0, 0.0]
290
  role = np.empty(26, dtype=np.int8)
@@ -968,8 +964,7 @@ def main() -> None:
968
  ap.add_argument("--seed", type=int, default=0)
969
  ap.add_argument("--key", default=None,
970
  help="secret key: shuffles the letter->bit alphabet per character; the "
971
- "recipient needs the same key to decode (omit it, or pass an empty "
972
- "string, for the fixed alphabet that anyone can decode)")
973
  ap.add_argument("--clean", action="store_true",
974
  help="print only the cover text — no progress, no verification. The "
975
  "exit code still reports whether the payload verified.")
 
280
  text each letter lands in each role about equally. A greedy pass in the keyed
281
  order fills the currently lightest role, keeping each role ~1/3 of letter
282
  frequency for fluency. key=None returns the fixed base assignment."""
283
+ if key is None:
 
 
 
 
284
  return _BASE_ROLE
285
  sums = [0.0, 0.0, 0.0]
286
  role = np.empty(26, dtype=np.int8)
 
964
  ap.add_argument("--seed", type=int, default=0)
965
  ap.add_argument("--key", default=None,
966
  help="secret key: shuffles the letter->bit alphabet per character; the "
967
+ "recipient needs the same key to decode (omit for the fixed alphabet)")
 
968
  ap.add_argument("--clean", action="store_true",
969
  help="print only the cover text — no progress, no verification. The "
970
  "exit code still reports whether the payload verified.")