3 ms·
Re #2 There’s this [1] tc39 proposal. You could also hack a solution using dynamic method names and Symbols. [1] https://github.com/tc39/proposal-private-meth
by goliatone 7y ago
Re #2 There’s this [1] tc39 proposal.
You could also hack a solution using dynamic method names and Symbols.
[1] https://github.com/tc39/proposal-private-methods/blob/master/README.md https://github.com/tc39/proposal-private-methods/blob/master...
- csande17 7y agoI don't think the private methods proposal will help with cryptography at all. The "security" it provides boils down to making it difficult for code outside the class to access the value, like you can already do with closures like this: function makeCounter() { var x = 0; return function() { return ++x; }; } It doesn't help at all with side-channel attacks, which are the main reason why it's hard to safely perform cryptographic operations in a just-in-time interpreted language like JavaScript. It also doesn't stop rogue scripts on the same page from pulling the user's passwords/keys right out of the password field, URL bar, localStorage, or wherever else your script gets them from.