-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BigInt support #510
Comments
@likern Yes, it is technically possible, though non-trivial. Unfortunately it is not on our short term roadmap since BigInt isn't used internally by our apps :-( |
Can I ask what is used instead for internal apps? Or for internal apps there was no need for larger than nomral numbers? |
Bump, this is quite important for all crypto-related apps, which is the future anyways. |
Another friendly bump. Facebook's recent rebranding to Meta underscores how important crypto-native mobile apps are and will continue to be. Flutter already has Right now, the workaround is to use JSC (limited to only iOS 14 and doesn't work on Android) or v8 (Android only). It's not ideal. Especially if Hermes is becoming the default JS engine. |
Hey! I've played around with trying to expose BigInt functionality through JSI to use C++ based big-number types, as well as using the JSBI polyfill - none of those support the Would be great to have that baked into Hermes, I would love to have a shot at this myself if you can give me any pointers with relevant lines of code in this repo cc @tmikov |
@mrousavy adding BigInt would touch a lot of components:
Overall, I would say that it is a pretty involved project, but is certainly doable. I am not actively working on Hermes anymore (I am currently focused on Juno), so I will let members of the Hermes team chime in here. cc: @neildhar |
Unfortunately, implementing BigInt is still not on our immediate roadmap. |
If it's possible to bring up BigInt with the team and possibly prioritize it, that would be very much appreciated. |
I want to point out that coming Temporal proposal (as I understand) is also using bigint, at least in polyfill. |
Here's another reason to support The widely used web3.js library is rewriting their library using modern TS and also replacing their |
Is there any update on this? Thanks. |
We have many heard complaints about the lack of |
Hi everyone, First of all, apologies for the delay in providing updates. Second, I am happy to say that we have been working on BigInts internally :). There should be some news around this soon! Please bear with us a little longer... John Paul |
Looking forward to it. |
@jpporto Any news on this? |
Hi @jzxchiang1, We're still (actively) implementing BigInts. We're currently trying to minimize the overall impact of adding BigInt to the VM. It is our goal to ensure that adding BigInt doesn't cause any meaningful performance regressions in non-BigInt usage (e.g., Numbers). Please bear with us a little longer. |
Any updates on this? Anxious to have BigInt in hermes in order to allow crypto packages to work correctly in react native. |
Hi, We're working to minimize the impact adding BigInt has in the VM. I want to point out, however, that js BigInts are not suitable to crypto workloads. Your best option is to use a native crypto library, add js bindings, and call those from your JS app. John Paul |
I hate to ask this, but do you have any idea of a timeline for when BigInt will be launched? |
I wish I had something more specific to say, but at this point I don't have any ETAs on when this support will land. :-( |
Hi, We have started the process of merging BigInt to hermes! It is a relatively large change (about 50 diffs), so it will be a while before everything makes to github. Hopefully everything will be ready by next week. :) Thank you for your patience! |
Good morning, All commits have been merged, and BigInt should be available on hermes starting in aa83f8bd6f536d4d0fc45fa092eecb360230dc7f. Here are the pre-built cli binaries for linux(sha256), macos(sha256), and windows(sha256). I'll close this issue as the feature is now implemented. Please report any problems in new issues. John Paul |
Incredible thank you. Will it be released with the next version of Hermes/RN? |
@jzxchiang1 it will be present with RN 0.70 |
For anyone's reading @jpporto 's comment that "bigints are unsuitable for crypto":
The advice is uninformed. First of all, using native bindings does not guarantee any resistance against timing attacks. Because, JS runtime would still be there. JS is garbage-collected language. And there are no guarantees your uint8arrays or any other data structure would be cleaned properly at some point. If you want 100% constant-time code, your best bet is using low-level languages directly, but even they are not the 100% solution: LLVM & other compilers could "optimize out" constant timeness. Also, you will need to not use branches (if differing conditions take different time to execute, you're in trouble). Also you will need to ensure secret data is not used as array indexes. Don't forget about division: It takes variable time on some cpus. Second, "Using a native crypto library" means users would need to run unsigned wasm binaries that may as well contain malware & trojans. Using pure javascript code allows every JS developer to verify the js code is indeed the one published on GitHub. Compiling C / Rust code to wasm produces huge binaries, commonly without using reproducible builds. The binaries may, or may not contain some dangerous garbage. NPM got hacked. GitHub got hacked. Developer accounts can and will get hacked. Binaries will be replaced with malware without account owner's knowledge. So using bigints js library is not worse than a bytebuffer-based native solution. I think, it's better. In fact, i've developed some bigint crypto libraries, which already received security audits. |
Hi Paul, Thank you for your feedback. I just wanted to point out that that's not my advice. Rather, I just quoted the JS spec, ipsis litteris. |
@jpporto can you link to where it says that? |
to clarify: MDN is not the spec, and not authoritative in any way. |
All I see is the MDN page (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#cryptography) which says the following:
This statement has limited scope and isnβt relevant to the debate at hand, plus as @ljharb mentioned this is not authoritative. |
(Apologies for the MDN vs. spec confusion. My bad.) I should have started by saying I am no crypto expert. Far from it, I have no technical knowledge about the area as I prefer working on compilers and runtimes. While ecma262 doesn't mention crypto, the bigint proposal (which is arguably what I should have quoted before) does:
I strongly believe in being transparent, so after having told krpeacock that BigInts were coming after he specifically asked about the feature in the crypto context, I deemed prudent to come on the record with this pitfall. This doesn't mean I am telling anyone not to use BigInts for crypto -- I added the feature for the community to use it after all! :) --, just for those who do, to do so carefully. |
I just read react-native blog post about 0.70 and Hermes integration and they say that BigInt support is "Ongoing work". I'm not 100% sure what that means. @kelset do you know if it finally made it (to the 0.70 rc)? |
as far as I can tell, in 0.70 we have the BigInt commits - so it should work. |
Thanks for getting this over the finish line. Although it may not seem like it, this is a big deal. |
Hi π Quick question: Does the new BigInt implementation in Hermes support the |
Hi, Hermes supports bigint literals, so you should be able to use 12345n. :) John Paul |
I think you have some bugs with regards to bigint exponentiation 123n ** 256n. Has this been tested thoroughly? |
Hi, I am not sure if the testing that's been done would be considered extensively by you, so I'll refrain from commenting on that. However, I don't see any issues with 123n ** 456n (hermes and v8 agree on what the result). If you have an issue, please report it on a new bug. I'll lock this one as this thread is too old, too long, and possibly include way too many people. John Paul |
Summary: The BigInt exponentiation code currently truncates the first digit of a BigInt from 64 to 32 bits. This means that for a single digit BigInt exponent that has a value larger than `UINT32_MAX`, we end up truncating the exponent and producing an incorrect value. To fix this, do not truncate the exponent until after we have guaranteed that it will fit in 32 bits. Reviewed By: fbmal7 Differential Revision: D47275000 fbshipit-source-id: 881b7653d0394b88aad9db11fb6f99e675a7e38f
Problem
Hello βπ» I've looked at documentation and source code and couldn't find
BigInt
type.@tmikov Is it possible to add
BigInt
support?The text was updated successfully, but these errors were encountered: