0

I'm not sure if this is already supported. The use case is like this:

Using secret-key cryptography, Alice and Bob would have to devise a single cryptographic key that they will both know and use each time they send each other a message.

Alice encrypts her message using this shared key, sends the ciphertext (the message, once encrypted) to Bob, then Bob uses the same key again to decrypt, ultimately reading the message.

An adversary cannot decrypt the message without knowing the secret key.

It looks like the following set of commands to encrypt and decrypt data:

// The p2p paload message that will be encrypted
message = 'the data'

someonesPrivateKey=ecc.PrivateKey.fromSeed('peerB')
someonesPublicKey=someonesPrivateKey.toPublic()

myPrivate=ecc.PrivateKey.fromSeed('peerA')
myPublic=myPrivate.toPublic()

encryptedMessage = ecc.Aes.encrypt(myPrivate, someonesPublicKey, message)
assert.equal(message, ecc.Aes.decrypt(someonesPrivateKey, myPublic, encryptedMessage))

Your Answer

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

Browse other questions tagged or ask your own question.