Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Web Crypto APIs #737
The goal of this PR is to make the cryptographic operations performed by blockstack.js more efficient -- less CPU & memory intensive and smaller file size (especially for mobile).
This primarily improves the performance of storage and authentication functions.
This PR includes a refactor of all usages of applicable cryptographic operations to use the W3C native Web Crypto APIs.
The dist bundle size is now down to 550KB.
The linter rules were tightened up, especially around Promise/async/await handling. This helped catch several instance of bugs like
For updates on our effected consumer apps, see:
Type of Change
Does this introduce a breaking change?
This is a breaking change and requires a major version update.
Note: the Web Crypto APIs only provide async functions, so the changes to use these propagated up to several other functions in the call graphs.
I kept a list of all functions that were previously synchronous which now return promises. Most of these are not public API functions. These have been listed in the CHANGELOG:
Are documentation updates required?
Possibly -- the API reference docs will be auto updated, but any tutorials referencing the above functions may need updated.
…crypto. * Remove dependency on ripemd160 package, replace with node.js crypto usage. * Import only what is used from the `crypto` lib.
* develop: (42 commits) Update changelog Remove unneeded line Oops, 4 instead of 3 passes required. Test `GaiaHubError` values Include correct error code Fix error message test Modify getFile test to expect throw on 404 instead of null Add `await` when getting blockstackErrorFromResponse Fix style issues Convert to async function + ts syntax Make functions `async` to account for async method for getting error from rrsponse getgaiaErrorResponse method (allow text or json body) Fix test + styling issues Get rid of getResponseDescription, integrate GaiaHubError Include response data in GaiaHubError types ErrorType -> ErrorData Add GaiaHubError, make gaia errors extend that instead FileNotFound -> DoesNotExistError centralized gaia error handling function support PayloadTooLargeError ... # Conflicts: # .vscode/launch.json # mdincludes/script-dist-file.md # package-lock.json # package.json # src/encryption/ec.ts
* Add dev dependency for webcrypto lib (has compatbility wrappers for node.js) for unit testing
@@ Coverage Diff @@ ## develop #737 +/- ## =========================================== + Coverage 68.62% 69.15% +0.53% =========================================== Files 57 65 +8 Lines 3429 3693 +264 Branches 623 658 +35 =========================================== + Hits 2353 2554 +201 - Misses 778 821 +43 - Partials 298 318 +20
@yknl If you are still running into test failures, can you ensure Node.js >=10 is being used, and try wiping your