canopy-network/canopy · error
unrecognized private key format: %d
Error message
unrecognized private key format: %d
What it means
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.
Source
Thrown at lib/crypto/key.go:151
if err != nil {
return nil, err
}
return NewPrivateKeyFromBytes(bz)
}
// NewPrivateKeyFromBytes() creates a new PrivateKeyI interface from bytes
func NewPrivateKeyFromBytes(bz []byte) (PrivateKeyI, error) {
switch len(bz) {
case BLS12381PrivKeySize:
//pk, err := BytesToSECP256K1Private(bz)
//if err == nil {
// return pk, nil
//}
return BytesToBLS12381PrivateKey(bz)
case Ed25519PrivKeySize:
return BytesToED25519Private(bz), nil
default:
return nil, fmt.Errorf("unrecognized private key format: %d", len(bz))
}
}
View on GitHub (pinned to ee8197d91d)
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.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at lib/crypto/key.go:151 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of canopy-network/canopy@ee8197d91d (2026-09-06).
Data as JSON: /api/errors/d75a1493c064ef31.
Report an issue: GitHub.