Skip to content
MistakesByDesignPublic

About

Unofficial Go port of the Spectre (Master Password) algorithm: a stateless password CLI

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ghostly

ghostly is a stateless password tool: an unofficial Go implementation of the Spectre algorithm (formerly Master Password). It isn't affiliated with or endorsed by the Spectre project or its author.

It doesn't store passwords; it derives them. Give it your name, your primary password and a site name, and it computes the same site password on any machine, every time. Nothing is saved or synced, and nothing is left behind. Its results are identical to those of any Spectre v3 client.

Status: early, but released. Every v3 test vector passes. Releases before v0.2.0 were named spectre-go; see Upgrading from v0.1.x.

Compatibility

The goal is output identical, byte for byte, to the reference implementation for:

  • algorithm version 3, which every current Spectre client uses (versions 0–2, from before 2015, aren't supported)
  • every template type: Maximum, Long, Medium, Short, Basic, PIN, Name and Phrase
  • passwords, logins and security-question answers
  • derived keys: raw cryptographic keys of 128 to 512 bits, upstream's "key" result type

The defaults are deliberately stronger than upstream's (see Defaults).

Correctness is defined by the official test vectors, which are vendored in internal/spectre/testdata/.

Install

On Linux or macOS:

curl -fsSL https://raw.githubusercontent.com/MistakesByDesign/ghostly/main/install.sh | sh

The installer puts ghostly in ~/.local/bin, with no sudo. It checks the binary against the release's SHA256SUMS and refuses to install on a mismatch. If the GitHub CLI is installed and logged in, it also verifies the build provenance. Set GHOSTLY_VERSION=v0.1.0 to pin a release, or GHOSTLY_INSTALL_DIR to choose another location. It's a short script, so read install.sh first if you prefer.

Or download a release binary for your platform from Releases and check it against SHA256SUMS:

sha256sum --check --ignore-missing SHA256SUMS

Every release binary also carries signed build provenance. To confirm it was built from this repository by its release workflow:

gh attestation verify ghostly-linux-amd64 --repo MistakesByDesign/ghostly

Success is silent: it prints nothing and exits 0. Add --format json to see the signing workflow, tag and commit.

Or build from source with Go 1.26 or later. The go command fetches the exact toolchain pinned in go.mod itself:

go install github.com/MistakesByDesign/ghostly/cmd/ghostly@latest

Binaries are statically linked and need no runtime dependencies.

Upgrading from v0.1.x

Up to v0.1.1 the project was called spectre-go and the command was spectre. Your passwords don't change, because the algorithm is the same. Only the names do:

  • Delete the old binary (rm ~/.local/bin/spectre), then install with the one-liner above.
  • Rename SPECTRE_USER to GHOSTLY_USER in your shell profile.
  • To verify a v0.1.x binary's provenance, use gh attestation verify <file> --owner MistakesByDesign, since its signature names the old repository.

Usage

ghostly password github.com              # the password for a site
ghostly login github.com                 # a login name for the site
ghostly answer github.com "first pet"    # the answer to a security question
ghostly key example.com ssh > ssh.key    # a raw 512-bit key; "ssh" is an optional label
$ export GHOSTLY_USER="Robert Lee Mitchell"
$ ghostly password github.com
Primary password:
Key ID: 98EEF4D1
<password>

The result is the only thing written to stdout, so ghostly password github.com | pbcopy copies just the password. Prompts go to the terminal, and the key ID goes to stderr.

Option
-u, --user NAME user name; defaults to $GHOSTLY_USER, otherwise you're asked
-c, --counter N increment to replace a site's result, 1 to 4294967294 (default 1)
-s, --style STYLE maximum, long, medium, short, basic, pin, name, phrase
--bits N key size for key: 128 to 512, in multiples of 8 (default 512)
--base64 print a key as base64 text, the way other Spectre clients show it, instead of raw bytes
--password-stdin read the primary password from the first line of piped stdin, for scripts (refused when stdin is a terminal, where it would echo)
-q, --quiet don't show the key ID

ghostly key writes raw bytes with no newline, for files and pipes (ghostly key example.com backup > backup.key). It refuses to write them to a terminal; use --base64 there. With no label, the key is the one any Spectre v3 client derives for the site, and each label gives a separate key. Different --bits sizes give unrelated keys, not truncations of one another.

The key ID is the first 8 hex digits of your user key's fingerprint. Learn yours; if it ever looks unfamiliar, you mistyped the primary password. Options may come before or after the site. ghostly --help lists everything.

Exit status: 0 on success, 1 on an error (such as no terminal and no --password-stdin), 2 on a usage mistake.

Defaults

ghostly picks the strongest settings by default, which differ from other Spectre clients:

ghostly Other Spectre clients
Password style maximum: 20 characters, symbols included long: 14 pronounceable characters
Algorithm v3 only v3 by default; v0–v2 on request

To get the same password another Spectre client gives you, pass the settings it used, for example --style long. Given the same inputs, the result is identical. A password created under algorithm v0–v2 can only be recovered with another client; rotate it afterwards.

How it works

user key = scrypt(primary password, scope ‖ len(user name) ‖ user name)
site key = HMAC-SHA-256(user key, scope ‖ len(site name) ‖ site name ‖ counter [‖ len(context) ‖ context])
password = render(template[site key[0]], site key[1:])

The full specification, with byte encodings and a worked example, is in docs/algorithm.md.

Security notes

  • Nothing is written to disk. The primary password is read from the terminal without echo and is never accepted as a command-line argument.
  • Each run costs about 32 MiB of memory and a noticeable fraction of a second for scrypt. That is deliberate.
  • The binary is pure Go (no cgo), and its only dependencies are the Go standard library and golang.org/x.
  • To report a vulnerability, see SECURITY.md.

Building

The only prerequisite is Go. go.mod pins the toolchain, and the go command fetches it automatically. CI and releases run these same targets:

Command What it does
make check vet, tests (including the vectors), lint and vulnerability scan
make dist static binaries for Linux, macOS and Windows (amd64 and arm64), plus SHA256SUMS, in dist/
make install-test runs install.sh against dist/, checking it installs a good build and refuses a tampered one

Pushing a tag such as v0.1.0 publishes a release: binaries, SHA256SUMS and provenance. Dependency updates arrive through Renovate and merge themselves once they're 3 days old and CI passes (ADR 0008).

Contributing

See CONTRIBUTING.md for the branch and PR workflow, the project layout and how to work on the code with Claude Code. GLOSSARY.md defines the domain terms, and docs/adr/ records the design decisions.

License

GPL-3.0-or-later, the same license as the reference implementation, whose test vectors this repository includes.

"Spectre" and "Master Password" are names belonging to Maarten Billemont's Spectre project, and the GPL grant gives no rights to use them as trademarks. This project uses them only to describe compatibility.

About

Unofficial Go port of the Spectre (Master Password) algorithm: a stateless password CLI

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages