I want to map an SHA-256 hash to an element in bn_t. I am using the following code to generate the hash of a string.
static int calc_and_compare_hash(const char *str, const unsigned char *expected)
{
static unsigned char hash[SHA256_DIGEST_LENGTH];
sha256_context_t sha256;
sha256_init(&sha256);
sha256_update(&sha256, (uint8_t*)str, strlen(str));
sha256_final(&sha256,hash);
return (memcmp(expected, hash, SHA256_DIGEST_LENGTH) == 0);
}
//
static void test_hashes_sha256_hash_sequence_01(void)
{
static const char *teststring = "Testing The Hash";
printf("output of hash %d\n", calc_and_compare_hash(teststring, h01));
}
The next step is to map this hash to a bn_t element and multiply it with the elliptic curve generator to get a new point on the curve using
ec_mul_gen(q, d);
I would appreciate it if someone can help me sort this out?