Skip to content

Commit

Permalink
change args of normalizeVec
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Sep 14, 2024
1 parent bd03995 commit 54f09aa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
6 changes: 3 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,10 @@ C++
void mclBnG1_normalize(mclBnG1 *y, const mclBnG1 *x);
void mclBnG2_normalize(mclBnG2 *y, const mclBnG2 *x);
// normalize x[i] for i = 0, 1, ..., n-1
// y[i] = normalize(x[i]) for i = 0, 1, ..., n-1
// faster than normalizing each one individually
void mclBnG1_normalizeVec(mclBnG1 *x, mclSize n);
void mclBnG2_normalizeVec(mclBnG2 *x, mclSize n);
void mclBnG1_normalizeVec(mclBnG1 *y, const mclBnG1 *x, mclSize n);
void mclBnG2_normalizeVec(mclBnG2 *y, const mclBnG2 *x, mclSize n);
```

C++
Expand Down
6 changes: 3 additions & 3 deletions include/mcl/bn.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,9 @@ MCLBN_DLL_API void mclBnG1_mulEach(mclBnG1 *x, const mclBnFr *y, mclSize n);
MCLBN_DLL_API mclSize mclBnFr_invVec(mclBnFr *x, mclSize n);
MCLBN_DLL_API mclSize mclBnFp_invVec(mclBnFp *x, mclSize n);

// x[i] = normalize(x[i]) : [X:Y:Z] -> [x:y:1] or 0 where (x, y) is Affine coordinate
MCLBN_DLL_API void mclBnG1_normalizeVec(mclBnG1 *x, mclSize n);
MCLBN_DLL_API void mclBnG2_normalizeVec(mclBnG2 *x, mclSize n);
// y[i] = normalize(x[i]) : [X:Y:Z] -> [x:y:1] or 0 where (x, y) is Affine coordinate
MCLBN_DLL_API void mclBnG1_normalizeVec(mclBnG1 *y, const mclBnG1 *x, mclSize n);
MCLBN_DLL_API void mclBnG2_normalizeVec(mclBnG2 *y, const mclBnG2 *x, mclSize n);

MCLBN_DLL_API void mclBn_pairing(mclBnGT *z, const mclBnG1 *x, const mclBnG2 *y);
MCLBN_DLL_API void mclBn_finalExp(mclBnGT *y, const mclBnGT *x);
Expand Down
8 changes: 4 additions & 4 deletions include/mcl/impl/bn_c_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,12 +937,12 @@ mclSize mclBnFp_invVec(mclBnFp *x, mclSize n)
return mcl::invVec(cast(x), cast(x), n);
}

void mclBnG1_normalizeVec(mclBnG1 *x, mclSize n)
void mclBnG1_normalizeVec(mclBnG1 *y, const mclBnG1 *x, mclSize n)
{
mcl::ec::normalizeVec(cast(x), cast(x), n);
mcl::ec::normalizeVec(cast(y), cast(x), n);
}

void mclBnG2_normalizeVec(mclBnG2 *x, mclSize n)
void mclBnG2_normalizeVec(mclBnG2 *y, const mclBnG2 *x, mclSize n)
{
mcl::ec::normalizeVec(cast(x), cast(x), n);
mcl::ec::normalizeVec(cast(y), cast(x), n);
}
14 changes: 4 additions & 10 deletions test/bn_c_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,10 @@ void G1test()
mclBnG1_add(&v1[i], &v1[i-1], &y);
}
mclBnG1_clear(&v1[N/2]);
for (size_t i = 0; i < N; i++) {
v2[i] = v1[i];
}
mclBnG1_normalizeVec(v1, N);
mclBnG1_normalizeVec(v2, v1, N);
for (size_t i = 0; i < N; i++) {
CYBOZU_TEST_ASSERT(mclBnG1_isEqual(&v1[i], &v2[i]));
CYBOZU_TEST_ASSERT(mclBnFp_isOne(&v1[i].z) || mclBnFp_isZero(&v1[i].z));
CYBOZU_TEST_ASSERT(mclBnFp_isOne(&v2[i].z) || mclBnFp_isZero(&v2[i].z));
}
}

Expand Down Expand Up @@ -333,13 +330,10 @@ CYBOZU_TEST_AUTO(G2)
mclBnG2_add(&v1[i], &v1[i-1], &y);
}
mclBnG2_clear(&v1[N/2]);
for (size_t i = 0; i < N; i++) {
v2[i] = v1[i];
}
mclBnG2_normalizeVec(v1, N);
mclBnG2_normalizeVec(v2, v1, N);
for (size_t i = 0; i < N; i++) {
CYBOZU_TEST_ASSERT(mclBnG2_isEqual(&v1[i], &v2[i]));
CYBOZU_TEST_ASSERT(mclBnFp2_isOne(&v1[i].z) || mclBnFp2_isZero(&v1[i].z));
CYBOZU_TEST_ASSERT(mclBnFp2_isOne(&v2[i].z) || mclBnFp2_isZero(&v2[i].z));
}
}

Expand Down

0 comments on commit 54f09aa

Please sign in to comment.