The key generator was initilized with a size of 1024, so why the printed sizes are 635 and 162?
import java.security.KeyPair; import java.security.KeyPairGen
First hint: 1024 bits = 128 bytes
1024 bits = 128 bytes
Second hint: privateKey.getEncoded() returns an encoded representation (i.e. not raw).
privateKey.getEncoded()
encoded