arrlaravel
v1.0.36
Published
A server-side library for creating and signing oblio transactions in php and nodejs
Downloads
4
Readme
#What is this? A server-side library for creating and signing oblio transactions in php and nodejs
A server-side library for creating and signing messages between servers in php and nodejs. there is a littlebit of hardwiring in here for project oblio sites as well, which should allow you to accept messages from these sites as being "trusted" if you want. but this part is really just for our own purposes and backend stuff.
Compatibility
tbh this might be the first library in history to be compatible in both php and nodejs. This comes at a cost at the PHP side, as it uses system commands to interact with javascript library (try using nodejs >=8.11.1). Sometimes function is more important than form, as a php library for signing transactions doesn't seem to exist inside the ethereum ecosystem except for this one, and we gain the advantage of using the exact same library in any relevant server environment.
This is important because:
One of the really important improvements of this library is that all signatures are inherently probabilistic (meaning noise is added before signing a message then automatically removed by the recipient). This enhances security because the same message will never be signed to the same value twice (important for deterring snoopers). It's actually standard practice in encryption, but I know some Ethereum libraries that don't do this by default.
Installation
nodejs
Run the command:
npm install --save arrlaravel
php/laravel
Run the command:
composer require "projectoblio/arrlaravel @dev"
Make sure you have nodejs >= 8.11.1 (but anything above 6 should work)
both!
Add a file called "serverKey" to your root project directory. Store a private key for your site in there. Can be any string
Initializiation
nodejs
var Arrlaravel = require("arrlaravel");
var arrlaravel = new ArrLaravel({"privateKey":"adsklfjaslkdjfalksjf"}); // easiest
// or
var arrlaravel = new ArrLaravel({"path":"/home/you/site/folder/serverKey"}); // path to privatekey
// or
var arrlaravel = new ArrLaravel({"path":"/home/you/site/folder/serverKey","siteName":"oblioBomb"}); // useful for identifying yourself to project oblio later on
laravel (simple mod for php i think
use Projectoblio\Arrlaravel\ArrProvider;
// class or whatever function thing {
//ajlkasdjflsakjfd is your private key. In oblio servers, this input is the siteName don't worry about that)
// second input is the vendor directory where your package will be installed. needed to access js auth.js
$arr = new ArrProvider("ajlkasdjflsakjfd","/root/laravel-tests/vendor/projectoblio/arrlaravel");
// call "commandByPrivateKey" since you initialized with a privateKey. Sorry about that
// first input is the command inside auth.js (_this[command]);
// second input is a comma-separated list of inputs
$output = $arr->commandByPrivateKey("createIdentity",""); // first input is the function name. second input is json version of your thing
// will give you an ethPublickey, private key as output
// this will give you an Ethereum address from any private key. Useful if you're creating addresses for users (be careful)
$output = $arr->commandByPrivateKey("privateKeyToAddress","oiewqufadshvflsadhf");
// This will give you the server's public key. Useful if you want another user or server to send you a signed message
$output = $arr->commandByPrivateKey("getServerPublicKey");
// Sign a message
// note that this has to be a public key, not an ethereum address ( :( ) . That's just how encryption works sadly
$output = $arr->commandByPrivateKey("send","aSecretMessage,aPublicKey");
// Receive a message. will be decrypted using your server's private key.
// ensure the message was sencrypted iwth your server's public key
$output = $arr->commandByPrivateKey("receive","theSecretMessage");
// Probabilstically encrypt a piece of data so that it can only be opened by dubs.projectoblio.com
// "dubs" is a hardwired string linked to the dubsPublicKey
$output = $arr->commandByPrivateKey("send","aSecretMessage,dubs")
Supported methods / commands
Questions?
Contact [email protected]
Manual package update (admin)
https://packagist.org/packages/projectoblio/arrlaravel
npm update
npm publish