2

I was trying to figure out a way to encrypt a small payload in a transaction memo to anonymize the memo id without having to store anything on the server. So can anyone help me to encrypt the memo text using sender's private key and receiver's public key? Thanks for any help.

I had gone through this link :https://github.com/stellarguard/secret-memo but I want asymmetric encryption.

2

Assuming javascript, you can use the Box-functionality in tweetnacl, and use https://github.com/dchest/ed2curve-js to convert the keys from ed25519 to curve25519.

const theirPublicKey = ed2curve.convertPublicKey(...);
const mySecretKey = ed2curve.convertSecretKey(...);
nacl.box(message, nonce, theirPublicKey, mySecretKey);
  • hey can you please let me know how can I specify messages in these case... I mean what will be the format for declaring messages ..I had tried var message = nacl.util.decodeUTF8('Keep silence'); but it is not working I am getting error ... so please help me – pri Sep 14 '18 at 6:38
  • I've never used the javascript version so I have no idea. Have you tried what they do in the tests? I.e., github.com/mkrecny/tweetnacl-js/blob/… – Johan Stén Sep 16 '18 at 4:41
0

It's very possible to use existing functionalities of Stellar SDK.

Considering the following Python implementation to get key pairs from the wallet via seed:

    from stellar_base.keypair import Keypair
    from nacl.signing import SigningKey, VerifyKey
    from nacl.bindings import crypto_box_beforenm
    # Create a keypair to do many things
    kp = Keypair.from_seed(seed)

    # Now you have key pair to do many things

    sk = SigningKey(kp.raw_seed()).to_curve25519_private_key()._private_key
    pk = VerifyKey(kp.raw_public_key()).to_curve25519_public_key()._public_key
    address = kp.address().decode()
    seed = kp.seed().decode()

Please refer to this project https://github.com/hmatejx/Interstellar-Whisper to have a whole workable demo.

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.