Currently, stellar-base is using synchronous cryptography calls for transactions hashing, signing, and verification.
This is sub-optimal in terms of general JavaScript-based applications development because SHA256 and ED25519 CPU-intensive computations block the main thread, an obvious antipattern for JS runtimes, which are single-threaded by design. In case of server applications this can also potentially provide an exploitable surface for DoS attacks for NodeJS or resource exhaustion for cloud edge-computing runtimes like Cloudflare Workers and Vercel Functions.
Besides that, packages required for the cryptography, significantly increase size of the client-side bundle.
It makes sense to change API of all hashing/signing functions and methods exposed by stellar-base to return Promise, and therefore, make all these functions async.
Motivation:
- Such CPU-intensive calls won't block the main thread.
- This will allow us to drop
sha.js and tweetnacl dependencies, replacing them with native built-in calls (NodeJS Crypto API and browser-based Web Crypto API). At this moment,
- Since this is a breaking change, which will require some work from maintainers to update client-side code, it makes sense to align this change with other breaking changes caused by Soroban-related updates. Otherwise, we'll have to wait for the next opportunity because this breaking change by itself is not that significant to force ecosystem developers to do refactor on their side.
If this looks good, I'll prepare a pull-request.
Currently,
stellar-baseis using synchronous cryptography calls for transactions hashing, signing, and verification.This is sub-optimal in terms of general JavaScript-based applications development because SHA256 and ED25519 CPU-intensive computations block the main thread, an obvious antipattern for JS runtimes, which are single-threaded by design. In case of server applications this can also potentially provide an exploitable surface for DoS attacks for NodeJS or resource exhaustion for cloud edge-computing runtimes like Cloudflare Workers and Vercel Functions.
Besides that, packages required for the cryptography, significantly increase size of the client-side bundle.
It makes sense to change API of all hashing/signing functions and methods exposed by
stellar-baseto returnPromise, and therefore, make all these functions async.Motivation:
sha.jsandtweetnacldependencies, replacing them with native built-in calls (NodeJS Crypto API and browser-based Web Crypto API). At this moment,If this looks good, I'll prepare a pull-request.