canopy-network/canopy · error
invalid empty class-group coefficient
Error message
invalid empty class-group coefficient
What it means
Raised in ClassGroup.Decode when the decoded ProtoClassGroup has an empty A or B coefficient byte slice. A class group form requires both coefficients to be present; empty coefficients indicate a corrupted or truncated VDF class-group encoding that cannot reconstruct a valid group.
Source
Thrown at lib/crypto/classgroup.go:336
// Encode() converts the ClassGroup into bytes
func (group *ClassGroup) Encode() (bz []byte) {
r := group.Reduced()
bz, _ = cdc.Marshal(&ProtoClassGroup{
A: encodeBigInt(r.a),
B: encodeBigInt(r.b),
})
return
}
// Encode() converts the bytes into ClassGroup
func (group *ClassGroup) Decode(bz []byte, discriminant *big.Int) (err error) {
classGroup := new(ProtoClassGroup)
if err = cdc.Unmarshal(bz, classGroup); err != nil {
return err
}
if len(classGroup.A) == 0 || len(classGroup.B) == 0 {
return fmt.Errorf("invalid empty class-group coefficient")
}
// convert the byte slices to big.Int values
a := decodeBigInt(classGroup.A)
b := decodeBigInt(classGroup.B)
*group = *newClassGroup(a, b, discriminant)
return
}
// Equal() compares two ClassGroups using their underlying values and returns true if they are equivalent
func (group *ClassGroup) Equal(other *ClassGroup) bool {
// reduce both to their simplest form
g := group.Reduced()
o := other.Reduced()
// compare a,b,c
return g.a.Cmp(o.a) == 0 && g.b.Cmp(o.b) == 0 && g.c.Cmp(o.c) == 0
}
// Discard() recycles the big ints used for the class groupView on GitHub (pinned to ee8197d91d)
Solutions
- Re-encode the ClassGroup via Encode() at the source; the producing side serialized zeroed coefficients.
- Validate discriminant/parameters used in the VDF proof before decode so the right group is reconstructed.
- Check for data truncation in storage/transport that zeroed the coefficient bytes.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at lib/crypto/classgroup.go:336 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/4d8f81c56d9cb768.
Report an issue: GitHub.