Finally Building a Solid (and Rusty) Foundation for the Internet

For almost the first time since the creation of the Internet, we have a programming language that provides us with native code but…

Photo by Jay Heike on Unsplash

Finally Building a Solid (and Rusty) Foundation for the Internet

For almost the first time since the creation of the Internet, we have a programming language that provides us with native code but overcomes many of the problems of version control and memory. And that language is Rust. While the learning curve may be steep, many companies are moving their core infrastructure towards Rust. So while you will see JavaScript in the browser, it is in the back-end where we need to increasingly build secure code.

So, I’ve been working on proxy encryption, where Alice can share encrypted data with Bob, and use the transformation of her private key to Bob’s private key. In fact, we never have to reveal the content of the original data. Initially, Alice will generate an encryption key, and then protect it with her public key. The only key which can decrypt it is then Alice’s secret key:

Now we can create a transformation key using Alice’s private key and Bob’s public key:

Now, Bob will be able to discover the original key with his private key. And, so I have coded the proxy encryption method into Rust here:

https://asecuritysite.com/rust/rust_transform

But, we can do even more with Rust, and it’s one of its great features in building a foundation. With this, we can now compile the Rust library into binary code and then use JavaScript (in the browser) or Node.js (on the back-end) to call up the Rust code. With this, a Rust binary is created using Node-pre-gyp and which creates a pre-compiled binary, which is then customised for the target.

For the Ironcorelabs install, we use the following to install a binary into Node.js:

npm install @ironcorelabs/recrypt-node-binding

and which then uses the Node-Pre-Gyp tool to install a binary file:

Then we can use Node.js integration [here] (to bind to the Rust binary code). The code is [here]:

A sample run [here]:

Plaintext value:  Hello
Ciphertext value: 6b3c32ab82f709f617b5c4be1dbf794536a5ae99e3625ede6d594667470a913e51490439cfb28b5541dff0114a2659bf03e65b85a4e9f9f1fede4794361e3dbe6145163f870706846f00917eab17dd3e318aa5540bbe619c4e2c57c9565b1b4c51151dd30d80727ad2fd80574faf5a1d5e9671f76ad1ca46d15625a7784472ce2e01a47db4705e5a63c705b06176f4fed43833e3c294ca3b9ddf39dfc2fc02c349b239f8d462521e53c34e7524024e0ef864ae2c1f83884abacdcc96494e14ab4920cf05d3b4ee40374ee0efb45d13c448713d687378dec66a1dc39e23d404bc40c06cde5c1f1c4c27a9df9317478e106109d6d58d9011919acb137adbca4be673a1d9436b3317425096766a30b578d0cc2b223a63ef114c4c762cc70f50f43d7b0a89ba1e2bd4724ad465be74462c333b5bb140d9f20349b4fc459d751102d1292334d3b8012c277dce7394e7ad6fcab7884c24b581ddbeec3ae43f5868b29b3b0826576f7cd2a3795dc2fa40dad75c59adc1a3c93ab0e243a346c9a41b93e7
Decrypted value: Hello

Conclusions

And, so, we may see a move away from our C++ foundation code, towards Rust, and for us to build binaries that can scale onto many different platforms.

Here are more Node.js examples:

https://asecuritysite.com/node

and for Rust:

https://asecuritysite.com/rust/