I saw a lot of code examples use geth but someone said to me parity is now even more popular than geth. Are there any statistics about how the nodes for Ethereum are generated – either using geth or parity?
Go-Ethereum – Number of Nodes Using Parity vs Geth
go-ethereumparity
Related Solutions
The connection will drop if they are on different chains, you can run Parity with -lsync=trace
to see what is going on.
It probably has to do with hard fork transitions, Geth does not include them by default. Have a look here and try using the linked generator.
You never use private keys to encrypt, you always use the public key to encrypt and the private key to decrypt. Assuming your are looking for the public key: To generate a new keypair you can use ethkey. For simplicity, I will generate a brain wallet from your nick, so you can reuse these params. Do not use this on public network.
$ ethkey generate brain YangYifei
secret: c3d09aa314f216b618c84b3592d4d6992096ad544158a511148450771882c16e
public: 8b22ba82b80cb8d9e5e6207cbd8039bdb84398aaa63e5dd0684786456cd69a7708d334c92c540ed1d1764736b51fdcb5b7b95540cc8663851a03da99862e305e
address: 0052afd86e17e4cf7163a619a4cc9724dd04506c
To do the same with parity, and directly add the key to your node for later usage, you can use parity_newAccountFromPhrase:
$ curl --data '{"method":"parity_newAccountFromPhrase","params":["YangYifei","password1337"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
{"jsonrpc":"2.0","result":"0x0052afd86e17e4cf7163a619a4cc9724dd04506c","id":1}
But note, that we also need the public key from ethkey
above. Now let me encrypt a message for you, it requires the message in hex (use an ascii-to-hex converter) and the 64 bytes public key. Now feed this to parity_encryptMessage:
$ curl --data '{"method":"parity_encryptMessage","params":["0x8b22ba82b80cb8d9e5e6207cbd8039bdb84398aaa63e5dd0684786456cd69a7708d334c92c540ed1d1764736b51fdcb5b7b95540cc8663851a03da99862e305e","0x48656c6c6f2c2059616e67596966656921"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
{"jsonrpc":"2.0","result":"0x04f0f2a86c0f172d1bc897c23af03d23e8a3d66b84eac9d201f942b11350b4e48e0abcc0dacff1fe75a6ee1b6caa2eb489126336146d38192e656a208c5f22575b94083909c157ce1e0b6182b11bc1aa845ee0f501c2c13134be2b143fe31dd1682ca0be95bdd33c0663c29b760a2ef31c3aa3d0309d79dcf55cae5ebfa50e74c706","id":1}
The result is your encrypted message. To decrypt it, you can do it with parity_decryptMessage, not this only works if you added this account to Parity before.
Since decrypting requires your private key, you either have to unlock your account with personal_unlockAccount or using the wallet's signer functionality.
Best Answer
EtherNodes.org would seem to suggest that there are still twice the number of Geth nodes as there are Parity nodes.
Specifically, as of 13 April 2018:
Including other clients as well, there's a total of 16436 nodes.