Giter Site home page Giter Site logo

TypeError: invalid_argument about mcl-wasm HOT 5 CLOSED

herumi avatar herumi commented on July 28, 2024
TypeError: invalid_argument

from mcl-wasm.

Comments (5)

herumi avatar herumi commented on July 28, 2024 1

I've fixed mcl.js to check type(9c61b5a)

from mcl-wasm.

herumi avatar herumi commented on July 28, 2024

Thank you for your report.

TypeError: invalid_argument sometime occurs while initializing this library.

I could not reproduce the bug. How do you call mcl.init()?

hashAndMapToG1 is not called in mcl.init().

from mcl-wasm.

jkawamoto avatar jkawamoto commented on July 28, 2024

Ah, that's true. The error occurred while calling hashAndMapToG1.

I did some unusual things to use this library from jest. Here is the essence of the code:

const mcl = require('../mcl')
const fs = require('fs')

describe('mcl-wasm module', () => {

  beforeAll(() => {
    global.fetch = async req => {
      const buf = fs.readFileSync(req)
      return {
        ok: true,
        arrayBuffer: async () => Uint8Array.from(buf).buffer,
      }
    }
  })

  test('initialize and hashAndMapToG1', async () => {
    await mcl.init()
    mcl.hashAndMapToG1(1)
  })

})

And, I got the output:

TypeError: invalid_argument
    at Int8Array.set (native)
    at /Users/junpei/src/github.com/jkawamoto/mcl-wasm/mcl.js:128:21
    at exports.G1._setter (/Users/junpei/src/github.com/jkawamoto/mcl-wasm/mcl.js:216:19)
    at exports.G1.setHashOf (/Users/junpei/src/github.com/jkawamoto/mcl-wasm/mcl.js:326:14)
    at Object.exports.hashAndMapToG1.s [as hashAndMapToG1] (/Users/junpei/src/github.com/jkawamoto/mcl-wasm/mcl.js:538:9)
    at Object.test (/Users/junpei/src/github.com/jkawamoto/mcl-wasm/__test__/test.js:18:21)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)

from mcl-wasm.

herumi avatar herumi commented on July 28, 2024

mcl.hashAndMapToG1(1)

hashAndMapToG1() accepts only string or Uint8Array.
Please use hashAndMapToG1("1") or hashAndMapToG1(new Uint8Array([1])).
These values are not same.

I will write document of mcl later.

from mcl-wasm.

jkawamoto avatar jkawamoto commented on July 28, 2024

Thanks! Converting the number to a string works for me.

I'll close this issue.

from mcl-wasm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.