-
Notifications
You must be signed in to change notification settings - Fork 186
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
[1/N] Chunk encoding optimization: Support encoding format with gnark #617
Conversation
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.
lgtm
encoding/serialization.go
Outdated
@@ -22,6 +23,41 @@ func (c *Frame) Deserialize(data []byte) (*Frame, error) { | |||
return c, err | |||
} | |||
|
|||
func (c *Frame) SerializeGnark() ([]byte, error) { | |||
coded := make([]byte, 0, 32*(1+len(c.Coeffs))) |
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.
can replace 32 with constants.go inside encoding/*
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.
for point size you can use SizeOfG1AffineUncompressed, see https://pkg.go.dev/github.com/consensys/gnark-crypto/ecc/bn254#G1Affine
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.
Done
@@ -22,6 +23,41 @@ func (c *Frame) Deserialize(data []byte) (*Frame, error) { | |||
return c, err | |||
} | |||
|
|||
func (c *Frame) SerializeGnark() ([]byte, error) { | |||
coded := make([]byte, 0, bn254.SizeOfG1AffineCompressed+BYTES_PER_SYMBOL*len(c.Coeffs)) |
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.
Do you want to consider to use SizeOfG1AffineUncompressed? Marshal uses uncompressed format. https://github.com/consensys/gnark-crypto/blob/v0.6.1/ecc/bn254/marshal.go#L607
In current EigenDA, we use uncompressed format with 64 bytes
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.
We could settle on a 32 bytes point for this new encoding format
Why are these changes needed?
There are inefficiency in chunk encoding, which causes more than data to transmit over network and store to db than necessary.
This PR adds the encoding with gnark. The followup PR will integrate it (compatibly).
Checks