{"record":{"id":"d75a1493c064ef31","repo":"canopy-network/canopy","slug":"unrecognized-private-key-format-d","errorCode":null,"errorMessage":"unrecognized private key format: %d","messagePattern":"unrecognized private key format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/crypto/key.go","lineNumber":151,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn NewPrivateKeyFromBytes(bz)\n}\n\n// NewPrivateKeyFromBytes() creates a new PrivateKeyI interface from bytes\nfunc NewPrivateKeyFromBytes(bz []byte) (PrivateKeyI, error) {\n\tswitch len(bz) {\n\tcase BLS12381PrivKeySize:\n\t\t//pk, err := BytesToSECP256K1Private(bz)\n\t\t//if err == nil {\n\t\t//\treturn pk, nil\n\t\t//}\n\t\treturn BytesToBLS12381PrivateKey(bz)\n\tcase Ed25519PrivKeySize:\n\t\treturn BytesToED25519Private(bz), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unrecognized private key format: %d\", len(bz))\n\t}\n}\n","sourceCodeStart":133,"sourceCodeEnd":154,"githubUrl":"https://github.com/canopy-network/canopy/blob/ee8197d91dd410f6592cb650a94c925ee6dc8bad/lib/crypto/key.go#L133-L154","documentation":"Generic guard raised in NewPrivateKeyFromBytes when the byte slice length matches neither BLS12381PrivKeySize (32) nor Ed25519PrivKeySize (32-byte ed25519 seed path); the offending length is reported in the message. The input bytes are not a supported private key format.","triggerScenarios":"Thrown at lib/crypto/key.go:151 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the source of the bytes (keystore decrypt, hex import, file) yields the correct raw length (32 bytes for BLS/ed25519).","If importing from hex/string, ensure decoding strips prefixes and whitespace before calling this function.","Check for double-encryption or extra wrapping bytes when reading from the keystore in DecryptPrivateKey/ImportRaw paths."],"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-14T05:17:10.506Z"}