Your code suggests you have a fundamental misunderstanding about how asymmetric cryptography is supposed to be used. Your sender and receiver should have their own, independent key pairs. The sender then encrypts data using the recipient's public key.
What you're doing is using a fixed string to generate the same key pair in two locations. That's not secure, as you've reduced your key space from 512 bits (which is already too small - use at least 1024-bits) down to the entropy associated with a (presumably short) string.
If you wish to have a "password" string used to derive keys at both ends, then use a symmetric algorithm (e.g. AES) and a password derivation function such as PBKDF2.