0

我运行下面的代码片段,我收到错误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
4

0 回答 0