{"record":{"id":"4d8f81c56d9cb768","repo":"canopy-network/canopy","slug":"invalid-empty-class-group-coefficient","errorCode":null,"errorMessage":"invalid empty class-group coefficient","messagePattern":"invalid empty class-group coefficient","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/crypto/classgroup.go","lineNumber":336,"sourceCode":"\n// Encode() converts the ClassGroup into bytes\nfunc (group *ClassGroup) Encode() (bz []byte) {\n\tr := group.Reduced()\n\tbz, _ = cdc.Marshal(&ProtoClassGroup{\n\t\tA: encodeBigInt(r.a),\n\t\tB: encodeBigInt(r.b),\n\t})\n\treturn\n}\n\n// Encode() converts the bytes into ClassGroup\nfunc (group *ClassGroup) Decode(bz []byte, discriminant *big.Int) (err error) {\n\tclassGroup := new(ProtoClassGroup)\n\tif err = cdc.Unmarshal(bz, classGroup); err != nil {\n\t\treturn err\n\t}\n\tif len(classGroup.A) == 0 || len(classGroup.B) == 0 {\n\t\treturn fmt.Errorf(\"invalid empty class-group coefficient\")\n\t}\n\t// convert the byte slices to big.Int values\n\ta := decodeBigInt(classGroup.A)\n\tb := decodeBigInt(classGroup.B)\n\t*group = *newClassGroup(a, b, discriminant)\n\treturn\n}\n\n// Equal() compares two ClassGroups using their underlying values and returns true if they are equivalent\nfunc (group *ClassGroup) Equal(other *ClassGroup) bool {\n\t// reduce both to their simplest form\n\tg := group.Reduced()\n\to := other.Reduced()\n\t// compare a,b,c\n\treturn g.a.Cmp(o.a) == 0 && g.b.Cmp(o.b) == 0 && g.c.Cmp(o.c) == 0\n}\n\n// Discard() recycles the big ints used for the class group","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/canopy-network/canopy/blob/ee8197d91dd410f6592cb650a94c925ee6dc8bad/lib/crypto/classgroup.go#L318-L354","documentation":"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.","triggerScenarios":"Thrown at lib/crypto/classgroup.go:336 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"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"}