Regarding the Ledger Nano S hardware wallet for cryptocurrencies, I've heard it claimed that the private keys for the wallet are securely stored on the physical device and protected even if the PC is infected with malware.
However, isn't it necessary for the private keys to be passed through USB into the client application's memory at some point in order to send money from the wallet onto the Bitcoin/Ethereum blockchain? Is that a possible attack vector?
Or is it possible for the client application to initiate a transaction without the private key, using some kind of derivative instead. If so, what if the malware was able to intercept this derivative?
Does someone with more technical knowledge of this understand how the security is maintained?