Remove vector_lincomb_indirect
This commit is contained in:
parent
0797b932c5
commit
620086ca4d
|
@ -232,7 +232,7 @@ static PyObject* vector_lincomb_wrap(PyObject *self, PyObject *args) {
|
||||||
|
|
||||||
Py_ssize_t i, j, m = PySequence_Length(PySequence_GetItem(vs, 0));
|
Py_ssize_t i, j, m = PySequence_Length(PySequence_GetItem(vs, 0));
|
||||||
|
|
||||||
const BLSFieldElement* *vectors = (const BLSFieldElement**)calloc(n * m, sizeof(BLSFieldElement*));
|
BLSFieldElement *vectors = (BLSFieldElement*)calloc(n * m, sizeof(BLSFieldElement));
|
||||||
|
|
||||||
if (vectors == NULL) return PyErr_NoMemory();
|
if (vectors == NULL) return PyErr_NoMemory();
|
||||||
|
|
||||||
|
@ -254,11 +254,11 @@ static PyObject* vector_lincomb_wrap(PyObject *self, PyObject *args) {
|
||||||
free(vectors);
|
free(vectors);
|
||||||
return PyErr_Format(PyExc_ValueError, "expected vectors of BLSFieldElement capsules");
|
return PyErr_Format(PyExc_ValueError, "expected vectors of BLSFieldElement capsules");
|
||||||
}
|
}
|
||||||
vectors[i * m + j] = (BLSFieldElement*)PyCapsule_GetPointer(out, "BLSFieldElement");
|
memcpy(&vectors[i * m + j], PyCapsule_GetPointer(out, "BLSFieldElement"), sizeof(BLSFieldElement));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const BLSFieldElement* *scalars = (const BLSFieldElement**)calloc(n, sizeof(BLSFieldElement*));
|
BLSFieldElement *scalars = (BLSFieldElement*)calloc(n, sizeof(BLSFieldElement));
|
||||||
|
|
||||||
if (scalars == NULL) {
|
if (scalars == NULL) {
|
||||||
free(vectors);
|
free(vectors);
|
||||||
|
@ -272,7 +272,7 @@ static PyObject* vector_lincomb_wrap(PyObject *self, PyObject *args) {
|
||||||
free(vectors);
|
free(vectors);
|
||||||
return PyErr_Format(PyExc_ValueError, "expected a BLSFieldElement capsule");
|
return PyErr_Format(PyExc_ValueError, "expected a BLSFieldElement capsule");
|
||||||
}
|
}
|
||||||
scalars[i] = (BLSFieldElement*)PyCapsule_GetPointer(tmp, "BLSFieldElement");
|
memcpy(&scalars[i], PyCapsule_GetPointer(tmp, "BLSFieldElement"), sizeof(BLSFieldElement));
|
||||||
}
|
}
|
||||||
|
|
||||||
BLSFieldElement *r = (BLSFieldElement*)calloc(m, sizeof(BLSFieldElement));
|
BLSFieldElement *r = (BLSFieldElement*)calloc(m, sizeof(BLSFieldElement));
|
||||||
|
@ -283,7 +283,7 @@ static PyObject* vector_lincomb_wrap(PyObject *self, PyObject *args) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
vector_lincomb_indirect(r, vectors, scalars, n, m);
|
vector_lincomb(r, vectors, scalars, n, m);
|
||||||
|
|
||||||
free(scalars);
|
free(scalars);
|
||||||
free(vectors);
|
free(vectors);
|
||||||
|
|
|
@ -835,22 +835,6 @@ void bytes_to_bls_field(BLSFieldElement *out, const uint8_t bytes[32]) {
|
||||||
blst_fr_from_scalar(out, &tmp);
|
blst_fr_from_scalar(out, &tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute linear combinations of a sequence of vectors with some scalars
|
|
||||||
*/
|
|
||||||
void vector_lincomb_indirect(fr_t out[], const fr_t* vectors[], const fr_t* scalars[], uint64_t n, uint64_t m) {
|
|
||||||
fr_t tmp;
|
|
||||||
uint64_t i, j;
|
|
||||||
for (j = 0; j < m; j++)
|
|
||||||
out[j] = fr_zero;
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
for (j = 0; j < m; j++) {
|
|
||||||
fr_mul(&tmp, scalars[i], vectors[i * m + j]);
|
|
||||||
fr_add(&out[j], &out[j], &tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute linear combinations of a sequence of vectors with some scalars
|
* Compute linear combinations of a sequence of vectors with some scalars
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -109,9 +109,6 @@ void free_trusted_setup(KZGSettings *s);
|
||||||
|
|
||||||
void bytes_to_bls_field(BLSFieldElement *out, const uint8_t bytes[32]);
|
void bytes_to_bls_field(BLSFieldElement *out, const uint8_t bytes[32]);
|
||||||
|
|
||||||
// TODO: probably remove this version
|
|
||||||
void vector_lincomb_indirect(BLSFieldElement out[], const BLSFieldElement* vectors[], const BLSFieldElement* scalars[], uint64_t num_vectors, uint64_t vector_len);
|
|
||||||
|
|
||||||
void vector_lincomb(BLSFieldElement out[], const BLSFieldElement vectors[], const BLSFieldElement scalars[], uint64_t num_vectors, uint64_t vector_len);
|
void vector_lincomb(BLSFieldElement out[], const BLSFieldElement vectors[], const BLSFieldElement scalars[], uint64_t num_vectors, uint64_t vector_len);
|
||||||
|
|
||||||
void g1_lincomb(KZGCommitment *out, const KZGCommitment points[], const BLSFieldElement scalars[], uint64_t num_points);
|
void g1_lincomb(KZGCommitment *out, const KZGCommitment points[], const BLSFieldElement scalars[], uint64_t num_points);
|
||||||
|
|
Loading…
Reference in New Issue