small improvement for inversion
parent
36be90765d
commit
7cd252c6de
|
@ -41,15 +41,15 @@ Python script `x25519.py`
|
||||||
Python script `ed25519.py`
|
Python script `ed25519.py`
|
||||||
|
|
||||||
Test 1: Length of message: 0 bytes
|
Test 1: Length of message: 0 bytes
|
||||||
Computation time: 53 ms
|
Computation time: 52 ms
|
||||||
Test 1 passed.
|
Test 1 passed.
|
||||||
|
|
||||||
Test 2: Length of message: 1 byte
|
Test 2: Length of message: 1 byte
|
||||||
Computation time: 53 ms
|
Computation time: 52 ms
|
||||||
Test 2 passed.
|
Test 2 passed.
|
||||||
|
|
||||||
Test 3: Length of message: 2 bytes
|
Test 3: Length of message: 2 bytes
|
||||||
Computation time: 53 ms
|
Computation time: 52 ms
|
||||||
Test 3 passed.
|
Test 3 passed.
|
||||||
|
|
||||||
Test 4: Length of message: 1023 bytes
|
Test 4: Length of message: 1023 bytes
|
||||||
|
|
|
@ -104,7 +104,8 @@ STEP_4:
|
||||||
shift_right(D);
|
shift_right(D);
|
||||||
}
|
}
|
||||||
sub9_zxy(u, u, v);
|
sub9_zxy(u, u, v);
|
||||||
if ((u[8] & 0x80000000) == 0) { // u >= v
|
if ((u[8] & 0x80000000) == 0) {
|
||||||
|
// u >= v
|
||||||
sub9_zxy(B, B, D);
|
sub9_zxy(B, B, D);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -112,16 +113,13 @@ STEP_4:
|
||||||
sub9_zxy(v, v, u);
|
sub9_zxy(v, v, u);
|
||||||
sub9_zxy(D, D, B);
|
sub9_zxy(D, D, B);
|
||||||
}
|
}
|
||||||
uint32_t cmp = 0;
|
for (uint32_t i=0; i<9; i++) {
|
||||||
for (int i=0; i<9; i++) cmp |= u[i];
|
if (u[i] != 0) goto STEP_4;
|
||||||
if (cmp == 0) {
|
|
||||||
if (D[8] & 0x80000000) {
|
|
||||||
add9_zxy(D, D, m); // D < 0
|
|
||||||
}
|
|
||||||
for (uint32_t i=0; i<8; i++) y[i] = D[i];
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
goto STEP_4;
|
if (D[8] & 0x80000000) {
|
||||||
|
add9_zxy(D, D, m); // D < 0
|
||||||
|
}
|
||||||
|
for (uint32_t i=0; i<8; i++) y[i] = D[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue