hash-to-curve readme

This commit is contained in:
Paul Miller 2023-02-14 23:03:18 +00:00
parent cde1d5c488
commit d5fe537159
No known key found for this signature in database
GPG Key ID: 697079DA6878B89B

@ -467,6 +467,17 @@ const x25519 = montgomery({
The module allows to hash arbitrary strings to elliptic curve points. Implements [hash-to-curve v11](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11). The module allows to hash arbitrary strings to elliptic curve points. Implements [hash-to-curve v11](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11).
Every curve has exported `hashToCurve` and `encodeToCurve` methods:
```ts
import { hashToCurve, encodeToCurve } from '@noble/curves/secp256k1';
import { randomBytes } from '@noble/hashes/utils';
console.log(hashToCurve(randomBytes())); // second argument of type htfOpts (see below) is optional
console.log(encodeToCurve(randomBytes()));
```
If you need low-level methods from spec:
`expand_message_xmd` [(spec)](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.4.1) produces a uniformly random byte string using a cryptographic hash function H that outputs b bits. `expand_message_xmd` [(spec)](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-11#section-5.4.1) produces a uniformly random byte string using a cryptographic hash function H that outputs b bits.
```ts ```ts