canopy-network/canopy · error
unrecognized public key format
Error message
unrecognized public key format
What it means
Raised in the batch verifier Add method when a key submitted for batched verification has a byte length matching no supported public key format. The same guard as NewPublicKeyFromBytes but applied at batch-accept time, so a malformed signature tuple is rejected before being queued into a typed batch bucket.
Source
Thrown at lib/crypto/key_batch.go:91
// exit
return nil
}
// initialize the batch tuple object and append to the proper list
t := BatchTuple{PublicKey: pk, Message: message, Signature: signature, index: b.count}
listIdx := b.count % 8
// classify by the decoded key type so serialized multisig keys follow the same path
// as one-by-one verification through NewPublicKeyFromBytes().
switch pk.(type) {
case *ED25519PublicKey:
b.ed25519[listIdx] = append(b.ed25519[listIdx], t)
case *ETHSECP256K1PublicKey:
b.ethSecp256k1[listIdx] = append(b.ethSecp256k1[listIdx], t)
case *SECP256K1PublicKey:
b.secp256k1[listIdx] = append(b.secp256k1[listIdx], t)
case *BLS12381PublicKey, *BLS12381MultiPublicKey:
b.bls12381[listIdx] = append(b.bls12381[listIdx], t)
default:
return fmt.Errorf("unrecognized public key format")
}
// increment the global count
b.count++
// exit
return
}
// Count() returns the number of signatures added to the batch verifier.
func (b *BatchVerifier) Count() int {
if b == nil {
return 0
}
return b.count
}
// Verify() returns the indices of bad signatures (if any)
func (b *BatchVerifier) Verify() (badIndices []int) {
// initialize sync variablesView on GitHub (pinned to ee8197d91d)
Solutions
- Validate the key's byte length/format before adding the tuple to the batch verifier.
- Ensure multisig (serialized multi-BLS) keys go through the same decoding used by NewPublicKeyFromBytes.
- Check callers like CheckSignature for corrupted or truncated key bytes in the signature payload.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at lib/crypto/key_batch.go:91 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/8d0a4735285aa38c.
Report an issue: GitHub.