{"record":{"id":"6774974dcc9ee909","repo":"canopy-network/canopy","slug":"invalid-bls-key","errorCode":null,"errorMessage":"invalid bls key","messagePattern":"invalid bls key","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/crypto/bls.go","lineNumber":135,"sourceCode":"func (b *BLS12381PrivateKey) MarshalJSON() ([]byte, error) { return json.Marshal(b.String()) }\n\n// UnmarshalJSON() is the json.Unmarshaler implementation for the BLS12381PrivateKey object\nfunc (b *BLS12381PrivateKey) UnmarshalJSON(bz []byte) (err error) {\n\tvar hexString string\n\tif err = json.Unmarshal(bz, &hexString); err != nil {\n\t\treturn\n\t}\n\tbz, err = hex.DecodeString(hexString)\n\tif err != nil {\n\t\treturn\n\t}\n\tpk, err := BytesToBLS12381PrivateKey(bz)\n\tif err != nil {\n\t\treturn err\n\t}\n\tbls, ok := pk.(*BLS12381PrivateKey)\n\tif !ok {\n\t\treturn errors.New(\"invalid bls key\")\n\t}\n\t*b = *bls\n\treturn\n}\n\n// BLS12381PublicKey is a public key wrapper implementation that satisfies the PublicKeyI interface\n// Boneh-Lynn-Shacham (BLS) signature scheme enables compact, aggregable digital signatures for secure, verifiable\n// messages between multiple parties\ntype BLS12381PublicKey struct {\n\tkyber.Point\n\tscheme *bdn.Scheme\n}\n\n// NewBLSPublicKey creates a new BLSPublicKey reference from a kyber point\nfunc NewBLS12381PublicKey(publicKey kyber.Point) *BLS12381PublicKey {\n\treturn &BLS12381PublicKey{Point: publicKey, scheme: newBLSScheme()}\n}\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/canopy-network/canopy/blob/ee8197d91dd410f6592cb650a94c925ee6dc8bad/lib/crypto/bls.go#L117-L153","documentation":"Raised in BLS12381PrivateKey.UnmarshalJSON after the hex string decodes and BytesToBLS12381PrivateKey succeeds, but the returned key fails the type assertion to *BLS12381PrivateKey. It indicates the key factory produced an unexpected key type — effectively a corrupted or non-standard key representation in the JSON field.","triggerScenarios":"Thrown at lib/crypto/bls.go:135 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-export/regenerate the key; the stored JSON value does not represent a valid BLS12-381 private key.","Verify the JSON field is a hex-encoded BLS private key of the expected byte length (32 bytes).","Check BytesToBLS12381PrivateKey wiring if this occurs on freshly generated keys."],"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"}