steemit / libcrypto-js

Cryptographic utilities for Steem in Javascript. Zero dependencies.
5 stars 17 forks source link

use 65-byte compressed signature format #6

Closed goldibex closed 6 years ago

goldibex commented 6 years ago

This PR introduces the concept of signatures from which the public key can be recovered (just requires a special header byte to be set). This is the way bitcoin serializes signatures and we need to replicate this behavior.

If you just want the plain old (r, s) of the signature all you have to do is slice the first byte off. Nothing else is different.

I've also added the PublicKey.recover(hash, signature) method, which re-obtains the canonical public key from (hash, signature).

jnordberg commented 6 years ago

LGTM, deferring to my betters though :)