taurushq-io / multi-party-sig

Implementation of protocols for threshold signatures

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Computing recovery id for ECDSA signature

tmpfs opened this issue · comments

commented

The type ecdsa.Signature included R and S but no recovery id (or v) value which would be required for ethereum-style recoverable signatures.

If memory serves correctly v is just whether the y co-ordinate for the point is negative but looking at the Point type I can't see any way to compute this easily.

Any advice on how we could compute the recovery id for ecdsa.Signature please?

@tmpfs I was able to get the value of v and send tx-
signature := signResult.(*ecdsa.Signature)

r, _ := signature.R.MarshalBinary()
s, _ := signature.S.MarshalBinary()
rs := make([]byte, 0)

rs = append(rs, r...)
rs = append(rs, s...)

v := rs[0] - 2
copy(rs, rs[1:])
rs[64] = v

but I got another error - Invalid Signature: s-values greater than secp256k1n/2 are considered invalid https://eips.ethereum.org/EIPS/eip-2 - paragraph 2
https://ethereum.stackexchange.com/questions/55245/why-is-s-in-transaction-signature-limited-to-n-21