OPosts: 3 · Reputation: 1043
hey, quick question, not sure if it's dumb
I've got something like this in pure python:
d = pow(g, f*(n-2), n)
so, g is just an integer generator and I wanna know how to do this with elliptic curves where g is a point instead?
SPosts: 145 · Reputation: 2023
yeah that’s totally doable
just gotta find the right resources on elliptic curve math
NoPosts: 57 · Reputation: 90
you mean like this?
check out the point multiplication on elliptic curves, it’s pretty straightforward if you look it up
OPosts: 3 · Reputation: 1043
let me break it down:
let n be the order of the secp256k1 group
n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
our generator G is:
G.x = 55066263022277343669578718895168534326250603453777594175500187360389116729240
G.y = 32670510020758816978083085130507043184471273380659243275938904335757337482424
when I calculate:
res = G * (n-2)
I end up with -2*G but with negative y. And if I plug 2 as DLP:
pow(2, n-2, n)
gives me 57896044618658097711785492504343953926418782139537452191302581570759080747169
NoPosts: 57 · Reputation: 90
the thing is, scalar multiplication on elliptic curves isn’t the same as exponentiation modulo n
this is why your results differ.
OPosts: 3 · Reputation: 1043
lol ChatGPT sure gets it wrong sometimes
i’ve been through so many sources
but all I see is exponential in ecdlp rewritten as multiplicative, no clue why.
NoPosts: 57 · Reputation: 90
you sure about that?
it’s meant to be additive, right? DLP is all about multiplication. thing is, notation can mess you up, trust me.
MrPosts: 139 · Reputation: 35
wait, is "pow" for power? that’s modular exponentiation
bigint libraries and ECC should have a ModPow() function, though I’m not sure the best algorithm for N-2.
DiPosts: 79 · Reputation: 2112
ECDSA and DSA ain’t the same. you got DSA and you wanna shift to ECDSA, but it’s tricky. DSA uses numbers, while ECDSA uses points.
which means if you’re only on private keys, it can work out. but on public keys? you can’t just multiply them or raise a generator like that. it's not just repeated multiplication.
check my old topic for more on this.