AI and network security

Device-issued identity vs API keys: which is safer?

Device-issued identity is safer for devices. An API key is a bearer secret, so anyone who copies it can use it, and it tends to be long-lived and shared. A device-issued identity is a key pair generated on the device whose private half never leaves it; the device proves who it is by signing, so there is nothing reusable to steal from the wire, a log or a repository.

TL;DR

An API key works for whoever holds it, so every copy in code, logs, config files and app binaries is a working credential. A device-issued identity keeps its private key on the device and proves itself with a signature, so it cannot be phished or replayed. Use it between devices, and keep scoped, rotated, short-lived API keys for server-to-server calls.

Learning objectives

After reading this article you will be able to:

  • Explain why API keys are bearer secrets and how that makes them leak
  • Describe how a device-issued key pair proves identity without sending a secret
  • Choose between an API key, short-lived credentials and device-issued identity for a given connection

Device-issued identity and API key differences

An API key is a secret string that grants access to whoever presents it. A device-issued identity is a key pair the device generates for itself: the private half stays on the device, and the device proves who it is by signing something fresh with it. The first is something you send; the second is something you prove without sending.

That one difference decides most of the security:

API keyDevice-issued identity
What is presentedThe secret itselfA signature made with a private key
Who can use a copyAnyone who holds itNobody, because the private key is never copied
Where it tends to end upCode, config files, CI logs, chat messages, app binariesPlatform key storage on one device
Typical lifetimeLong, until someone rotates itTied to the device, replaced when the device is
Scope of one leakEverything the key can do, from anywhereOne device, revoked on its own

API key leak causes

API keys leak because a key is useful anywhere it is copied, and it gets copied everywhere. A key starts in a secret manager, then lands in an environment file, a CI variable, a teammate’s laptop, a debugging log and sometimes a public commit. GitGuardian’s 2025 report counted 23,770,171 new secrets in public GitHub commits in 2024, a 25% rise on the year before, and found that 70% of the secrets it saw leaked in 2022 were still valid. AI coding tools have not helped: the same report found secret leakage in 6.4% of repositories using GitHub Copilot, against a 4.6% average across public repositories.

A key shipped inside a mobile or desktop app has to be treated as public. Anyone with the binary can extract it. Offline Protocol’s own docs say this plainly about the one key its SDK can carry, the telemetry key: it ships in the application binary and can be extracted, so scope it to that application, monitor its use, and delete it if it is exposed.

Device key signature verification

A device-issued identity proves who it is by signing. The device generates a key pair, keeps the private key in platform storage such as the iOS keychain or Android Keystore, and shares the public key. When another party wants proof, it sends a fresh random challenge, the device signs it, and the other party checks the signature against the public key. The challenge is new each time, so a recorded answer cannot be replayed.

Some systems go one step further and derive the device’s address from its public key. That makes the address a self-certifying identifier: anyone can check that a presented key belongs to the address by recomputing it, with no directory or certificate authority to ask.

This is the same principle as passkeys. The FIDO Alliance describes passkeys as using standard public key cryptography to provide phishing-resistant sign-in: the private key stays on the user’s device and is bound to the site, so there is no shared secret for a fake page to collect.

API keys for server-to-server calls

An API key is still the right choice for server-to-server calls to a third-party service that only offers keys. Then make the key as small and short-lived as the platform allows:

  • Scope it to one job. A key that can only read one resource is a small loss when it leaks.
  • Prefer temporary credentials. AWS recommends relying on temporary credentials instead of long-term access keys wherever possible, and using roles for workloads so that no long-lived key is distributed at all.
  • Store it in a secret manager and rotate it. OWASP’s secrets guidance recommends regular rotation so that a stolen credential only works for a short time, and immediate revocation when one is exposed.
  • Never put a broad key in a client. Anything in a browser or app binary is readable by whoever has it.

For devices talking to devices, or devices proving themselves to your backend, use device-issued identity. What happens when an API key leaks? covers the clean-up when a key gets out.

Offline Protocol device identity without API keys

Offline Protocol gives every device its own Ed25519 identity key, generated and held on the device, and derives the device’s off1 address from the public key. Two devices verify each other directly from the key, with no lookup, no certificate authority and no round trip, and a mismatch is refused. Sessions between them are end-to-end encrypted with MLS. A local mesh session needs no portal account and no API key at all.

When a device needs to belong to an existing account, your server binds it the device-issued way: it issues a fresh nonce, the device signs it, and the server verifies the signature, checks the derived address and stores the binding. An app API key is needed only for hosted services such as hosted MCP, SDK telemetry and CLI use in CI, and the portal stores only a hash of each key, so a lost key is replaced, never recovered. The result is a fleet whose devices carry no shared secret that could be pasted into the wrong place, and where one lost device is one key to revoke.

Frequently asked questions

Are API keys insecure?

Not by themselves, but they are bearer secrets, so their safety depends on never being copied to the wrong place. Scope each key to one job, keep it in a secret manager, rotate it, and prefer short-lived credentials where the platform offers them.

Can a device-issued key be stolen?

Not by reading traffic, logs or code, because the private key never leaves the device. An attacker would need control of the device itself, and keys held in non-exportable platform storage are hard to extract even then.

Is a device key the same as a passkey?

They use the same idea. A passkey is a key pair whose private half stays on the user's device and signs a challenge from a website; a device key does the same for a device talking to other devices or to a server.

Why do API keys stay valid after they leak?

Because nothing expires them. GitGuardian found that 70% of the secrets it saw leaked in 2022 were still valid when it checked, which is why short lifetimes and fast revocation matter.

Does Offline Protocol need an API key for devices to talk?

No. A local mesh session needs no portal account or API key; devices identify each other with Ed25519 keys they generate themselves. An app API key is needed only for hosted MCP, SDK telemetry and CLI use in CI.

Sources

Build it with Offline Protocol

The device identity guide shows how each device's Ed25519 key and off1 address work, and how to bind a device to an existing account by verifying a signature over a fresh server-issued nonce.

Read the device identity guide