TypeError: Cannot read property 'elGamal' of undefined

150 views Asked by At

Im running the below code snippet and I'm getting the error TypeError: Cannot read property 'elGamal' of undefined

    var sjcl = require("sjcl");
    var keys = sjcl.ecc.elGamal.publicKey(); //choose a stronger/weaker curve

    var pubkem = keys.pub.kem(); //KEM is Key Encapsulation Mechanism
    var pubkey = pubkem.key;
    var seckey = keys.sec.unkem(pubkem.tag); //tag is used to derive the secret (private) key

    var plain = "hello world!";
    var cipher = sjcl.encrypt(pubkey, plain); //defaults to AES
    var result = sjcl.decrypt(seckey, cipher);

    console.log(plain === result); //true
0

There are 0 answers