Closed LaurentTrk closed 1 year ago
The encyption/decryption support was contributed, so have really not tested it apart from the available supplied tests. I have not seen it out in the wild, so if the feedback is it doesn't work, it will need to be removed.
Thanks @jacogr for your reply !
I don't know what to think about it...
This issue is closely related to this feature on the extension(which will be obsolete if this one does not work), and I think it was the plan of @RoyTimes when he first worked on this encryption feature.
@LaurentTrk @jacogr Let me look into it. I thought such case is covered with the original tests? I can change the code so that it appends the 32 bytes Curve25519 public key of the sender to the beginning of the message.
Thanks @RoyTimes !
Yes, sr25519
tests seems covered, but it appears that coming from an ed25519
and convert it to sr255159
(the way it's done in the tests) works, whereas using a native sr25519
does not.
The test code I am using:
const keyring = new Keyring();
const senderPair = keyring.createFromUri(mnemonicGenerate(), { name: 'first pair' }, 'sr25519');
const receiverPair = keyring.createFromUri(mnemonicGenerate(), { name: 'second pair' }, 'sr25519');
const message = stringToU8a('This is a test.');
const encryptedMessage = senderPair.encryptMessage(message, receiverPair.publicKey);
const decryptedMessage = receiverPair.decryptMessage(encryptedMessage, senderPair.publicKey);
const isMatch = u8aToString(message) === u8aToString(decryptedMessage);
// Verify that the decrypted message matches the original message
console.log(`Does the decrypted message match the original message? ${isMatch}`);
Under the hood, the conversion of the sr25519
public key with the ed2curve.convertPublicKey()
function fails (make sense as the ed2curve is designed to handle ed25519
keypairs.
Thanks again for your help.
@LaurentTrk @jacogr I have posted a fix.
This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days.
Thanks - ran into issues with this today, looking forward to this fix.
@jacogr @LaurentTrk I'm still facing this issue with sr25519, for some keys encryptMessage() works, for others it errors with Unable to convert publicKey to ed25519
from convertPublicKeyToCurve25519().
This functionality will probably be removed completely. There is no sane way of doing this at all. (Where “sane” refers to no having to share other keys out of band)
Hi @amany9000 As @jacogr mentionned, this will not be fixed in the Polkadot JS library, nor the extension.
If you plan to use this feature from a wallet, I am aware that the Talisman Wallet team has added support for encryption/decryption recently (from the version v1.10.0).
Thank you for the confirmation @jacogr .
@LaurentTrk That's pretty interesting but I couldn't find any implementation or documentation on talisman-society. Could you please point me to any of those?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.
Hi all ! This issue is the continuation of the closed #1124 about the support of sr25519 keypair for the Encryption/Decryption feature.
After several tests, I cannot get it work, as the
ed2curve.convertPublicKey
used to convert the public key does not work for sr25519 public key.The Ristretto decoding of the public key used in Schnorrkel is not the same as in ed25519.
I managed to make encryption/decryption between 2 sr22519 keypairs using Ristretto255.js, but I can't do it between one ed25519 and one sr25519.
Could anyone help me ?
Thanks !