Skip to content

Conversation

@mikelodder7
Copy link
Contributor

Adds hash to curve according to draft v13.

For now is enabled with the hashing feature.


# optional dependencies
ecdsa-core = { version = "0.13", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
hash2field = { version = "0.4", optional = true }
Copy link
Member

Choose a reason for hiding this comment

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

@tarcieri Maybe it's worth to incorporate this crate into elliptic-curve?

Copy link
Member

Choose a reason for hiding this comment

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

@mikelodder7 would you be interested in upstreaming hash2field somewhere, either elliptic-curve or possibly ff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing. Elliptic-curve probably makes more sense but I can be convinced otherwise

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good!

If you're up for it, I think it might also be possible to extract a generic implementation of SSWU, although I'm fine with duplication for now and I can try to extract it as part of a follow-up:

#439 (comment)

You can use e.g. ff::{Field, PrimeField} as the bounds, and I can look into ensuring they're impl'd for the respective FieldElement types in k256 and p256.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah if ff::Field is impl'd then the dedup is easy from there. osswu will just have to take a set of params but otherwise, they'll be the same. Should osswu go upstream as well in elliptic-curve?

Copy link
Member

Choose a reason for hiding this comment

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

I think it'd be great if you can add a generic implementation, and in parallel I can work on trying to get the ff traits impl'd for the FieldElement types for k256 and p256.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool. I'd extract the osswu method and hash2field crate to elliptic-curve.

Copy link
Member

Choose a reason for hiding this comment

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

Awesome!

@mikelodder7
Copy link
Contributor Author

OSSWU upstreamed in PR 854

Signed-off-by: Michael Lodder <redmike7@gmail.com>
@daxpedda
Copy link
Contributor

daxpedda commented Jan 4, 2022

I tested this as part of opaque-ke and it works great so far, following requests:

  • It would be amazing if the new hash_from_bytes and encode_from_bytes can be part of a trait specified in elliptic-curve.
  • Currently everything is already in place to support hash_to_field(), which is the new FieldElement::encode() function. It would be great if this too can be exposed for Scalar, preferably through a trait specified in elliptic-curve too.

@tarcieri
Copy link
Member

It seems like with #503 merged this can be closed?

@tarcieri tarcieri closed this Jan 15, 2022
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.

4 participants