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: improve poseidon API #109

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

varun-doshi
Copy link

Pull Request type

What is the current behavior?

StarkHash trait does have hash_single funciton

Resolves: #107

What is the new behavior?

  • StarkHash now implements hash_single function

Does this introduce a breaking change?

No

Other information

This results in Pedersen needing to implement hash_single as well. Currently, it is set as todo!

@tdelabro
Copy link
Collaborator

tdelabro commented Jan 7, 2025

@varun-doshi need any help?

@varun-doshi
Copy link
Author

@varun-doshi need any help?

I'm not sure how to go about hash_single for Pedersen...since it's now in the trait for both Poseidon and Pedersen hence it needs to be implemented as well.

I can open this PR for review if that'll help?

@varun-doshi varun-doshi marked this pull request as ready for review January 9, 2025 06:30
@tdelabro
Copy link
Collaborator

@varun-doshi I think the pedersen hash_single impl should be pedersen(0, value)

@tdelabro
Copy link
Collaborator

@varun-doshi let's go with pedersen(value, 0) (based on @liorgold2 feedbacks) and make it very explicit in the documentation that there is room for collision as:
pedersen(value) and pedersen(value, 0) will return the same values
and
pedersen_array([value]) and pedersen(pedersen(0, value), 1) will too

Add the first example to the hash_single doc and the second one to the hash_array doc

crates/starknet-types-core/src/hash/pedersen.rs Outdated Show resolved Hide resolved
crates/starknet-types-core/src/hash/pedersen.rs Outdated Show resolved Hide resolved
@varun-doshi varun-doshi requested a review from jbcaron January 24, 2025 18:05
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.

dev: improve poseidon API
3 participants