javascript – Elliptic, genkeypair, not generating, html, js-ThrowExceptions

Exception or error:

so I am trying to create a key pair for a blockchain using the elliptic library. When I try to generate the keypair, then console.log it to the console, it does not seem to appear, meaning it is not generating. How would one solve this?

relevant code:

<script src="https://cdn.jsdelivr.net/npm/elliptic@6.4.1/lib/elliptic.min.js"></script>
const EC = new elliptic.ec;
const ec = new EC('secp256k1');
const keyPair = ec.genKeyPair(); // {ec: EC, priv: BN, pub: null}
const pk = JSON.stringify(keyPair.getPublic());
console.log(pk);
</script>

web browser console:

elliptic.js:3 Uncaught ReferenceError: exports is not defined
    at elliptic.js:3
(anonymous) @ elliptic.js:3
VM298:137 DomDistiller debug level: 0

elliptic.js:3
specifically line that reads “var elliptic = exports;”

'use strict';

var elliptic = exports;

elliptic.version = require('../package.json').version;
elliptic.utils = require('./elliptic/utils');
elliptic.rand = require('brorand');
elliptic.curve = require('./elliptic/curve');
elliptic.curves = require('./elliptic/curves');

// Protocols
elliptic.ec = require('./elliptic/ec');
elliptic.eddsa = require('./elliptic/eddsa');

thanks!

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *