UNPKG

@stellot/crypto

Version:

Crypto libraries for front and backend

13 lines (12 loc) 584 B
import { StrKey } from 'stellar-sdk'; import { encrypt as _encrypt, decrypt as _decrypt } from './ed25519-box'; export function encrypt(keys, to, input, nonce, authenticate = true) { const privKey = keys.rawSecretKey(); const pubKey = StrKey.decodeEd25519PublicKey(to); return _encrypt(privKey, pubKey, input, nonce, authenticate); } export function decrypt(keys, from, input, nonce, authenticate = true) { const privKey = keys.rawSecretKey(); const pubKey = StrKey.decodeEd25519PublicKey(from); return _decrypt(privKey, pubKey, input, nonce, authenticate); }