I was exploring this code from the tests in eth-lightwallet:

describe('Asymmetric Encryption', function() {

    it('encrypts and decrypts a string', function (done) {
        var pw = Uint8Array.from(fixtures.valid[0].pwDerivedKey);
        var ks = new keyStore(fixtures.valid[0].mnSeed, pw);
        var hdPath = "m/0'/0'/2'";
        ks.addHdDerivationPath(hdPath, pw, {curve: 'curve25519', purpose: 'asymEncrypt'});
        ks.generateNewEncryptionKeys(pw, 2, hdPath);
        var pubKeys = ks.getPubKeys(hdPath);
        var msg = "Hello World!";
        var encrypted = encryption.asymEncryptString(ks, pw, msg, pubKeys[0], pubKeys[1], hdPath);
        var cleartext = encryption.asymDecryptString(ks, pw, encrypted, pubKeys[1], pubKeys[0], hdPath);

The use of encryption.asymEncryptString() is described as:

encryption.multiEncryptString(keystore, pwDerivedKey, msg, myPubKey, theirPubKeyArray [, hdPathString])

Ignorant of a possible difference between the keys for signing and encryption I tried an Eth address in the theirPubKeyArray Eg.

pubKeys[0] = ["09d5043d675d5ca75ee7bb51691fcc44543faade"];

I got an error in a checkBoxLengths function somewhere reporting that it was a bad public key size.

I noticed the keys generated by generateNewEncryptionKeys() were longer. What is the difference here?

  • So I realized that the Ethereum address is not a public key. – Interition Oct 4 '16 at 15:33

An explanation as to why the Ethereum address is not a Public Key can be found here. How are ethereum addresses generated? .

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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