Chia-Network / bls-signatures

BLS signatures in C++, using the blst library for BLS12-381
Apache License 2.0
297 stars 212 forks source link

Cannot read property 'key_gen' of undefined #285

Closed Rasika9596 closed 2 years ago

Rasika9596 commented 3 years ago

Hello,

I've installed bls-signatures using 'npm i bls-signatures --save' and using the below code,

const loadBls = require("bls-signatures");
 const BLS = await loadBls();
    var seed = Uint8Array.from([
      0, 50, 6, 244, 24, 199, 1, 25, 52, 88, 192, 19, 18, 12, 89, 6, 220, 18,
      102, 58, 209, 82, 12, 62, 89, 110, 182, 9, 44, 20, 254, 22,
    ]);
    var sk = BLS.AugSchemeMPL.key_gen(seed);
    console.log(sk);
    var pk = sk.get_g1();
    console.log(pk);

But I'm getting this error,

image

package.json,

image

Could anyone please help here?

Rasika9596 commented 3 years ago

Hello,

Can anyone please help me here?

hoffmang9 commented 3 years ago

The version on npm is quite out of date and we are attempting to rectify that. The version direct from this repository is what you should use.

ChiaMineJP commented 3 years ago

I propose you 2 options. (Reference: https://github.com/Chia-Mine/bls-signatures/tree/npm)

1. Build npm module for yourself

  1. Check node/cmake/emscripten exists in your environment or install them if they are missing.
    See https://emscripten.org/docs/getting_started/downloads.html for emscripten installation.
    For my current environment, I use

    • Ubuntu Ubuntu 20.04.2
    • emsdk 2.0.23 (77b065ace39e6ab21446e13f92897f956c80476a)
    • node-14.15.5-64bit
    • cmake 3.16.3
  2. Git clone from the trusted source code

    cd <directory you like>
    git clone https://github.com/Chia-Network/bls-signatures
    cd bls-signatures
    git checkout f9db7faa370c4743e48be8a9823232e4d906c4d0 # You will be warned by git as it is `detached-state` but don't worry.
  3. Build js-binding

    mkdir js_build && cd js_build
    cmake ../ -DCMAKE_TOOLCHAIN_FILE=/PATH-TO-EMSDK-ROOT/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
    cmake --build . --
  4. Check out the products

    
    ls -l js-bindings/

You will see output like this.

The files should be the same as contents of this branch except for this README

#

drwxrwxr-x 4 chiaminejp chiaminejp 4096 June 16 11:09 CMakeFiles

-rw-rw-r-- 1 chiaminejp chiaminejp 16817 June 16 11:09 Makefile

-rw-rw-r-- 1 chiaminejp chiaminejp 6591 June 16 11:09 README.md

-rw-rw-r-- 1 chiaminejp chiaminejp 4091 June 16 11:09 blsjs.d.ts

-rw-rw-r-- 1 chiaminejp chiaminejp 47671 June 16 11:10 blsjs.js

-rwxrwxr-x 1 chiaminejp chiaminejp 248515 June 16 11:10 blsjs.wasm

-rw-rw-r-- 1 chiaminejp chiaminejp 1002 June 16 11:09 cmake_install.cmake

-rw-rw-r-- 1 chiaminejp chiaminejp 100600 June 16 11:09 package-lock.json

-rw-rw-r-- 1 chiaminejp chiaminejp 1290 June 16 11:09 package.json

drwxrwxr-x 2 chiaminejp chiaminejp 4096 June 16 11:09 tests

4. You can install the npm by path such as:  
`npm install /path/to/the/js-bindings` in your project folder.

## 2. Install my npm which is compatible to bls-signatures at commit f9db7faa370c4743e48be8a9823232e4d906c4d0

Just execute command like this:
```shell
npm install @chiamine/bls-signatures # or yarn add @chiamine/bls-signatures
Rasika9596 commented 3 years ago

Thank you so much! I'll give it a try and get back.

github-actions[bot] commented 2 years ago

'This issue has been flagged as stale as there has been no activity on it in 14 days. If this issue is still affecting you and in need of review, please update it to keep it open.'

github-actions[bot] commented 2 years ago

'This issue was automatically closed because it has been flagged as stale and subsequently passed 7 days with no further activity.'