Post
Topic
Board Development & Technical Discussion
Merits 4 from 2 users
Re: ECDSA math questions
by
Coding Enthusiast
on 20/11/2018, 05:20:46 UTC
⭐ Merited by NeuroticFish (3) ,ETFbitcoin (1)
I hope that ordering and reading Mastering Bitcoin: Programming the Open Blockchain will help with the math, and trying to write my own blockchain parser.
FWIW you don't need to know "the math behind bitcoin" to write a blockchain parser.

This includes the Q (curve generator),
It is called "G" for Generator not Q!

I couldn't see how the order was calculated, given other values.
Order (or n) is the order of the generator or G.
Order of a point (G is a point on the curve) is the smallest positive integer such that nP = O.

Can you briefly describe what a base point is?
Base point is a point on the curve which is used in public key cryptography.

When trying to find:
Code:
y=pow(y2,(p+1)/4,p)  --> this line computes sqrt(y^2) = y
Is this always how it's done, for any y2, p is always the same, and the (p+1)/4 part is constant as well for getting y from y2?
What you need to have in mind is that calculations used in Elliptic Curve Cryptography are not regular arithmetic. Instead they are Modular Arithmetic. So y2=... is in fact y2=... mod p.
Calculating it requires using special algorithms one example is Tonelli–Shanks algorithm. There are special cases which can speed up the calculation. In case of secp256k1 elliptic curve that bitcoin is using, the prime number has a special characteristic which makes the calculation easier. And that is the fact that p%4=3 so you can use that formula above with (p+1/4 mod p)