diff --git a/toxcore/tox.api.h b/toxcore/tox.api.h index b678f4238ff..281cb998c17 100644 --- a/toxcore/tox.api.h +++ b/toxcore/tox.api.h @@ -240,6 +240,11 @@ const PUBLIC_KEY_SIZE = 32; */ const SECRET_KEY_SIZE = 32; +/** + * The size of the nospam in bytes when written in a Tox address. + */ +const NOSPAM_SIZE = sizeof(uint32_t); + /** * The size of a Tox address in bytes. Tox addresses are in the format * [Public Key ($PUBLIC_KEY_SIZE bytes)][nospam (4 bytes)][checksum (2 bytes)]. @@ -248,7 +253,7 @@ const SECRET_KEY_SIZE = 32; * byte is an XOR of all the even bytes (0, 2, 4, ...), the second byte is an * XOR of all the odd bytes (1, 3, 5, ...) of the Public Key and nospam. */ -const ADDRESS_SIZE = PUBLIC_KEY_SIZE + sizeof(uint32_t) + sizeof(uint16_t); +const ADDRESS_SIZE = PUBLIC_KEY_SIZE + NOSPAM_SIZE + sizeof(uint16_t); /** * Maximum length of a nickname in bytes. diff --git a/toxcore/tox.h b/toxcore/tox.h index f7724c8f382..69296e4361d 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -245,6 +245,13 @@ uint32_t tox_public_key_size(void); uint32_t tox_secret_key_size(void); +/** + * The size of the nospam in bytes when written in a Tox address. + */ +#define TOX_NOSPAM_SIZE (sizeof(uint32_t)) + +uint32_t tox_nospam_size(void); + /** * The size of a Tox address in bytes. Tox addresses are in the format * [Public Key (TOX_PUBLIC_KEY_SIZE bytes)][nospam (4 bytes)][checksum (2 bytes)]. @@ -253,7 +260,7 @@ uint32_t tox_secret_key_size(void); * byte is an XOR of all the even bytes (0, 2, 4, ...), the second byte is an * XOR of all the odd bytes (1, 3, 5, ...) of the Public Key and nospam. */ -#define TOX_ADDRESS_SIZE (TOX_PUBLIC_KEY_SIZE + sizeof(uint32_t) + sizeof(uint16_t)) +#define TOX_ADDRESS_SIZE (TOX_PUBLIC_KEY_SIZE + TOX_NOSPAM_SIZE + sizeof(uint16_t)) uint32_t tox_address_size(void); @@ -2938,3 +2945,4 @@ uint16_t tox_self_get_tcp_port(const Tox *tox, TOX_ERR_GET_PORT *error); #endif #endif +