-
Notifications
You must be signed in to change notification settings - Fork 67
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
chore: Add HashPointToBytes
method
#428
Conversation
Bytes
method on Points with MapToScalarFieldBytes
Bytes
method on the Point struct with MapToScalarFieldBytes
tree.go
Outdated
// TODO: hash.Bytes() and MapToScalarFieldBytes(n.commitment) should give the same value | ||
// TODO: its not clear why both values were needed before this change | ||
// TODO: hash.Bytes should likely use BytesLE to be consistent with LE format |
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.
nit: remove TODO
ipa.go
Outdated
@@ -60,3 +60,9 @@ func FromBytes(fr *Fr, data []byte) { | |||
copy(aligned[32-len(data):], data) | |||
fr.SetBytes(aligned[:]) | |||
} | |||
|
|||
func MapToScalarFieldBytes(point *Point) [32]byte { |
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.
Whether it should go into go-ipa can be bikeshedded imo -- main goal is to update all libraries to have this breaking change
Signed-off-by: Ignacio Hagopian <[email protected]>
…s using MapToScalarField
35d8e5f
to
58815f7
Compare
Bytes
method on the Point struct with MapToScalarFieldBytes
MapToScalarFieldBytes
method
MapToScalarFieldBytes
methodMapToScalarFieldBytes
method
The |
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. Left my 2c reg the API name.
MapToScalarFieldBytes
methodHashPointToBytes
method
Rationale
We currently have two ways to convert a Point to 32 bytes, using the
.Bytes
method and theMapToScalarField
method. The latter requires you to serialize the scalar field, though you can think of it as 32 bytes.~~For all intents and purposes in the verkle API, it seems we only need one of these. The root node uses the former, but for other internal nodes we use the latter. This PR changes it so that the root node is not treated differently from the other internal nodes and this allows us to remove
.Bytes
from the public API*. ~~It is still used when serializing proofs, but from the point of view of a verkle trie library, a proof is(should be) just an opaque set of bytes.
*This PR alone won't allow us to remove
.Bytes
-- it is used in pedersen_hash/get_tree_key_hash. I'll make a PR to remove it from geth.Linking to crate-crypto/rust-verkle#86
EDIT:
Ignacio pointed out that Serialize/Bytes is needed because we need to deserialize the root node in the header in order to use it in a proof.