sorting public keys for p2sh multisig transactions



Summary:

In a p2sh multisig transaction, the serialized script consists of multiple public keys and an OP_CHECKMULTISIG operation. The order of the public keys affects the resulting p2sh address, so there needs to be a standard way of sorting them to ensure consistency. There are two types of public keys: compressed and uncompressed, with the latter being longer. Sorting methods such as string, big endian number, and little endian number can be used, but they have different outcomes. For instance, sorting as strings may result in a compressed key being ranked higher than an uncompressed one due to their length. On the other hand, sorting them as big endian numbers would give the correct order.


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