wirelineio / wireline-core

GNU Affero General Public License v3.0
1 stars 1 forks source link

Assess move to Dat 7 #147

Closed dboreham closed 2 years ago

dboreham commented 4 years ago

Previous dup: https://github.com/wirelineio/specs/issues/9

dboreham commented 4 years ago
okdistribute commented 4 years ago

see https://github.com/decentstack for a contained example of required migration work.

okdistribute commented 4 years ago

We cannot update to next hypercore-protocol yet. @substack just found that it doesn't work in the browser. It requires extra routines in sodium-universal that are not implemented. It will require aead methods to be implemented in https://github.com/sodium-friends/sodium-javascript

See the overview of methods not implemented in Javascript here: https://github.com/sodium-friends/sodium-universal

If it is crucial to update soon, it would be best to contract someone to complete this work. I don't expect that this is being prioritized by core maintainers.

okdistribute commented 4 years ago

Assigning to rich. We need to assess if this is now a priority, and if so, it will likely require an outside contract.

dboreham commented 4 years ago

Do we know why hypercore depends on sodium-universal (and hence sodium-javascript in the browser environment), rather than libsodium.js ? (libsodium.js is a straight compilation of the stock C sodium source to wasm and therefore should have feature parity with sodium-native).

tinchoz49 commented 4 years ago

The problem is the loader of libsodium.js is async. So there is no easy way to provide a hybrid solution for both worlds node and browser.

The only fix that it comes to my mind is to build an alias module for webpack and provide the same API of sodium-universal and during the initialization of the webapp wait for the libsodium to be loaded and then start the app.

Another good thing could be to organize a meeting with the mafintosh team to get a solution and help them to do it.

RangerMauve commented 4 years ago

Another thing to note is that sodium-universal has a JS fallback for when you're running the code in older browsers / engines that don't have WASM. I ran into this when integrating with react-native

okdistribute commented 4 years ago

@substack also said he'd be willing to tackle this as part of a contract, and has an idea of how it'd get done

okdistribute commented 4 years ago

he's already started: https://github.com/sodium-friends/sodium-test/pull/6/files

dboreham commented 4 years ago

Another thing to note is that sodium-universal has a JS fallback for when you're running the code in older browsers / engines that don't have WASM. I ran into this when integrating with react-native

Yeah I think that's actually the problem though -- the JS fallback is an incomplete implementation of the sodium library, missing stuff that's needed for noise protocol. As @tinchoz49 says above ideally we want a "universal" shim that selects between libsodium.js and sodium-native, falling back to sodium-javascript only if neither Node nor wasm is available.

tinchoz49 commented 4 years ago

he's already started: https://github.com/sodium-friends/sodium-test/pull/6/files

this is great!