-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sign: add message signing and verification #104
sign: add message signing and verification #104
Conversation
-signing functions are now residing in sign.h and sign.c -key functions to do with eckey structure are now in key.c -added sign.h/.c to Makefile.am and CMakeLists.txt
-refactored message signing & verification functions to append the recid on the end of the signature. -added updated functions to corresponding documentation. -added new new_eckey_from_privkey function to derive an eckey pair from a WIF encoded private key.
-verifymessage now requires passing an address to it as this allows us to determine which network prefixes are needed for creating the correct address from the recovered public key. -added is_testnet bool to new_eckey and start_key functions as new_eckey was the only function wherein we can't determine what chainparams are needed, thus let the user decide. -updated documentation and example to reflect said changes.
46e35fe
to
de4df7e
Compare
-per spec's from core, each signed message is prepended with 'Dogecoin Signed Message:\n' which is now implemented in all signed messages.
de4df7e
to
fdefb02
Compare
Force pushed to amend the commit message to include a forgotten detail. |
7daa2b7
to
16b6c8e
Compare
Greatly simplified the implementation with the help of @edtubbs over the weekend. There is only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed and tested, ACK
…igning sign: add message signing and verification
This PR introduces message signing and verification into libdogecoin. It adheres to BIP-137 although is only applicable for P2PKH addressing and is slightly different considering we append the
recid
to the end of the signature if therecid
!= 0. This is needed in order to recover the public key in the verification step later on.There are two implementations, one (
signmsgwithprivkey
andverifymessage
) returns the signature as achar*
and verifies the signature by passing a corresponding address into the verification function and the other (signmsgwitheckey
andverifymessagewithsig
) uses theeckey
structure andsignature
structure to either auto generate a random privkey/pubkey pair or derives it from a private key in WIF format. This allows us to set the correct chain parameters for the rest of the usage throughout the process.For instance, in
such
there is a hybrid implementation that uses theeckey
andsignature
structures for the signing as we don't know the address and only provide the message we want to sign and the private key. On the verification step we can then pass the message, the signature and the corresponding address affiliated.There is documentation for the API's (
eckey.md
,signing.md
andtools.md
) and corresponding examples withincontrib/example.c
.