How does the wallet check against the key image in a tx that it was them that spent it, given the private/public view and private/public spend?
If a wallet has received an output in the past, that means the wallet will know the private key for that output. This is the case even if you restore the wallet from seed.
The private key for the output is calculated as
a is the private view key,
R is the transaction public key published with the transaction,
i is the index of the output in the incoming transaction,
b is your private spend key, and
Hs() means keccak hash the contents and return a scalar (integer).
The key image is calculated as
G is the agreed-upon base point on the ed25519 curve,
B is your public spend key, and
Hp() means keccak hash the contents and return a curve point.
The wallet checks if the key image of any previously received output is observed to be attached to any transaction it comes across as it scans the blockchain.
The daemon will reject transactions that are broadcast which contain any previously encountered key images. Although the daemon will not know which specific output referenced in each ring that each key image refers to, it doesn't need to know. All it needs to do is reject duplicates.