https://github.com/TokTok/c-toxcore/blob/2abc00693cc99f277c7c8fe1a201ec33becb01f1/toxcore/DHT.c#L2743..L2751
Since you have a function named public_key_valid, PK from random_bytes generates an invalid PK each 1/2 attempt.
void random_bytes(uint8_t *data, size_t length)
{
randombytes(data, length); // from NaCl
}
bool public_key_valid(const uint8_t *public_key)
{
if (public_key[31] >= 128) { /* Last bit of key is always zero. */
return 0;
}
return 1;
}
https://github.com/TokTok/c-toxcore/blob/2abc00693cc99f277c7c8fe1a201ec33becb01f1/toxcore/DHT.c#L2743..L2751
Since you have a function named
public_key_valid, PK fromrandom_bytesgenerates an invalid PK each 1/2 attempt.