4

I read the JSONRPC document of Parity these days.

And I want to encrypt my message with the public key and private key of the accounts in Parity.

I found a JSONRPC in this web parity_encryptMessage

But it refers that

"Encrypt some data with a public key under ECIES."

And one of its parameters is

"Hash - Public EC key generated with secp256k1 curve, truncated to the last 64 bytes."

I can't understand it. I don't know how to get it. It generate by Parity or it should generate by myself? Please give me some advice. Thanks a lot~

1 Answer 1

5

ECIES is the Elliptic Curve Integrated Encryption Scheme. You should not wrap your head around the terminology too much, this is basically the crypto behind all Ethereum keypairs.

To generate a new keypair you can use ethkey.

 $ ethkey generate random
secret:  f302ecc87edbd4575bbe9bd8cbdaad3470191dad232c6df47cc294af084c15b7
public:  0bec09505ad3ac5e5a2562b43393938648dfaa4c60280ee8d1f6d00e5fbbbf422b3fb64d29ba56b4c2595b48202d9fd75375839b3b40886370cf5a559e374a81
address: fb80f51c9006a8eb3804821053305130d823c35a

Ethkey comes bundled with any Parity installation. Let's generate a brain wallet from your nick. Do not use this on public network:

$ ethkey generate brain YangYifei
secret:  c3d09aa314f216b618c84b3592d4d6992096ad544158a511148450771882c16e
public:  8b22ba82b80cb8d9e5e6207cbd8039bdb84398aaa63e5dd0684786456cd69a7708d334c92c540ed1d1764736b51fdcb5b7b95540cc8663851a03da99862e305e
address: 0052afd86e17e4cf7163a619a4cc9724dd04506c

The public key you are looking for is 0x8b22... above (64 bytes).

1
  • Note that the info about truncation to 64 bytes arises when public keys are specified as ASN.1 encoded 'uncompressed'. A prefix byte is used to indicate that the value is compressed or not. If this prefix is 0x04, the total byte length is 65 bytes, with the following 64 being the public key. The public key is actually 2 numbers, each of 32 bytes, being the coordinates on an elliptic curve. These coordinates are used to mathematical operations to sign things, encrypt things etc.
    – Sentinel
    Jun 25, 2018 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.