Add conversions to/from uint64s to the interface

This commit is contained in:
Ramana Kumar 2022-09-29 19:32:23 +01:00
parent 8a072d68ba
commit 24212039b2
No known key found for this signature in database
GPG Key ID: ED471C788B900433
2 changed files with 17 additions and 0 deletions

View File

@ -753,6 +753,15 @@ static bool pairings_verify(const g1_t *a1, const g2_t *a2, const g1_t *b1, cons
} }
void BLSFieldElement_from_uint64s(BLSFieldElement *out, const uint64_t in[4]) {
blst_fr_from_uint64(out, in);
}
void uint64s_from_BLSFieldElement(uint64_t out[4], const BLSFieldElement *in) {
blst_uint64_from_fr(out, in);
}
C_KZG_RET load_trusted_setup(KZGSettings *out, FILE *in) { C_KZG_RET load_trusted_setup(KZGSettings *out, FILE *in) {
uint64_t n2, i; uint64_t n2, i;

View File

@ -38,6 +38,14 @@ typedef g1_t KZGCommitment;
typedef g1_t KZGProof; typedef g1_t KZGProof;
typedef fr_t BLSFieldElement; typedef fr_t BLSFieldElement;
/**
* BLSFieldElements are communicated directly to/from clients,
* so we need to expose the functions for translating between this
* type and uint256. BLST represents uint256 as uint64[4].
*/
void BLSFieldElement_from_uint64s(BLSFieldElement *out, const uint64_t[4]);
void uint64s_from_BLSFieldElement(uint64_t out[4], const BLSFieldElement*);
/** /**
* The common return type for all routines in which something can go wrong. * The common return type for all routines in which something can go wrong.
* *