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

Hash to scalar? #674

Closed
4 tasks
matthiasgeihs opened this issue Aug 8, 2023 · 2 comments
Closed
4 tasks

Hash to scalar? #674

matthiasgeihs opened this issue Aug 8, 2023 · 2 comments

Comments

@matthiasgeihs
Copy link

Summary

I would like to hash arbitrary byte strings to group scalars.

let msg = "Hello world!".as_bytes();
let h = ark_bn254::Fr::hash(msg);

Problem Definition

This is relevant for some cryptographic schemes in order to expand the message space to arbitrary byte strings (e.g., Catalano-Fiore vector commitments, page 8, footnote 8).

Proposal

Introduce an API for hashing bytes to scalars / prime field elements as described above.
(If this is already implemented, I would be happy to get a pointer into the right direction.)


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@burdges
Copy link
Contributor

burdges commented Aug 10, 2023

Arkworks always provides try-n-increment, which always works but kinda sucks. You likely want #643 or at least its component 15fc1a5 I need to pull that PR into some smaller parts though.

@Pratyush Pratyush transferred this issue from arkworks-rs/curves Sep 4, 2023
@mmagician
Copy link
Member

The question is actually about hashing into scalars @burdges, for which you don't need try-and-increment, that's for hashing to EC points.

@matthiasgeihs You can use the DefaultFieldHasher, see

pub struct DefaultFieldHasher<H: FixedOutputReset + Default + Clone, const SEC_PARAM: usize = 128> {
, there's also a doctest which serves as a good usage example.

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

No branches or pull requests

3 participants