Renaming ambiguous names

This commit is contained in:
Imbus 2025-08-24 15:24:05 +02:00
parent 94c4bbd6cf
commit 2134acdc09

22
main.c
View file

@ -27,15 +27,15 @@ int main(void) {
// uint8_t seed[32]; // uint8_t seed[32];
// arc4random_buf(seed, 32); // arc4random_buf(seed, 32);
uint8_t sk[64]; /* secret key */ uint8_t seckey[64]; /* secret key */
uint8_t pk[32]; /* Matching public key */ uint8_t pubkey[32]; /* Matching public key */
PRINT_HEX(seed, seed_len); PRINT_HEX(seed, seed_len);
/* The seed is wiped automatically here */ /* The seed is wiped automatically here */
crypto_eddsa_key_pair(sk, pk, seed); crypto_eddsa_key_pair(seckey, pubkey, seed);
print_hex("PubKey", pk, 32); PRINT_HEX(pubkey, 32);
print_hex("SecKey", sk, 64); PRINT_HEX(seckey, 64);
uint8_t message[4]; uint8_t message[4];
@ -43,24 +43,24 @@ int main(void) {
arc4random_buf(message, 4); arc4random_buf(message, 4);
PRINT_HEX(message, sizeof(message)); PRINT_HEX(message, sizeof(message));
uint8_t sig[64]; uint8_t signature[64];
/* Sign it and store the signature in sig[] */ /* Sign it and store the signature in sig[] */
crypto_eddsa_sign(sig, sk, (const uint8_t *)message, sizeof(message)); crypto_eddsa_sign(signature, seckey, (const uint8_t *)message, sizeof(message));
print_hex("Signature:", sig, 64); PRINT_HEX(signature, 64);
/* Assert valid */ /* Assert valid */
assert(!crypto_eddsa_check(sig, pk, (const uint8_t *)message, sizeof(message))); assert(!crypto_eddsa_check(signature, pubkey, (const uint8_t *)message, sizeof(message)));
/* Tamper with payload to invalidate the signature */ /* Tamper with payload to invalidate the signature */
arc4random_buf(message, 4); arc4random_buf(message, 4);
PRINT_HEX(message, sizeof(message)); PRINT_HEX(message, sizeof(message));
/* Assert invalid */ /* Assert invalid */
assert(crypto_eddsa_check(sig, pk, (const uint8_t *)message, sizeof(message))); assert(crypto_eddsa_check(signature, pubkey, (const uint8_t *)message, sizeof(message)));
/* Wipe the secret key if it is no longer needed */ /* Wipe the secret key if it is no longer needed */
crypto_wipe(sk, 32); crypto_wipe(seckey, 32);
printf("Program finished: Ok!\n"); printf("Program finished: Ok!\n");
} }