diff --git a/src/bls12_381.c b/src/bls12_381.c index 6592284..250679f 100644 --- a/src/bls12_381.c +++ b/src/bls12_381.c @@ -121,6 +121,16 @@ void fr_from_uint64(fr_t *out, uint64_t n) { fr_from_uint64s(out, vals); } +/** + * Convert the field element to an array of four 64-bit unsigned integers. + * + * @param out array for returned values, little-endian ordering of the 64-bit words + * @param vals The field element equivalent of @p n + */ +void fr_to_uint64s(uint64_t out[4], const fr_t* fr) { + blst_uint64_from_fr(out, fr); +} + /** * Test whether two field elements are equal. * diff --git a/src/bls12_381.h b/src/bls12_381.h index add1c94..9649c97 100644 --- a/src/bls12_381.h +++ b/src/bls12_381.h @@ -104,6 +104,7 @@ bool fr_is_null(const fr_t *p); void fr_from_scalar(fr_t *out, const scalar_t *a); void fr_from_uint64s(fr_t *out, const uint64_t *vals); void fr_from_uint64(fr_t *out, uint64_t n); +void fr_to_uint64s(uint64_t out[4], const fr_t* fr); bool fr_equal(const fr_t *aa, const fr_t *bb); void fr_negate(fr_t *out, const fr_t *in); void fr_add(fr_t *out, const fr_t *a, const fr_t *b);