Closed wighawag closed 10 months ago
If you want to recover keys while passing it along hexed, you can invent your own format, for example, just prepend it to compact hex.
It depends on the signature format, usually in ECC the signature is represented as a ScalarPoint in the curve, x and y. Some tools serialize is in base64. For public keys, you have something called SEC1 format. The latter is like this :
04 for uncompressed key + X coord bytes + X coord bytes 02 for compressed key with even Y coord + X coord bytes 03 for compressed key with odd Y coord + X coord bytes
This format can be very convenient for compressing and deflating keys, keeping it at 33 bytes
You could typically find some format close to this based on a prefix with your recovery bits and signature. But be aware that the recovery bit is never used in the signature-verification process. I don't know if the signature can be compressed, the only requirement is that the point is on the curve.
Good luck.
Hey, I got a question about the api for signatures
When I get a signature from calling
secp256k1.sign(msgHash, priv);
I get a signature objectThen if I call
sig.toCompactHex();
orsig.toDERHex();
and try to recover the signature object from the resulting string withsecp256k1.Signature.fromCompact(
orsecp256k1.Signature.fromDER
the signature object is missing the recovery idDoes this means I should also save it along the result of
sig.toCompactHex
and add it back withaddRecoveryBit
? or am I using the api wrong somehow ?