sorting public keys for p2sh multisig transactions



Summary:

The discussion is about the standard way of sorting public keys for a p2sh multisig transaction. The serialized script consists of m, n, public key and OP_CHECKMULTISIG. The order of public keys matters because the hash depends on it. There are two types of public keys: compressed and uncompressed. Sorting them as strings, big endian numbers, or little endian numbers yield different results. Alan Reiner's comment suggests using parallel trees to generate P2SH addresses after sorting the keys lexicographically, which probably means sorting as strings. The writer implemented sorting in javascript, where he sorted them as big endian numbers and filled in the 0s. However, he doesn't care which method they use as long as everyone in the Bitcoin world uses the same standard.


Updated on: 2023-06-08T14:58:24.319092+00:00