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

[feat] Implement Hash trait for OutPoint #110

Closed
m-kus opened this issue Aug 27, 2024 · 10 comments · Fixed by #154
Closed

[feat] Implement Hash trait for OutPoint #110

m-kus opened this issue Aug 27, 2024 · 10 comments · Fixed by #154
Assignees
Labels
good first issue Good for newcomers time sensitive Blocks another issue or milestone

Comments

@m-kus
Copy link
Collaborator

m-kus commented Aug 27, 2024

We will need to calculate hashes of outpoints to update Utreexo accumulator and local cache.

Hash trait: https://github.com/starkware-libs/cairo/blob/93221753088d58f54f9a7f35a0bb338cf0bfb952/corelib/src/hash.cairo#L13

Hints:

  • Rename hash::Hash to Digest to avoid confusion
  • Use Serde::serialize to convert Outpoint into array of felts

Suggested deadline: 9 Sep

@m-kus m-kus added the good first issue Good for newcomers label Aug 27, 2024
@m-kus m-kus changed the title [feat] Implement HashTrait for OutPoint [feat] Implement Hash trait for OutPoint Aug 27, 2024
@ScottyDavies
Copy link

ScottyDavies commented Aug 27, 2024

@m-kus can you please assign this issue to me?

@m-kus
Copy link
Collaborator Author

m-kus commented Aug 31, 2024

How is the progress @ScottyDavies ? Do you need help with this task?

@ScottyDavies
Copy link

It’s going fine, I would be done soon

@maciejka maciejka added this to the Milestone 4 milestone Sep 2, 2024
@maciejka
Copy link
Collaborator

maciejka commented Sep 4, 2024

@ScottyDavies how is it going? Do you need any help? Please let us know when do you expect to complete this issue.

@m-kus m-kus added help wanted Extra attention is needed time sensitive Blocks another issue or milestone and removed help wanted Extra attention is needed labels Sep 5, 2024
@dlaciport
Copy link
Contributor

Can I work on this issue? My PR #142 is almost done.

Copy link

onlydustapp bot commented Sep 5, 2024

Hey @bloomingpeach!
Thanks for showing interest.
We've created an application for you to contribute to Raito - Bitcoin ZK Client.
Go check it out on OnlyDust!

Copy link

onlydustapp bot commented Sep 5, 2024

Hey @od-hunter!
Thanks for showing interest.
We've created an application for you to contribute to Raito - Bitcoin ZK Client.
Go check it out on OnlyDust!

@m-kus
Copy link
Collaborator Author

m-kus commented Sep 5, 2024

@bloomingpeach ideally you'd need to wait for #144 to be merged to use it for serialization

@dlaciport
Copy link
Contributor

Hi, @m-kus, could you help me a little bit on this issue? what hash function should I use and should I introduce a new struct for the purpose of implement the HashState trait?

@m-kus
Copy link
Collaborator Author

m-kus commented Sep 6, 2024

@bloomingpeach Hash trait is agnostic to the particular hash function, it just allows to update hash state with a value of a given type. You can use Poseidon in unit tests for example.

You can find more info here: https://book.cairo-lang.org/ch11-04-hash.html#working-with-hashes

Here is an example of how Hash is implemented for a new type: https://github.com/starkware-libs/cairo/blob/004d2b4627b6a06a72f837957f0970cdd49d01d7/corelib/src/hash.cairo#L92

Note that you can also derive hash like #[derive(Hash)] as long as all members also implement it.
Maybe it will be enough to just implement Hash for @ByteArray (see how Serde is implemented for @ByteArray in types::transaction) and derive for the rest of the types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers time sensitive Blocks another issue or milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants