mirror of
https://github.com/status-im/c-kzg-4844.git
synced 2025-01-12 03:04:11 +00:00
Add bytes_to_g1 to the interface
This commit is contained in:
parent
b3d550d1a3
commit
f0f72d3fd1
@ -757,6 +757,12 @@ void bytes_from_g1(uint8_t out[48], const g1_t *in) {
|
|||||||
blst_p1_compress(out, in);
|
blst_p1_compress(out, in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bytes_to_g1(g1_t* out, const uint8_t bytes[48]) {
|
||||||
|
blst_p1_affine tmp;
|
||||||
|
blst_p1_uncompress(&tmp, bytes);
|
||||||
|
blst_p1_from_affine(out, &tmp);
|
||||||
|
}
|
||||||
|
|
||||||
void uint64s_from_BLSFieldElement(uint64_t out[4], const BLSFieldElement *in) {
|
void uint64s_from_BLSFieldElement(uint64_t out[4], const BLSFieldElement *in) {
|
||||||
blst_uint64_from_fr(out, in);
|
blst_uint64_from_fr(out, in);
|
||||||
}
|
}
|
||||||
@ -765,7 +771,6 @@ void uint64s_from_BLSFieldElement(uint64_t out[4], const BLSFieldElement *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;
|
||||||
int j; uint8_t c[96];
|
int j; uint8_t c[96];
|
||||||
blst_p1_affine g1_affine;
|
|
||||||
blst_p2_affine g2_affine;
|
blst_p2_affine g2_affine;
|
||||||
g1_t *g1_projective;
|
g1_t *g1_projective;
|
||||||
|
|
||||||
@ -781,8 +786,7 @@ C_KZG_RET load_trusted_setup(KZGSettings *out, FILE *in) {
|
|||||||
for (j = 0; j < 48; j++) {
|
for (j = 0; j < 48; j++) {
|
||||||
fscanf(in, "%2hhx", &c[j]);
|
fscanf(in, "%2hhx", &c[j]);
|
||||||
}
|
}
|
||||||
blst_p1_uncompress(&g1_affine, c);
|
bytes_to_g1(&g1_projective[i], c);
|
||||||
blst_p1_from_affine(&g1_projective[i], &g1_affine);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n2; i++) {
|
for (i = 0; i < n2; i++) {
|
||||||
|
@ -41,11 +41,13 @@ typedef fr_t BLSFieldElement;
|
|||||||
* KZGCommitment and KZGProof can be recovered as 48 bytes
|
* KZGCommitment and KZGProof can be recovered as 48 bytes
|
||||||
*/
|
*/
|
||||||
void bytes_from_g1(uint8_t out[48], const g1_t*);
|
void bytes_from_g1(uint8_t out[48], const g1_t*);
|
||||||
|
void bytes_to_g1(g1_t* out, const uint8_t[48]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BLSFieldElements are communicated directly to/from clients,
|
* BLSFieldElements are communicated directly to/from clients,
|
||||||
* so we need to expose the functions for translating between this
|
* so we need to expose the functions for translating between this
|
||||||
* type and uint256. BLST represents uint256 as uint64[4].
|
* type and uint256. BLST represents uint256 as uint64[4].
|
||||||
|
* TODO: we should perhaps just used bytes[32] for this too.
|
||||||
* For conversion to BLSFieldElement use bytes_to_bls_field.
|
* For conversion to BLSFieldElement use bytes_to_bls_field.
|
||||||
*/
|
*/
|
||||||
void uint64s_from_BLSFieldElement(uint64_t out[4], const BLSFieldElement*);
|
void uint64s_from_BLSFieldElement(uint64_t out[4], const BLSFieldElement*);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user