import { TransactNote } from '../note/transact-note'; import { UnshieldNote } from '../note/unshield-note'; import { ClearSignOutput } from '../wallet/clear-sign'; /** * `ByteUtils.fastHexToBytes` assumes lowercase — it maps any char >= '9' by subtracting * 87, so 'A'-'F' decode to negative nibbles and produce garbage with no error. EVM * addresses arrive EIP-55 checksummed, so anything user- or address-derived must be * normalised before conversion or the device is handed the wrong bytes silently. */ declare const hexToBytesSafe: (hex: string) => Uint8Array; /** Map one internal note to its device output, tagged by the note's own output type. */ export declare const clearSignOutputForNote: (note: TransactNote) => ClearSignOutput; export { hexToBytesSafe }; export declare const clearSignOutputForUnshield: (note: UnshieldNote) => ClearSignOutput; /** * Order the transact's outputs the way the device will. * * This is NOT cosmetic. The device computes its msgHash over `commitmentsOut` in the * order it received the outputs, while the engine builds `commitmentsOut` from * `allOutputs` in caller-add order. If those differ the two hashes can never agree — a * plain transfer-plus-change transact already differs, since the engine emits * [transfer, change] and the device expects [change, transfer]. * * So the engine adopts the device's order for the whole transaction rather than trying to * permute responses back afterwards. Output order within a transact is arbitrary as long * as ciphertext[i] corresponds to commitmentsOut[i], so this is free. */ export declare const canonicallyOrderOutputs: (outputs: readonly T[]) => T[]; export type OrderedClearSignOutputs = { /** Device-ordered outputs, ready to send. */ readonly outputs: readonly ClearSignOutput[]; /** * `sourceIndices[i]` is the index into `internalOutputs` that produced `outputs[i]`, or * `null` when `outputs[i]` is the unshield. Carry this to map device responses back. */ readonly sourceIndices: readonly (number | null)[]; }; /** * Sort into the device's canonical order and record where each entry came from. * * Sorting is stable within a rank, so two outputs of the same type keep their relative * engine order and the mapping stays unambiguous. */ export declare const orderClearSignOutputs: (internalOutputs: readonly TransactNote[], unshieldNote?: UnshieldNote) => OrderedClearSignOutputs;