Hash to curve
Map bytes to elliptic-curve points with RFC 9380.
from oxcrypto.hazmat.curve.hash_to_curve import HASH_TO_CURVE
suite = HASH_TO_CURVE.P256_XMD_SHA256_SSWU
point = suite.hash(b"input", dst=b"MYAPP-V01-CS01-with-P256_XMD:SHA-256_SSWU_RO_")hash(msg, *, dst, compressed=False) is RFC 9380 hash_to_curve (the _RO_
suites) and encode(msg, *, dst, compressed=False) is encode_to_curve (the
_NU_ suites). Both return a SEC1 point. dst is the domain separation tag;
an empty tag raises ValueError, and tags longer than 255 bytes are hashed as
RFC 9380 section 5.3.3 specifies.
| Selector | Suites |
|---|---|
P256_XMD_SHA256_SSWU | P256_XMD:SHA-256_SSWU_RO_, _NU_ |
P384_XMD_SHA384_SSWU | P384_XMD:SHA-384_SSWU_RO_, _NU_ |
P521_XMD_SHA512_SSWU | P521_XMD:SHA-512_SSWU_RO_, _NU_ |
SECP256K1_XMD_SHA256_SSWU | secp256k1_XMD:SHA-256_SSWU_RO_, _NU_ |
Hash-to-curve is a building block for protocols such as OPRFs and BLS-style signatures. Choosing a tag and using the point correctly needs protocol expertise.
- Standard: RFC 9380 (Informational, IRTF CFRG).
- Crates:
hash2curve0.14.0 withp256,p384,p521andk2560.14.0 (group-digestfeature), stable, no published audit (k256has the NCC Group review noted on the ECDSA page). Builds with Rust 1.88. - The inputs are public, so no zeroization applies.
- Tests use the RFC 9380 appendix J vectors from cfrg/draft-irtf-cfrg-hash-to-curve.