我从的测试中探索了这段代码:
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);
expect(cleartext).to.equal(msg);
done();
});
});encryption.asymEncryptString()的使用描述为:
encryption.multiEncryptString(keystore, pwDerivedKey, msg, myPubKey, theirPubKeyArray [, hdPathString])不知道用于签名和加密的密钥之间可能有什么不同,我在theirPubKeyArray示例中尝试了Eth地址。
pubKeys[0] = ["09d5043d675d5ca75ee7bb51691fcc44543faade"];我在某个地方的checkBoxLengths函数中发现了一个错误,报告说它是一个糟糕的公钥大小。
我注意到generateNewEncryptionKeys()生成的密钥更长。这里有什么区别?
发布于 2016-10-04 16:14:45
在这里可以找到一个解释,说明为什么Ethereum地址不是公钥。以太地址是如何产生的?。
https://ethereum.stackexchange.com/questions/9020
复制相似问题