mirror of
https://github.com/luxfi/crypto.git
synced 2026-07-27 01:54:50 +00:00
The //go:build !cgo (CIRCL) SignatureFromBytes stored any length-96 non-zero blob as a Signature with NO point validation, diverging from the CGO/blst path (Uncompress + SigValidate(false)) and admitting garbage signatures into the verifier. Parse the input through bls12381.G2.SetBytes, which decodes the compressed point and calls IsOnG2() = isValidProjective && isOnCurve && isRTorsion (the prime-order r-torsion SUBGROUP check) before returning — the exact analogue of blst SigValidate(false). PublicKeyFromCompressedBytes already calls pk.Validate(); this restores symmetry on the signature side. Adds a !cgo-tagged regression test proving the behavioral change: a non-G2 garbage blob the old byte-loop accepted is now rejected; real signatures still round-trip; all-zero and wrong-length stay rejected. CIRCL exposes no public API to mint an on-curve-non-subgroup point, so the subgroup leg is enforced by SetBytes (verified at ecc/bls12381/g2.go:86) and source review.