Without getting too into the weeds, Ed25519 signing uses both the public key and the private key.
The 64 bytes you see in the Keypair
class of @solana/web3.js
is actually the Ed25519
key-pair. The first half is the seed used to derive the private scalar and the second half is the actual public key itself.
In fact, if you convert the second half of the key-pair bytes into a base58 string, you'll get your Solana address!
@solana/web3.js
doesn't need to pass both keys to the ed25519
library since that library uses the seed to derive both the private scalar and the public key.
https://github.com/paulmillr/noble-curves/blob/7f851873f97e55b7e4e46457c268f61400887ba3/src/abstract/edwards.ts#L448
As far as your specific question as to why they're included together in the first place, this was likely a design choice made by engineers for a few possible reasons, including:
- compatibility with libraries who expect the 64-byte format
- increased performance (don't need to compute the public key from the seed)
- possibly others