bitwiseshiftleft / sjcl

Stanford Javascript Crypto Library
http://bitwiseshiftleft.github.com/sjcl/
Other
7.18k stars 986 forks source link

TypeError: Cannot read property 'elGamal' of undefined #423

Open medi11 opened 3 years ago

medi11 commented 3 years ago

Here is a code snippet. whenever I execute it I get the above error `const sjcl = require("sjcl"); var gkey1 = sjcl.ecc.elGamal.generateKeys(384, 10); var alicekeys = gkey1.pub.kem(10);

var gkey2 = sjcl.ecc.elGamal.generateKeys(384, 10); var bobkeys = gkey2.pub.kem(10);

var aliceshared = alicekeys.key; var bobshared = gkey2.sec.unkem(alicekeys.tag); `

BruceMacD commented 2 years ago

In order to enable some sjlc modules it is required to re-compile the library yourself.

$ git clone https://github.com/bitwiseshiftleft/sjcl.git
$ cd sjcl
$ ./configure # Requests for extensions go here, e.g. --with-ecc --with-srp
$ make sjcl.js
$ make test  # If any of the tests fail, beware.

Then reference your build of sjlc in your code:

import sjcl from <path_to_local_build>/sjcl";