Skip to content

fix: enforce GT subgroup membership in ArkGT deserialization#22

Merged
markosg04 merged 2 commits into
mainfrom
fix/gt-subgroup-validation
May 8, 2026
Merged

fix: enforce GT subgroup membership in ArkGT deserialization#22
markosg04 merged 2 commits into
mainfrom
fix/gt-subgroup-validation

Conversation

@moodlezoup

@moodlezoup moodlezoup commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes FJ-ACT-H-08: Dory proof GT elements deserialized as raw Fq12 without subgroup validation, allowing a malicious prover to supply arbitrary Fq12 elements outside the GT subgroup.

  • ArkGT now wraps PairingOutput<Bn254> instead of raw Fq12PairingOutput's Valid::check() verifies GT subgroup membership by computing x^r == 1 (where r is the scalar field characteristic), whereas Fq12::check() only validates field encoding
  • Wire format is unchanged — PairingOutput serializes the same bytes as Fq12, with an additional subgroup check on deserialization
  • random() now generates valid GT elements via pairing instead of random Fq12 (which is almost certainly not in GT)
  • Removed clippy::suspicious_arithmetic_impl allows — PairingOutput uses additive notation for GT group ops, so + inside add() is no longer suspicious

Changed files

  • ark_group.rsArkGT wraps PairingOutput<Bn254>; manual Default returning group identity; operators use PairingOutput's group ops
  • ark_pairing.rs — Stop unwrapping PairingOutput at all 5 construction sites (ArkGT(result.0)ArkGT(result))
  • ark_serde.rsDoryDeserialize deserializes as PairingOutput<Bn254> (subgroup check on validation); Valid::check() now delegates to PairingOutput::check()
  • tests/ — Wrap test Fq12::rand(...) in PairingOutput(...) to match new inner type

Test plan

  • cargo build --all-features — clean
  • cargo clippy --features "arkworks,parallel,zk" — clean
  • cargo test --features "arkworks,parallel,zk" — 90/90 pass
  • Pre-existing cache-feature test flake (21 failures) confirmed on original code — unrelated

🤖 Generated with Claude Code

@moodlezoup

Copy link
Copy Markdown
Collaborator Author

@markosg04 is there a reason why ArkGT wraps Fq12 and not the PairingOutput(Fq12)? The Valid impl for PairingOutput does perform the subgroup check

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the arkworks backend’s GT (ArkGT) validation during deserialization by adding an explicit prime-order subgroup membership check, addressing a soundness issue where non-GT Fq12 elements could previously pass validation.

Changes:

  • Enforce GT subgroup membership for ArkGT by checking x^r == 1 (with r = Fr::characteristic()).
  • Route DoryDeserialize::deserialize_with_mode(..., Validate::Yes) for ArkGT through the new subgroup check (fully qualified to avoid the encoding-only ark_serialize::Valid).
  • Add unit tests covering rejection/acceptance and Validate::{Yes,No} behavior for ArkGT deserialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/backends/arkworks/ark_serde.rs Outdated
ArkGT now wraps PairingOutput<Bn254> instead of raw Fq12, ensuring
deserialization validates GT subgroup membership (x^r == 1) rather than
only field encoding. This closes the attack surface where a malicious
prover could supply arbitrary Fq12 elements outside GT.

Addresses: FJ-ACT-H-08

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@moodlezoup moodlezoup force-pushed the fix/gt-subgroup-validation branch from 6b0bf09 to 375fc7c Compare May 8, 2026 17:45

@markosg04 markosg04 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@markosg04 markosg04 merged commit ab25a01 into main May 8, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants