indutny / bn.js

BigNum in pure javascript
MIT License
1.2k stars 151 forks source link

BN mul #210

Closed geghamjivanyan closed 5 years ago

geghamjivanyan commented 5 years ago

I have 2 32-byte length BN objects - bn1 and bn2. bn = bn1.mul(bn2); bn.length = 64

Is it possible to multiply 2 BN's without changing length as it works in C++, Python etc?

fanatid commented 5 years ago

This is not possible with bn.js.. can you explain how this possible in python?

geghamjivanyan commented 5 years ago

Python is a wrapper of C++ code. So if anything is possible, then it is possible in C++. For example OpenSSL lib https://github.com/openssl/openssl.

And now I have a compatibility problem between Python and JS due to BN size.

fanatid commented 5 years ago

When Python become wrapper of C++ code?

If you want stay with same length of number you can apply .mod after multiplication. Of course this will be slower than just multiplication with specific length, but this will works.

geghamjivanyan commented 5 years ago

When Python become wrapper of C++ code? I mean Python lib which I use for BN is a wrapper of C++ Lib.

geghamjivanyan commented 5 years ago

It is worked with .mod. Thanks