Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用32*256的缓存提升SM2基点倍乘性能 #1558

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
将缓存修改为局部静态变量
  • Loading branch information
zhu.junling committed Sep 11, 2023
commit f6e9df37ba94af11c7602fe040e01942944a99a5
9 changes: 3 additions & 6 deletions src/sm2_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@


#define sm2_print_bn(label,a) sm2_bn_print(stderr,0,0,label,a) // 这个不应该放在这里,应该放在测试文件中

#define USE_SM2_GCACHE
#ifdef USE_SM2_GCACHE
static SM2_JACOBIAN_POINT SM2_JPOINT_GCACHE[32][256];
static int SM2_GCACHE_INITED = 0;
#endif

const SM2_BN SM2_P = {
0xffffffff, 0xffffffff, 0x00000000, 0xffffffff,
Expand Down Expand Up @@ -1076,13 +1071,15 @@ void sm2_init_cache(SM2_JACOBIAN_POINT cache[][256], const SM2_JACOBIAN_POINT *G
sm2_jacobian_point_get_xy(Q, x, y);
sm2_jacobian_point_set_xy(Q, x, y);
}
sm2_jacobian_point_copy(&SM2_JPOINT_GCACHE[i][j], Q);
sm2_jacobian_point_copy(&cache[i][j], Q);
}
}
}

void sm2_jacobian_point_fastmul_generator(SM2_JACOBIAN_POINT *R, const uint8_t k[32])
{
static SM2_JACOBIAN_POINT SM2_JPOINT_GCACHE[32][256];
static int SM2_GCACHE_INITED = 0;
int i;
SM2_JACOBIAN_POINT *P;
SM2_JACOBIAN_POINT _Q, *Q = &_Q;
Expand Down