Match Avalanche X-Chain multisignature credentials to owner indices
A multisignature spend can carry the required number of signatures yet fail verification if their order does not match the selected indices in the referenced output.
Start from the actual UTXO owner array
Decode the referenced secp256k1 output, including its threshold and locktime. Use its serialized, sorted owner list directly. In the example the signer set is A and C, corresponding to indices 0 and 2. A local contact book in the order C, A, B must not redefine those indices.
owners = [A, B, C] // already sorted by address bytes
threshold = 2
ownerIndices = [0, 2]
credential = [signatureFromA, signatureFromC]
Build one credential for the matching input
Put signatures in the order of the input’s increasing address indices. With several inputs, align each credential to its input in the final serialized transaction. Sorting inputs after collecting signatures changes signing material and can also move a credential to the wrong input. Recheck locktime independently of signature completeness.