What is sentc

Sentc is an end-to-end encryption SDK with user and group management.

TIP

Sentc now supports post quantum cryptography with CRYSTALS Kyber and CRYSTALS Dilithium. See more here.

CRYSTALS Kyber is used in hybrid with x25519

CRYSTALS Dilithium is used in hybrid with ed25519

End-to-end encryption can be difficult to develop and maintain. Fortunately, Sentc gives you full control of your application and provides easy-to-use encryption for groups or between users.

Sentc uses a flexible protocol to be able to change the underlying encryption algorithm in the feature. To ensure backward compatibility, data that was encrypted with older algorithm can still be decrypted but new data will be encrypted by the newest.

TIP

There is also a sdk version without the encryption but with the user and group management. This is very helpful to create secure login systems and to group users to manage their access to resources.

See more at sdk-light

TIP

Sentc can also be used with another backend, such as Firebase or your own.

You can configure your app to call some functions only from the backend using your secret token. For backend-only function calls, use the equivalent of the function with a prepare or done prefix, such as prepareRegister() instead of register and call your backend with the data from prepareRegister or doneRegister() after registration.

See more at own backend

Sentc is currently available for JavaScript in the browser and flutter on android and windows (linux will follow), but we are also working on more.

Contact

If you want to learn more, just contact me contact@sentclose.com.

Quick start

Playground

User and group functionalities can be tested in our playground without creating an account.

Create an account and an app

To use the sdk, you need a public and secret token.

The public token will be used in your sdk at the frontend and the secret token should only be used at your backend. You can set what function should be called with which token.

  1. Got to https://api.sentc.com/dashboard/registeropen in new window and create an account. You will be redirected to the account dashboard.
  2. Verify the email. We email you to make sure that your email address belongs to you.
  3. In your dashboard click on the blue button: New App. You will get the app tokens and the first jwt keys.

Now you are ready to use the sdk.

See this guide for more information.

Install the sdk.

It is also available directly in the browser via CDN.

npm install @sentclose/sentc
yarn add @sentclose/sentc
<script src="https://cdn.jsdelivr.net/npm/@sentclose/sentc/dist/sentc.min.js"></script>

WARNING

Module bundler

The core SDK uses WebAssembly (WASM) in the browser.

If you are using a module bundler like Webpack and you are not using the browser import, please refer to the module bundler WASM configuration in our documentation. see Module bundler

Initialize the SDK.

This function checks if the user is logged in and verifies the JSON Web Token (JWT).

For javascript it is also necessary to load the wasm file.

import Sentc from "@sentclose/sentc";

//init the javascript client
await Sentc.init({
    app_token: "5zMb6zs3dEM62n+FxjBilFPp+j9e7YUFA+7pi6Hi"  // <-- your app token
});
<script>
    //init the wasm
    const sentc = window.Sentc.default;

    async function run() {
        await sentc.init({
           app_token: "5zMb6zs3dEM62n+FxjBilFPp+j9e7YUFA+7pi6Hi" // <-- your app token
        });
    }

    run();
</script>

Ready

You are now ready to register, log in, delete a user, or a group.

WARNING

Every function that makes a request (in JavaScript with a Promise) will throw an error if the request or server output is not correct.

We have noted when the function will also throw an error.

The Error is a json string which can be decoded into the Error type:

interface SentcError
{
	status: string,
	error_message: string
}

Examples

The following examples are minimal code blocks. To see more, including their configurations, please refer to the documentation for each part.

Register and login user

You can register a user from the client. It is also possible to register a user from your own backend. Please refer to the User documentation for more information.

import Sentc from "@sentclose/sentc";

await Sentc.register("username", "password");
<script>
    //init the wasm
    const sentc = window.Sentc.default;

    async function run() {
        await sentc.init({
           app_token: "5zMb6zs3dEM62n+FxjBilFPp+j9e7YUFA+7pi6Hi" // <-- your app token
        });
        
        await sentc.register("username", "password");
    }

    run();
</script>

Login a user

Log in a user with their username and password. The user can also enable Multi-factor auth. learn more here After login, the user receives a JSON Web Token (JWT).

After logging in, you will receive a user object.

import Sentc from "@sentclose/sentc";

//login a user, ignoring possible Multi-factor auth
const user = await Sentc.login("username", "password", true);
<script>
    //init the wasm
    const sentc = window.Sentc.default;

    async function run() {
        await sentc.init({
           app_token: "5zMb6zs3dEM62n+FxjBilFPp+j9e7YUFA+7pi6Hi" // <-- your app token
        });

		//login a user, ignoring possible Multi-factor auth
        const user = await sentc.login("username", "password", true);
    }

    run();
</script>

Create a group

You can create a group using the user object. The group keys are automatically encrypted by the user keys.

With the group object, you can encrypt/decrypt content, invite or delete members, and perform key rotation. For more information, please refer to the Groups documentation.

This is the same for installed and browser.

//the user obj from login
const group_id = await user.createGroup();

//now fetch the group
const group = await user.getGroup(group_id);

Encrypt in a group

You can perform encryption and decryption of raw data or strings in a group.

For javascript the format for raw data is Uint8Array.

//the group obj from getGroup
const encrypted_string = await group.encryptString("hello there!");

//now every user in the group can decrypt the string
const decrypted_string = await group.decryptString(encrypted_string);

console.log(decrypted_string);  //hello there!

//or raw data

const encrypted = await group.encrypt(new Uint8Array([1,1,1,1]));

const decrypted = await group.decrypt(encrypted);
Last Updated: