Skip to content
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

Fix variable size bytes output for operator id fn #125

Closed

Conversation

vanderian
Copy link

Motivation

current impl of GetOperatorID() uses big.Int.Bytes() fn which is not fixed in size
for values such as:

g1.x = 5057380699593752404133723351400442269436321976269356819697538492070112962825
g1.y = 63181752827174633838690742712527804366333094176439493577707800024549061549

g1.x.Bytes() = 0x0b2e6043f9172f0910023e406597d9c42571c7b810c35052c896ddaaee96a909
g1.y.Bytes() = 0x23c27576442b69b7d8497b55ced346743564d58ef3e070578ed99d64c673ad
id = 0x62abc5097efdd84a760cc6b55661f858379fe409aecd9e50e9dc92b22af5c0a0

the g1.y.Bytes() is not [32]byte sized and produces an invalid pubkey hash

Solution

using the FillBytes(new([32]byte)[:]) we use proper fixed sized byte arrays to produce the hash

g1.x.Bytes() = 0x0b2e6043f9172f0910023e406597d9c42571c7b810c35052c896ddaaee96a909
g1.y.Bytes() = 0x0023c27576442b69b7d8497b55ced346743564d58ef3e070578ed99d64c673ad
id = 0x011f431d33c8ac9df5f8b5aab5d52747bcbd268c11bd4403042d216757f8959c

@vanderian vanderian changed the title fix variable size bytes output for operator id fn Fix variable size bytes output for operator id fn Feb 23, 2024
@samlaf
Copy link
Collaborator

samlaf commented Feb 23, 2024

Thanks for this! Just checked and seems like eigenDA fixed this bug in their codebase.
But they used geth's U256Bytes function: https://github.com/Layr-Labs/eigenda/blob/3c66c994e6ffb09afcf957b68fe6e01d34d614bf/core/attestation.go#L103C48-L103C65
Tested and those 2 functions give the same result for your case, but are we confident the simple Bytes conversion always gives the correct result? I feel like I'd rather use geth's U256Bytes to make sure we're exactly equivalent to whatever the evm is doing.

@samlaf
Copy link
Collaborator

samlaf commented Mar 13, 2024

Fixed in #151 , closing here.

@samlaf samlaf closed this Mar 13, 2024
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