Day 51 Layer 0 Cryto
December 25, 2021•259 words
What I did: Continued fleshing out
Time spent: 111.917
Comments:
Working on Crypto.encrypt. Method that is hiddenly complex.
If has encryptionKey don't return encryptionKey
Return encryptionKey
Nounce and Tag
Encrypted Data.
Researching the library now to understand.
Alright understanding. However since building for:
Web
Desktop
Mobile
That means that I'll need to create an 'wrapper layer' to ensure that we can communicate.
Alright so for web we can use:
https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
For desktop we can use:
const crypto = require("crypto"); Which is node.
For mobile we can use:
https://github.com/rh389/react-native-securerandom
Now using JS magic to ensure that I can get the global context regardless of if browser or node. Function('return this')() returns global object.
What I'm doing is attaching the critical objects that we need to use within the global object. Since it'll be nesting everything under 'gaya' it'll mean that there is no chance of colliding with other objects.
Now having to figure out the global context nesting and initialization before I can write the crypto library along with how things are passed around and accessed.
The application is build like so:
let app = new Application(cryptoInterface);
Inside Application will spin up the nessary taskScheduler and to each pass an ApplicationContext reference.
Each taskScheduler will pass the ApplicationContext to each subsystem that requires it.
What does the cryptoInterface look like?
.generateRandomBytes(length) synchronous
In the future we could set it up so that it can on the offtime schedule the randomness so it can provide the random data 'instantously' since it's already pregenerated it during a slow cycle.