Have I missed something or is the only thing protecting the encryption scheme from impersonation of the phone the fact that the web-component's public key is (hopefully) never send to the WhatsApp servers?
The public key of the phone (the first 32 bytes of the variable "secret") is never authenticated by the web-component. Assuming they have the public key of the web-component, the WA Servers could hijack the whole scheme by sending their own public key in the "secret" instead of the phones. MITM doesn't seems possible though as the phone verifies the web-components public key by QR code.
I am no expert so, as I said, maybe I missed something, but relying on keeping a public key secret for security seems icky to me. Or maybe it's stupid to think about that too much, considering that both the phone-application and the servers including the Web API are closed-source anyway and will thus always remain icky security-wise.