-
Notifications
You must be signed in to change notification settings - Fork 174
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a073210
[1/N] Chunk encoding optimization: Support encoding format with gnark
jianoaix 0b04de2
more coeffs
jianoaix a78bed7
memory
jianoaix 5191a21
constant
jianoaix 4c36e04
Merge branch 'master' of https://github.com/Layr-Labs/eigenda into ch…
jianoaix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package encoding_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/Layr-Labs/eigenda/encoding" | ||
"github.com/consensys/gnark-crypto/ecc/bn254/fp" | ||
"github.com/consensys/gnark-crypto/ecc/bn254/fr" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSerDeserGnark(t *testing.T) { | ||
var XCoord, YCoord fp.Element | ||
_, err := XCoord.SetString("21661178944771197726808973281966770251114553549453983978976194544185382599016") | ||
assert.NoError(t, err) | ||
_, err = YCoord.SetString("9207254729396071334325696286939045899948985698134704137261649190717970615186") | ||
assert.NoError(t, err) | ||
|
||
numCoeffs := 64 | ||
var f encoding.Frame | ||
f.Proof = encoding.Proof{ | ||
X: XCoord, | ||
Y: YCoord, | ||
} | ||
for i := 0; i < numCoeffs; i++ { | ||
f.Coeffs = append(f.Coeffs, fr.NewElement(uint64(i))) | ||
} | ||
|
||
gnark, err := f.SerializeGnark() | ||
assert.Nil(t, err) | ||
// The gnark encoding via f.Serialize() will generate less bytes | ||
// than gob. | ||
assert.Equal(t, 32*(1+numCoeffs), len(gnark)) | ||
gob, err := f.Serialize() | ||
assert.Nil(t, err) | ||
// 2080 with gnark v.s. 2574 with gob | ||
assert.Equal(t, 2574, len(gob)) | ||
|
||
// Verify the deserialization can get back original data | ||
c, err := new(encoding.Frame).DeserializeGnark(gnark) | ||
assert.Nil(t, err) | ||
assert.True(t, f.Proof.Equal(&c.Proof)) | ||
assert.Equal(t, len(f.Coeffs), len(c.Coeffs)) | ||
for i := 0; i < len(f.Coeffs); i++ { | ||
assert.True(t, f.Coeffs[i].Equal(&c.Coeffs[i])) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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