What this specification covers
It covers the Encrypted Link between the UP↑SCALE app (a browser app using Web Bluetooth) and the scale firmware (ESP32-S3 / ESP32-C3), the optional registered-apps mode, the password envelope and the scale identity key they build on. It is written for IT-security, QA and validation reviewers. It does not cover the website, the licence server, or how a customer stores exported files.
UP↑SCALE has not had the implementation evaluated by a third party (for example FIPS 140-3 or Common Criteria). The algorithms are standard; the way they are combined is our own protocol. Section 8 lists its known limits.
Encryption runs end to end in the app and the firmware
Encryption is done at the application layer by the two endpoints. The Bluetooth LE link itself stays unpaired, so BLE link-layer security is not relied on. A hook on each side wraps the three UP↑SCALE GATT characteristics; the rest of the code sees plain 42-byte packets.
Standard algorithms only, from mbedTLS and Web Crypto
The firmware uses mbedTLS from the ESP-IDF / Arduino-ESP32 core. The app uses the browser's Web Crypto API. Neither side contains its own cipher code.
| Function | Algorithm | Parameters | Standard |
|---|---|---|---|
Scale identity key (sk / pk) | ECDSA key pair | secp256r1 (P-256), made once on the scale | FIPS 186-5 |
| Key agreement | ECDH, ephemeral–ephemeral | P-256; a new key pair on both sides for every handshake; shared secret = x-coordinate (32 bytes) | SP 800-56A |
| Scale authentication | ECDSA signature | with sk over SHA-256("UPSCALE-LINK2-S" ‖ A ‖ B) | FIPS 186-5 |
| Public-key check | point validation | scale: mbedtls_ecp_check_pubkey; app: Web Crypto importKey | SP 800-56A 5.6.2.3 |
| Key derivation | HKDF-SHA256 | salt = A ‖ B, info = "UPSCALE-LINK2", 52 bytes out | RFC 5869, SP 800-56C |
| Payload encryption | AES-GCM | 128-bit key, 96-bit IV, 128-bit tag, 6-byte AAD | FIPS 197, SP 800-38D |
| Downlink key transport | AES-GCM key wrap | key Kw and IV from HKDF, 128-bit tag | SP 800-38D |
| App authentication (optional) | ECDSA signature | app key P-256 over SHA-256("UPSCALE-LINK2-A" ‖ A ‖ B) | FIPS 186-5 |
| Password envelope | ECDH + AES-GCM | P-256 with sk, key = SHA-256(Z ‖ nonce ‖ "UPSCALE-PW1")[0..16], 128-bit tag; travels inside the Encrypted Link on PRO / ENTERPRISE | SP 800-56A, SP 800-38D |
| Stored user passwords | PBKDF2-HMAC-SHA256 | 16-byte random salt | SP 800-132, RFC 8018 |
| Seals and certificates | ECDSA | P-256 over SHA-256, raw r ‖ s | FIPS 186-5 |
| Random numbers | scale: hardware RNG (esp_fill_random, radio on); app: browser CSPRNG | — | Espressif TRM, W3C Web Crypto |
Every connection gets its own keys, signed by the scale
Each handshake yields an uplink key Ku for app → scale. Each Bluetooth connection gets a downlink key Kd for scale → app; two browser tabs that share one connection also share its Kd.
- State (plain). The app sends
GO-LC 1; the scale answers[227] 1: setting, licence, active, key exists, boot id, registered-apps mode. - Scale identity (plain). The app asks for the seal state (
GO-EQ 26);[232] 13carriespkand, on ENTERPRISE scales, the seal certificate. - Trust. A valid UP↑SCALE seal certificate for this
pk(and this Device ID) makes the key trusted at once. Without one, the firstpkis pinned in the browser and a later change must be confirmed by the user. - App one-time key. The app makes a P-256 key pair and sends its public key A in two parts (
GO-LC 2). - Scale one-time key. The scale validates A, makes its own one-time key pair b / B, computes Z = ECDH(b, A) and wipes b. It signs SHA-256("UPSCALE-LINK2-S" ‖ A ‖ B) with
sk. - Derivation. Both sides run HKDF-SHA256(salt = A ‖ B, ikm = Z, info = "UPSCALE-LINK2") → Ku (16) ‖ salt_u (8) ‖ Kw (16) ‖ IVw (12).
- Scale answer.
[227] 3= B ‖ signature (4 parts).[227] 4= AES-GCMKw, IVw(Kd ‖ salt_d ‖ boot id), 28 + 16 bytes (2 parts). Kd and salt_d are random, made at the first handshake of the connection, RAM only. - App check. The app verifies the signature with the trusted
pk; a wrong signature ends the handshake. It then unwraps Kd and keeps Ku and Kd as non-extractable Web Crypto keys.
Re-keying. A reconnect always runs a new handshake with new one-time keys on both sides. A scale restart changes the boot id; apps notice and start again. Up to 4 handshakes and 4 connections are kept at once.
A 42-byte packet becomes 63 bytes on the air
| Bytes | Length | Content |
|---|---|---|
| 0 | 1 | marker 226 |
| 1–4 | 4 | counter, uint32 little-endian, strictly rising per sender and key |
| 5–46 | 42 | AES-128-GCM ciphertext |
| 47–62 | 16 | GCM tag (128 bits) |
IV (96 bits) = salt (8) ‖ counter (4). AAD (6 bytes) = 226 ‖ direction ‖ counter, with direction 0 for Sending, 1 for Extra and 9 for app → scale. A packet cannot be moved to another characteristic or sent back the other way.
Replay and forgery. The scale takes an app packet only with a counter higher than the last one of that handshake. The app takes each counter once inside a 64-packet window. After 16 packets on one connection that fail the tag or the counter check, the scale drops the connection.
IV uniqueness. Each key has its own counter; every key is new per handshake or per connection, so an IV never repeats under one key.
| Direction | Plain while the link is encrypted | Why |
|---|---|---|
| scale → app | [227] state and handshake answers | needed before the keys exist; the key itself is wrapped, B is signed |
| scale → app | [232] 13 seal state | carries the public identity key and certificate |
| app → scale | GO-LC 1, 2, 4, GO-EQ 26 | handshake and proof |
| both | advertising, Decent Scale service, ESP-NOW | outside the Encrypted Link |
Any other plain write is refused, and the scale answers with its state (at most once per second).
Only the identity key and the app list live in flash
| Key | Made by | Stored | Lifetime | Wiped |
|---|---|---|---|---|
Identity key sk (32 B) | scale, once, after the first start (radio on) | NVS EQUIP/sk, not encrypted | until the flash is erased | never automatically |
| Seal certificate (144 B) | UP↑SCALE licence tool | NVS EQUIP/scert | as sk | when sk changes |
| One-time keys a, b | app, scale | memory | one handshake | b: right after ECDH; a: dropped |
| Z, HKDF output, Kw | both sides | memory | one handshake | mbedtls_platform_zeroize / fill(0) |
| Ku, salt_u | both sides (HKDF) | scale RAM slot; app non-extractable CryptoKey | one handshake | on disconnect |
| Kd, salt_d | scale (RNG) | scale RAM; app non-extractable CryptoKey | one connection | on disconnect |
| Registered app keys (8 × 64 B public) | the apps | NVS EQUIP/lapps | until removed | REMOVE ALL |
| App key (private) | browser, once | IndexedDB, non-extractable | until browser data is cleared | — |
| Password envelope key | both, from ECDH + nonce | RAM | one use, 30 s | after use or timeout |
The Encrypted Link is on by default and active when the setting is on, the licence is PRO or ENTERPRISE, and the identity key exists. Switching it on also switches off BLE FOR ALL, which puts the weight into the plain advertising; the user can switch that on again.
Only the devices you registered get the keys
Each browser keeps its own ECDSA P-256 key, created non-extractable in IndexedDB. The scale stores up to 8 public app keys. With registered apps only on, the scale withholds the wrapped Kd and refuses all app packets until the app signs SHA-256("UPSCALE-LINK2-A" ‖ A ‖ B) with a registered key.
- Registering, switching on and removing go only over the encrypted link, need ENTERPRISE and pass the ADMIN settings gate when users are set up.
- Only an app that has proven itself can switch the mode on, so the device that does it cannot lock itself out.
- A new device is let in from a registered one for 2 minutes. Recovery when all devices are lost: the USB serial command
LINKOPEN(physical access). - Every change is written to the activity log (settings 28 and 29).
What the Encrypted Link protects against
The Encrypted Link stops a passive sniffer and an active attacker on the radio from reading, changing, replaying or injecting payloads.
| Protected against | Not protected against |
|---|---|
| Reading payloads over the air, also from recordings made earlier: one-time keys on both sides, so a later leak of the scale key does not open them | — |
| A device posing as the scale: its one-time key must be signed with the trusted identity key; ENTERPRISE scales are checked against the UP↑SCALE seal certificate | On PRO scales (no certificate) the very first connection of a browser: the key is pinned then, later changes are asked |
| Changed, injected, replayed or redirected packets: 128-bit tags, counters, direction in the AAD; 16 failed packets drop the connection | Traffic analysis: that a connection exists, packet timing and rate (all packets are 63 bytes) |
| Unknown devices (ENTERPRISE, registered apps only): no keys without a signature of a registered app key | With registered apps only off, or on PRO: any central can complete the handshake; users and passwords are then the access control |
| One app reading another app's traffic: a separate downlink key per Bluetooth connection | Browser tabs that share one Bluetooth connection share its key |
| Recorded passwords: they never cross the link in plain text; stored as PBKDF2-HMAC-SHA256 | Weak passwords chosen by the users: the minimum is 8 characters - choose long ones |
| — | BLE FOR ALL (off by default, if switched on), the Decent Scale service, USB serial and ESP-NOW: plain by design |
Tests: the app side is tested against an emulation of the firmware protocol (handshake, signature check, wrong signature, replay, tampered tag, AAD direction, registration and proof, unregistered app refused, pinned key change). On a DIY scale (ESP32-C3) the full handshake takes about 1 second; registration, the registered-apps mode, refusal of an unregistered app and the USB recovery were tested there. The other scale variants follow.
Where each part lives in the source
| Part | Firmware | App |
|---|---|---|
| Handshake, wire format, replay, registered apps | l16_seal_link.ino | link_crypt.js |
| Identity key, signatures, envelope | l16_seal.ino | seal.js, pw_envelope.js |
| Licence and certificate check | l16_licence.ino | licence.js |
| Password hashing | l16_pwhash.ino, l16_register.ino | — |
| Hooks into the BLE stack | send_queued_BLE_packets(), IncomingCallback::queue_it(), onDisconnect | linkcrypt_hook() |
| Revision | Date | Change |
|---|---|---|
| 1.1 | 2026-11-01 | link v2: signed one-time scale key, HKDF, 128-bit tags, key per connection, registered apps, PBKDF2 passwords, certificate check of the scale key |
| 1.0 | 2026-11-01 | first issue |