Why Go’s New crypto/passkey Package Could Nail Password‑less Login
Filippo Valsorda’s proposal to add a crypto/passkey package to Go’s standard library introduces a stateless, no‑callback API that simplifies Passkey integration for small‑to‑medium sites by standardising credential storage, redefining user‑ID handling, and trimming unnecessary protocol features.
In 2024, former Go cryptography lead Filippo Valsorda (FiloSottile) submitted Issue #80663 to add a crypto/passkey package to the Go standard library. The proposal targets a “stateless, no‑callback, no‑interface” server‑side API aimed at reducing the barrier for small‑to‑medium web applications to adopt Passkey authentication.
What is a Passkey?
A Passkey is the consumer‑grade name for a discoverable WebAuthn credential. It replaces passwords with a public‑private key pair: the private key stays on the user’s device (phone, computer, or security key) and never leaves it, while the public key is stored by the website. During login the server sends a random challenge, the device signs it with the private key, and the server verifies the signature with the stored public key, providing phishing‑resistant authentication.
User Experience
From a user’s perspective, Passkey registration and login involve a single biometric or PIN verification on the device, with no password entry. Passkeys can be synced across devices via iCloud Keychain, Google Password Manager, or Microsoft Windows Hello, and can be transferred to another device via a QR‑code‑based hybrid transport.
Key Design Elements of the Proposal
Official Package: Introduces crypto/passkey with a minimal API.
Passkey Record: A single opaque string (e.g., $webauthn$v=1$transports=hybrid+internal$<base64 data>) that encodes all credential data, enabling language‑agnostic storage.
Storage Model: One table indexed only by user_id, storing the opaque record; no need for a unique index on credential_id, eliminating cross‑account credential collisions.
Stateless API: The RelyingParty object is a pure configuration holder that holds no session state.
No Callbacks: Instead of a callback that could process untrusted data (as illustrated by the GO‑2024‑3321 vulnerability), the API returns a Response object that the caller parses, preserving the UnauthenticatedUserID flag to signal untrusted data.
User ID Generation: Recommends using crypto/rand.Text() to create a random, opaque string that never contains identifiable information.
Origin & RP ID Handling: Enforces a single, explicitly configured Origin per RelyingParty instance to avoid cross‑origin replay attacks; multiple origins require separate RelyingParty instances.
Feature Trim: Omits attestation and signature‑counter checks, arguing they add little value for consumer‑grade Passkeys and would reject legitimate logins.
Registration Flow Example
optionsJSON, err := rp.NewRegistration(
passkey.User{ID: opaqueUserID, Name: username}, existingPasskeys)
// send optionsJSON to frontend, call navigator.credentials.create()
record, err := rp.Register(responseJSON)
// store record string in databaseLogin Flow Example
The login response includes an UnauthenticatedUserID value that must be used only to look up Passkey records, never as an authenticated identity.
Proposal Status
The proposal is currently in the Go standard library review process: public discussion on the issue tracker, feedback collection, and eventual acceptance by the Go team before inclusion in a future Go release. An interactive API documentation page is already available.
Conclusion
By reducing Passkey integration to storing a single opaque string per user and providing a clear, stateless API, the crypto/passkey package promises to make password‑less login accessible to most web developers without deep protocol expertise.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
TonyBai
Tony Bai's tech world (tonybai.com). Not satisfied with just "knowing how", we strive for mastery. Focused on Go language internals, high-quality engineering practices, and cloud‑native architecture, exploring cutting‑edge intersections of Go and AI. Gophers who pursue technology are welcome—follow me and evolve with Go.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
