{"id":410,"date":"2026-11-23T21:14:52","date_gmt":"2026-11-23T20:14:52","guid":{"rendered":"https:\/\/memristors.uib.es\/index.php\/resources\/media\/what-is-chaotic-encryption\/"},"modified":"2026-11-23T23:03:52","modified_gmt":"2026-11-23T22:03:52","slug":"what-is-chaotic-encryption","status":"publish","type":"page","link":"https:\/\/memristors.uib.es\/index.php\/resources\/media\/what-is-chaotic-encryption\/","title":{"rendered":"What is chaotic encryption?"},"content":{"rendered":"\n<div class=\"wp-block-group mem-page is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<p class=\"wp-block-paragraph\">Chaotic circuits produce signals that look like noise but are completely deterministic. Two identical chaotic circuits can be made to <strong>synchronise<\/strong>, and that makes them a natural tool for hiding information. This page explains the idea and presents the fully digital chaotic encryption scheme developed by our group, with simulations you can run in your browser.<\/p>\n\n\n\n<div class=\"wp-block-group mem-tabs is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<style>\n\/* ---------- tokens ---------- *\/\n.mem-page{--mem-accent:#1d5b94;--mem-accent-soft:#e8f0f8;--mem-line:color-mix(in srgb,currentColor 16%,transparent);--mem-muted:color-mix(in srgb,currentColor 62%,transparent);--mem-surface:color-mix(in srgb,currentColor 4%,transparent)}\n\n\/* ---------- tab containers ---------- *\/\n.mem-tabs,.mem-subtabs{position:relative;display:flex;flex-wrap:wrap;align-items:flex-end}\n.entry-content .mem-page{max-width:min(1040px,100%) !important;margin-inline:auto !important}\n.mem-page > p:first-child{max-width:760px;margin-inline:auto}\n.mem-tabs > *,.mem-subtabs > *{margin:0 !important}\n.mem-tabs > input,.mem-subtabs > input{position:absolute;opacity:0;width:1px;height:1px;pointer-events:none}\n.mem-panel{display:none;flex:0 0 100%;max-width:100%;min-width:0}\n.mem-panel > * + *{margin-block-start:1.15em}\n\n\/* main tabs: segmented control *\/\n.mem-nav{display:flex;gap:4px;padding:4px;margin:0 auto 1.8em !important;border-radius:999px;background:var(--mem-surface);border:1px solid var(--mem-line);width:max-content;max-width:100%;overflow-x:auto}\n.mem-nav label{cursor:pointer;padding:.55em 1.4em;border-radius:999px;font-weight:600;font-size:.95em;white-space:nowrap;color:var(--mem-muted);transition:background .15s,color .15s,box-shadow .15s}\n.mem-nav label:hover{color:inherit}\n\n\/* sub tabs: underline *\/\n.mem-subnav{display:flex;gap:1.5em;flex:0 0 100%;border-bottom:1px solid var(--mem-line);margin-bottom:1.5em !important;overflow-x:auto}\n.mem-subnav label{cursor:pointer;padding:.6em 0;font-weight:600;color:var(--mem-muted);border-bottom:2px solid transparent;margin-bottom:-1px;white-space:nowrap}\n.mem-subnav label:hover{color:inherit}\n\n\/* ---------- content details ---------- *\/\n.mem-eq{font-family:\"Cambria Math\",\"STIX Two Math\",\"Latin Modern Math\",Cambria,Georgia,serif;font-size:1.12em;text-align:center;padding:.7em 1em;border-radius:8px;background:var(--mem-surface);overflow-x:auto}\n.mem-note{border-left:3px solid var(--mem-accent);padding:.6em 1em;background:var(--mem-surface);border-radius:0 8px 8px 0}\n.mem-todo{background:#fff3b0;color:#5a4500;padding:0 .3em;border-radius:3px;font-size:.85em;font-weight:600}\n.mem-ref{padding-left:2.6em;text-indent:-2.6em}\n.mem-figure{margin-inline:auto;max-width:520px;text-align:center}\n.mem-figure svg{width:100%;height:auto;display:block}\n.mem-figure figcaption{font-size:.88em;color:var(--mem-muted);margin-top:.4em}\n.mem-panel .wp-block-table td,.mem-panel .wp-block-table th{padding:.5em .8em}\nsup a{text-decoration:none}\n\n\/* ---------- simulator ---------- *\/\n.mem-sim{--ms-v:#2563eb;--ms-i:#ea580c;--ms-s:#059669;--ms-iv:#1d5b94;--ms-bg:#fff;border:1px solid var(--mem-line);border-radius:14px;padding:16px;background:var(--ms-bg);font-size:15px;box-shadow:0 1px 3px rgba(0,0,0,.05)}\n.ms-bar{display:flex;flex-wrap:wrap;gap:10px;justify-content:space-between;align-items:center;margin-bottom:12px}\n.ms-seg{display:inline-flex;padding:3px;border-radius:999px;background:var(--mem-surface);border:1px solid var(--mem-line)}\n.ms-seg button{all:unset;cursor:pointer;padding:.38em 1em;border-radius:999px;font-weight:600;font-size:.9em;color:var(--mem-muted)}\n.ms-seg button.on{background:var(--ms-bg);color:var(--mem-accent);box-shadow:0 1px 3px rgba(0,0,0,.15)}\n.ms-seg button:focus-visible,.ms-btn:focus-visible{outline:2px solid var(--mem-accent);outline-offset:2px}\n.ms-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}\n.ms-btn{all:unset;cursor:pointer;padding:.4em 1em;border-radius:8px;border:1px solid var(--mem-line);font-weight:600;font-size:.9em}\n.ms-btn:hover{background:var(--mem-surface)}\n.ms-primary{background:var(--mem-accent);border-color:var(--mem-accent);color:#fff;min-width:4.5em;text-align:center}\n.ms-primary:hover{background:color-mix(in srgb,var(--mem-accent) 85%,#000)}\n.ms-small{font-size:.82em;padding:.3em .8em;justify-self:start}\n.ms-select{font:inherit;font-size:.9em;padding:.3em .5em;border-radius:8px;border:1px solid var(--mem-line);background:var(--ms-bg);color:inherit}\n.ms-check{display:inline-flex;gap:.4em;align-items:center;font-size:.9em;cursor:pointer}\n.ms-plots{display:grid;grid-template-columns:1.15fr 1fr;grid-template-rows:auto auto;gap:12px}\n.ms-fig{border:1px solid var(--mem-line);border-radius:10px;padding:8px 8px 4px;min-width:0}\n.ms-fig-title{font-size:.82em;font-weight:600;margin:0 0 4px 4px;color:var(--mem-muted)}\n.ms-fig canvas{display:block;width:100%}\n.ms-iv{grid-row:1 \/ span 2}\n.ms-iv canvas{height:410px}\n.ms-vt canvas,.ms-st canvas{height:170px}\n.ms-key{display:inline-block;width:14px;height:3px;border-radius:2px;vertical-align:middle;margin:0 5px 2px 0}\n.ms-kv{background:var(--ms-v)}.ms-ki{background:var(--ms-i)}.ms-ks{background:var(--ms-s)}\n.ms-readout{display:flex;flex-wrap:wrap;gap:6px 18px;font-variant-numeric:tabular-nums;font-size:.86em;padding:10px 4px;color:var(--mem-muted)}\n.ms-controls{display:grid;grid-template-columns:1fr 2fr;gap:12px;align-items:start}\n.ms-group{border:1px solid var(--mem-line);border-radius:10px;padding:8px 14px 12px;margin:0;display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px 18px;min-width:0}\n.ms-group legend{font-weight:700;font-size:.85em;padding:0 6px}\n.ms-ctl{display:grid;grid-template-columns:1fr auto;align-items:baseline;gap:0 8px;font-size:.86em}\n.ms-ctl input[type=range]{grid-column:1 \/ -1;width:100%;accent-color:var(--mem-accent);margin:2px 0}\n.ms-ctl .ms-select{grid-column:1 \/ -1}\n.ms-ctl output{font-variant-numeric:tabular-nums;color:var(--mem-accent);font-weight:600}\n@media (max-width:820px){\n  .ms-plots{grid-template-columns:1fr}\n  .ms-iv{grid-row:auto}\n  .ms-iv canvas{height:320px}\n  .ms-controls{grid-template-columns:1fr}\n}\n@media (max-width:600px){\n  .mem-nav label{padding:.5em .9em;font-size:.9em}\n  .mem-sim{padding:10px}\n}\n\n\/* readable text column inside the wide tab area; simulators, tables and figures keep the full width *\/\n.mem-panel > :is(p,h2,h3,h4,ul,ol,dl,.wp-block-details),.mem-subnav{max-width:780px;margin-inline:auto !important;box-sizing:border-box}\n.mem-panel > .wp-block-heading{width:100%}\n\n\/* ---------- PUF page: additions to mem_style.css ---------- *\/\n.puf-group{margin-top:12px !important}\n.puf-grid4{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}\n.puf-sq canvas{height:200px}\n.puf-memgrid{display:grid;grid-template-columns:1fr 1.4fr 1fr;gap:10px}\n.puf-hist canvas{height:200px}\n.puf-race canvas{height:150px}\n.puf-delta canvas{height:190px}\n.puf-race,.puf-delta,.puf-robars,.puf-robits,.puf-hd,.puf-ml{margin-top:10px}\n.puf-robars canvas{height:230px}\n.puf-robits canvas{height:34px}\n.puf-hd canvas{height:260px}\n.puf-ml canvas{height:320px}\n.puf-tiles{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0 0}\n.puf-tile{flex:1 1 150px;border:1px solid var(--mem-line);border-radius:10px;padding:7px 11px;background:var(--mem-surface);font-size:.85em;display:flex;flex-direction:column;gap:1px}\n.puf-tile span{color:var(--mem-muted)}\n.puf-tile strong{font-size:1.2em;font-variant-numeric:tabular-nums;word-break:break-all}\n.puf-tile em{font-style:normal;font-size:.85em;color:var(--mem-muted)}\n.puf-tile.puf-good strong{color:#047857}\n.puf-tile.puf-warn strong{color:#c2410c}\n.puf-chal{display:flex;flex-wrap:wrap;align-items:center;gap:4px;margin:4px 0 0}\n.puf-chal-l{font-size:.86em;color:var(--mem-muted);margin-right:6px}\n.puf-bit{all:unset;cursor:pointer;width:1.9em;text-align:center;padding:.25em 0;border-radius:6px;border:1px solid var(--mem-line);font-family:ui-monospace,Menlo,Consolas,monospace;font-weight:700}\n.puf-bit.on{background:var(--mem-accent);border-color:var(--mem-accent);color:#fff}\n.puf-bit:focus-visible{outline:2px solid var(--mem-accent);outline-offset:2px}\n.ms-btn.on{background:var(--mem-accent);color:#fff;border-color:var(--mem-accent)}\n.puf-fe{display:flex;flex-direction:column;gap:6px;overflow-x:auto}\n.puf-row{display:grid;grid-template-columns:210px 1fr;gap:10px;align-items:center}\n.puf-row-l{font-size:.85em;font-weight:600;line-height:1.2}\n.puf-row-l em{display:block;font-style:normal;font-weight:400;color:var(--mem-muted);font-size:.9em}\n.puf-bits{display:flex;flex-wrap:wrap;gap:2px 6px}\n.puf-bits span{display:inline-flex;gap:1px}\n.puf-bits i{display:inline-block;width:9px;height:16px;border-radius:2px;background:#e8edf4;box-shadow:inset 0 0 0 1px rgba(0,0,0,.08)}\n.puf-bits i.b1{background:var(--mem-accent)}\n.puf-bits i.b0.pub{background:#fde7c8}.puf-bits i.b1.pub{background:#d97706}\n.puf-bits i.x{background:#dc2626 !important}\n.puf-figure{max-width:900px;margin-inline:auto !important;text-align:center}\n.puf-figure svg{width:100%;height:auto;display:block;border-radius:16px}\n.puf-figure figcaption{font-size:.88em;color:var(--mem-muted);margin-top:.5em}\n@media (max-width:820px){\n  .puf-grid4{grid-template-columns:repeat(2,1fr)}\n  .puf-memgrid{grid-template-columns:1fr}\n  .puf-row{grid-template-columns:1fr}\n}\n\/* ---------- chaotic-encryption page: additions to mem_style.css and puf_style.css ---------- *\/\n.chx-grid{display:grid;grid-template-columns:1.5fr 1fr;grid-template-rows:auto auto;gap:10px}\n.chx-dig{grid-column:1;grid-row:1}\n.chx-phase{grid-column:2;grid-row:1 \/ span 2}\n.chx-err{grid-column:1;grid-row:2}\n.chx-dig canvas{height:200px}\n.chx-phase canvas{height:420px}\n.chx-err canvas{height:190px}\n.chx-sens canvas{height:300px}\n.chx-img4{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}\n.chx-sq canvas{height:200px;image-rendering:pixelated}\n.chx-lab{display:block;font-size:.86em;font-weight:600;margin-bottom:4px}\n.chx-ta{width:100%;box-sizing:border-box;font:inherit;font-size:.92em;padding:8px 10px;border-radius:8px;border:1px solid var(--mem-line);background:var(--ms-bg,#fff);color:inherit;resize:vertical}\n.chx-out{display:grid;gap:8px;margin-top:10px}\n.chx-box{border:1px solid var(--mem-line);border-radius:10px;padding:8px 12px;background:var(--mem-surface)}\n.chx-box span{display:block;font-size:.8em;font-weight:700;color:var(--mem-muted);margin-bottom:3px}\n.chx-box p{margin:0;font-size:.92em;word-break:break-word}\n.chx-box code{display:block;font-size:.8em;word-break:break-all;color:#b91c1c}\n.chx-ok{border-left:4px solid #16a34a}\n.chx-bad{border-left:4px solid #d97706}\n.chx-file{position:relative;overflow:hidden}\n.chx-file input{position:absolute;inset:0;opacity:0;cursor:pointer}\n.chx-note{font-size:.8em;color:var(--mem-muted)}\n.mem-panel .wp-block-table td,.mem-panel .wp-block-table th{font-variant-numeric:tabular-nums}\n@media (max-width:820px){\n  .chx-grid{grid-template-columns:1fr}\n  .chx-dig,.chx-phase,.chx-err{grid-column:auto;grid-row:auto}\n  .chx-phase canvas{height:300px}\n  .chx-img4{grid-template-columns:repeat(2,1fr)}\n}\n.chx-keys{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:8px 10px;margin-bottom:8px}\n.chx-kcell{display:flex;flex-direction:column;gap:2px;font-size:.84em}\n.chx-kname{font-weight:700}\n.chx-kin{font:inherit;font-variant-numeric:tabular-nums;padding:4px 6px;border-radius:6px;border:1px solid var(--mem-line);background:var(--ms-bg,#fff);color:inherit;width:100%;box-sizing:border-box}\n.chx-kin.chx-kmod{border-color:#d97706;box-shadow:0 0 0 1px #d97706}\n.chx-kin.chx-kbad{border-color:#dc2626;box-shadow:0 0 0 1px #dc2626}\n.chx-kq{font-size:.85em;color:var(--mem-muted);font-style:normal}\n.ms-group.chx-keygrp{display:block}\n.chx-keygrp .ms-bar{margin-top:4px}\n.chx-warn{margin:10px 0 0;padding:8px 12px;border-left:4px solid #d97706;background:rgba(217,119,6,.08);border-radius:6px;font-size:.9em}\n.chx-pwmrow{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:2px 0 8px;font-size:.9em}\n.chx-pwmrow .ms-select{max-width:100%}\n.chx-search{margin-top:6px}\n.chx-search .chx-note{flex:1 1 220px}\n.chx-jopts{margin-top:6px}\n\n#mem-t-introduction:checked ~ .mem-p-introduction{display:block}\n#mem-t-our-scheme:checked ~ .mem-p-our-scheme{display:block}\n#mem-t-try-it:checked ~ .mem-p-try-it{display:block}\n#mem-t-security:checked ~ .mem-p-security{display:block}\n#mem-t-references:checked ~ .mem-p-references{display:block}\n#mem-t-live-link:checked ~ .mem-p-live-link{display:block}\n#mem-t-text:checked ~ .mem-p-text{display:block}\n#mem-t-image:checked ~ .mem-p-image{display:block}\n#mem-t-introduction:checked ~ .mem-nav label[for=mem-t-introduction],#mem-t-our-scheme:checked ~ .mem-nav label[for=mem-t-our-scheme],#mem-t-try-it:checked ~ .mem-nav label[for=mem-t-try-it],#mem-t-security:checked ~ .mem-nav label[for=mem-t-security],#mem-t-references:checked ~ .mem-nav label[for=mem-t-references]{background:var(--ms-bg,#fff);color:var(--mem-accent);box-shadow:0 1px 3px rgba(0,0,0,.14)}\n#mem-t-introduction:focus-visible ~ .mem-nav label[for=mem-t-introduction],#mem-t-our-scheme:focus-visible ~ .mem-nav label[for=mem-t-our-scheme],#mem-t-try-it:focus-visible ~ .mem-nav label[for=mem-t-try-it],#mem-t-security:focus-visible ~ .mem-nav label[for=mem-t-security],#mem-t-references:focus-visible ~ .mem-nav label[for=mem-t-references],#mem-t-live-link:focus-visible ~ .mem-subnav label[for=mem-t-live-link],#mem-t-text:focus-visible ~ .mem-subnav label[for=mem-t-text],#mem-t-image:focus-visible ~ .mem-subnav label[for=mem-t-image]{outline:2px solid var(--mem-accent);outline-offset:2px}\n#mem-t-live-link:checked ~ .mem-subnav label[for=mem-t-live-link],#mem-t-text:checked ~ .mem-subnav label[for=mem-t-text],#mem-t-image:checked ~ .mem-subnav label[for=mem-t-image]{color:var(--mem-accent);border-bottom-color:var(--mem-accent)}\n<\/style>\n<input type=\"radio\" name=\"mem-tab\" id=\"mem-t-introduction\" checked><input type=\"radio\" name=\"mem-tab\" id=\"mem-t-our-scheme\"><input type=\"radio\" name=\"mem-tab\" id=\"mem-t-try-it\"><input type=\"radio\" name=\"mem-tab\" id=\"mem-t-security\"><input type=\"radio\" name=\"mem-tab\" id=\"mem-t-references\">\n<div class=\"mem-nav\" role=\"presentation\"><label for=\"mem-t-introduction\">Introduction<\/label><label for=\"mem-t-our-scheme\">Our scheme<\/label><label for=\"mem-t-try-it\">Try it<\/label><label for=\"mem-t-security\">Security and performance<\/label><label for=\"mem-t-references\">References<\/label><\/div>\n\n\n\n<div id=\"introduction\" class=\"wp-block-group mem-panel mem-p-introduction is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<h2 class=\"wp-block-heading\">Hiding a message in chaos<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A chaotic system is deterministic: given the same equations, parameters and starting point, it always does the same thing. Yet its output is aperiodic, has a broad, noise-like spectrum and depends extremely sensitively on its parameters and initial conditions (see <a href=\"https:\/\/memristors.uib.es\/index.php\/resources\/media\/whats-nonlinear-electronics\/#chaos\">What&#8217;s nonlinear electronics?<\/a>). To an outside observer a chaotic signal looks random, but someone who knows exactly how it was generated can reproduce it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In 1990 Pecora and Carroll showed that a chaotic system can be <strong>synchronised<\/strong> to a copy of itself by driving the copy with one of the original&#8217;s signals <sup><a href=\"#ref-pecora1990\">[3]<\/a><\/sup>. Cuomo and Oppenheim soon built a pair of synchronised Lorenz circuits and used them to transmit a hidden message <sup><a href=\"#ref-cuomo1993\">[4]<\/a><\/sup>. The principle of chaotic secure communication is:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <strong>transmitter<\/strong> mixes the message with a chaotic carrier, so that the transmitted signal looks like noise.<\/li>\n\n\n<li>The <strong>receiver<\/strong> contains an identical chaotic system, which synchronises to the transmitter from the received signal and regenerates the carrier.<\/li>\n\n\n<li>Removing the regenerated carrier recovers the message. An eavesdropper without an exact copy of the system, its <em>key<\/em>, cannot synchronise and sees only noise.<\/li>\n\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Why chaos for the Internet of Things?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">IoT devices need encryption, but they have very little memory, computing power and energy. In 2018 NIST launched a competition for <em>lightweight cryptography<\/em>, won by the Ascon family <sup><a href=\"#ref-turan2023\">[6]<\/a>,<a href=\"#ref-dobraunig2021\">[7]<\/a><\/sup>. Those algorithms are simplified versions of conventional cryptography, but they still need hundreds or thousands of logic cells. A chaotic system can be very small, a few additions, multiplications and a comparison per clock, and it encrypts bit by bit as the data stream in.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The challenge: chaos in the digital world<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Most chaotic communication systems are analogue or mixed-signal circuits. They are elegant, but two analogue circuits are never exactly identical: component tolerances, temperature and noise make it hard to match transmitter and receiver, and impossible to make thousands of identical devices. Our approach is to implement the whole scheme <strong>digitally<\/strong> <sup><a href=\"#ref-karagiorgos2024\">[1]<\/a><\/sup>. A digital circuit can be copied exactly, its parameters are numbers that do not drift, and it fits in an FPGA, a microcontroller or a few lines of software.<\/p>\n\n\n\n<p class=\"mem-note wp-block-paragraph\">The scheme is described in our paper in the <em>IEEE Internet of Things Journal<\/em> <sup><a href=\"#ref-karagiorgos2024\">[1]<\/a><\/sup>, which is open access, and the microcontroller code is <a href=\"https:\/\/github.com\/rpicos-uib\/chaotic_transmission_2022\">available on GitHub<\/a>. The next tab explains how it works.<\/p>\n\n\n<\/div>\n\n\n\n<div id=\"our-scheme\" class=\"wp-block-group mem-panel mem-p-our-scheme is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<h2 class=\"wp-block-heading\">A fully digital chaotic encryption scheme<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The scheme <sup><a href=\"#ref-karagiorgos2024\">[1]<\/a><\/sup> is built from the digital, non-autonomous chaotic oscillator presented in <sup><a href=\"#ref-stavrinides2013\">[2]<\/a><\/sup>. It has two parts with almost the same structure: an encoder-transmitter and a decoder-receiver.<\/p>\n\n\n\n<figure class=\"puf-figure\">\n<svg viewBox=\"0 0 1000 520\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" role=\"img\" aria-labelledby=\"chxfig-t chxfig-d\" font-family=\"system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif\">\n<title id=\"chxfig-t\">Digital chaotic encrypted communication scheme<\/title>\n<desc id=\"chxfig-d\">Block diagram. In the transmitter, a fourth-order IIR filter produces V1 and V2. V2 is compared with a threshold V0 by a shifted Heaviside function H; the result is XORed with the message M to give the transmitted signal F, which is also fed back into the filter through the coefficients c1 and c2 with one and two clock delays. F is the only signal sent over the channel. In the receiver, an identical IIR filter is driven by F and produces V2 prime; its Heaviside output H prime is XORed with F to recover the message M prime.<\/desc>\n<rect width=\"1000\" height=\"520\" rx=\"18\" fill=\"#f3f6fa\"\/>\n<rect x=\"20\" y=\"20\" width=\"960\" height=\"215\" rx=\"14\" fill=\"none\" stroke=\"#1d5b94\" stroke-width=\"1.5\" stroke-dasharray=\"6 5\"\/>\n<text x=\"40\" y=\"46\" font-size=\"15\" fill=\"#1d5b94\" font-weight=\"800\" text-anchor=\"start\">TRANSMITTER (encoder)<\/text>\n<rect x=\"160\" y=\"70\" width=\"120\" height=\"56\" rx=\"9\" fill=\"#ffffff\" stroke=\"#1d5b94\" stroke-width=\"2\"\/><text x=\"220.0\" y=\"98.0\" font-size=\"15\" fill=\"#1d5b94\" font-weight=\"700\" text-anchor=\"middle\">c\u2081 z\u207b\u00b9 + c\u2082 z\u207b\u00b2<\/text><text x=\"220.0\" y=\"117.0\" font-size=\"12.5\" fill=\"#5b6b85\" font-weight=\"400\" text-anchor=\"middle\">feedback of F<\/text>\n<rect x=\"340\" y=\"62\" width=\"190\" height=\"72\" rx=\"9\" fill=\"#ffffff\" stroke=\"#1d5b94\" stroke-width=\"2\"\/><text x=\"435.0\" y=\"98.0\" font-size=\"15\" fill=\"#1d5b94\" font-weight=\"700\" text-anchor=\"middle\">4th-order IIR filter<\/text><text x=\"435.0\" y=\"117.0\" font-size=\"12.5\" fill=\"#5b6b85\" font-weight=\"400\" text-anchor=\"middle\">\u03b1, b coefficients<\/text>\n<rect x=\"600\" y=\"70\" width=\"120\" height=\"56\" rx=\"9\" fill=\"#ffffff\" stroke=\"#1d5b94\" stroke-width=\"2\"\/><text x=\"660.0\" y=\"98.0\" font-size=\"15\" fill=\"#1d5b94\" font-weight=\"700\" text-anchor=\"middle\">H(V\u2080 \u2212 V\u2082)<\/text><text x=\"660.0\" y=\"117.0\" font-size=\"12.5\" fill=\"#5b6b85\" font-weight=\"400\" text-anchor=\"middle\">threshold V\u2080<\/text>\n<circle cx=\"800\" cy=\"98\" r=\"15\" fill=\"#ffffff\" stroke=\"#1d5b94\" stroke-width=\"2\"\/><path d=\"M785,98 L815,98 M800,83 L800,113\" stroke=\"#1d5b94\" stroke-width=\"2\"\/>\n<path d=\"M280,98 L340,98\" fill=\"none\" stroke=\"#1d5b94\" stroke-width=\"2\"\/><path d=\"M331,93 L340,98 L331,103 Z\" fill=\"#1d5b94\"\/>\n<path d=\"M530,98 L600,98\" fill=\"none\" stroke=\"#1d5b94\" stroke-width=\"2\"\/><path d=\"M591,93 L600,98 L591,103 Z\" fill=\"#1d5b94\"\/>\n<text x=\"565\" y=\"117\" font-size=\"13\" fill=\"#5b6b85\" font-weight=\"400\" text-anchor=\"middle\">V\u2082<\/text>\n<path d=\"M720,98 L785,98\" fill=\"none\" stroke=\"#1d5b94\" stroke-width=\"2\"\/><path d=\"M776,93 L785,98 L776,103 Z\" fill=\"#1d5b94\"\/>\n<text x=\"800\" y=\"170\" font-size=\"15\" fill=\"#16a34a\" font-weight=\"700\" text-anchor=\"middle\">M(n)<\/text>\n<text x=\"800\" y=\"188\" font-size=\"12\" fill=\"#5b6b85\" font-weight=\"400\" text-anchor=\"middle\">message<\/text>\n<path d=\"M800,156 L800,113\" fill=\"none\" stroke=\"#16a34a\" stroke-width=\"2\"\/><path d=\"M795,122 L800,113 L805,122 Z\" fill=\"#16a34a\"\/>\n<path d=\"M815,98 L930,98\" fill=\"none\" stroke=\"#dc2626\" stroke-width=\"2\"\/><path d=\"M921,93 L930,98 L921,103 Z\" fill=\"#dc2626\"\/>\n<text x=\"905\" y=\"88\" font-size=\"15\" fill=\"#dc2626\" font-weight=\"700\" text-anchor=\"middle\">F(n)<\/text>\n<path d=\"M870,98 L870,205 L120,205 L120,98 L160,98\" fill=\"none\" stroke=\"#dc2626\" stroke-width=\"2\"\/><path d=\"M151,93 L160,98 L151,103 Z\" fill=\"#dc2626\"\/>\n<path d=\"M930,98 L950,98 L950,275 L120,275 L120,300\" fill=\"none\" stroke=\"#dc2626\" stroke-width=\"2.5\" stroke-dasharray=\"7 5\"\/><path d=\"M115,291 L120,300 L125,291 Z\" fill=\"#dc2626\"\/>\n<rect x=\"300\" y=\"257\" width=\"400\" height=\"36\" rx=\"18\" fill=\"#fff\" stroke=\"#dc2626\" stroke-width=\"1.5\"\/>\n<text x=\"500\" y=\"280\" font-size=\"14\" fill=\"#dc2626\" font-weight=\"700\" text-anchor=\"middle\">channel: only F(n) is sent, no separate sync line<\/text>\n<rect x=\"20\" y=\"305\" width=\"960\" height=\"195\" rx=\"14\" fill=\"none\" stroke=\"#2563eb\" stroke-width=\"1.5\" stroke-dasharray=\"6 5\"\/>\n<text x=\"40\" y=\"485\" font-size=\"15\" fill=\"#2563eb\" font-weight=\"800\" text-anchor=\"start\">RECEIVER (decoder)<\/text>\n<rect x=\"160\" y=\"352\" width=\"120\" height=\"56\" rx=\"9\" fill=\"#ffffff\" stroke=\"#2563eb\" stroke-width=\"2\"\/><text x=\"220.0\" y=\"380.0\" font-size=\"15\" fill=\"#2563eb\" font-weight=\"700\" text-anchor=\"middle\">c\u2081 z\u207b\u00b9 + c\u2082 z\u207b\u00b2<\/text><text x=\"220.0\" y=\"399.0\" font-size=\"12.5\" fill=\"#5b6b85\" font-weight=\"400\" text-anchor=\"middle\">driven by F<\/text>\n<rect x=\"340\" y=\"344\" width=\"190\" height=\"72\" rx=\"9\" fill=\"#ffffff\" stroke=\"#2563eb\" stroke-width=\"2\"\/><text x=\"435.0\" y=\"380.0\" font-size=\"15\" fill=\"#2563eb\" font-weight=\"700\" text-anchor=\"middle\">identical IIR filter<\/text><text x=\"435.0\" y=\"399.0\" font-size=\"12.5\" fill=\"#5b6b85\" font-weight=\"400\" text-anchor=\"middle\">same key: \u03b1, b, c<\/text>\n<rect x=\"600\" y=\"352\" width=\"120\" height=\"56\" rx=\"9\" fill=\"#ffffff\" stroke=\"#2563eb\" stroke-width=\"2\"\/><text x=\"660.0\" y=\"380.0\" font-size=\"15\" fill=\"#2563eb\" font-weight=\"700\" text-anchor=\"middle\">H\u2032(V\u2080 \u2212 V\u2032\u2082)<\/text><text x=\"660.0\" y=\"399.0\" font-size=\"12.5\" fill=\"#5b6b85\" font-weight=\"400\" text-anchor=\"middle\">same V\u2080<\/text>\n<circle cx=\"800\" cy=\"380\" r=\"15\" fill=\"#ffffff\" stroke=\"#2563eb\" stroke-width=\"2\"\/><path d=\"M785,380 L815,380 M800,365 L800,395\" stroke=\"#2563eb\" stroke-width=\"2\"\/>\n<path d=\"M120,300 L120,380 L160,380\" fill=\"none\" stroke=\"#dc2626\" stroke-width=\"2\"\/><path d=\"M151,375 L160,380 L151,385 Z\" fill=\"#dc2626\"\/>\n<path d=\"M280,380 L340,380\" fill=\"none\" stroke=\"#2563eb\" stroke-width=\"2\"\/><path d=\"M331,375 L340,380 L331,385 Z\" fill=\"#2563eb\"\/>\n<path d=\"M530,380 L600,380\" fill=\"none\" stroke=\"#2563eb\" stroke-width=\"2\"\/><path d=\"M591,375 L600,380 L591,385 Z\" fill=\"#2563eb\"\/>\n<text x=\"565\" y=\"399\" font-size=\"13\" fill=\"#5b6b85\" font-weight=\"400\" text-anchor=\"middle\">V\u2032\u2082<\/text>\n<path d=\"M720,380 L785,380\" fill=\"none\" stroke=\"#2563eb\" stroke-width=\"2\"\/><path d=\"M776,375 L785,380 L776,385 Z\" fill=\"#2563eb\"\/>\n<path d=\"M120,330 L800,330 L800,365\" fill=\"none\" stroke=\"#dc2626\" stroke-width=\"2\"\/><path d=\"M795,356 L800,365 L805,356 Z\" fill=\"#dc2626\"\/>\n<path d=\"M815,380 L930,380\" fill=\"none\" stroke=\"#16a34a\" stroke-width=\"2\"\/><path d=\"M921,375 L930,380 L921,385 Z\" fill=\"#16a34a\"\/>\n<text x=\"890\" y=\"368\" font-size=\"15\" fill=\"#16a34a\" font-weight=\"700\" text-anchor=\"middle\">M\u2032(n)<\/text>\n<text x=\"890\" y=\"410\" font-size=\"13\" fill=\"#5b6b85\" font-weight=\"400\" text-anchor=\"middle\">= F \u2295 H\u2032 = M<\/text>\n<text x=\"470\" y=\"455\" font-size=\"14\" fill=\"#13294b\" font-weight=\"600\" text-anchor=\"middle\">Once V\u2032\u2082 follows V\u2082, H\u2032 = H and the XOR cancels the chaos: M \u2295 H \u2295 H = M<\/text>\n<\/svg>\n<figcaption>The scheme, redrawn after Fig. 1 of our paper: the message drives the chaotic oscillator through the XOR feedback, and the same transmitted signal F synchronises the receiver.<\/figcaption>\n<\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">The transmitter<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">At its core is a fourth-order IIR (infinite impulse response) digital filter with two internal signals, <em>V<\/em><sub>1<\/sub> and <em>V<\/em><sub>2<\/sub>. A nonlinearity, the shifted Heaviside function <em>H<\/em>(<em>V<\/em><sub>0<\/sub> \u2212 <em>V<\/em><sub>2<\/sub>), equal to 1 when <em>V<\/em><sub>2<\/sub> is below the threshold <em>V<\/em><sub>0<\/sub> = 0.35 and 0 otherwise, turns <em>V<\/em><sub>2<\/sub> into a bit. That bit is XORed with the message bit <em>M<\/em>(<em>n<\/em>), and the result <em>F<\/em>(<em>n<\/em>) is both the transmitted signal and the input fed back into the filter. With one clock period <em>T<\/em><sub>S<\/sub>:<\/p>\n\n\n\n<p class=\"mem-eq wp-block-paragraph\"><em>V<\/em><sub>1<\/sub>(<em>n<\/em>) = \u03b1<sub>11<\/sub><em>V<\/em><sub>1<\/sub>(<em>n<\/em>\u22121) + \u03b1<sub>12<\/sub><em>V<\/em><sub>1<\/sub>(<em>n<\/em>\u22122) + \u03b1<sub>21<\/sub><em>V<\/em><sub>2<\/sub>(<em>n<\/em>\u22121) + \u03b1<sub>22<\/sub><em>V<\/em><sub>2<\/sub>(<em>n<\/em>\u22122) + <em>c<\/em><sub>1<\/sub><em>F<\/em>(<em>n<\/em>\u22121) + <em>c<\/em><sub>2<\/sub><em>F<\/em>(<em>n<\/em>\u22122)<br><em>V<\/em><sub>2<\/sub>(<em>n<\/em>) = <em>b<\/em><sub>11<\/sub><em>V<\/em><sub>1<\/sub>(<em>n<\/em>\u22121) + <em>b<\/em><sub>12<\/sub><em>V<\/em><sub>1<\/sub>(<em>n<\/em>\u22122) + <em>b<\/em><sub>21<\/sub><em>V<\/em><sub>2<\/sub>(<em>n<\/em>\u22121) + <em>b<\/em><sub>22<\/sub><em>V<\/em><sub>2<\/sub>(<em>n<\/em>\u22122)<br><em>F<\/em>(<em>n<\/em>) = <em>M<\/em>(<em>n<\/em>) \u2295 <em>H<\/em>[<em>V<\/em><sub>0<\/sub> \u2212 <em>V<\/em><sub>2<\/sub>(<em>n<\/em>)]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The filter on its own is stable, so the signals cannot run away to infinity; the feedback through the XOR and the Heaviside function supplies the nonlinearity and the drive that make the oscillator chaotic. Because the oscillator is <em>non-autonomous<\/em>, the message itself keeps the chaos going: the information is not added on top of the chaotic carrier, it drives it. The coefficients were obtained from a stability analysis of the filter that also set the clock period, <em>T<\/em><sub>S<\/sub> = 3.2 \u00b5s (312.5 kHz) <sup><a href=\"#ref-stavrinides2013\">[2]<\/a><\/sup>. Following <sup><a href=\"#ref-stavrinides2013\">[2]<\/a><\/sup>, the resulting system is a chaotic system with minimum embedding dimension 5, fractal dimension 3.4 and Kolmogorov\u2013Sinai entropy of 0.40 bits\/s.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Coefficient<\/th><th>Value<\/th><th>Q6.10 value (FPGA)<\/th><th>Coefficient<\/th><th>Value<\/th><th>Q6.10 value (FPGA)<\/th><\/tr><\/thead><tbody><tr><td>\u03b1<sub>11<\/sub><\/td><td>0.9905882<\/td><td>0.9902343750<\/td><td><em>b<\/em><sub>11<\/sub><\/td><td>\u22120.4800000<\/td><td>\u22120.4794921875<\/td><\/tr><tr><td>\u03b1<sub>12<\/sub><\/td><td>0.0031372<\/td><td>0.0029296875<\/td><td><em>b<\/em><sub>12<\/sub><\/td><td>0.1600000<\/td><td>0.1591796875<\/td><\/tr><tr><td>\u03b1<sub>21<\/sub><\/td><td>0.4800000<\/td><td>0.4794921875<\/td><td><em>b<\/em><sub>21<\/sub><\/td><td>0.9905882<\/td><td>0.9902343750<\/td><\/tr><tr><td>\u03b1<sub>22<\/sub><\/td><td>\u22120.1481480<\/td><td>\u22120.1474609375<\/td><td><em>b<\/em><sub>22<\/sub><\/td><td>0.0031372<\/td><td>0.0029296875<\/td><\/tr><tr><td><em>c<\/em><sub>1<\/sub><\/td><td>1.0666666<\/td><td>1.0664062500<\/td><td><em>c<\/em><sub>2<\/sub><\/td><td>\u22120.3555550<\/td><td>\u22120.3554687500<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">The receiver<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The receiver contains an identical IIR filter, but without its own feedback loop: it is <em>driven<\/em> by the received signal <em>F<\/em>(<em>n<\/em>) through the same coefficients <em>c<\/em><sub>1<\/sub> and <em>c<\/em><sub>2<\/sub>. If its coefficients are the same as the transmitter&#8217;s, its internal signals <em>V\u2032<\/em><sub>1<\/sub> and <em>V\u2032<\/em><sub>2<\/sub> converge to <em>V<\/em><sub>1<\/sub> and <em>V<\/em><sub>2<\/sub>, its Heaviside function reproduces the transmitter&#8217;s, and a second XOR removes it:<\/p>\n\n\n\n<p class=\"mem-eq wp-block-paragraph\"><em>M\u2032<\/em>(<em>n<\/em>) = <em>F<\/em>(<em>n<\/em>) \u2295 <em>H\u2032<\/em>[<em>V<\/em><sub>0<\/sub> \u2212 <em>V\u2032<\/em><sub>2<\/sub>(<em>n<\/em>)] = <em>M<\/em>(<em>n<\/em>) \u2295 <em>H<\/em> \u2295 <em>H\u2032<\/em> = <em>M<\/em>(<em>n<\/em>) &nbsp;&nbsp;when <em>H\u2032<\/em> = <em>H<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No separate synchronisation signal is needed: the encrypted signal itself synchronises the receiver.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why the receiver synchronises<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Subtracting the receiver&#8217;s equations from the transmitter&#8217;s, the drive terms cancel and the errors \u0394<em>V<\/em><sub>1<\/sub> = <em>V<\/em><sub>1<\/sub> \u2212 <em>V\u2032<\/em><sub>1<\/sub> and \u0394<em>V<\/em><sub>2<\/sub> = <em>V<\/em><sub>2<\/sub> \u2212 <em>V\u2032<\/em><sub>2<\/sub> obey a <em>linear<\/em> system with the filter&#8217;s own coefficients. Its four characteristic roots all lie inside the unit circle, so any initial difference decays to zero and synchronisation is guaranteed, whatever the message:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Characteristic roots<\/th><th>Exact coefficients<\/th><th>Q6.10 coefficients<\/th><th>Meaning<\/th><\/tr><\/thead><tbody><tr><td>Dominant pair<\/td><td>0.9420 \u00b1 0.3336 j, |<em>z<\/em>| = 0.9994<\/td><td>0.9417 \u00b1 0.3338 j, |<em>z<\/em>| = 0.9991<\/td><td>slowly decaying oscillation with a period of about 18 clocks<\/td><\/tr><tr><td>Fast pair<\/td><td>0.0485 \u00b1 0.1462 j, |<em>z<\/em>| = 0.154<\/td><td>0.0486 \u00b1 0.1455 j, |<em>z<\/em>| = 0.153<\/td><td>dies out within a few clocks<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">These roots, which we computed from the coefficients above, explain the shape of the synchronisation transient measured in the paper: an oscillating error, with a period of about 18 clocks, that shrinks within a few hundred clocks. You can watch the same transient in the <a href=\"#live-link\">Live link<\/a> simulator.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sending data<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the FPGA implementation each data bit is sent with pulse-width modulation: a bit lasts 16 chaotic clocks (51.2 \u00b5s) and is a pulse with a 75 % duty cycle for a 1 and 25 % for a 0. The receiver&#8217;s PWM demodulator measures the duty cycle of <em>M\u2032<\/em>(<em>n<\/em>). The simulators on this page do the same.<\/p>\n\n\n<\/div>\n\n\n\n<div id=\"try-it\" class=\"wp-block-group mem-panel mem-p-try-it is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<h2 class=\"wp-block-heading\">Try it<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These simulators implement equations (1)\u2013(3) of the paper exactly, with the coefficients above (or your own), in the same Q6.10 fixed-point arithmetic as the FPGA (16-bit signed numbers with 10 fractional bits) or in floating point. Each one also runs an <strong>eavesdropper<\/strong>: a receiver whose key differs from the transmitter&#8217;s in one coefficient.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The key<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Every simulator starts from the paper&#8217;s parameters (Table II), but you can change them here: edit any coefficient or the threshold <em>V<\/em><sub>0<\/sub> and press <strong>Apply<\/strong> (or Enter). Transmitter and legitimate receiver always share the key; the eavesdropper&#8217;s error is applied on top of it. Changed values are outlined, and the tiles give a quick check of the new key: whether the oscillator stays bounded, whether the receiver still locks on, and how often <em>F<\/em> equals the message. Not every key works: because transmitter and receiver are driven by the same <em>F<\/em>, the receiver&#8217;s error obeys the linear recursion <em>e<\/em>(<em>n<\/em>) = <em>A<\/em>\u00b7<em>e<\/em>(<em>n<\/em>\u22121), so the receiver only synchronises if the spectral radius of the filter matrix <em>A<\/em> is below 1. The paper&#8217;s key sits just inside (0.9995), which is why locking on takes a few hundred clocks. The <strong>PWM clock<\/strong> selector sets how many chaotic clocks each PWM bit lasts: every message bit is sent as the four PWM bits 1110 (for 1) or 1000 (for 0), so a message bit takes 64, 16 (the paper&#8217;s FPGA) or 4 chaotic clocks. Before the data, every simulator sends a lock-in <strong>preamble<\/strong> of alternating 1s and 0s whose length you can choose; the paper does not specify one, so the default of 1,024 chaotic clocks is our choice. <strong>Test values<\/strong> loads an alternative key, found with the search below, together with PWM_CLK = CH_CLK and a 16,384-clock preamble; <strong>Paper values<\/strong> restores the paper&#8217;s key, PWM clock and the default preamble. <strong>Run random until F equals M is within \u00b1x % of 50 %<\/strong> tries random keys around the paper&#8217;s (coefficients within the chosen spread, and <em>V<\/em><sub>0<\/sub> within the chosen absolute range around 0.35, since the bias of <em>F<\/em> depends mainly on where the threshold sits) and stops at the first one whose receiver synchronises without errors and whose transmitted signal <em>F<\/em> agrees with the message 50 % of the time within the chosen tolerance. Values far from 50 % in either direction leak the message: an attacker who sees <em>F<\/em> = <em>M<\/em> only 40 % of the time simply inverts <em>F<\/em> and is right 60 % of the time.<\/p>\n\n\n\n<div class=\"mem-sim chx-key\"><noscript>This interactive simulation needs JavaScript.<\/noscript><\/div>\n\n\n\n<div class=\"wp-block-group mem-subtabs is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<input type=\"radio\" name=\"chx-sub\" id=\"mem-t-live-link\" checked><input type=\"radio\" name=\"chx-sub\" id=\"mem-t-text\"><input type=\"radio\" name=\"chx-sub\" id=\"mem-t-image\">\n<div class=\"mem-subnav\" role=\"presentation\"><label for=\"mem-t-live-link\">Live link<\/label><label for=\"mem-t-text\">Encrypt text<\/label><label for=\"mem-t-image\">Encrypt an image<\/label><\/div>\n\n\n\n<div id=\"live-link\" class=\"wp-block-group mem-panel mem-p-live-link is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<h3 class=\"wp-block-heading\">Live link<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The transmitter and two receivers run clock by clock. The receivers start from random states, so you can see them lock on (or fail to).<\/p>\n\n\n\n<div class=\"mem-sim chx-link\"><noscript>This interactive simulation needs JavaScript.<\/noscript><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Things to try<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Press <strong>Restart receivers<\/strong> and watch the blue synchronisation error fall: after a few hundred clocks <em>M\u2032<\/em> equals <em>M<\/em>.<\/li>\n\n\n<li>Look at <em>F<\/em>: it carries the message, but it has no visible relation to it.<\/li>\n\n\n<li>Reduce the eavesdropper&#8217;s error towards 0 %: below a small fraction of a percent the eavesdropper starts decoding, which shows how precisely the key must be known.<\/li>\n\n\n<li>Choose <strong>Message: none<\/strong>: without a driving message the non-autonomous oscillator settles down, so in practice the data, or a preamble, keep it chaotic.<\/li>\n\n<\/ul>\n\n\n<\/div>\n\n\n\n<div id=\"text\" class=\"wp-block-group mem-panel mem-p-text is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<h3 class=\"wp-block-heading\">Encrypt text<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the paper, two Arduino boards exchanged the first paragraph of <em>Don Quixote<\/em>. Here the text is converted to bits (UTF-8), sent with the PWM scheme after a short preamble that lets the receiver lock on, and decoded by both receivers. Then try the eavesdropper with an error in c<sub>1<\/sub> or c<sub>2<\/sub> instead of \u03b1<sub>11<\/sub>.<\/p>\n\n\n\n<div class=\"mem-sim chx-text\"><noscript>This interactive simulation needs JavaScript.<\/noscript><\/div>\n\n\n<\/div>\n\n\n\n<div id=\"image\" class=\"wp-block-group mem-panel mem-p-image is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<h3 class=\"wp-block-heading\">Encrypt an image<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The FPGA demonstration sent a black-and-white QR code through the 16,384-bit block RAM of the Spartan-3E. Here a 64 \u00d7 64 black-and-white picture (4,096 bits) is encrypted, transmitted and decoded. Switch to <strong>JPEG file<\/strong> to send a compressed file instead: the picture is encoded as a real JPEG, its bytes are sent bit by bit through the chaotic link, and each receiver tries to open what it got as a JPEG. You can also load your own image (a JPEG of up to 24 kB can be sent unchanged); it is processed only in your browser.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Compression changes the picture of security. In a bitmap, neighbouring pixels are alike, so a receiver that gets 70 % of the bits right still shows a recognisable picture; a JPEG is compact, high-entropy data in which a few wrong bits already make the file unreadable or garble it. The legitimate receiver must therefore be error-free (look at the <em>Received bytes wrong<\/em> tile, and try PWM_CLK = CH_CLK with a short preamble), while the eavesdropper&#8217;s file normally cannot even be opened.<\/p>\n\n\n\n<div class=\"mem-sim chx-img\"><noscript>This interactive simulation needs JavaScript.<\/noscript><\/div>\n\n\n<\/div>\n\n\n<\/div>\n\n\n<\/div>\n\n\n\n<div id=\"security\" class=\"wp-block-group mem-panel mem-p-security is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<h2 class=\"wp-block-heading\">Security and performance<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">The key<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The secret shared by transmitter and receiver is the system itself: the filter coefficients (the paper discusses the <em>a<\/em>, <em>b<\/em> and <em>c<\/em> constants) and the initial conditions. A brute-force attack must find five parameters and four initial conditions; with <em>N<\/em> = 10 bits each that is a search space of (2<sup>10<\/sup>)<sup>9<\/sup> = 2<sup>90<\/sup> possibilities <sup><a href=\"#ref-karagiorgos2024\">[1]<\/a><\/sup>. Smarter attacks search for the parameters that minimise the Hamming distance between the eavesdropper&#8217;s output and the transmitted signal <sup><a href=\"#ref-zanin2013\">[8]<\/a><\/sup>, but they must still explore a nine-dimensional space with many local minima.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Key sensitivity<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">How precisely must the receiver know the key? The simulator below sends 300 random bits for a range of errors in one coefficient of the receiver and measures the bit-error rate. For \u03b1<sub>11<\/sub>, as in the paper&#8217;s Fig. 13, a +1 % mismatch already scrambles the output; try other coefficients and signs to see how the sensitivity varies from one key parameter to another.<\/p>\n\n\n\n<div class=\"mem-sim chx-sens\"><noscript>This interactive simulation needs JavaScript.<\/noscript><\/div>\n\n\n\n<p class=\"mem-note wp-block-paragraph\">In Q6.10 arithmetic every coefficient is rounded to a multiple of 1\/1024, so changes smaller than that step may round to the same value and have no effect; the effective precision of the key is set by the word length.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Hardware cost<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">On a Xilinx Spartan-3E (XC3S500E) the transmitter uses a tiny fraction of the device <sup><a href=\"#ref-karagiorgos2024\">[1]<\/a><\/sup>:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Resource<\/th><th>Used<\/th><th>Available<\/th><th>Utilisation<\/th><\/tr><\/thead><tbody><tr><td>Slices<\/td><td>29<\/td><td>4,656<\/td><td>0.62 %<\/td><\/tr><tr><td>Slice flip-flops<\/td><td>1<\/td><td>9,312<\/td><td>0.01 %<\/td><\/tr><tr><td>4-input LUTs<\/td><td>56<\/td><td>9,312<\/td><td>0.60 %<\/td><\/tr><tr><td>Bonded IOBs<\/td><td>35<\/td><td>232<\/td><td>15.08 %<\/td><\/tr><tr><td>MULT18\u00d718<\/td><td>5<\/td><td>20<\/td><td>25.00 %<\/td><\/tr><tr><td>Global clocks<\/td><td>1<\/td><td>24<\/td><td>4.16 %<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">For comparison, FPGA implementations of the NIST lightweight-cryptography finalists need far more logic. These figures, reported for a Xilinx Artix-7, can only be compared qualitatively with our Spartan-3E result <sup><a href=\"#ref-karagiorgos2024\">[1]<\/a><\/sup>:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Implementation<\/th><th>LUTs<\/th><th>Flip-flops<\/th><th>Slices<\/th><\/tr><\/thead><tbody><tr><td><strong>Our scheme<\/strong> (Spartan-3E)<\/td><td><strong>56<\/strong><\/td><td><strong>1<\/strong><\/td><td><strong>29<\/strong><\/td><\/tr><tr><td>ASCON_GMU-v2<\/td><td>1,790<\/td><td>974<\/td><td>513<\/td><\/tr><tr><td>Elephant-v5<\/td><td>2,645<\/td><td>1,502<\/td><td>759<\/td><\/tr><tr><td>GIFT-COFB_GMU-v6<\/td><td>2,363<\/td><td>872<\/td><td>696<\/td><\/tr><tr><td>PHOTON-Beetle-v1<\/td><td>2,065<\/td><td>729<\/td><td>620<\/td><\/tr><tr><td>Romulus-v5<\/td><td>887<\/td><td>422<\/td><td>246<\/td><\/tr><tr><td>TinyJAMBU-TJT-v3<\/td><td>576<\/td><td>432<\/td><td>215<\/td><\/tr><tr><td>Xoodyak_XT-v8<\/td><td>2,443<\/td><td>559<\/td><td>618<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Software cost<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">On an ESP32 microcontroller, a non-optimised implementation needs less memory and less time per encrypted byte than the NIST lightweight finalists, as evaluated by NIST <sup><a href=\"#ref-karagiorgos2024\">[1]<\/a>,<a href=\"#ref-turan2023\">[6]<\/a><\/sup>:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Algorithm<\/th><th>Memory (kB)<\/th><th>Time per byte (\u00b5s)<\/th><\/tr><\/thead><tbody><tr><td><strong>Our scheme<\/strong><\/td><td><strong>29.5<\/strong><\/td><td><strong>5.39<\/strong><\/td><\/tr><tr><td>AES-GCM<\/td><td>33.9<\/td><td>67.75<\/td><\/tr><tr><td>ASCON<\/td><td>32.2<\/td><td>22.86<\/td><\/tr><tr><td>Elephant<\/td><td>33.7<\/td><td>3986.3<\/td><\/tr><tr><td>GIFT-COFB<\/td><td>33.6<\/td><td>55.61<\/td><\/tr><tr><td>GRAIN-128AED<\/td><td>33.0<\/td><td>119.72<\/td><\/tr><tr><td>ISAP<\/td><td>32.6<\/td><td>608.46<\/td><\/tr><tr><td>PHOTON-Beetle<\/td><td>33.4<\/td><td>185.76<\/td><\/tr><tr><td>Romulus<\/td><td>33.5<\/td><td>114.16<\/td><\/tr><tr><td>SPARKLE<\/td><td>32.5<\/td><td>62.2<\/td><\/tr><tr><td>TinyJAMBU<\/td><td>32.3<\/td><td>43.59<\/td><\/tr><tr><td>Xoodyak<\/td><td>32.6<\/td><td>39.18<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Side channels<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The time needed to encrypt or decrypt does not depend on the key or the message, so timing attacks do not apply. Power analysis is also difficult, because the message interacts with the chaotic signal one bit at a time in a single XOR gate. Experimental side-channel testing is still pending.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Open questions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Chaos-based cryptography is a young field, and several proposed schemes have been broken; Alvarez and Li list the requirements such systems must meet <sup><a href=\"#ref-alvarez2006\">[5]<\/a><\/sup>. Our future work includes testing the scheme under noisy conditions, a formal evaluation of its encryption strength, combining it with a physical unclonable function to derive the key (see <a href=\"https:\/\/memristors.uib.es\/index.php\/resources\/media\/what-are-pufs\/\">What are PUFs?<\/a>), and integrating it into a wireless platform. A further countermeasure against brute-force attacks would be to change the parameters dynamically, driven by another chaotic system, after a given amount of information has been transmitted.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Our work on chaotic communications<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A digital non-autonomous chaotic oscillator for information transmission <sup><a href=\"#ref-stavrinides2013\">[2]<\/a><\/sup>.<\/li>\n\n\n<li>The digital chaotic encrypted communication scheme on FPGA, Arduino and ESP32 <sup><a href=\"#ref-karagiorgos2024\">[1]<\/a><\/sup>.<\/li>\n\n\n<li>Real-world encrypted communication with synchronised chaotic circuits without a dedicated synchronisation line, and with synchronised Lorenz circuits <sup><a href=\"#ref-anagnostopoulos2024\">[9]<\/a>,<a href=\"#ref-george2024\">[10]<\/a><\/sup>.<\/li>\n\n\n<li>Secure communication for unmanned aerial vehicles based on chaotic communication architectures <sup><a href=\"#ref-souli2024\">[11]<\/a>,<a href=\"#ref-souli2025\">[12]<\/a><\/sup>.<\/li>\n\n\n<li>Stochastic computing implementations of chaotic systems <sup><a href=\"#ref-camps2021\">[13]<\/a><\/sup>.<\/li>\n\n<\/ul>\n\n\n<\/div>\n\n\n\n<div id=\"references\" class=\"wp-block-group mem-panel mem-p-references is-layout-flow wp-block-group-is-layout-flow\">\n\n\n<h2 class=\"wp-block-heading\">References<\/h2>\n\n\n\n<p id=\"ref-karagiorgos2024\" class=\"mem-ref wp-block-paragraph\">[1] N. F. Karagiorgos, S. G. Stavrinides, C. de Benito, S. Nikolaidis and R. Picos, &#8220;Unconventional security for IoT: hardware and software implementation of a digital chaotic encrypted communication scheme,&#8221; <em>IEEE Internet of Things Journal<\/em>, vol. 11, no. 11, pp. 19914\u201319925, 2024. <a href=\"https:\/\/doi.org\/10.1109\/JIOT.2024.3371091\">doi:10.1109\/JIOT.2024.3371091<\/a> (open access).<\/p>\n\n\n\n<p id=\"ref-stavrinides2013\" class=\"mem-ref wp-block-paragraph\">[2] S. G. Stavrinides, N. Karagiorgos, K. Papathanasiou, S. Nikolaidis and A. Anagnostopoulos, &#8220;A digital nonautonomous chaotic oscillator suitable for information transmission,&#8221; <em>IEEE Transactions on Circuits and Systems II: Express Briefs<\/em>, vol. 60, no. 12, pp. 887\u2013891, 2013.<\/p>\n\n\n\n<p id=\"ref-pecora1990\" class=\"mem-ref wp-block-paragraph\">[3] L. M. Pecora and T. L. Carroll, &#8220;Synchronization in chaotic systems,&#8221; <em>Physical Review Letters<\/em>, vol. 64, no. 8, pp. 821\u2013824, 1990.<\/p>\n\n\n\n<p id=\"ref-cuomo1993\" class=\"mem-ref wp-block-paragraph\">[4] K. M. Cuomo and A. V. Oppenheim, &#8220;Circuit implementation of synchronized chaos with applications to communications,&#8221; <em>Physical Review Letters<\/em>, vol. 71, no. 1, pp. 65\u201368, 1993.<\/p>\n\n\n\n<p id=\"ref-alvarez2006\" class=\"mem-ref wp-block-paragraph\">[5] G. Alvarez and S. Li, &#8220;Some basic cryptographic requirements for chaos-based cryptosystems,&#8221; <em>International Journal of Bifurcation and Chaos<\/em>, vol. 16, no. 8, pp. 2129\u20132151, 2006.<\/p>\n\n\n\n<p id=\"ref-turan2023\" class=\"mem-ref wp-block-paragraph\">[6] M. S. Turan <em>et al.<\/em>, &#8220;Status report on the final round of the NIST lightweight cryptography standardization process,&#8221; National Institute of Standards and Technology, NIST IR 8454, 2023.<\/p>\n\n\n\n<p id=\"ref-dobraunig2021\" class=\"mem-ref wp-block-paragraph\">[7] C. Dobraunig, M. Eichlseder, F. Mendel and M. Schl\u00e4ffer, &#8220;Ascon v1.2: lightweight authenticated encryption and hashing,&#8221; <em>Journal of Cryptology<\/em>, vol. 34, art. 33, 2021.<\/p>\n\n\n\n<p id=\"ref-zanin2013\" class=\"mem-ref wp-block-paragraph\">[8] M. Zanin, J. Sevilla-Escoboza, R. Jaimes-Re\u00e1tegui, J. Garc\u00eda-L\u00f3pez, G. Huerta-Cuellar and A. N. Pisarchik, &#8220;Synchronization attack to chaotic communication systems,&#8221; <em>Discontinuity, Nonlinearity, and Complexity<\/em>, vol. 2, no. 4, pp. 333\u2013343, 2013.<\/p>\n\n\n\n<p id=\"ref-anagnostopoulos2024\" class=\"mem-ref wp-block-paragraph\">[9] N. A. Anagnostopoulos, A. E. George, N. Mexis, T. Arul, S. Katzenbeisser, R. Picos and S. G. Stavrinides, &#8220;The synchronisation is the message: real-world encrypted communication based on synchronised chaotic circuits without using a dedicated synchronisation line,&#8221; in <em>13th International Conference on Modern Circuits and Systems Technologies (MOCAST)<\/em>, 2024, pp. 1\u20136.<\/p>\n\n\n\n<p id=\"ref-george2024\" class=\"mem-ref wp-block-paragraph\">[10] A. E. George, E. Gel\u00f3czi, N. Mexis, T. Arul, S. Katzenbeisser, S. G. Stavrinides <em>et al.<\/em>, &#8220;Real-world secure communication based on synchronised Lorenz chaotic circuits,&#8221; in <em>13th International Conference on Modern Circuits and Systems Technologies (MOCAST)<\/em>, 2024.<\/p>\n\n\n\n<p id=\"ref-souli2024\" class=\"mem-ref wp-block-paragraph\">[11] N. Souli, S. G. Stavrinides, P. Kardaras, R. Picos, M. Karatzia, P. Kolios <em>et al.<\/em>, &#8220;Performance evaluation of a prototype UAV-based secure communication system employing ROS and chaotic communications,&#8221; in <em>International Conference on Unmanned Aircraft Systems (ICUAS)<\/em>, 2024, pp. 1034\u20131041.<\/p>\n\n\n\n<p id=\"ref-souli2025\" class=\"mem-ref wp-block-paragraph\">[12] N. Souli, S. G. Stavrinides, R. Picos, M. Karatzia, P. Kolios and G. Ellinas, &#8220;Development of a lightweight secure communication system for UAVs enhanced by an unconventional chaotic communication architecture,&#8221; <em>Journal of Intelligent &amp; Robotic Systems<\/em>, vol. 111, no. 3, art. 85, 2025.<\/p>\n\n\n\n<p id=\"ref-camps2021\" class=\"mem-ref wp-block-paragraph\">[13] O. Camps, S. G. Stavrinides and R. Picos, &#8220;Stochastic computing implementation of chaotic systems,&#8221; <em>Mathematics<\/em>, vol. 9, no. 4, art. 375, 2021.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code and related pages<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/rpicos-uib\/chaotic_transmission_2022\">chaotic_transmission_2022<\/a>: Arduino code of the transmitter and receiver.<\/li>\n\n\n<li><a href=\"https:\/\/memristors.uib.es\/index.php\/resources\/media\/whats-nonlinear-electronics\/\">What&#8217;s nonlinear electronics?<\/a>: chaos, attractors and synchronisation.<\/li>\n\n\n<li><a href=\"https:\/\/memristors.uib.es\/index.php\/resources\/media\/what-are-pufs\/\">What are PUFs?<\/a>: hardware fingerprints, another approach to lightweight security.<\/li>\n\n<\/ul>\n\n\n<\/div>\n\n\n<\/div>\n\n\n\n<script>\n\/* Interactive simulators for \"How does chaotic encryption work?\": the digital chaotic encrypted communication scheme of\n   Karagiorgos, Stavrinides, de Benito, Nikolaidis and Picos, IEEE Internet of Things Journal 11(11), 2024.\n   Mounts into .chx-link, .chx-text, .chx-img and .chx-sens. No dependencies.\n   WordPress mangles the ampersand inside inline scripts, so this file never uses it, and a less-than sign is always\n   followed by a space. *\/\n(function () {\n  'use strict';\n\n  \/* ---------- the scheme, equations (1)\u2013(3) of the paper ---------- *\/\n  \/\/ coefficients: exact values and their Q6.10 fixed-point versions (Table II of the paper)\n  var EXACT = { a11: 0.9905882, a12: 0.0031372, a21: 0.48, a22: -0.148148, b11: -0.48, b12: 0.16, b21: 0.9905882, b22: 0.0031372, c1: 1.0666666, c2: -0.355555 };\n  \/\/ a key found with the search on this page: F equals M close to 50 % with PWM_CLK = CH_CLK and a 16,384-clock preamble\n  var TEST = { a11: 0.9741585, a12: 0.003100615, a21: 0.4805595, a22: -0.1489118, b11: -0.4716866, b12: 0.1595585, b21: 1.008363, b22: 0.003141299, c1: 2.076992, c2: -2.3559273 };\n  var TEST_V0 = -0.509;\n  var KEYS = ['a11', 'a12', 'a21', 'a22', 'b11', 'b12', 'b21', 'b22', 'c1', 'c2'];\n  var KEY = {}; KEYS.forEach(function (k) { KEY[k] = EXACT[k]; }); \/\/ the key in use: editable in the key panel\n  var V0_PAPER = 0.35, V0 = V0_PAPER; \/\/ comparison threshold\n  \/\/ PWM: each message bit becomes 4 PWM bits, 1110 (75 % duty) for 1 and 1000 (25 %) for 0. Each PWM bit lasts PWMX chaotic\n  \/\/ clocks (PWM_CLK = PWMX \u00d7 CH_CLK; the paper's FPGA uses 4), so a message bit lasts BPW = 4\u00b7PWMX clocks.\n  var PWMX = 4, BPW = 16, PRE_CLK = 1024; \/\/ PRE_CLK: chaotic clocks of alternating 1\/0 lock-in preamble before the data\n  function setPwm(x) { PWMX = x; BPW = 4 * x; }\n  function pwm(bit, j) { return j < (bit ? 3 : 1) * PWMX ? 1 : 0; }\n  function preBits() { return Math.ceil(PRE_CLK \/ BPW); }\n  function q610(x) { var v = Math.round(x * 1024) \/ 1024; return v > 31.999 ? 31.999 : v < -32 ? -32 : v; }\n  function coeffs(fixed, tweak) {\n    var c = {};\n    KEYS.forEach(function (k) { c[k] = KEY[k]; });\n    if (tweak) {\n      if (tweak.swap) { ['11', '12', '21', '22'].forEach(function (s) { var t = c['a' + s]; c['a' + s] = c['b' + s]; c['b' + s] = t; }); }\n      if (tweak.key) c[tweak.key] *= 1 + tweak.delta;\n    }\n    if (fixed) KEYS.forEach(function (k) { c[k] = q610(c[k]); });\n    return c;\n  }\n  \/\/ spectral radius of the autonomous (linear) part. The receiver's error obeys e(n) = A e(n\u22121) because both oscillators get\n  \/\/ the same drive F, so the receiver can only synchronise if this is below 1. Gelfand's formula: growth rate of the norm of A^n.\n  function radius(c) {\n    var A = [[c.a11, c.a12, c.a21, c.a22], [1, 0, 0, 0], [c.b11, c.b12, c.b21, c.b22], [0, 0, 1, 0]];\n    var V = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]], lg = 0, N = 3000, i;\n    for (i = 0; i < N; i++) {\n      V = V.map(function (x) { return A.map(function (r) { return r[0] * x[0] + r[1] * x[1] + r[2] * x[2] + r[3] * x[3]; }); });\n      var n = Math.max.apply(null, V.map(function (x) { return Math.hypot(x[0], x[1], x[2], x[3]); }));\n      if (!(n > 0)) return 0;\n      V = V.map(function (x) { return x.map(function (y) { return y \/ n; }); }); lg += Math.log(n);\n    }\n    return Math.exp(lg \/ N);\n  }\n  \/\/ one oscillator (transmitter or driven receiver): state V1(n\u22121), V1(n\u22122), V2(n\u22121), V2(n\u22122) and the drive F(n\u22121), F(n\u22122)\n  function Osc(c, fixed, init) {\n    this.c = c; this.fixed = fixed;\n    this.v1 = [init[0], init[1]]; this.v2 = [init[2], init[3]];\n  }\n  Osc.prototype.next = function (F1, F2) {\n    var c = this.c, v1 = this.v1, v2 = this.v2;\n    var V1 = c.a11 * v1[0] + c.a12 * v1[1] + c.a21 * v2[0] + c.a22 * v2[1] + c.c1 * F1 + c.c2 * F2;\n    var V2 = c.b11 * v1[0] + c.b12 * v1[1] + c.b21 * v2[0] + c.b22 * v2[1];\n    if (this.fixed) { V1 = q610(V1); V2 = q610(V2); }\n    else { V1 = Math.max(-1e6, Math.min(1e6, V1)); V2 = Math.max(-1e6, Math.min(1e6, V2)); }\n    this.v1 = [V1, v1[0]]; this.v2 = [V2, v2[0]];\n    return V2;\n  };\n  \/\/ the link: transmitter, legitimate receiver and an optional eavesdropper with different coefficients\n  function Link(fixed, eve, seed) {\n    var R = rng(seed || 1);\n    this.fixed = fixed;\n    this.tx = new Osc(coeffs(fixed), fixed, [0.1, 0, 0, 0]);\n    this.rx = new Osc(coeffs(fixed), fixed, [4 * R() - 2, 4 * R() - 2, 4 * R() - 2, 4 * R() - 2]);\n    this.ev = eve ? new Osc(coeffs(fixed, eve), fixed, [4 * R() - 2, 4 * R() - 2, 4 * R() - 2, 4 * R() - 2]) : null;\n    this.F = [0, 0]; this.n = 0;\n  }\n  Link.prototype.step = function (m) {\n    var F1 = this.F[0], F2 = this.F[1];\n    var V2 = this.tx.next(F1, F2), H = V0 > V2 ? 1 : 0, F = m ^ H;                 \/\/ transmitter, eq. (1)\n    var W2 = this.rx.next(F1, F2), Mr = F ^ (V0 > W2 ? 1 : 0);                     \/\/ receiver, eqs. (2)\u2013(3)\n    var E2 = this.ev ? this.ev.next(F1, F2) : 0, Me = this.ev ? F ^ (V0 > E2 ? 1 : 0) : 0;\n    this.F = [F, F1]; this.n++;\n    return { m: m, F: F, Mr: Mr, Me: Me, V1: this.tx.v1[0], V2: V2, W2: W2, E2: E2 };\n  };\n  \/\/ send a bit string with PWM (16 clocks per bit) and decode both receivers by duty cycle\n  function sendBits(bits, fixed, eve, seed, preamble) {\n    var L = new Link(fixed, eve, seed), out = { F: [], rx: [], ev: [] }, k, j, s, sr, se;\n    var pre = preamble == null ? preBits() : preamble;\n    for (k = 0; k < pre; k++) for (j = 0; j < BPW; j++) L.step(pwm(k % 2, j)); \/\/ lock-in preamble\n    for (k = 0; k < bits.length; k++) {\n      sr = 0; se = 0; s = 0;\n      for (j = 0; j < BPW; j++) { var r = L.step(pwm(bits[k], j)); s += r.F; sr += r.Mr; se += r.Me; }\n      out.F.push(s \/ BPW); out.rx.push(sr * 2 > BPW ? 1 : 0); out.ev.push(se * 2 > BPW ? 1 : 0);\n    }\n    return out;\n  }\n\n  \/* ---------- helpers ---------- *\/\n  function rng(seed) {\n    var a = seed | 0;\n    return function () {\n      a = (a + 0x6D2B79F5) | 0;\n      var t = Math.imul(a ^ (a >>> 15), 1 | a);\n      t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n      return ((t ^ (t >>> 14)) >>> 0) \/ 4294967296;\n    };\n  }\n  function el(tag, cls, parent, html) { var e = document.createElement(tag); if (cls) e.className = cls; if (html != null) e.innerHTML = html; if (parent) parent.appendChild(e); return e; }\n  function pct(v) { return (100 * v).toFixed(1) + ' %'; }\n  function colors(root) {\n    var cs = getComputedStyle(root);\n    function v(n, d) { var x = cs.getPropertyValue(n).trim(); return x || d; }\n    return { text: cs.color || '#222', grid: 'rgba(127,127,127,.18)', axis: 'rgba(127,127,127,.55)', A: v('--ms-iv', '#1d5b94'), M: '#16a34a', F: '#dc2626', R: '#2563eb', E: '#d97706', bg: v('--ms-bg', '#fff') };\n  }\n  function visible(node) { if (!node.offsetParent) return false; var r = node.getBoundingClientRect(); return r.bottom > 0 ? r.top < window.innerHeight : false; }\n  function niceTicks(lo, hi, n) {\n    var span = hi - lo; if (!(span > 0)) return [lo];\n    var raw = span \/ n, mag = Math.pow(10, Math.floor(Math.log10(raw))), r = raw \/ mag;\n    var step = (r < 1.5 ? 1 : r < 3 ? 2 : r < 7 ? 5 : 10) * mag, out = [];\n    for (var v = Math.ceil(lo \/ step) * step; v <= hi + step * 1e-6; v += step) out.push(Math.abs(v) < step * 1e-6 ? 0 : v);\n    return out;\n  }\n  function Canvas(parent, cls, title) {\n    this.fig = el('div', 'ms-fig ' + (cls || ''), parent); this.title = el('div', 'ms-fig-title', this.fig, title || '');\n    this.c = el('canvas', '', this.fig); this.ctx = this.c.getContext('2d');\n    this.c.setAttribute('role', 'img'); this.c.setAttribute('aria-label', (title || '').replace(\/<[^>]+>\/g, ''));\n  }\n  Canvas.prototype.size = function () {\n    var c = this.c, dpr = window.devicePixelRatio || 1, w = c.clientWidth, h = c.clientHeight;\n    if (!w) return false;\n    if (!h) return false;\n    if (c.width !== Math.round(w * dpr)) c.width = Math.round(w * dpr);\n    if (c.height !== Math.round(h * dpr)) c.height = Math.round(h * dpr);\n    this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0); this.w = w; this.h = h; this.ctx.clearRect(0, 0, w, h);\n    return true;\n  };\n  Canvas.prototype.begin = function (o) {\n    if (!this.size()) return false;\n    this.o = o; this.L = o.L || 48; this.R = 10; this.T = 10; this.B = o.noX ? 8 : 32;\n    this.pw = this.w - this.L - this.R; this.ph = this.h - this.T - this.B; return true;\n  };\n  Canvas.prototype.X = function (x) { var r = this.o.x; return this.L + (x - r[0]) \/ (r[1] - r[0]) * this.pw; };\n  Canvas.prototype.Y = function (y) { var r = this.o.y; return this.T + (1 - (y - r[0]) \/ (r[1] - r[0])) * this.ph; };\n  Canvas.prototype.axes = function (col) {\n    var ctx = this.ctx, o = this.o, self = this, xf = o.xf || function (v) { return +v.toPrecision(3) + ''; }, yf = o.yf || xf;\n    ctx.font = '11px system-ui, sans-serif'; ctx.lineWidth = 1; ctx.strokeStyle = col.grid; ctx.fillStyle = col.text;\n    ctx.textAlign = 'center'; ctx.textBaseline = 'top';\n    (o.xt || niceTicks(o.x[0], o.x[1], Math.max(2, Math.round(this.pw \/ 70)))).forEach(function (t) {\n      var X = self.X(t); ctx.beginPath(); ctx.moveTo(X, self.T); ctx.lineTo(X, self.T + self.ph); ctx.stroke(); if (!o.noX) ctx.fillText(xf(t), X, self.T + self.ph + 5);\n    });\n    ctx.textAlign = 'right'; ctx.textBaseline = 'middle';\n    (o.yt || niceTicks(o.y[0], o.y[1], Math.max(2, Math.round(this.ph \/ 40)))).forEach(function (t) {\n      var Y = self.Y(t); ctx.beginPath(); ctx.moveTo(self.L, Y); ctx.lineTo(self.L + self.pw, Y); ctx.stroke(); ctx.fillText(yf(t), self.L - 6, Y);\n    });\n    ctx.strokeStyle = col.axis; ctx.strokeRect(this.L + 0.5, this.T + 0.5, this.pw, this.ph);\n    ctx.textAlign = 'center'; ctx.textBaseline = 'bottom';\n    if (o.xl) ctx.fillText(o.xl, this.L + this.pw \/ 2, this.h - 1);\n    if (o.yl) { ctx.save(); ctx.translate(11, this.T + this.ph \/ 2); ctx.rotate(-Math.PI \/ 2); ctx.textBaseline = 'middle'; ctx.fillText(o.yl, 0, 0); ctx.restore(); }\n  };\n  Canvas.prototype.line = function (xs, ys, color, width, alpha) {\n    var ctx = this.ctx; if (xs.length < 2) return;\n    ctx.save(); ctx.beginPath(); ctx.rect(this.L, this.T, this.pw, this.ph); ctx.clip();\n    ctx.globalAlpha = alpha || 1; ctx.strokeStyle = color; ctx.lineWidth = width || 1.6; ctx.lineJoin = 'round';\n    ctx.beginPath(); ctx.moveTo(this.X(xs[0]), this.Y(ys[0]));\n    for (var k = 1; k < xs.length; k++) ctx.lineTo(this.X(xs[k]), this.Y(ys[k]));\n    ctx.stroke(); ctx.restore();\n  };\n  \/\/ stacked digital traces\n  Canvas.prototype.digital = function (traces, n0, col) {\n    if (!this.size()) return;\n    var ctx = this.ctx, L = 34, w = this.w - L - 8, rows = traces.length, rh = (this.h - 8) \/ rows, N = traces[0].v.length;\n    ctx.font = '12px system-ui, sans-serif'; ctx.textAlign = 'right'; ctx.textBaseline = 'middle';\n    traces.forEach(function (tr, i) {\n      var y0 = 4 + i * rh + rh * 0.82, y1 = 4 + i * rh + rh * 0.18;\n      ctx.fillStyle = tr.color; ctx.fillText(tr.label, L - 6, (y0 + y1) \/ 2);\n      ctx.strokeStyle = col.grid; ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(L, y0); ctx.lineTo(L + w, y0); ctx.stroke();\n      ctx.strokeStyle = tr.color; ctx.lineWidth = 1.6; ctx.beginPath();\n      for (var k = 0; k < N; k++) {\n        var x = L + w * k \/ N, xn = L + w * (k + 1) \/ N, y = tr.v[k] ? y1 : y0;\n        if (k === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);\n        ctx.lineTo(xn, y);\n      }\n      ctx.stroke();\n      if (tr.bad) { ctx.fillStyle = 'rgba(220,38,38,.18)'; for (k = 0; k < N; k++) if (tr.bad[k]) ctx.fillRect(L + w * k \/ N, y1 - 3, w \/ N + 0.5, y0 - y1 + 6); }\n    });\n  };\n  function bar(root) { var b = el('div', 'ms-bar', root); return { l: el('div', 'ms-actions', b), r: el('div', 'ms-actions', b) }; }\n  function button(parent, label, fn, primary) { var b = el('button', 'ms-btn' + (primary ? ' ms-primary' : ''), parent, label); b.type = 'button'; b.addEventListener('click', fn); return b; }\n  function select(parent, opts, val, fn, aria) {\n    var s = el('select', 'ms-select', parent); if (aria) s.setAttribute('aria-label', aria);\n    opts.forEach(function (o) { el('option', '', s, o[1]).value = o[0]; }); s.value = val; s.addEventListener('change', function () { fn(s.value); }); return s;\n  }\n  function checkbox(parent, label, val, fn) { var lg = el('label', 'ms-check', parent), cb = el('input', '', lg); cb.type = 'checkbox'; cb.checked = val; el('span', '', lg, label); cb.addEventListener('change', function () { fn(cb.checked); }); return cb; }\n  function slider(parent, label, min, max, step, val, fmt, fn) {\n    var row = el('div', 'ms-ctl', parent), id = 'cx' + Math.random().toString(36).slice(2, 8);\n    el('label', '', row, label).htmlFor = id; var out = el('output', '', row), inp = el('input', '', row);\n    inp.type = 'range'; inp.id = id; inp.min = min; inp.max = max; inp.step = step; inp.value = val; out.textContent = fmt(val);\n    inp.addEventListener('input', function () { out.textContent = fmt(+inp.value); fn(+inp.value); });\n    return { set: function (v) { inp.value = v; out.textContent = fmt(v); } };\n  }\n  function tiles(parent) { return el('div', 'puf-tiles', parent); }\n  function setTiles(box, items) {\n    box.innerHTML = items.map(function (t) { return '\\x3cdiv class=\"puf-tile' + (t.cls ? ' ' + t.cls : '') + '\">\\x3cspan>' + t.label + '\\x3c\/span>\\x3cstrong>' + t.value + '\\x3c\/strong>' + (t.note ? '\\x3cem>' + t.note + '\\x3c\/em>' : '') + '\\x3c\/div>'; }).join('');\n  }\n  var KEYOPTS = KEYS.map(function (k) { return [k, k.charAt(0) === 'c' ? 'c' + k.slice(1).replace('1', '\u2081').replace('2', '\u2082') : k.charAt(0) + k.slice(1).replace(\/1\/g, '\u2081').replace(\/2\/g, '\u2082')]; });\n  KEYOPTS.forEach(function (o) { o[1] = o[1].replace(\/^a\/, '\u03b1').replace(\/^b\/, 'b'); });\n\n  \/* ================= live link ================= *\/\n  function LinkSim(root) {\n    var self = this; this.root = root; this.fixed = true; this.msg = 'pwm'; this.running = true; this.speed = 1; this.acc = 0;\n    this.eve = { key: 'a11', delta: 0.01, swap: false }; this.seed = 1;\n    root.innerHTML = '';\n    var b = bar(root);\n    select(b.l, [['pwm', 'Message: random bits (PWM)'], ['pulse', 'Message: pulse train'], ['zero', 'Message: none (all 0)']], 'pwm', function (v) { self.msg = v; }, 'Message');\n    select(b.l, [['1', 'Q6.10 fixed point (as on the FPGA)'], ['0', 'Floating point']], '1', function (v) { self.fixed = v === '1'; self.reset(); }, 'Arithmetic');\n    this.play = button(b.r, 'Pause', function () { self.running = !self.running; self.play.textContent = self.running ? 'Pause' : 'Play'; }, true);\n    button(b.r, 'Restart receivers', function () { self.seed++; self.reset(); });\n    select(b.r, [['0.5', '0.5\u00d7'], ['1', '1\u00d7'], ['4', '4\u00d7'], ['16', '16\u00d7']], '1', function (v) { self.speed = +v; }, 'Speed');\n    var g = el('div', 'chx-grid', root);\n    this.cD = new Canvas(g, 'chx-dig', 'Last 160 clocks: message \\x3cb style=\"color:#16a34a\">M\\x3c\/b>, transmitted \\x3cb style=\"color:#dc2626\">F\\x3c\/b>, recovered \\x3cb style=\"color:#2563eb\">M\u2032\\x3c\/b> and eavesdropper \\x3cb style=\"color:#d97706\">M\u2033\\x3c\/b>');\n    this.cP = new Canvas(g, 'chx-phase', 'Transmitter phase portrait V\\x3csub>2\\x3c\/sub> vs V\\x3csub>1\\x3c\/sub>');\n    this.cE = new Canvas(g, 'chx-err', 'Synchronisation error |V\\x3csub>2\\x3c\/sub> \u2212 V\u2032\\x3csub>2\\x3c\/sub>| (receiver) and |V\\x3csub>2\\x3c\/sub> \u2212 V\u2033\\x3csub>2\\x3c\/sub>| (eavesdropper)');\n    this.tiles = tiles(root);\n    var grp = el('fieldset', 'ms-group puf-group', root); el('legend', '', grp, 'Eavesdropper: a receiver with a slightly wrong key');\n    var row = el('div', 'ms-ctl', grp); el('label', '', row, 'Coefficient that differs');\n    el('output', '', row); select(row, KEYOPTS, 'a11', function (v) { self.eve.key = v; self.reset(); }, 'Coefficient');\n    this.dS = slider(grp, 'Error in that coefficient', -5, 5, 0.1, 1, function (v) { return (v > 0 ? '+' : '') + v.toFixed(1) + ' %'; }, function (v) { self.eve.delta = v \/ 100; self.reset(); });\n    var row2 = el('div', 'ms-ctl', grp); el('label', '', row2, 'Wrong structure'); el('output', '', row2);\n    checkbox(row2, 'swap \u03b1\\x3csub>ij\\x3c\/sub> \u2194 b\\x3csub>ij\\x3c\/sub> (the paper\\'s test)', false, function (v) { self.eve.swap = v; self.reset(); });\n    this.reset();\n  }\n  LinkSim.prototype.onKey = function () { this.reset(); };\n  LinkSim.prototype.reset = function () {\n    this.L = new Link(this.fixed, this.eve, this.seed * 7919);\n    this.h = { m: [], F: [], Mr: [], Me: [], V1: [], V2: [], er: [], ee: [], n: [] }; this.bit = 0; this.R = rng(this.seed); this.errs = []; this.eerrs = [];\n    this.dirty = true;\n  };\n  LinkSim.prototype.message = function (n) {\n    if (this.msg === 'zero') return 0;\n    if (this.msg === 'pulse') return Math.floor(n \/ 8) % 2;\n    var j = n % BPW; if (j === 0) this.bit = this.R() < 0.5 ? 1 : 0;\n    return pwm(this.bit, j);\n  };\n  LinkSim.prototype.advance = function (k) {\n    var h = this.h;\n    for (var i = 0; i < k; i++) {\n      var n = this.L.n, r = this.L.step(this.message(n));\n      h.m.push(r.m); h.F.push(r.F); h.Mr.push(r.Mr); h.Me.push(r.Me); h.V1.push(r.V1); h.V2.push(r.V2); h.n.push(n);\n      h.er.push(Math.log10(Math.max(1e-4, Math.abs(r.V2 - r.W2)))); h.ee.push(Math.log10(Math.max(1e-4, Math.min(1e6, Math.abs(r.V2 - r.E2)))));\n      this.errs.push(r.Mr !== r.m ? 1 : 0); this.eerrs.push(r.Me !== r.m ? 1 : 0);\n    }\n    var cut = h.m.length - 3000;\n    if (cut > 0) Object.keys(h).forEach(function (key) { h[key].splice(0, cut); });\n    if (this.errs.length > 1000) { this.errs.splice(0, this.errs.length - 1000); this.eerrs.splice(0, this.eerrs.length - 1000); }\n    this.dirty = true;\n  };\n  LinkSim.prototype.tick = function (dt) {\n    if (!this.running) return;\n    this.acc += dt * 120 * this.speed;\n    var k = Math.floor(this.acc); this.acc -= k; if (k) this.advance(k);\n  };\n  LinkSim.prototype.draw = function () {\n    var col = colors(this.root), h = this.h, N = h.m.length, w = Math.min(160, N), a = N - w;\n    if (!N) { this.advance(1); return; }\n    var bad = h.Mr.slice(a).map(function (v, i) { return v !== h.m[a + i]; });\n    var bade = h.Me.slice(a).map(function (v, i) { return v !== h.m[a + i]; });\n    this.cD.digital([{ label: 'M', v: h.m.slice(a), color: col.M }, { label: 'F', v: h.F.slice(a), color: col.F },\n      { label: 'M\u2032', v: h.Mr.slice(a), color: col.R, bad: bad }, { label: 'M\u2033', v: h.Me.slice(a), color: col.E, bad: bade }], 0, col);\n    var P = this.cP, m = 0;\n    for (var i = 0; i < N; i++) m = Math.max(m, Math.abs(h.V1[i]), Math.abs(h.V2[i]));\n    m = Math.max(1, m * 1.1);\n    if (P.begin({ x: [-m, m], y: [-m, m], xl: 'V\u2081', yl: 'V\u2082' })) { P.axes(col); P.line(h.V1, h.V2, col.A, 0.8, 0.7); }\n    var E = this.cE;\n    if (E.begin({ x: [h.n[0], Math.max(h.n[N - 1], h.n[0] + 1)], y: [-4, 6], yt: [-4, -2, 0, 2, 4, 6], xl: 'clock n', yl: 'log\u2081\u2080 error',\n      yf: function (v) { return '10' + (v < 0 ? '\u207b' : '') + '\u2070\u00b9\u00b2\u00b3\u2074\u2075\u2076\u2077\u2078\u2079'[Math.abs(v)]; } })) {\n      E.axes(col); E.line(h.n, h.ee, col.E, 1.2, 0.9); E.line(h.n, h.er, col.R, 1.6);\n    }\n    var ber = this.errs.reduce(function (s, v) { return s + v; }, 0) \/ Math.max(1, this.errs.length);\n    var bere = this.eerrs.reduce(function (s, v) { return s + v; }, 0) \/ Math.max(1, this.eerrs.length);\n    var ones = h.F.reduce(function (s, v) { return s + v; }, 0) \/ N;\n    setTiles(this.tiles, [\n      { label: 'Clock n', value: this.L.n, note: 'one clock = 3.2 \u00b5s on the FPGA' },\n      { label: 'Receiver errors (last 1000 clocks)', value: pct(ber), cls: ber < 0.01 ? 'puf-good' : 'puf-warn', note: ber < 0.01 ? 'synchronised' : 'locking on\u2026' },\n      { label: 'Eavesdropper errors', value: pct(bere), cls: bere > 0.3 ? 'puf-good' : 'puf-warn', note: '50 % = learns nothing' },\n      { label: 'Ones in F', value: pct(ones), note: 'the transmitted signal' }\n    ]);\n    this.dirty = false;\n  };\n\n  \/* ================= text ================= *\/\n  function TextSim(root) {\n    var self = this; this.root = root; this.eve = { key: 'a11', delta: 0.01, swap: false }; this.fixed = true;\n    root.innerHTML = '';\n    var lab = el('label', 'chx-lab', root, 'Plaintext (try your own)'); var id = 'cxt' + Math.random().toString(36).slice(2, 7); lab.htmlFor = id;\n    this.ta = el('textarea', 'chx-ta', root); this.ta.id = id; this.ta.rows = 3;\n    this.ta.value = 'En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que viv\u00eda un hidalgo de los de lanza en astillero, adarga antigua, roc\u00edn flaco y galgo corredor.';\n    var b = bar(root);\n    button(b.l, 'Encrypt and send', function () { self.run(); }, true);\n    var grp = el('fieldset', 'ms-group puf-group', root); el('legend', '', grp, 'Eavesdropper');\n    var row = el('div', 'ms-ctl', grp); el('label', '', row, 'Coefficient that differs'); el('output', '', row);\n    select(row, KEYOPTS, 'a11', function (v) { self.eve.key = v; self.run(); }, 'Coefficient');\n    slider(grp, 'Error in that coefficient', -5, 5, 0.1, 1, function (v) { return (v > 0 ? '+' : '') + v.toFixed(1) + ' %'; }, function (v) { self.eve.delta = v \/ 100; self.run(); });\n    this.out = el('div', 'chx-out', root);\n    this.tiles = tiles(root);\n    this.dirty = false; this.ran = false;\n  }\n  function textBits(s) { var bytes = new TextEncoder().encode(s), bits = []; bytes.forEach(function (v) { for (var i = 7; i >= 0; i--) bits.push((v >> i) % 2); }); return bits; }\n  function bitsText(bits) {\n    var bytes = new Uint8Array(Math.floor(bits.length \/ 8));\n    for (var k = 0; k < bytes.length; k++) { var v = 0; for (var i = 0; i < 8; i++) v = v * 2 + bits[k * 8 + i]; bytes[k] = v; }\n    return new TextDecoder('utf-8', { fatal: false }).decode(bytes);\n  }\n  function esc(s) { return s.replace(\/[\\u0000-\\u001f\\u007f-\\u009f]\/g, '\u00b7').replace(\/[<>\"'\\u0026]\/g, function (c) { return '\\u0026#' + c.charCodeAt(0) + ';'; }); }\n  TextSim.prototype.run = function () {\n    var bits = textBits(this.ta.value.slice(0, 600)), r = sendBits(bits, this.fixed, this.eve, 99);\n    var fbits = [], hex = '';\n    \/\/ what an observer of the channel sees: the chaotic PWM stream, shown as the bytes of its first 512 clocks\n    var L = new Link(true, null, 99), k, j;\n    for (k = 0; k < preBits(); k++) for (j = 0; j < BPW; j++) L.step(pwm(k % 2, j));\n    for (k = 0; k < bits.length; k++) for (j = 0; j < BPW; j++) if (fbits.length < 512) fbits.push(L.step(pwm(bits[k], j)).F);\n    for (k = 0; k + 8 <= fbits.length; k += 8) { var v = 0; for (j = 0; j < 8; j++) v = v * 2 + fbits[k + j]; hex += ('0' + v.toString(16)).slice(-2) + (k % 64 === 56 ? ' ' : ''); }\n    \/\/ byte-level comparison, as in the JPEG demo: the UTF-8 bytes of the text\n    var u8 = bitsToBytes(bits), rx = bitsToBytes(r.rx), ev = bitsToBytes(r.ev), eb = 0, ee = 0;\n    for (k = 0; k < u8.length; k++) { eb += rx[k] !== u8[k] ? 1 : 0; ee += ev[k] !== u8[k] ? 1 : 0; }\n    this.out.innerHTML = '\\x3cdiv class=\"chx-box\">\\x3cspan>On the channel (first ' + fbits.length + ' chaotic clocks, as hex)\\x3c\/span>\\x3ccode>' + hex + '\u2026\\x3c\/code>\\x3c\/div>' +\n      '\\x3cdiv class=\"chx-box chx-ok\">\\x3cspan>Legitimate receiver\\x3c\/span>\\x3cp>' + esc(bitsText(r.rx)) + '\\x3c\/p>\\x3c\/div>' +\n      '\\x3cdiv class=\"chx-box chx-bad\">\\x3cspan>Eavesdropper (' + (this.eve.delta > 0 ? '+' : '') + (this.eve.delta * 100).toFixed(1) + ' % on one coefficient)\\x3c\/span>\\x3cp>' + esc(bitsText(r.ev)) + '\\x3c\/p>\\x3c\/div>';\n    setTiles(this.tiles, [\n      { label: 'Text sent (UTF-8)', value: u8.length.toLocaleString() + ' bytes', note: bits.length.toLocaleString() + ' bits, ' + (bits.length * BPW).toLocaleString() + ' chaotic clocks' },\n      { label: 'Received bytes wrong', value: eb, cls: eb ? 'puf-warn' : 'puf-good', note: eb ? 'text damaged' : 'identical text' },\n      { label: 'Eavesdropper bytes wrong', value: pct(ee \/ Math.max(1, u8.length)), cls: ee \/ Math.max(1, u8.length) > 0.5 ? 'puf-good' : 'puf-warn', note: ee ? (ee * 2 > u8.length ? 'text unreadable' : 'text partly readable') : 'identical text: this key error does not protect' }\n    ]);\n    this.ran = true;\n  };\n  TextSim.prototype.onKey = function () { if (this.ran) this.run(); };\n  TextSim.prototype.draw = function () { if (!this.ran) this.run(); this.dirty = false; };\n\n  \/* ================= image ================= *\/\n  function ImgSim(root) {\n    var self = this; this.root = root; this.S = 64; this.eve = { key: 'a11', delta: 0.01, swap: false };\n    this.mode = 'bmp'; this.jpx = 64; this.jq = 0.5; this.file = null; this.seq = 0;\n    root.innerHTML = '';\n    var b = bar(root);\n    select(b.l, [['bmp', 'Send: 64 \u00d7 64 bitmap (1 bit per pixel)'], ['jpg', 'Send: JPEG file (its bytes, bit by bit)']], 'bmp', function (v) { self.mode = v; self.showOpts(); self.run(); }, 'What to send');\n    button(b.l, 'Encrypt and send', function () { self.run(); }, true);\n    var up = el('label', 'ms-btn chx-file', b.l, 'Use my own image\u2026'); var fi = el('input', '', up); fi.type = 'file'; fi.accept = 'image\/*';\n    fi.addEventListener('change', function () {\n      var f = fi.files[0]; if (!f) return;\n      var img = new Image(); img.onload = function () { self.load(img); self.run(); }; img.src = URL.createObjectURL(f);\n      self.file = null;\n      if (f.type === 'image\/jpeg') f.arrayBuffer().then(function (buf) { self.file = new Uint8Array(buf); self.showOpts(); });\n      self.showOpts();\n    });\n    el('span', 'chx-note', b.r, 'images never leave your browser');\n    this.opts = el('div', 'ms-bar chx-jopts', root); var ol = el('div', 'ms-actions', this.opts);\n    this.pxSel = select(ol, [['32', 'JPEG 32 \u00d7 32'], ['48', 'JPEG 48 \u00d7 48'], ['64', 'JPEG 64 \u00d7 64'], ['96', 'JPEG 96 \u00d7 96'], ['128', 'JPEG 128 \u00d7 128'], ['file', 'my JPEG file, unchanged']], '64',\n      function (v) { self.jpx = v; self.run(); }, 'JPEG size');\n    this.qSel = select(ol, [['0.3', 'quality 30'], ['0.5', 'quality 50'], ['0.7', 'quality 70'], ['0.9', 'quality 90']], '0.5', function (v) { self.jq = +v; self.run(); }, 'JPEG quality');\n    this.jnote = el('span', 'chx-note', this.opts, '');\n    var g = el('div', 'chx-img4', root);\n    this.c = [new Canvas(g, 'chx-sq', 'Original'), new Canvas(g, 'chx-sq', 'Transmitted signal F'), new Canvas(g, 'chx-sq', 'Received (right key)'), new Canvas(g, 'chx-sq', 'Eavesdropper (wrong key)')];\n    this.tiles = tiles(root);\n    var grp = el('fieldset', 'ms-group puf-group', root); el('legend', '', grp, 'Eavesdropper');\n    var row = el('div', 'ms-ctl', grp); el('label', '', row, 'Coefficient that differs'); el('output', '', row);\n    select(row, KEYOPTS, 'a11', function (v) { self.eve.key = v; self.run(); }, 'Coefficient');\n    slider(grp, 'Error in that coefficient', -5, 5, 0.1, 1, function (v) { return (v > 0 ? '+' : '') + v.toFixed(1) + ' %'; }, function (v) { self.eve.delta = v \/ 100; self.run(); });\n    var row2 = el('div', 'ms-ctl', grp); el('label', '', row2, 'Wrong structure'); el('output', '', row2);\n    checkbox(row2, 'swap \u03b1\\x3csub>ij\\x3c\/sub> \u2194 b\\x3csub>ij\\x3c\/sub>', false, function (v) { self.eve.swap = v; self.run(); });\n    this.makeDefault(); this.res = null; this.showOpts();\n  }\n  ImgSim.prototype.showOpts = function () {\n    this.opts.style.display = this.mode === 'jpg' ? '' : 'none';\n    var fo = this.pxSel.querySelector('option[value=\"file\"]');\n    fo.disabled = this.file ? (this.file.length > 24576) : true;\n    if (fo.disabled ? this.pxSel.value === 'file' : false) { this.pxSel.value = '64'; this.jpx = '64'; }\n    this.qSel.disabled = this.jpx === 'file';\n    this.jnote.textContent = this.file ? (this.file.length > 24576 ? 'your JPEG is ' + Math.round(this.file.length \/ 1024) + ' kB: too large to send unchanged (max 24 kB), so it is re-encoded' : '') :\n      'load a JPEG of up to 24 kB to send the file itself, unchanged';\n  };\n  \/\/ the source picture, kept in colour at 128 \u00d7 128; the bitmap mode thresholds it, the JPEG mode compresses it\n  ImgSim.prototype.makeDefault = function () {\n    var S = 128, cv = document.createElement('canvas'); cv.width = S; cv.height = S; var ctx = cv.getContext('2d');\n    var gr = ctx.createLinearGradient(0, 0, S, S); gr.addColorStop(0, '#fff7e0'); gr.addColorStop(1, '#dbeafe');\n    ctx.fillStyle = gr; ctx.fillRect(0, 0, S, S); ctx.fillStyle = '#13294b'; ctx.strokeStyle = '#1d5b94';\n    ctx.font = 'bold 52px system-ui, sans-serif'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.fillText('UIB', S \/ 2, S \/ 2 - 24);\n    ctx.lineWidth = 6; ctx.beginPath(); ctx.arc(S \/ 2, S \/ 2 + 36, 24, 0, 2 * Math.PI); ctx.stroke();\n    ctx.strokeStyle = '#dc2626';\n    ctx.beginPath(); ctx.moveTo(S \/ 2 - 14, S \/ 2 + 36); ctx.lineTo(S \/ 2 + 14, S \/ 2 + 36); ctx.moveTo(S \/ 2, S \/ 2 + 22); ctx.lineTo(S \/ 2, S \/ 2 + 50); ctx.stroke();\n    this.src = cv; this.fromCanvas();\n  };\n  ImgSim.prototype.load = function (img) {\n    var S = 128, cv = document.createElement('canvas'); cv.width = S; cv.height = S; var ctx = cv.getContext('2d');\n    ctx.fillStyle = '#fff'; ctx.fillRect(0, 0, S, S);\n    var sc = Math.min(S \/ img.width, S \/ img.height); ctx.drawImage(img, (S - img.width * sc) \/ 2, (S - img.height * sc) \/ 2, img.width * sc, img.height * sc);\n    this.src = cv; this.fromCanvas();\n  };\n  ImgSim.prototype.fromCanvas = function () {\n    var S = this.S, cv = document.createElement('canvas'); cv.width = S; cv.height = S; cv.getContext('2d').drawImage(this.src, 0, 0, S, S);\n    var d = cv.getContext('2d').getImageData(0, 0, S, S).data, bits = [], sum = 0, k;\n    for (k = 0; k < S * S; k++) sum += d[4 * k] + d[4 * k + 1] + d[4 * k + 2];\n    var thr = sum \/ (S * S);\n    for (k = 0; k < S * S; k++) bits.push(d[4 * k] + d[4 * k + 1] + d[4 * k + 2] > thr ? 0 : 1); \/\/ 1 = dark pixel\n    this.bits = bits;\n  };\n  function bytesToBits(u8) { var bits = [], k, i; for (k = 0; k < u8.length; k++) for (i = 7; i >= 0; i--) bits.push((u8[k] >> i) % 2); return bits; }\n  function bitsToBytes(bits) { var u8 = new Uint8Array(Math.floor(bits.length \/ 8)), k, i; for (k = 0; k < u8.length; k++) { var v = 0; for (i = 0; i < 8; i++) v = v * 2 + bits[k * 8 + i]; u8[k] = v; } return u8; }\n  function decodeJpeg(u8) { \/\/ resolves to an ImageBitmap, or null when the bytes are not a decodable JPEG\n    return createImageBitmap(new Blob([u8], { type: 'image\/jpeg' })).then(function (b) { return b; }, function () { return null; });\n  }\n  ImgSim.prototype.run = function () {\n    var self = this;\n    if (this.mode === 'bmp') { this.fromCanvas(); this.res = sendBits(this.bits, true, this.eve, 5); this.jres = null; this.dirty = true; return; }\n    var seq = ++this.seq;\n    function send(u8) {\n      if (seq !== self.seq) return;\n      var bits = bytesToBits(u8), r = sendBits(bits, true, self.eve, 5), rx = bitsToBytes(r.rx), ev = bitsToBytes(r.ev);\n      Promise.all([decodeJpeg(u8), decodeJpeg(rx), decodeJpeg(ev)]).then(function (im) {\n        if (seq !== self.seq) return;\n        var eb = 0, ee = 0; for (var k = 0; k < u8.length; k++) { eb += rx[k] !== u8[k] ? 1 : 0; ee += ev[k] !== u8[k] ? 1 : 0; }\n        self.jres = { bytes: u8.length, bits: bits.length, F: r.F, im: im, eb: eb, ee: ee }; self.dirty = true;\n      });\n    }\n    if (this.jpx === 'file') { send(this.file); return; }\n    var S = +this.jpx, cv = document.createElement('canvas'); cv.width = S; cv.height = S; cv.getContext('2d').drawImage(this.src, 0, 0, S, S);\n    cv.toBlob(function (blob) { blob.arrayBuffer().then(function (buf) { send(new Uint8Array(buf)); }); }, 'image\/jpeg', this.jq);\n  };\n  ImgSim.prototype.onKey = function () { this.run(); };\n  ImgSim.prototype.draw = function () {\n    if (this.mode === 'jpg') { this.drawJpeg(); return; }\n    if (!this.res) this.run();\n    var S = this.S, bits = this.bits, r = this.res;\n    this.titles(['Original (64 \u00d7 64, 1 bit per pixel)', 'Transmitted signal F (duty per bit)', 'Received (right key)', 'Eavesdropper (wrong key)']);\n    function paint(C, f) {\n      if (!C.size()) return; var s = Math.floor(Math.min(C.w, C.h) \/ S) || 1, ox = (C.w - s * S) \/ 2, oy = (C.h - s * S) \/ 2, ctx = C.ctx;\n      for (var k = 0; k < S * S; k++) { ctx.fillStyle = f(k); ctx.fillRect(ox + (k % S) * s, oy + Math.floor(k \/ S) * s, s, s); }\n    }\n    paint(this.c[0], function (k) { return bits[k] ? '#111' : '#fff'; });\n    paint(this.c[1], function (k) { var g = Math.round(255 * (1 - r.F[k])); return 'rgb(' + g + ',' + g + ',' + g + ')'; });\n    paint(this.c[2], function (k) { return r.rx[k] ? '#111' : '#fff'; });\n    paint(this.c[3], function (k) { return r.ev[k] ? '#111' : '#fff'; });\n    var er = 0, ee = 0; for (var k = 0; k < bits.length; k++) { er += r.rx[k] !== bits[k] ? 1 : 0; ee += r.ev[k] !== bits[k] ? 1 : 0; }\n    setTiles(this.tiles, [\n      { label: 'Pixels (bits) sent', value: bits.length, note: (bits.length * BPW).toLocaleString() + ' chaotic clocks' },\n      { label: 'Received pixels wrong', value: er, cls: er ? 'puf-warn' : 'puf-good', note: er ? '' : 'identical, as in the paper\\'s Fig. 10' },\n      { label: 'Eavesdropper pixels wrong', value: pct(ee \/ bits.length), cls: ee \/ bits.length > 0.3 ? 'puf-good' : 'puf-warn' }\n    ]);\n    this.dirty = false;\n  };\n  ImgSim.prototype.titles = function (t) { for (var i = 0; i < 4; i++) if (this.c[i].title.innerHTML !== t[i]) this.c[i].title.innerHTML = t[i]; };\n  ImgSim.prototype.drawJpeg = function () {\n    var j = this.jres, col = colors(this.root);\n    this.titles(['JPEG sent', 'Transmitted signal F (duty per bit)', 'Received file (right key)', 'Eavesdropper\\'s file (wrong key)']);\n    if (!j) { if (!this.seq) this.run(); this.dirty = false; return; }\n    function pic(C, im) {\n      if (!C.size()) return; var ctx = C.ctx;\n      if (!im) {\n        ctx.fillStyle = 'rgba(127,127,127,.12)'; ctx.fillRect(0, 0, C.w, C.h); ctx.fillStyle = col.text; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';\n        ctx.font = '600 13px system-ui, sans-serif'; ctx.fillText('not a valid JPEG:', C.w \/ 2, C.h \/ 2 - 9); ctx.fillText('the file cannot be opened', C.w \/ 2, C.h \/ 2 + 9); return;\n      }\n      var sc = Math.min(C.w \/ im.width, C.h \/ im.height), w = im.width * sc, h = im.height * sc;\n      ctx.imageSmoothingEnabled = false; ctx.drawImage(im, (C.w - w) \/ 2, (C.h - h) \/ 2, w, h);\n    }\n    pic(this.c[0], j.im[0]); pic(this.c[2], j.im[1]); pic(this.c[3], j.im[2]);\n    var C = this.c[1];\n    if (C.size()) {\n      var N = j.F.length, side = Math.ceil(Math.sqrt(N)), s = Math.min(C.w, C.h) \/ side, ox = (C.w - s * side) \/ 2, oy = (C.h - s * side) \/ 2, ctx = C.ctx;\n      for (var k = 0; k < N; k++) { var g = Math.round(255 * (1 - j.F[k])); ctx.fillStyle = 'rgb(' + g + ',' + g + ',' + g + ')'; ctx.fillRect(ox + (k % side) * s, oy + Math.floor(k \/ side) * s, s + 0.4, s + 0.4); }\n    }\n    setTiles(this.tiles, [\n      { label: 'JPEG file sent', value: j.bytes.toLocaleString() + ' bytes', note: j.bits.toLocaleString() + ' bits, ' + (j.bits * BPW).toLocaleString() + ' chaotic clocks' },\n      { label: 'Received bytes wrong', value: j.eb, cls: j.eb ? 'puf-warn' : 'puf-good', note: j.eb ? (j.im[1] ? 'file opens, but damaged' : 'file cannot be opened') : 'identical file' },\n      { label: 'Eavesdropper bytes wrong', value: pct(j.ee \/ j.bytes), cls: j.ee \/ j.bytes > 0.5 ? 'puf-good' : 'puf-warn', note: j.im[2] ? 'file opens, check the picture' : 'file cannot be opened' }\n    ]);\n    this.dirty = false;\n  };\n\n  \/* ================= key sensitivity ================= *\/\n  function SensSim(root) {\n    var self = this; this.root = root; this.key = 'a11'; this.span = 3;\n    root.innerHTML = '';\n    var b = bar(root);\n    select(b.l, KEYOPTS, 'a11', function (v) { self.key = v; self.start(); }, 'Coefficient');\n    select(b.l, [['3', '\u00b1 3 %'], ['0.5', '\u00b1 0.5 %'], ['0.05', '\u00b1 0.05 %']], '3', function (v) { self.span = +v; self.start(); }, 'Range');\n    this.cS = new Canvas(root, 'chx-sens', 'Bit errors of a receiver whose coefficient differs from the transmitter\\'s');\n    this.tiles = tiles(root);\n    this.start();\n  }\n  SensSim.prototype.start = function () {\n    this.xs = []; this.ys = []; this.i = 0; this.N = 81; var R = rng(3), bits = []; for (var k = 0; k < 300; k++) bits.push(R() < 0.5 ? 1 : 0); this.msg = bits; this.dirty = true;\n  };\n  SensSim.prototype.onKey = function () { this.start(); };\n  SensSim.prototype.tick = function () {\n    var t0 = performance.now();\n    while (this.i < this.N) {\n      if (performance.now() - t0 > 12) break;\n      var d = (-1 + 2 * this.i \/ (this.N - 1)) * this.span \/ 100, r = sendBits(this.msg, true, { key: this.key, delta: d }, 11), e = 0;\n      for (var k = 0; k < this.msg.length; k++) e += r.ev[k] !== this.msg[k] ? 1 : 0;\n      this.xs.push(d * 100); this.ys.push(100 * e \/ this.msg.length); this.i++; this.dirty = true;\n    }\n  };\n  SensSim.prototype.draw = function () {\n    var col = colors(this.root), C = this.cS;\n    if (C.begin({ x: [-this.span, this.span], y: [0, 70], xl: 'error in the receiver\\'s coefficient (%)', yl: 'bit errors (%)', yt: [0, 10, 20, 30, 40, 50, 60, 70] })) {\n      C.axes(col); C.line([-this.span, this.span], [50, 50], col.axis, 1);\n      C.line(this.xs, this.ys, col.A, 2);\n      var ctx = C.ctx; ctx.fillStyle = col.A; for (var i = 0; i < this.xs.length; i++) { ctx.beginPath(); ctx.arc(C.X(this.xs[i]), C.Y(this.ys[i]), 2.5, 0, 2 * Math.PI); ctx.fill(); }\n    }\n    var tol = null;\n    for (var j = 0; j < this.xs.length; j++) if (this.ys[j] < 1) { var a = Math.abs(this.xs[j]); if (tol == null) tol = a; else if (a > tol) tol = a; }\n    setTiles(this.tiles, [\n      { label: 'Progress', value: Math.round(100 * this.i \/ this.N) + ' %' },\n      { label: 'Largest error still decoding (below 1 % bit errors)', value: tol == null ? '\u2013' : '\u00b1 ' + tol.toFixed(this.span < 0.1 ? 4 : 3) + ' %', note: 'outside this window the receiver is lost' }\n    ]);\n    this.dirty = false;\n  };\n\n  \/* ================= key editor (shared by every simulator) ================= *\/\n  function KeySim(root) {\n    var self = this; this.root = root; this.inp = {};\n    root.innerHTML = '';\n    var grp = el('fieldset', 'ms-group puf-group chx-keygrp', root); el('legend', '', grp, 'Key: the parameters shared by transmitter and receiver');\n    var g = el('div', 'chx-keys', grp);\n    KEYOPTS.concat([['V0', 'V\u2080 (threshold)']]).forEach(function (o) {\n      var cell = el('label', 'chx-kcell', g), id = 'cxk' + o[0] + Math.random().toString(36).slice(2, 6);\n      el('span', 'chx-kname', cell, o[1]);\n      var i = el('input', 'chx-kin', cell); i.type = 'number'; i.step = 'any'; i.id = id;\n      i.value = o[0] === 'V0' ? V0 : KEY[o[0]];\n      el('em', 'chx-kq', cell, '');\n      i.addEventListener('change', function () { self.apply(); });\n      self.inp[o[0]] = i;\n    });\n    var pr = el('div', 'chx-pwmrow', grp); el('span', 'chx-kname', pr, 'PWM clock');\n    this.pwmSel = select(pr, [['16', 'PWM_CLK = 16 \u00d7 CH_CLK (64 clocks per bit)'], ['4', 'PWM_CLK = 4 \u00d7 CH_CLK (16 clocks per bit, as in the paper)'],\n      ['1', 'PWM_CLK = CH_CLK (4 clocks per bit)']], '4', function (v) { setPwm(+v); self.apply(); }, 'PWM clock');\n    var pr2 = el('div', 'chx-pwmrow', grp); el('span', 'chx-kname', pr2, 'Lock-in preamble');\n    this.preSel = select(pr2, [['0', 'none'], ['256', '256 chaotic clocks'], ['1024', '1,024 chaotic clocks'], ['4096', '4,096 chaotic clocks'],\n      ['16384', '16,384 chaotic clocks']], '1024', function (v) { PRE_CLK = +v; self.apply(); }, 'Preamble length');\n    var b = bar(grp);\n    button(b.l, 'Apply', function () { self.apply(); }, true);\n    function preset(c, v0, x, pre) { setPwm(x); self.pwmSel.value = String(x); PRE_CLK = pre; self.preSel.value = String(pre); self.set(c, v0); }\n    button(b.l, 'Paper values', function () { preset(EXACT, V0_PAPER, 4, 1024); });\n    button(b.l, 'Test values', function () { preset(TEST, TEST_V0, 1, 16384); });\n    button(b.l, 'Random nearby key', function () { var c = self.randomKey(); self.set(c, c.V0); });\n    this.spreadSel = select(b.l, [['0.01', '\u00b1 1 %'], ['0.02', '\u00b1 2 %'], ['0.05', '\u00b1 5 %'], ['0.1', '\u00b1 10 %']], '0.02', function () {}, 'Spread of random keys');\n    this.v0Sel = select(b.l, [['0', 'V\u2080 fixed'], ['0.5', 'V\u2080 \u00b1 0.5'], ['1', 'V\u2080 \u00b1 1'], ['2', 'V\u2080 \u00b1 2'], ['3', 'V\u2080 \u00b1 3']], '2', function () {}, 'Range of V0 for random keys');\n    var sr = el('div', 'ms-bar chx-search', grp), sl = el('div', 'ms-actions', sr);\n    this.searchBtn = button(sl, 'Run random until F equals M is within', function () { if (self.searching) { KEYS.forEach(function (k) { KEY[k] = self.saved[k]; }); V0 = self.saved.V0; self.stop('stopped; key unchanged'); } else self.search(); });\n    this.targetSel = select(sl, [['0.005', '\u00b1 0.5 %'], ['0.01', '\u00b1 1 %'], ['0.02', '\u00b1 2 %'], ['0.05', '\u00b1 5 %'], ['0.1', '\u00b1 10 %']], '0.01', function () {}, 'Tolerance around 50 %');\n    el('span', 'chx-kname', sl, 'of 50 %');\n    this.status = el('span', 'chx-note', sl, 'only keys whose receiver synchronises (spectral radius below 1, no bit errors) are accepted');\n    el('span', 'chx-note', b.r, 'used by all simulators on this page, including the key-sensitivity sweep');\n    this.tiles = tiles(root);\n    this.warn = el('p', 'chx-warn', root, '');\n    this.apply(true);\n  }\n  KeySim.prototype.set = function (c, v0) {\n    var self = this; KEYS.forEach(function (k) { self.inp[k].value = c[k]; }); this.inp.V0.value = v0; this.apply();\n  };\n  KeySim.prototype.apply = function (first) {\n    var self = this, bad = false;\n    KEYS.concat(['V0']).forEach(function (k) {\n      var v = parseFloat(self.inp[k].value), ok = isFinite(v);\n      self.inp[k].classList.toggle('chx-kbad', !ok); if (!ok) { bad = true; return; }\n      if (k === 'V0') V0 = v; else KEY[k] = v;\n      var q = q610(v); self.inp[k].nextSibling.textContent = 'Q6.10: ' + q.toFixed(4);\n      self.inp[k].classList.toggle('chx-kmod', k === 'V0' ? v !== V0_PAPER : v !== EXACT[k]);\n    });\n    if (bad) return;\n    this.check();\n    if (!first) W.forEach(function (w) { if (w !== self) { if (w.onKey) w.onKey(); w.dirty = true; } });\n  };\n  \/\/ a random key around the paper's, spread \u00b1 the selected fraction, rejecting keys whose receiver cannot synchronise\n  KeySim.prototype.randomKey = function () {\n    var c, R = Math.random, t = 0, sp = 2 * +this.spreadSel.value;\n    do { c = {}; KEYS.forEach(function (k) { c[k] = +(EXACT[k] * (1 + sp * (R() - 0.5))).toPrecision(7); }); t++; }\n    while (t < 500 ? radius(c) > 0.9995 : false);\n    var w = +this.v0Sel.value; c.V0 = w ? +(V0_PAPER + w * (2 * R() - 1)).toFixed(4) : V0; \/\/ V0 around the paper's 0.35, absolute range\n    return c;\n  };\n  \/\/ quick health check of the current key (KEY, V0, PWM clock, preamble): is the transmitter bounded, does the receiver lock on,\n  \/\/ how biased is F? The statistics of F are taken in Q6.10, as on the FPGA, after the lock-in preamble, over the data bits only.\n  KeySim.prototype.measure = function () {\n    var R = rng(21), bits = [], k, j, NB = Math.max(400, Math.ceil(8000 \/ BPW)); for (k = 0; k < NB; k++) bits.push(R() < 0.5 ? 1 : 0);\n    var o = { NB: NB, mx: 0, flips: 0, agree: 0, n: 0, er: 0 };\n    var rho = radius(coeffs(true)); o.rho = rho; o.stable = rho > 0.99995 ? false : true;\n    var Lf = new Link(false, null, 4), Lq = new Link(true, null, 4), last = 0, P = preBits();\n    for (k = 0; k < P; k++) for (j = 0; j < BPW; j++) { Lf.step(pwm(k % 2, j)); last = Lq.step(pwm(k % 2, j)).F; } \/\/ the same lock-in preamble as sendBits\n    for (k = 0; k < bits.length; k++) for (j = 0; j < BPW; j++) { \/\/ statistics over the data only\n      var m = pwm(bits[k], j), r = Lf.step(m), q = Lq.step(m);\n      o.mx = Math.max(o.mx, Math.abs(r.V1), Math.abs(r.V2)); o.flips += q.F !== last ? 1 : 0; o.agree += q.F === m ? 1 : 0; o.n++;\n      last = q.F;\n    }\n    var s = sendBits(bits, true, null, 4); for (k = 0; k < bits.length; k++) o.er += s.rx[k] !== bits[k] ? 1 : 0;\n    o.state = !isFinite(o.mx) || o.mx > 1e5 ? 'diverges' : o.mx > 31 ? 'overflows Q6.10' : 'bounded';\n    o.fm = o.agree \/ Math.max(1, o.n);\n    return o;\n  };\n  KeySim.prototype.check = function () {\n    var o = this.measure(), rho = o.rho, stable = o.stable, mx = o.mx;\n    setTiles(this.tiles, [\n      { label: 'Spectral radius of the filter (Q6.10)', value: rho.toFixed(4), cls: stable ? 'puf-good' : 'puf-warn',\n        note: stable ? 'below 1: receivers synchronise' : 'not below 1: receivers cannot synchronise, decoding is luck' },\n      { label: 'Transmitter (float)', value: o.state, cls: o.state === 'bounded' ? 'puf-good' : 'puf-warn', note: 'largest |V| = ' + (isFinite(mx) ? mx.toPrecision(3) : '\u221e') },\n      { label: 'Legit receiver bit errors (Q6.10)', value: pct(o.er \/ o.NB), cls: o.er ? 'puf-warn' : 'puf-good', note: o.NB + ' data bits after a ' + preBits() * BPW + '-clock preamble' },\n      { label: 'F equals M (Q6.10)', value: pct(o.fm), cls: Math.abs(o.fm - 0.5) > 0.05 ? 'puf-warn' : 'puf-good', note: 'data bits only; 50 % = no statistical leak' },\n      { label: 'Transitions in F', value: pct(o.flips \/ Math.max(1, o.n)), note: 'per clock' }\n    ]);\n    this.warn.innerHTML = stable ? '' : '\u26a0 With this key the linear part of the filter is unstable (spectral radius ' + rho.toFixed(4) +\n      '). The receiver\\'s error obeys e(n) = A\u00b7e(n\u22121), so it grows instead of dying out, and the oscillators only coincide when both ' +\n      'saturate at the Q6.10 limit. Whether a receiver decodes then depends on its random starting state, not on the key: ' +\n      'an eavesdropper with the same key may succeed while the legitimate receiver fails, or the other way round.';\n    this.warn.style.display = stable ? 'none' : '';\n  };\n  \/\/ try random keys (in small time slices, so the page stays responsive) until one gives F equals M above the target\n  KeySim.prototype.search = function () {\n    var self = this, tol = +this.targetSel.value, saved = {}, tries = 0, best = null, MAX = 2000;\n    KEYS.forEach(function (k) { saved[k] = KEY[k]; }); saved.V0 = V0; this.saved = saved;\n    this.searching = true; this.searchBtn.textContent = 'Stop';\n    function slice() {\n      if (!self.searching) return;\n      var t0 = performance.now();\n      while (performance.now() - t0 > 30 ? false : true) {\n        if (tries >= MAX) { KEYS.forEach(function (k) { KEY[k] = saved[k]; }); V0 = saved.V0; self.stop('no key found in ' + MAX + ' tries' + (best ? '; best F equals M = ' + pct(best.fm) : '') + '. Try a larger spread, a wider V\u2080 range or a larger tolerance.'); if (best) self.set(best.c, best.c.V0); return; }\n        var c = self.randomKey(); tries++;\n        KEYS.forEach(function (k) { KEY[k] = c[k]; }); V0 = c.V0;\n        var o = self.measure();\n        if (o.stable ? (o.er === 0 ? o.state === 'bounded' : false) : false) {\n          if (best === null ? true : Math.abs(o.fm - 0.5) > Math.abs(best.fm - 0.5) ? false : true) best = { c: c, fm: o.fm };\n          if (Math.abs(o.fm - 0.5) > tol ? false : true) { self.stop('found after ' + tries + ' tries: F equals M = ' + pct(o.fm) + ', V\u2080 = ' + c.V0); self.set(c, c.V0); return; }\n        }\n      }\n      self.status.textContent = 'searching\u2026 ' + tries + ' tries' + (best ? ', best so far ' + pct(best.fm) : '');\n      setTimeout(slice, 0);\n    }\n    slice();\n  };\n  KeySim.prototype.stop = function (msg) {\n    this.searching = false; this.searchBtn.textContent = 'Run random until F equals M is within'; this.status.textContent = msg;\n  };\n  KeySim.prototype.draw = function () { this.dirty = false; };\n\n  \/* ---------- boot ---------- *\/\n  var W = [], MAP = { 'chx-key': KeySim, 'chx-link': LinkSim, 'chx-text': TextSim, 'chx-img': ImgSim, 'chx-sens': SensSim };\n  function boot() {\n    Object.keys(MAP).forEach(function (cls) { document.querySelectorAll('.' + cls).forEach(function (n) { if (!n.__chx) { n.__chx = new MAP[cls](n); W.push(n.__chx); } }); });\n    var last = performance.now();\n    function frame(now) {\n      var dt = Math.min(0.1, (now - last) \/ 1000); last = now;\n      W.forEach(function (w) {\n        if (!visible(w.root)) return;\n        if (w.tick) w.tick(dt);\n        var cw = w.root.clientWidth; if (cw !== w.lastW) { w.lastW = cw; w.dirty = true; }\n        if (w.dirty) w.draw();\n      });\n      requestAnimationFrame(frame);\n    }\n    requestAnimationFrame(frame);\n  }\n  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot); else boot();\n})();\n\n<\/script>\n<script>\n(function(){\n  function open(hash){\n    if(!hash) return;\n    if(hash.length < 2) return;\n    var el=document.getElementById(decodeURIComponent(hash.slice(1)));\n    if(!el) return;\n    var node=el,opened=false;\n    while(node){\n      if(node===document.body) break;\n      if(node.classList ? node.classList.contains('mem-panel') : false){\n        var m=node.className.match(\/mem-p-([\\w-]+)\/);\n        var r=m ? document.getElementById('mem-t-'+m[1]) : null;\n        if(r){r.checked=true;opened=true;}\n      }\n      node=node.parentNode;\n    }\n    if(opened){ var tabs=document.querySelector('.mem-page .mem-nav'); if(tabs) tabs.scrollIntoView({block:'start'}); if(!el.classList.contains('mem-panel')) el.scrollIntoView({block:'start'}); }\n  }\n  document.addEventListener('DOMContentLoaded',function(){\n    open(location.hash);\n    document.querySelectorAll('.mem-page input[type=radio][id^=\"mem-t-\"]').forEach(function(r){\n      r.addEventListener('change',function(){history.replaceState(null,'','#'+r.id.replace('mem-t-',''));});\n    });\n  });\n  window.addEventListener('hashchange',function(){open(location.hash);});\n})();\n<\/script>\n\n\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Chaotic circuits produce signals that look like noise but are completely deterministic. Two identical chaotic circuits can be made to synchronise, and that makes them a natural tool for hiding information. This page explains the idea and presents the fully digital chaotic encryption scheme developed by our group, with simulations you can run in your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-410","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/memristors.uib.es\/index.php\/wp-json\/wp\/v2\/pages\/410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/memristors.uib.es\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/memristors.uib.es\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/memristors.uib.es\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/memristors.uib.es\/index.php\/wp-json\/wp\/v2\/comments?post=410"}],"version-history":[{"count":15,"href":"https:\/\/memristors.uib.es\/index.php\/wp-json\/wp\/v2\/pages\/410\/revisions"}],"predecessor-version":[{"id":425,"href":"https:\/\/memristors.uib.es\/index.php\/wp-json\/wp\/v2\/pages\/410\/revisions\/425"}],"up":[{"embeddable":true,"href":"https:\/\/memristors.uib.es\/index.php\/wp-json\/wp\/v2\/pages\/2"}],"wp:attachment":[{"href":"https:\/\/memristors.uib.es\/index.php\/wp-json\/wp\/v2\/media?parent=410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}