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 VerifyMembership proof #11

Merged
merged 6 commits into from
Jan 31, 2024
Merged

Conversation

dongrie
Copy link
Contributor

@dongrie dongrie commented Dec 12, 2023

Signed-off-by: Dongri Jin <dongri.jin@speee.jp>
Signed-off-by: Dongri Jin <dongri.jin@speee.jp>
Signed-off-by: Dongri Jin <dongri.jin@speee.jp>
Signed-off-by: Dongri Jin <dongri.jin@speee.jp>
@dongrie dongrie marked this pull request as ready for review December 14, 2023 06:29
Comment on lines 126 to 127
heightBig.Or(revisionNumberBig, revisionHeightBig)
hashHeight := sha256.Sum256(heightBig.Bytes())
Copy link
Contributor

@siburu siburu Dec 21, 2023

Choose a reason for hiding this comment

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

There are two mistakes.

  • Look at the spec again. height is concatenated to the other stuffs before hashing.
  • The byte length of heightBig.Bytes() can be less than 16.
    • For example, if revisionNumber == 0, it will be 8.
    • You should use FillBytes instead of Bytes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can use encoding/binary to do this easilier.
https://pkg.go.dev/encoding/binary#example-ByteOrder-Put

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks
Change to use encoding/binary
28f2d67

Signed-off-by: Dongri Jin <dongri.jin@speee.jp>
@dongrie dongrie requested a review from siburu January 10, 2024 01:11
Copy link
Contributor

@siburu siburu left a comment

Choose a reason for hiding this comment

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

@dongrie Check the spec of Solidity's ABI encoding.
https://docs.soliditylang.org/en/latest/abi-spec.html

Comment on lines 123 to 124
binary.LittleEndian.PutUint64(heightBuf[:8], revisionHeight)
binary.LittleEndian.PutUint64(heightBuf[8:], revisionNumber)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use BigEndian and put revisionNumber at first and revisionHeight at last.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed
331c660

Signed-off-by: Dongri Jin <dongri.jin@speee.jp>
@dongrie dongrie requested a review from siburu January 31, 2024 01:58
Copy link
Contributor

@siburu siburu left a comment

Choose a reason for hiding this comment

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

@dongrie LGTM

@siburu siburu merged commit b37f2fc into datachainlab:main Jan 31, 2024
1 check passed
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.

None yet

2 participants