HUGE disclaimer, I DO NOT recommend doing this with any key pair that contains substantial funds.
Re-read that line, before continuing.
I've recently mentioned #age #encryption tool.
Besides encrypting with a --password, age has --recipient flag, which allows bech32 encoded X25519 public keys.
Now there are few things to untagle here.
In #Symbol we're using ed25519 keys, therefore we represent public keys as compressed coordinates on Edwards curve.
x25519 key pair is somewhat similar but different:
* it uses slightly different 'raw' private key - which is better suited for some applications,
* public keys are usually represented as (compressed) coordinates on Montgomery curve.
Luckily it just so happens, that it's pretty easy to turn ed25519 keypair into x25519 keypair,
moreover due to birational mapping, it's also somewhat easy to covert just the public key,
for more details see https://www.rfc-editor.org/rfc/rfc7748.html#section-5.
Bech32 is just an encoding, quite similar to base32, note howevere, that --recipient is bech32 encoding of public key, and not really an address.
What that means is that we can use Symbol accounts as encrypted age file --recipients.
Let's consider account with (ed25519) public key:
`23AC0770A1060241604A8E60A47166E3E5B4034D4EE321DBE19B342E85B21544`
Converting to Montgomery curve, we get (x25519) public key:
`0959f53de990977507dd785f76e94128d16b902349d30b4f6ba4551dafbc425b`
bech32 recipient is:
`age1p9vl200fjzth2p7a0p0hd62p9rgkhyprf8fsknmt5323mtaugfdsad26fu`
I'll be using #rage (https://github.com/str4d/rage), but #age command line is exactly the same.
Anyone can encrypt file intended for that recipient:
rage --recipient age1...26fu --output super.secret.age cat.txt
Recipient having his x25519 PRIVATE key inside identity.x25519, can decrypt the file.
rage --decrypt --identity identity.x25519 --output super.secret.age unknown.txt
Bonus, identity key can be encrypted with a password:
rage --encrypt --password --output identity.x25519.age identity.x25519
And there will be password prompt, when decrypting the file using ENCRYPTED private key:
rage --decrypt --identity identity.x25519.age --output super.secret.age unknown.txt
Last but not least, If you're curious: in ed25519, the 'raw' key material is first passed through sha512, and first 32 bytes
are used as actual scalar, in x25519 there's no such step.
Finally, if you want to experiment on your own, I've made a small page, that does everything within a browser .
P.S. In case of symbol, I'd rather recommend generating fresh x25519 key pair (i.e. using rage-keygen) and associating x25519 public key with an account using some metadata key (i.e. 0x3931353532656761)