Installation
The following programming languages are currently supported:
Client SDK:
Server SDK:
Installation​
Client SDK​
- JavaScript
Pick one of the following methods to install the blindnet devkit.
- npm
- yarn
- umd
For more info, check the api reference.
Server SDK​
- PHP
- Node.js
composer require blindnet/blindnet-sdk-php
For more info, check the api reference.
Pick one of the following methods to install the blindnet devkit.
- npm
- yarn
Run the following command in your terminal.
npm i -S @blindnet/sdk-node
Run the following command in your terminal.
yarn add @blindnet/sdk-node
For more info, check the api reference.
Imports​
Client SDK​
The blindnet devkit api is enclosed in the Blindnet
module. It should be imported together with the error types
and optionally, utilities
(e.g. to encode and decode the encrypted data).
- JavaScript
If the SDK was installed as an npm
package, it is imported as
import { Blindnet, util, error } from '@blindnet/sdk-javascript'
If it was imported as an umd
package, use
const { Blindnet, util, error } = blindnet
For more info, check the api reference.
Server SDK​
- PHP
- Node.js
require 'vendor/autoload.php';
use Blindnet\BlindnetSDKPHP\Blindnet;
For more info, check the api reference.
const Blindnet = require('@blindnet/sdk-node')
For more info, check the api reference.
Initialization​
Client SDK​
blindnet devkit must be initialized before you can use it (with the exception for some static methods, e.g. secret derivation).
To initialize the library, you need to provide the authentication token generated using the server SDK.
Also, blindnet endpoint url can be provided. The default value is https://api.blindnet.io
.
If you are testing the library, use https://test.blindnet.io
.
Initialization is done with the init
method.
- JavaScript
const blindnet = Blindnet.init(token)
// for testing
const blindnet = Blindnet.init(token, 'https://test.blindnet.io')
Server SDK​
To initialize the server SDK, you need to obtain application id and application key. You can obtain them from the dashboard, or generate them on your own (see next section).
As for the client SDK, you can provide an endpoint. For testing, use https://test.blindnet.io
.
- PHP
- Node.js
$blindnet=Blindnet.init($appKey, $appId)
// for testing
$blindnet=Blindnet.init($appKey, $appId, 'https://test.blindnet.io')
const blindnet = await Blindnet.init(appKey, appId)
// for testing
const blindnet = await Blindnet.init(appKey, appId, 'https://test.blindnet.io')
Generating application keys​
Application key is actually an Ed25519 private key used to sign the tokens that allow your users to access blindnet. You can generate it either in the blindnet dashboard or on your own. If you decide to generate the application key on your own, you need to generate an Ed25519 key pair, take the private key as your blindnet application key, and register the public key in your application on the dashboard.
Examples of how to generate the Ed25519 key pair:
- JavaScript
- PHP
import * as ed from 'noble-ed25519';
const privateKey = ed.utils.randomPrivateKey(32);
const publicKey = await ed.getPublicKey(privateKey);
console.log("application key: " + btoa(String.fromCharCode(...privateKey, ...publicKey)));
console.log("public key: " + btoa(String.fromCharCode(...publicKey)));
$keypair = sodium_crypto_sign_keypair();
$publicKey = base64_encode(sodium_crypto_sign_publickey($keypair));
$privateKey = base64_encode(sodium_crypto_sign_secretkey($keypair));
echo ('application key: ' . $privateKey . "\n");
echo ('public key: ' . $publicKey . "\n");
Examples of Ed25519 keys:
Ed25519 keys
public key: QqglmSldC4PerNo+zQJIkV5+CkCHL2Tlq5aO1NXiY7Y=
private key: GWuUnD5bn0Xuk8GdbLGoX+0UBanFmY3/Qq8JY8Fff2pCqCWZKV0Lg96s2j7NAkiRXn4KQIcvZOWrlo7U1eJjtg==