{"record":{"id":"c5ce591824e35006","repo":"ipfs/kubo","slug":"q-is-not-a-known-key-an-ipns-name-or-a-valid","errorCode":null,"errorMessage":"'%q' is not a known key, an IPNS Name, or a valid PeerID","messagePattern":"'%q' is not a known key, an IPNS Name, or a valid PeerID","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/coreapi/key.go","lineNumber":338,"sourceCode":"\t\tname string\n\t\tpk   crypto.PubKey\n\t\terr  error\n\t)\n\tif keyOrName == \"\" || keyOrName == \"self\" {\n\t\tname = \"self\"\n\t\tpk = api.privateKey.GetPublic()\n\t} else if sk, err := api.repo.Keystore().Get(keyOrName); err == nil {\n\t\tname = keyOrName\n\t\tpk = sk.GetPublic()\n\t} else if ipnsName, err := ipns.NameFromString(keyOrName); err == nil {\n\t\t// This works for both IPNS names and Peer IDs.\n\t\tname = \"\"\n\t\tpk, err = ipnsName.Peer().ExtractPublicKey()\n\t\tif err != nil {\n\t\t\treturn nil, false, err\n\t\t}\n\t} else {\n\t\treturn nil, false, fmt.Errorf(\"'%q' is not a known key, an IPNS Name, or a valid PeerID\", keyOrName)\n\t}\n\n\tpid, err := peer.IDFromPublicKey(pk)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\n\tkey, err := newKey(name, pid)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\n\tdata = append([]byte(signedMessagePrefix), data...)\n\n\tvalid, err := pk.Verify(data, signature)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/coreapi/key.go#L320-L356","documentation":"KeyAPI.Verify accepts either a key name, an IPNS name, or a PeerID. When the provided string is none of these, the lookup path falls through to this error. The keystore was checked, the IPNS-name parse/ExtractPublicKey path was exhausted, and the string did not resolve to any usable public key.","triggerScenarios":"Calling KeyAPI.Verify(ctx, keyOrName, msg, sig) with an arbitrary string that is not a keystore key name, not parseable as an IPNS name, and not a valid PeerID.","commonSituations":"Passing a full /ipns/ or /p2p/ multiaddr-style string instead of the bare ID; passing a CID that is not a peer ID; passing a key name from a different node's keystore.","solutions":["Pass a key name that exists in the local keystore (`ipfs key list`).","Pass a valid PeerID (multibase/multihash identity of a public key) or a valid IPNS name.","Strip prefixes like /ipns/ or /p2p/ before passing the identifier.","If verifying with a raw public key not in the keystore, embed it in a PeerID that carries the pubkey (identity multihash) or import the key first."],"exampleFix":"// before\npk, err := api.Key().Verify(ctx, \"/ipns/k51qzi5uqu5d...\", msg, sig)\n// after\npk, err := api.Key().Verify(ctx, \"k51qzi5uqu5d...\", msg, sig)","handlingStrategy":"validation","validationCode":"func isVerifiableID(s string) bool {\n    if _, err := peer.Decode(s); err == nil {\n        return true\n    }\n    if strings.HasPrefix(s, \"/ipns/\") {\n        return true\n    }\n    return false // otherwise require it to be a keystore key name\n}","typeGuard":"func isPeerIDString(s string) bool {\n    _, err := peer.Decode(s)\n    return err == nil\n}","tryCatchPattern":"pk, err := api.Key().Verify(ctx, keyOrName, msg, sig)\nif err != nil && strings.Contains(err.Error(), \"is not a known key\") {\n    return fmt.Errorf(\"invalid verification identity %q: use a keystore key name, IPNS name, or PeerID\", keyOrName)\n}","preventionTips":["Strip /ipns/ and /p2p/ prefixes before passing identifiers.","Validate PeerIDs with peer.Decode first.","Only pass key names that appear in KeyAPI.List output."],"tags":["verification","ipns","key-lookup"],"backgroundTag":"unknown-key-identifier","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}