Make get_rand_blob return a full blob (#99)

* Fix a problem in get_rand_blob

* Use bytes field instead of new var
This commit is contained in:
Justin Traglia 2023-01-30 17:36:18 +01:00 committed by GitHub
parent 05bd73bca5
commit 3340843c91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 7 deletions

View File

@ -40,8 +40,6 @@ static void get_rand_field_element(Bytes32 *out) {
fr_t tmp_fr;
Bytes32 tmp_bytes;
memset(out, 0, sizeof(Bytes32));
/*
* Take 32 random bytes, make them an Fr, and then
* turn the Fr back to a bytes array.
@ -52,11 +50,8 @@ static void get_rand_field_element(Bytes32 *out) {
}
void get_rand_blob(Blob *out) {
memset(out, 0, sizeof(Blob));
uint8_t *blob_bytes = (uint8_t *) out;
for (int i = 0; i < 128; i++) {
get_rand_field_element((Bytes32 *)&blob_bytes[i * 32]);
for (int i = 0; i < FIELD_ELEMENTS_PER_BLOB; i++) {
get_rand_field_element((Bytes32 *)&out->bytes[i * 32]);
}
}