Post
Topic
Board Development & Technical Discussion
Re: secp256k1 library in pure assembly
by
AlexanderCurl
on 02/12/2022, 17:39:30 UTC
also some good ecc implementation based on gmp: https://github.com/masterzorag/ec_gmp

I used that library for some tools that I made but it is not optimized for secp256k1 also it is some kind of vulnerable to some side channels attacks and incomplete because it declare EC.b parameter but it never use.

A lot of improvements can be made to that implementation.

The fastest implementation for secp256k1 code that I ever see and use it is already inside of kangaroo tool.

https://github.com/JeanLucPons/Kangaroo/tree/master/SECPK1

Same library that I actually use in my keyhunt code.






That is right. I also use it as base for my project. And have everything there. Just P2TR Taproot addresses are left to add (only the tweak parts).
And will add Jacobian coordinates. Mainly for what I care only points addition operation to be the fastest.
I use scalar multiplication just to set input parameters.
But since I use secp256k1 curve only for testing and research I do no care much for any of  possible vulnerabilities and attacks.
And EC.b can is used here:

bool Point_On_Curve(struct Point A) {
   
    mpz_t X, Y;
    mpz_init(X); mpz_init(Y);
    mpz_pow_ui(X, A.x, 3);
    mpz_add(X, X, EC.b);
    mpz_mod(X, X, EC.p);
    mpz_pow_ui(Y, A.y, 2);
    mpz_mod(Y, Y, EC.p);
    if (mpz_cmp(X, Y) == 0) {
        mpz_clear(X);
        mpz_clear(Y);
        return true;
    } else {
        mpz_clear(X);
        mpz_clear(Y);
        return false;
    }
   
}