const pbox = require('private-box') const sodium = require('sodium').api const keypair = sodium.crypto_sign_keypair function b64ify_keys(k) { return { 'public': k.publicKey.toString('base64'), 'secret': k.secretKey.toString('base64'), } } function simple() { const keys = [keypair(), keypair()] const msg = "this is generated by test-case-creator/index.js (function simple())" const ctxt = pbox.encrypt(Buffer.from(msg), keys.map(k => sodium.crypto_sign_ed25519_pk_to_curve25519(k.publicKey))) return { cypher_text: ctxt.toString('base64'), msg: msg, keys: keys.map(b64ify_keys), } } console.log(JSON.stringify(simple(), null, 2))