Sign and verify message with bitcoin address #524

pull sipa wants to merge 8 commits into bitcoin:master from sipa:signandverif changing 6 files +372 −38
  1. sipa commented at 3:26 PM on September 20, 2011: member

    This is a reworked version of #183

    Adds two RPC commands:

    • signmessage [address] [message]: create a base64-encoded signature string
    • verifymessage [address] [signature] [message]: verify whether a signature string is valid

    The signature string contains both the ECDSA pubkey and signature, to allow address-based verification. Verifymessage simply returns true or false.

    This pull request also contains a full inline base64 encoded and decoder, replacing the openssl-based code. The decoder is based on JoelKatz' base64 decoder from #430.

  2. gavinandresen commented at 3:48 PM on September 20, 2011: contributor

    This seems like a perfect candidate for some unit tests, both for the base64 encoder/decoder and for the sign/verify.

    A performance unit-test for the old versus new base64 code would be spiffy, too...

  3. ByteCoin commented at 12:48 AM on September 21, 2011: none

    I suggest that the code from https://github.com/sipa/bitcoin/commit/6e223c405988a1002eeeee69db88a1128a38b0a3 be used to recover the public key from the ECDSA signature on verification. This means that the public key need not be base-64 encoded which makes signatures about 87 characters shorter. The verification step is simply to check that the inferred public key matches the address. See https://bitcointalk.org/index.php?topic=6428.msg536734#msg536734 for further justification and improvements.

  4. Faster Base64 decoder. 4e67a6216b
  5. Inline base64 encoder/decoder
    This replaces the openssl-based base64 encoder and decoder with a more
    efficient internal one. Tested against the rfc4648 test vectors.
    
    Decoder is based on JoelKatz' version.
    4b603f1cd6
  6. Test case for base64 encode/decode e93bf37e86
  7. Sign and verify message with bitcoin address and public key
    Add padding to input (fixed string + address) before hashing
    cc2567e32f
  8. Incorporate pubkey in signature, check based on address
    Include the public key in the signature string, to allow verification
    based on address.
    b53d6284eb
  9. base64-based sign/verify d9867551fc
  10. Compact signatures and key recovery
    Introduce a new type of signatures that are only 65 bytes long, and allow
    reconstruction of the public key that was used to create the signature.
    01cc526318
  11. Use key recovery for message signatures
    Instead of encoding the public key inside the signature string, use
    key recovery to do verification. This allows 88-character base64-encoded
    signature strings instead of 188-character ones.
    3a570dc80a
  12. alexwaters commented at 5:19 AM on September 29, 2011: contributor

    Ran the 10 test cases with no error.

    I have testnet-in-a-box running and can sign and verify between the two clients.

    Signed the same address with multiple messages, verified true:true and false:false (no true:false). TBH I don't know if this is even necessary, but why not.

    Strict verification was tested (x to y or z etc.), observed expected behavior.

    Any chance you could add Gavin's requested performance test?

  13. gavinandresen commented at 3:16 PM on September 29, 2011: contributor

    ACK; I'd still like hard numbers on the performance of the base64 code, but that's not a show-stopper for pulling this.

  14. alexwaters commented at 6:11 AM on September 30, 2011: contributor

    ACK

  15. sipa commented at 10:50 AM on September 30, 2011: member

    There is a bit of discussion on the forums still; see https://bitcointalk.org/index.php?topic=6428.msg550155#msg550155

  16. gavinandresen referenced this in commit f4769e44a3 on Sep 30, 2011
  17. gavinandresen merged this on Sep 30, 2011
  18. gavinandresen closed this on Sep 30, 2011

  19. coblee referenced this in commit 8bc246aba1 on Jul 17, 2012
  20. gpmn commented at 2:11 AM on February 8, 2014: none

    I need the pubkey which has been encoded in the signed message

    But now it just feedback a true or false.I saw the code,but I don't like to copy it in golang again.

    Besides others tell me, is there any way to got the pubkey from message?

  21. gpmn commented at 2:40 AM on February 8, 2014: none

    I wish verifymessage could feed back the pubkey if user supply an extra param

  22. sanch0panza referenced this in commit a71ddfb989 on May 5, 2017
  23. kallewoof referenced this in commit f9cb345798 on Oct 4, 2019
  24. lateminer referenced this in commit 9feff4b2e1 on Jul 17, 2020
  25. KolbyML referenced this in commit bc86927231 on Sep 4, 2020
  26. rajarshimaitra referenced this in commit 36ef0d0279 on Aug 5, 2021
  27. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-15 15:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me