-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
…zkFold/symbolic into vlasin-group-elements-generator
…zkFold/symbolic into vlasin-group-elements-generator
import ZkFold.Algebra.EllipticCurve.Class (CyclicGroup (..)) | ||
|
||
-- | Supported groups | ||
data Group = BN254_G1 | BN254_G2 | BLS12_381_G1 | BLS12_381_G2 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 🔥 🔥
Adds an executable to
symbolic-base
that computes a set of group points of the formg^(x^n)
for the inputx
. This is useful for public testing to ensurex
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.