Currently, Snap! uses its own SHA-512 implementation at src/sha512.js. While this is nice and all, it adds a lot of bloat to the codebase and it’s slower than WebCrypto; furthermore, when there’s a complicated cryptographic algorithm being handwritten in a complicated scripting language, it makes plenty of room for bugs; whatever bugs exist will likely remain for the foreseeable future, as the library used (crypto-js) was discontinued years ago, and the version used here is from 2012.
Would it be possible to switch to WebCrypto and scrap sha512.js?
Edit: For clarification, WebCrypto is a native browser API, so this would reduce the number of dependencies in Snap!.
im by no means one of the hardcore computer scientists that does stuff with cryptology, but i’d assume using a different method than what was already used would break a few projects? i dunno how, but its always a possibility, changing or deprecating a feature like this
I think that SHA-512 is mostly used within Snap!'s internals. Dev mode has a block for getting SHA-512 hashes, but it should be pretty easy to rewrite the underlying primitive so that nothing breaks.
ah, okay then. where is it used? if its like getting stuff from the server that might not be the best idea… though honestly i dont know where it would be used anyway
I kind of agree that it should change to use the new native web api. Speed honestly doesn’t really matter here, cause it’s always been fast enough and I doubt switching to the native implementation would make much difference in terms of speed. However I honestly don’t think it really matters much, so I don’t doubt that it’ll likely stay using the javascript version.
Generally Jens doesn’t like to rely on third party libraries for fear of software rot, so I would have said this is a nonstarter, but if the existing version also depends on an external library, I suspect Jens would agree that it should be updated. But just recently he’s been going crazy putting out fires for German schools, so this will be low priority and you shouldn’t hold your breath.