Skip to content

Group elements generator #608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jun 11, 2025
Merged

Group elements generator #608

merged 27 commits into from
Jun 11, 2025

Conversation

vlasin
Copy link
Contributor

@vlasin vlasin commented Jun 6, 2025

Adds an executable to symbolic-base that computes a set of group points of the form g^(x^n) for the input x. This is useful for public testing to ensure x is not leaked. For production, we need to either use an already precomputed set of points or do an MPC setup ceremony.

Also, fixes some unsafe operations in PlonkUp and makes corrections to UtxoAccumulator example.

@vlasin vlasin requested review from TurtlePU and vks4git June 10, 2025 10:59
import ZkFold.Algebra.EllipticCurve.Class (CyclicGroup (..))

-- | Supported groups
data Group = BN254_G1 | BN254_G2 | BLS12_381_G1 | BLS12_381_G2
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of storing just a name of a group, you can directly store the required operations, like this:

data Group = forall pt. (CyclicGroup pt, Show pt, ToJSON pt) => Group

supportedGroups :: [(String, Group)]
supportedGroups =
    [ ("bn254-g1", Group @BN254_G1_Point)
    , ("bn254-g2", Group @BN254_G1_Point)
    , ("bls12381-g1", Group @BLS12_381_G1_Point)
    , ("bls12381-g2", Group @BLS12_381_G2_Point)
    ]

But that's just a suggestion, the code looks 🔥 🔥 🔥 as is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, apparently, this approach requires TypeAbstractions to work, which requires GHC 9.14.

When we upgrade to that version, we can use something like this:

case optGroup opts of
    Group @pt -> pointGen @pt

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, that's strange, the extension page says that it's available since 9.8.
And the following basic example runs fine for me on GHC 9.6:

{-# LANGUAGE AllowAmbiguousTypes       #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE ScopedTypeVariables       #-}
{-# LANGUAGE TypeApplications          #-}

data Mon = forall a. (Monoid a, Show a) => Mon

runMon :: Mon -> String
runMon (Mon @a) = show (mempty @a <> mempty)

main :: IO ()
main = putStrLn $ runMon (Mon @[Int])

TurtlePU
TurtlePU previously approved these changes Jun 10, 2025
Copy link
Contributor

@TurtlePU TurtlePU left a comment

Choose a reason for hiding this comment

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

🔥 🔥 🔥

TurtlePU
TurtlePU previously approved these changes Jun 10, 2025
@vlasin vlasin merged commit 6fd1df5 into main Jun 11, 2025
2 checks passed
@vlasin vlasin deleted the vlasin-group-elements-generator branch June 11, 2025 07:21
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.

2 participants