ipfs/kubo · error
unrecognized key type: %s
Error message
unrecognized key type: %s
What it means
Generate switches on the requested key algorithm (e.g. RSA, Ed25519, ECDSA, secp256k1) to call the matching crypto key generator. An algorithm value outside the recognized set falls into the default branch and returns this error.
Source
Thrown at core/coreapi/key.go:113
pk = pub
case "ed25519":
priv, pub, err := crypto.GenerateEd25519Key(rand.Reader)
if err != nil {
return nil, err
}
sk = priv
pk = pub
case "secp256k1":
priv, pub, err := crypto.GenerateSecp256k1Key(rand.Reader)
if err != nil {
return nil, err
}
sk = priv
pk = pub
default:
return nil, fmt.Errorf("unrecognized key type: %s", options.Algorithm)
}
err = api.repo.Keystore().Put(name, sk)
if err != nil {
return nil, err
}
pid, err := peer.IDFromPublicKey(pk)
if err != nil {
return nil, err
}
return newKey(name, pid)
}
// List returns a list keys stored in keystore.
func (api *KeyAPI) List(ctx context.Context) ([]coreiface.Key, error) {
_, span := tracing.Span(ctx, "CoreAPI.KeyAPI", "List")View on GitHub (pinned to 329838acdf)
Solutions
- Use one of the supported --type values: RSA, Ed25519, ECDSA, secp256k1 (exact casing/values per `ipfs key gen --help`).
- Fix the algorithm string in the script/config that produced the wrong value.
- Check the kubo/crypto implementation in use if you need an algorithm you believe should be supported.
Example fix
// before ipfs key gen mykey --type=ed // after ipfs key gen mykey --type=ed25519
Defensive patterns
Strategy: validation
Validate before calling
var valid = map[string]bool{"RSA": true, "Ed25519": true, "ECDSA": true, "secp256k1": true}
if !valid[options.Algorithm] {
return fmt.Errorf("unsupported key type %q; use RSA, Ed25519, ECDSA, or secp256k1", options.Algorithm)
} Type guard
func knownKeyType(t string) bool {
switch t {
case "RSA", "Ed25519", "ECDSA", "secp256k1":
return true
}
return false
} Try / catch
sk, err := genKey(options.Algorithm, options.Size)
if err != nil {
return fmt.Errorf("key type %q not supported by this build: %w", options.Algorithm, err)
} Prevention
- Only pass algorithms accepted by `ipfs key gen --help`
- Centralize algorithm constants instead of raw strings in scripts
- Check kubo docs for the algorithm set of your kubo version
When it happens
Trigger: KeyAPI.Generate with caopts.KeyGenerateOptions whose Algorithm is misspelled, empty, or unsupported by this crypto build (e.g. `ipfs key gen k --type=rsa4096` or `--type=ed` instead of ed25519).
Common situations: Typo in the --type flag in scripts; keys generated on a binary built without a particular crypto backend; copying flag values from docs of a different tool/version.
Related errors
- cannot create key with name 'self'
- cannot rename key with name 'self'
- cannot overwrite key with name 'self'
- unrecognized key type: %s
- refusing to export key to %s: not a regular file, character
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/daa91fb8c568c45e.
Report an issue: GitHub.