supranational / blst

Multilingual BLS12-381 signature library
Apache License 2.0
454 stars 171 forks source link

Using the C library: exp_mont_384 is hard to use #180

Closed divad1196 closed 11 months ago

divad1196 commented 11 months ago

Hi,

Situation

I am currently trying to do (blst_p2)a ^ (size_t)b. I found out that sometimes, the blst_p2 in the header file becomes vec384 in the source file, so i guessed that exp_mont_384 might be what I want.

I then looked for its usage and I think I should be able to write my own power function

void blst_p2_power2(blst_p2* result, blst_p2* base, size_t exp) {
    // 2 definitions of limb_t in the lib
    // typedef uint64_t limb_t;
    // typedef unsigned long long limb_t;
    static const unsigned long long p0 = (limb_t)0x89f3fffcfffcfffd;
    exp_mont_384(result, base, &exp, sizeof(exp) * 8, BLS12_381_P, p0);
}

The issue is that I cannot really import const.h for limb_t has 2 different definition in the project

typedef uint64_t limb_t;
typedef unsigned long long limb_t;

Questions

divad1196 commented 11 months ago

Sorry, I was confused by multiplicative notation. Still, having the same typedef for different types is confusing