convention/standard for sorting public keys for p2sh multisig transactions [combined summary]



Individual post summaries: Click here to read the original discussion on the bitcoin-dev mailing list

Published on: 2015-01-16T18:40:17+00:00


Summary:

The email thread discusses the need for a BIP outlining how to determine multisig scripthash address. The current method assumes the set of keys and sorts them before deriving and sending funds to such an address. However, there is scope for further refinement by anticipating only compressed keys for scripts. This is because it is possible to cause confusion if one puts forward a compressed key at some time and an uncompressed key at another, even though there is no difference to the keys involved. There is agreement among the developers that there is a need for a BIP outlining this process, and the writer is building a list of implementations which currently support sorting. The email also contains a discussion about pubkeys and their representation as DER-encoded integers. The email author's PGP key is available in the attachment.In a discussion on the Bitcoin development mailing list, Matt Whitlock raises a question about the representation of pubkeys in Script. Eric Lombrozo clarifies that internally, pubkeys are DER-encoded integers, but in Script, they are represented as raw integers. Wladimir adds that OP_CHECKSIG (and OP_CHECKSIGVERIFY) takes a DER-encoded pubkey and a DER-encoded signature on the stack. He also notes that it is not helpful to consider pubkeys or hashes as integers, as they are binary blob objects with either a fixed format (DER) or a fixed size (hashes). The conversation continues with Ruben de Vries from BlockTrail providing his contact information.Ruben de Vries, CTO of BlockTrail, has suggested the need for a standard way of sorting public keys in P2SH multisig transactions. According to him, the order of public keys affects the hash and there is no agreed-upon way of sorting them. He proposes that setting a standard would make it easier for multisig services to be compatible with each other and allow importation of keys from one service to another. Although he is not suggesting forcing the order, he believes that recommending a standard would encourage new services to follow suit. Ryan from BitPay had previously brought up this issue, and Bitcore has implemented lexicographical sorting on the hex of the public key. Ruben could not find any other library with a sorting function, let alone using it by default, so Bitcore is currently his only reference. Jeff Garzik, a Bitcoin core developer and open source evangelist at BitPay, responded to Ruben's proposal, suggesting that it warrants a micro-BIP to bring everyone on the same page.In January 2015, Ruben de Vries suggested on the Bitcoin-development mailing list that a standard way of sorting public keys should be set for p2sh multisig transactions to ensure compatibility between services. He suggested using lexicographical sorting on the hex of the public key, which had already been implemented in bitcore. Jeff Garzik agreed that a micro-BIP should be created to establish a standard and get everyone on the same page. The existing BIP45 mentions "lexicographically sorting the public keys" but does not provide specific details on how this should be done.The conversation dated 14th January 2015 between Jeffrey Paul and an unknown person regarding the clarification of the raw bytes of public keys has been provided. In the conversation, Jeffrey Paul asked for clarification about the raw bytes of the public key itself, not the ascii base58 representation of the pubkey hash. The unknown person was requested to give an example of two pubkeys where raw(pubkey1) > raw(pubkey2) and base58(pubkey1) is greater than or equal to base58(pubkey2).A discussion between devrandom and Jeffrey Paul took place on January 14, 2015. Devrandom's message explained that CryptoCorp recommends to its customers to sort lexicographically by the public key bytes of the leaf public keys in the same way as BitPay does. Jeffrey Paul sought clarification if it was the raw bytes of the public key itself, not the ASCII base58 representation of the pubkey hash. He added his contact details at eeqj.com and two phone numbers for America and worldwide.Haskoin, a company in the cryptocurrency industry, follows the same method of sorting public keys as recommended by CryptoCorp. The method involves sorting the public keys lexicographically based on the bytes of their leaf public keys. This is the same approach used by BitPay. The recommendation was made in an email exchange on January 14, 2015, between devrandom and an unknown recipient. The use of public keys is essential in the functioning of cryptocurrencies. Public keys are used to receive payments, while private keys are used to authorize transactions. Sorting public keys based on their bytes simplifies the process of verifying transactions and ensures that transactions can be traced back to the correct parties. CryptoCorp was a prominent player in the cryptocurrency industry until its closure in 2015.


Updated on: 2023-08-01T11:07:01.898565+00:00