# Cannot read property 'isZero' of undefined

**URL:** <https://community.auth0.com/t/cannot-read-property-iszero-of-undefined/20972>\
**Category:** JWT.io\
**Created:** [February 5, 2019, 5:41pm UTC](https://community.auth0.com/t/cannot-read-property-iszero-of-undefined/20972 "2019-02-05T17:41:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahonarpour](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ahonarpour](https://community.auth0.com/u/ahonarpour)\
**Post date:** [February 5, 2019, 5:41pm UTC](https://community.auth0.com/t/cannot-read-property-iszero-of-undefined/20972/1 "2019-02-05T17:41:17Z")

</div>

Having trouble generating a token when running code below:  
`const token = jwt.sign(tokenPayload, tokenSecret, { algorithm: 'RS256' });`  
(where `tokenSecret` is a public key, same one used by server)

If I don’t include the `algorithm` option it works, but then the server is unable to `verify` saying `invalid algorithm`. Which makes sense because algorithm on server is `RS256` and from my understanding, `jwt.sign` uses `HS256` by default.

But when I do include the `algorithm` option, `jwt.sign` throws an error saying `Cannot read property 'isZero' of undefined` caused by the `bn` package which I assume is a dependancy of dependancies of `jsonwebtoken`.

Any ideas?

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [February 6, 2019, 8:37pm UTC](https://community.auth0.com/t/cannot-read-property-iszero-of-undefined/20972/3 "2019-02-06T20:37:01Z")

</div>

Hey there @ahonarpour, I see you have opened a [Github issue related to this](https://github.com/auth0/node-jsonwebtoken/issues/572) which is perfect for tracking purposes! I will look into this and see if I can find anything more on our side of things while the Github issue stands active. Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 21, 2019, 8:37pm UTC](https://community.auth0.com/t/cannot-read-property-iszero-of-undefined/20972/4 "2019-02-21T20:37:01Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
