small changes as well as 32 and 64 bit dlls
This commit is contained in:
parent
0f0045bdaf
commit
52a916313a
Binary file not shown.
BIN
ed25519_64.dll
Normal file
BIN
ed25519_64.dll
Normal file
Binary file not shown.
@ -10,7 +10,7 @@ void ed25519_add_scalar(unsigned char *public_key, unsigned char *private_key, c
|
|||||||
unsigned char n[32];
|
unsigned char n[32];
|
||||||
ge_p3 nB;
|
ge_p3 nB;
|
||||||
ge_p1p1 A_p1p1;
|
ge_p1p1 A_p1p1;
|
||||||
ge_p2 A;
|
ge_p3 A;
|
||||||
ge_p3 public_key_unpacked;
|
ge_p3 public_key_unpacked;
|
||||||
ge_cached T;
|
ge_cached T;
|
||||||
|
|
||||||
@ -27,21 +27,30 @@ void ed25519_add_scalar(unsigned char *public_key, unsigned char *private_key, c
|
|||||||
sc_muladd(private_key, SC_1, n, private_key);
|
sc_muladd(private_key, SC_1, n, private_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* public key: A = nB + T */
|
||||||
if (public_key) {
|
if (public_key) {
|
||||||
/* unpack public key into T */
|
/* if we know the private key we don't need a point addition, which is faster */
|
||||||
ge_frombytes_negate_vartime(&public_key_unpacked, public_key);
|
/* using a "timing attack" you could find out wether or not we know the private
|
||||||
fe_neg(public_key_unpacked.X, public_key_unpacked.X); // undo negate
|
key, but this information seems rather useless - if this is important pass
|
||||||
fe_neg(public_key_unpacked.T, public_key_unpacked.T); // undo negate
|
public_key and private_key seperately in 2 function calls */
|
||||||
ge_p3_to_cached(&T, &public_key_unpacked);
|
if (private_key) {
|
||||||
|
ge_scalarmult_base(&A, private_key);
|
||||||
|
} else {
|
||||||
|
/* unpack public key into T */
|
||||||
|
ge_frombytes_negate_vartime(&public_key_unpacked, public_key);
|
||||||
|
fe_neg(public_key_unpacked.X, public_key_unpacked.X); // undo negate
|
||||||
|
fe_neg(public_key_unpacked.T, public_key_unpacked.T); // undo negate
|
||||||
|
ge_p3_to_cached(&T, &public_key_unpacked);
|
||||||
|
|
||||||
/* calculate n*B */
|
/* calculate n*B */
|
||||||
ge_scalarmult_base(&nB, n);
|
ge_scalarmult_base(&nB, n);
|
||||||
|
|
||||||
/* A = n*B + T */
|
/* A = n*B + T */
|
||||||
ge_add(&A_p1p1, &nB, &T);
|
ge_add(&A_p1p1, &nB, &T);
|
||||||
ge_p1p1_to_p2(&A, &A_p1p1);
|
ge_p1p1_to_p3(&A, &A_p1p1);
|
||||||
|
}
|
||||||
/* pack public key */
|
|
||||||
ge_tobytes(public_key, &A);
|
/* pack public key */
|
||||||
|
ge_p3_tobytes(public_key, &A);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
24
test.c
24
test.c
@ -80,15 +80,24 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* test performance */
|
/* test performance */
|
||||||
|
printf("testing seed generation performance: ");
|
||||||
|
start = clock();
|
||||||
|
for (i = 0; i < 10000; ++i) {
|
||||||
|
ed25519_create_seed(seed);
|
||||||
|
}
|
||||||
|
end = clock();
|
||||||
|
|
||||||
|
printf("%fus per seed\n", ((double) ((end - start) * 1000)) / CLOCKS_PER_SEC / i * 1000);
|
||||||
|
|
||||||
|
|
||||||
printf("testing key generation performance: ");
|
printf("testing key generation performance: ");
|
||||||
start = clock();
|
start = clock();
|
||||||
for (i = 0; i < 10000; ++i) {
|
for (i = 0; i < 10000; ++i) {
|
||||||
ed25519_create_seed(seed);
|
|
||||||
ed25519_create_keypair(public_key, private_key, seed);
|
ed25519_create_keypair(public_key, private_key, seed);
|
||||||
}
|
}
|
||||||
end = clock();
|
end = clock();
|
||||||
|
|
||||||
printf("%fus per seed and keypair\n", ((double) ((end - start) * 1000)) / CLOCKS_PER_SEC / i * 1000);
|
printf("%fus per keypair\n", ((double) ((end - start) * 1000)) / CLOCKS_PER_SEC / i * 1000);
|
||||||
|
|
||||||
printf("testing sign performance: ");
|
printf("testing sign performance: ");
|
||||||
start = clock();
|
start = clock();
|
||||||
@ -109,7 +118,7 @@ int main(int argc, char *argv[]) {
|
|||||||
printf("%fus per signature\n", ((double) ((end - start) * 1000)) / CLOCKS_PER_SEC / i * 1000);
|
printf("%fus per signature\n", ((double) ((end - start) * 1000)) / CLOCKS_PER_SEC / i * 1000);
|
||||||
|
|
||||||
|
|
||||||
printf("testing scalar addition performance: ");
|
printf("testing keypair scalar addition performance: ");
|
||||||
start = clock();
|
start = clock();
|
||||||
for (i = 0; i < 10000; ++i) {
|
for (i = 0; i < 10000; ++i) {
|
||||||
ed25519_add_scalar(public_key, private_key, scalar);
|
ed25519_add_scalar(public_key, private_key, scalar);
|
||||||
@ -118,6 +127,15 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
printf("%fus per keypair\n", ((double) ((end - start) * 1000)) / CLOCKS_PER_SEC / i * 1000);
|
printf("%fus per keypair\n", ((double) ((end - start) * 1000)) / CLOCKS_PER_SEC / i * 1000);
|
||||||
|
|
||||||
|
printf("testing public key scalar addition performance: ");
|
||||||
|
start = clock();
|
||||||
|
for (i = 0; i < 10000; ++i) {
|
||||||
|
ed25519_add_scalar(public_key, NULL, scalar);
|
||||||
|
}
|
||||||
|
end = clock();
|
||||||
|
|
||||||
|
printf("%fus per key\n", ((double) ((end - start) * 1000)) / CLOCKS_PER_SEC / i * 1000);
|
||||||
|
|
||||||
printf("testing key exchange performance: ");
|
printf("testing key exchange performance: ");
|
||||||
start = clock();
|
start = clock();
|
||||||
for (i = 0; i < 10000; ++i) {
|
for (i = 0; i < 10000; ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user