ECDSA signing in Go

How do I do this Python code in Go?

from ecdsa import SigningKey  

signing_key = SigningKey.from_pem(data) 

signature = signing_key.sign(to_sign_as_bytes, hashfunc=sha256, sigencode=ecdsa.util.sigencode_der) 

There’s an example at ecdsa package - crypto/ecdsa -

Yes, I used the relevant packages. But I am getting a different signature. I used Go’s ecdsa.Sign()

Sorry, it’s probably because the docs at the link say it uses SHA-512 instead of the SHA-256 that your code lists.

Interesting. Looks like a dead end to me.

The ecdsa code is available. The algo listed at wikipedia lists the hash function in only the first step. It may be easy enough to hack the code to use sha256 instead.

Yes, I can try that. Thank you for pointing this out.

I see line 215 of ecdsa.go

md := sha512.New()

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.