Comments (13)
I suggest to use browserify for this:
- Write tweetnacl in pure node
- Use https://github.com/crypto-browserify/randombytes
browserify nacl-fast.js -s nacl > dist/nacl-fast.js
This solves all the requirements stated above (it also considers self
), except AMD support.
Its the route we took successfully with PouchDB.
from tweetnacl-js.
Thanks, I'll think about it, but I don't want to introduce another build tool just for a few lines of code.
from tweetnacl-js.
I totally understand your objections. Just to add: since here is already a build step (uglifyjs) it does not add more maintenance efford. And browserify has been made exactly for this purpose.
from tweetnacl-js.
@RainaBatwing do you think it will solve #59?
@jo where can I take a look at what browserify replaces Buffer with? Thanks!
from tweetnacl-js.
https://github.com/feross/buffer
from tweetnacl-js.
@jo thank you! It's kinda big, but would solve #44, #38, and #59. Unfortunately, it's using MIT license, and I'd like to keep TweetNaCl public domain. Maybe I'll write my own? :-) Does browserify allows custom replacements for Node objects?
from tweetnacl-js.
Yes, I think in package.json you can just point to a file or (a node module):
"browser": {
"buffer": "./lib/buffer.js"
}
https://github.com/substack/node-browserify#browser-field
Extensive docu can be found in the Browserify Handbook.
from tweetnacl-js.
I would like to see this change, but I'd much rather you use the browserify Buffer than invent a new one. MIT license is not a restrictive one, and having more code that can potentially introduce bugs seems antithetical to the spirit of tweetnacl as a small audit-able library.
If there really are users who cannot use MIT-licensed software but can accept third party public domain code, they could open an issue later and we can reconsider then?
from tweetnacl-js.
Thanks for opinions, everyone. I'm sorry that I'm so picky about this change, but I just can't handle this little fact:
- Buffer.js — 38 KB
- nacl.js — 33 KB
I know, an average image on a website is bigger than that, but still I'd like to avoid including a library for frigging byte arrays that's bigger than the whole project. Especially, since Buffer is here mostly for Node.js, which is better served by a native NaCl.
from tweetnacl-js.
So it seems like the arguments are:
Node Buffers (and browserify shim):
- One code base to audit for buffers
- In theory, better audited since it's more widely used
- More consistent buffer implementations
- Solves a few outlying bugs
TweetNaCl typed arrays:
- Typed arrays are native to the browser
- Small, concise code that should be easy to audit
Personally, I'd say stick with the typed arrays, since it does make more sense in the browser. TweetNaCl is great for the client-side, and if you'd like to run it under Node, that's easily doable even with the typed arrays. But, like @dchest mentioned, under Node you really could just use a library with native NaCl bindings, which would definitely offer better performance, and would probably use buffers as well.
So, +1 for the current implementation from me. Small and simple on the client-side, but still fairly simple to use on the server-side if necessary.
from tweetnacl-js.
Another option is to implement both Buffers and typed arrays as @RainaBatwing proposed in #59. If you pass a Buffer to functions, they will return Buffers, if you pass a typed array, they will return typed arrays.
from tweetnacl-js.
My interest in using tweetnacl-js is because I'm developing cross platform p2p apps using NW.js and depending on platform-specific code makes software update distribution much more complicated. For my things, there are no clients or servers. I'd like to have just one version which works on every platform, and I'd like all the application specific code to be in javascript, so anyone can take it and alter it easily. I strongly dislike the idea of shipping binary packages, but most users do not have C build tools on their computer.
from tweetnacl-js.
Use react-native-tweetnacl npm package for using tweetnacl in mobile apps.
from tweetnacl-js.
Related Issues (20)
- Please also export "pack" function in nacl.lowlevel HOT 2
- Box keypair from seed? HOT 2
- Public-key authenticated encryption (box) without authentication HOT 1
- Generating keypair leaks memory HOT 9
- setPRNG HOT 4
- nacl.sign.keyPair & nacl.box.keyPair have inconsistent pubkey HOT 6
- How to use ed25519 secret key in php (Should I convert it to to PEM/OpenSSH compatible format?) HOT 4
- How to add public keys (EC points)? HOT 6
- Hierarchical Deterministic (HD) style extended keys HOT 1
- Support Ed25519ph (HashEdDSA) RFC 8032 Section 5 HOT 2
- Converting ed25519 keys from elliptic lib
- Security vulnerability: nacl.sign.detached accepts invalid keys HOT 8
- no PRNG in react-native HOT 1
- ed25519 verification is malleable and accepts forged signatures HOT 7
- tweetnacl for signal protocol keypairs?
- decrypt with box always return null HOT 1
- This package is unlicensed HOT 1
- Licensing library under MIT HOT 1
- 2.0 or something revamped? HOT 1
- Improve Readability of Code Snippets in README HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tweetnacl-js.