-Z should be a bit faster now
This commit is contained in:
parent
a06d5149af
commit
f7a87a1300
23
main.c
23
main.c
@ -694,11 +694,11 @@ static void onionready(char *sname, const u8 *secret, const u8 *pubonion)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// little endian inc
|
// little endian inc
|
||||||
static void addseed(u8 *seed)
|
static void addsk32(u8 *sk)
|
||||||
{
|
{
|
||||||
register unsigned int c = 1;
|
register unsigned int c = 8;
|
||||||
for (size_t i = 0;i < SEED_LEN;++i) {
|
for (size_t i = 0;i < 32;++i) {
|
||||||
c = (unsigned int)seed[i] + c; seed[i] = c & 0xFF; c >>= 8;
|
c = (unsigned int)sk[i] + c; sk[i] = c & 0xFF; c >>= 8;
|
||||||
// unsure if needed
|
// unsure if needed
|
||||||
if (!c) break;
|
if (!c) break;
|
||||||
}
|
}
|
||||||
@ -756,6 +756,7 @@ static void *dowork(void *task)
|
|||||||
|
|
||||||
initseed:
|
initseed:
|
||||||
randombytes(seed,sizeof(seed));
|
randombytes(seed,sizeof(seed));
|
||||||
|
ed25519_seckey_expand(sk,seed);
|
||||||
#ifdef STATISTICS
|
#ifdef STATISTICS
|
||||||
++st->numrestart.v;
|
++st->numrestart.v;
|
||||||
#endif
|
#endif
|
||||||
@ -764,7 +765,6 @@ again:
|
|||||||
if (unlikely(endwork))
|
if (unlikely(endwork))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
ed25519_seckey_expand(sk,seed);
|
|
||||||
ed25519_pubkey(pk,sk);
|
ed25519_pubkey(pk,sk);
|
||||||
|
|
||||||
#ifdef STATISTICS
|
#ifdef STATISTICS
|
||||||
@ -784,6 +784,9 @@ again:
|
|||||||
shiftpk(wpk,wpk,filter_len(j));
|
shiftpk(wpk,wpk,filter_len(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// sanity check
|
||||||
|
if ((sk[0] & 248) != sk[0] || ((sk[31] & 63) | 64) != sk[31])
|
||||||
|
goto initseed;
|
||||||
|
|
||||||
ADDNUMSUCCESS;
|
ADDNUMSUCCESS;
|
||||||
|
|
||||||
@ -799,7 +802,7 @@ again:
|
|||||||
goto initseed;
|
goto initseed;
|
||||||
});
|
});
|
||||||
next:
|
next:
|
||||||
addseed(seed);
|
addsk32(sk);
|
||||||
goto again;
|
goto again;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
@ -889,13 +892,7 @@ initseed:
|
|||||||
// update secret key with counter
|
// update secret key with counter
|
||||||
addsztoscalar32(sk,counter);
|
addsztoscalar32(sk,counter);
|
||||||
// sanity check
|
// sanity check
|
||||||
if (((sk[0] & 248) == sk[0]) && (((sk[31] & 63) | 64) == sk[31])) {
|
if ((sk[0] & 248) != sk[0] || ((sk[31] & 63) | 64) != sk[31])
|
||||||
/* These operations should be a no-op. */
|
|
||||||
sk[0] &= 248;
|
|
||||||
sk[31] &= 63;
|
|
||||||
sk[31] |= 64;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
goto initseed;
|
goto initseed;
|
||||||
|
|
||||||
ADDNUMSUCCESS;
|
ADDNUMSUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user