{"record":{"id":"b9869b2493453b58","repo":"canopy-network/canopy","slug":"unrecognized-public-key-format","errorCode":null,"errorMessage":"unrecognized public key format","messagePattern":"unrecognized public key format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/crypto/key.go","lineNumber":116,"sourceCode":"\t}\n\treturn NewPublicKeyFromBytes(bz)\n}\n\n// NewPublicKeyFromBytes() creates a new PublicKeyI interface from a byte slice\nfunc NewPublicKeyFromBytes(bz []byte) (PublicKeyI, error) {\n\tswitch len(bz) {\n\tcase Ed25519PubKeySize:\n\t\treturn BytesToED25519Public(bz), nil\n\tcase ETHSECP256K1PubKeySize, ETHSECP256K1PubKeySize + 1:\n\t\treturn BytesToEthSECP256K1Public(bz)\n\tcase SECP256K1PubKeySize:\n\t\treturn BytesToSECP256K1Public(bz)\n\tcase BLS12381PubKeySize:\n\t\treturn BytesToBLS12381Public(bz)\n\t}\n\tmultiKey, err := NewMultiBLSFromPublicKey(bz)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unrecognized public key format\")\n\t}\n\treturn multiKey, nil\n}\n\n// PrivateKeyToFile() writes a private key to a file located at filepath\nfunc PrivateKeyToFile(key PrivateKeyI, filepath string) error {\n\tbz, err := json.MarshalIndent(key, \"\", \"  \")\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn os.WriteFile(filepath, bz, 0600)\n}\n\n// NewPrivateKeyFromString() creates a new PrivateKeyI interface from a hex string\nfunc NewPrivateKeyFromString(s string) (PrivateKeyI, error) {\n\tbz, err := hex.DecodeString(s)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/canopy-network/canopy/blob/ee8197d91dd410f6592cb650a94c925ee6dc8bad/lib/crypto/key.go#L98-L134","documentation":"Generic guard raised in NewPublicKeyFromBytes when the byte slice length matches none of the supported key sizes (Ed25519, ETH/secp256k1, secp256k1, BLS12-381) AND NewMultiBLSFromPublicKey also fails to parse it as a multisig key. The byte slice is not recognizable as any supported public key format.","triggerScenarios":"Thrown at lib/crypto/key.go:116 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the byte length of the input; it must match one of the supported key sizes (e.g. 32 for ed25519, 33/65 for secp256k1).","If the key is a multisig BLS key, verify it is serialized in the format NewMultiBLSFromPublicKey expects.","Trace where the bytes were produced/stored — truncation or wrong encoding (hex vs raw) is the usual cause."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ee8197d91dd410f6592cb650a94c925ee6dc8bad","analyzedAt":"2026-09-06T09:30:15.973Z","contentChangedAt":"2026-09-06T09:30:15.973Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}