Code Monkey home page Code Monkey logo

gmp-wasm's People

Contributors

daninet avatar yuristuken avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gmp-wasm's Issues

crashy behavior with Kotlin/JS

I've been trying on and off to get gmp-wasm to work for me, and I'm getting a variety of weird behaviors. I suspect one of my bugs can be blamed on Kotlin/JS and another might be related to gmp-wasm. I've created a minimal repository that allows the bugs to be reproduced:

https://github.com/danwallach/gmp-wasm-kotlin

The README.md documents how to run the code and has the outputs. In short, I built a Kotlin BigInteger class that speaks directly to the mpz functions, and tries to manage gmp-wasm memory using FinalizationRegistry (so when the JavaScript wrapper object is garbage collected, it will tell gmp-wasm to free the corresponding mpz object).

I'd appreciate if you could take a look at this.

Memory management

I'm looking at the way you're managing memory, by keeping mpz_t_arr for all the temporary values and then blowing all of them away when the surrounding context finishes. I'm curious if you've looked at the possibility of leveraging finalizers, to allow the JavaScript garbage collector call back to you when it's time to ultimately call mpz_t_free.

This would allow higher-level logic to write arithmetic expressions as normal, without having to worry about object lifetimes.

TypeScript "declaration file"?

For what it's worth, I want to call this library from Kotlin, which apparently would be easier if there was a declaration file (*.d.ts). Not that I have any idea what that is, but I'm curious if it's on your agenda to make such a thing.

Feature request: xmpz's bit range feature, byte arrays

First, thank you for this library. It's exactly what I need.

GnuMP has a very useful feature for selecting bit ranges from an xmpz. For my particular application, this allows for an optimization worth about 9x (precompute to optimize modular exponentiation for known bases).

Python binding: https://gmpy2.readthedocs.io/en/latest/advmpz.html

I'd love something analogous to the "bit slice" read feature. I don't actually need anything else, but I imagine others might want the full suite of xmpz mutability features.

Also, in terms of general purpose features, it would be handy to have input and output as byte arrays. Java BigInteger defines this to be big endian, twos complement, which seems as good as anything else you might do.

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.