Map a SHA256 hash to bn_t element

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_update(&sha256, (uint8_t*)str, strlen(str));
    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?

Hi @cryptSys this seems to be a relic question. Please try to get in contact with the community directly via mailing list or GitHub issue: GitHub - relic-toolkit/relic: Code.

btw: is our relic package still maintained? It points to a snapshot that’s more than 3 years old.

1 Like

I did use the package recently.

1 Like

Yes, the library is working fine, its just this small function that I am unaware of.

Thank you. I will post there.