#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "libbitcoinpqc/fn_dsa.h"
#include "../../falcon/falcon.h"
#define FN_DSA_DEBUG 0
#define DEBUG_PRINT(fmt, ...) \
do { if (FN_DSA_DEBUG) printf(fmt, ##__VA_ARGS__); } while (0)
int fn_dsa_512_verify(
const uint8_t *sig,
size_t siglen,
const uint8_t *m,
size_t mlen,
const uint8_t *pk
) {
if (!sig || !m || !pk) {
DEBUG_PRINT("FN-DSA verify: Invalid arguments\n");
return -1;
}
size_t tmp_size = FALCON_TMPSIZE_VERIFY(9);
uint8_t *tmp = malloc(tmp_size);
if (!tmp) {
DEBUG_PRINT("FN-DSA verify: Memory allocation failed\n");
return -1;
}
DEBUG_PRINT("FN-DSA verify: Calling falcon_verify\n");
int result = falcon_verify(
sig, siglen, FALCON_SIG_COMPRESSED, pk, FN_DSA_512_PUBLIC_KEY_SIZE, m, mlen, tmp, tmp_size );
DEBUG_PRINT("FN-DSA verify: Verification result %d\n", result);
memset(tmp, 0, tmp_size);
free(tmp);
return result;
}