mattrglobal / node-bbs-signatures

An implementation of BBS+ signatures using rust and typescript for node.js
Apache License 2.0
57 stars 23 forks source link

Changing between installed versions of this package fails to update the associated native node module #134

Open tplooker opened 3 years ago

tplooker commented 3 years ago

When changing between installed versions of node-bbs-signatures it appears that the native node module './index.node' is not always being downloaded and updated by node-pre-gyp leading to issues, especially when changing between versions of the library that feature breaking API changes.

How to reproduce

Start with new empty project and install node-bbs-signatures

yarn add @mattrglobal/node-bbs-signatures@0.10.0

Then run the following

node
require("./node_modules/@mattrglobal/node-bbs-signatures/native/index.node")

Which will output

{ bls_generate_blinded_g2_key: [Function],
  bls_generate_blinded_g1_key: [Function],
  bls_generate_g2_key: [Function],
  bls_generate_g1_key: [Function],
  bls_secret_key_to_bbs_key: [Function],
  bls_public_key_to_bbs_key: [Function],
  bbs_sign: [Function],
  bbs_verify: [Function],
  bbs_blind_signature_commitment: [Function],
  bbs_verify_blind_signature_proof: [Function],
  bbs_blind_sign: [Function],
  bbs_get_unblinded_signature: [Function],
  bbs_create_proof: [Function],
  bbs_verify_proof: [Function],
  bls_verify_proof: [Function] }

Now change the installed version of the package

yarn add @mattrglobal/node-bbs-signatures@0.9.0

And run

node
require("./node_modules/@mattrglobal/node-bbs-signatures/native/index.node")

Note the output

{ bls_generate_blinded_g2_key: [Function],
  bls_generate_blinded_g1_key: [Function],
  bls_generate_g2_key: [Function],
  bls_generate_g1_key: [Function],
  bls_secret_key_to_bbs_key: [Function],
  bls_public_key_to_bbs_key: [Function],
  bbs_sign: [Function],
  bbs_verify: [Function],
  bbs_blind_signature_commitment: [Function],
  bbs_verify_blind_signature_proof: [Function],
  bbs_blind_sign: [Function],
  bbs_get_unblinded_signature: [Function],
  bbs_create_proof: [Function],
  bbs_verify_proof: [Function],
  bls_verify_proof: [Function] }

Which is incorrect for the 0.9.0 package which did not feature blinded key generation support and the function bls_generate_g2_key was instead called bls_generate_key

Intermediary Solution

It is recommended when changing between installed versions of the library to uninstall and reinstall the library at the new targeted version to ensure the correct native node module is downloaded.

tplooker commented 3 years ago

cc @colinyip who observed and documented this issue.