Hey, I know this might sound silly.
So, I've got something like this in pure Python:
d = pow(g, f * (n 2), n)
where:
g is the generator as an integer
f is some int value
n is the order
Now, I'm trying to figure out how to do this with elliptic curves where g is a point instead. Any ideas?
You mean something like this?: https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication
COBRAS is right, it is easy to find out the answer on this one. Literally just inserted your question into ChatGPT:
I will explain:
let n -> order of the group - choosed as secp256k1
n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
we have our generaror as G in secp256k1:
G.x = 55066263022277343669578718895168534326250603453777594175500187360389116729240
G.y = 32670510020758816978083085130507043184471273380659243275938904335757337482424
now when I do :
res = G * (n-2)
result is -2*G but with negate y.
now lets :
generator is 2 as DLP:
when I will do with the same order:
pow(2,n-2,n)
I got resultat 57896044618658097711785492504343953926418782139537452191302581570759080747169
which is half point of G of secp256k1
why not n-2?
scalar multiplication on elliptic curves and exponentiation modulo n are governed by different mathematical structures.
That is why you got two different results.
Ain't ChatGPT a beautiful thing?
Are you sure? It is supposed to be additive. DLP is multiplicative. I think your issue lies in notation (as mentioned, due to different mathematical structures).
g*g*g =/= 3g
Is "pow" power? That's just modular exponentiation https://en.wikipedia.org/wiki/Modular_exponentiation and all "bigint" libs and ECC libraries should have a function that computes ModPow() for you. There are a couple of algorithms that can be used but I don't know what would be best for N-2 though...
ECDSA is not DSA. This is not how it works. You have DSA, and you want to convert it into ECDSA, but you won't, because in DSA, you have just some numbers, while in ECDSA, you have points.
Which means, that if you work only on private keys, then you can of course compute all things there. But: when you want to do the same thing on public keys, then you won't multiply two public keys alone. And also, you won't raise a given generator, to a given power, because exponentiation is just repeated multiplication.
My old topic about it: https://bitcointalk.org/index.php?topic=5460766.0