Crates.io | sentc |
lib.rs | sentc |
version | 0.3.0 |
source | src |
created_at | 2023-05-17 20:04:31.71366 |
updated_at | 2024-10-26 13:22:30.35594 |
description | Encryption and group/user management sdk. Easy-to-use encryption with post quantum cryptography. |
homepage | https://sentc.com/ |
repository | https://github.com/sentclose/sentc-rust |
max_upload_size | |
id | 867183 |
size | 303,778 |
It supports user- and group management as well as key rotation and its build to serve large amount of users without any problems.
The other sdk's like javascript or flutter are designed with datastore in mind. In js it uses the indexeddb in the browser and in flutter the device storage or encrypted storage.
This sdk was designed to use your own storage. This means you need to provide more information for each function than in the other sdk's. But this gives you the flexibility to use it in your programs without compromises.
There is no init function anymore. You can just use the functions you need.
In all doc examples we are using the StdKeys implementation. You can switch it by changing the features and use other implementation or even write your own.
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.
Now you are ready to use the sdk.
Please choose an implementation of the algorithms. There are StdKeys, FIPS or Rec keys. The impl can not work together.
The net feature is necessary for the requests to the backend. The library reqwest is used to do it.
cargo add sentc
use sentc::keys::{StdUser, StdGroup};
async fn example()
{
//register a user
let user_id = StdUser::register("base_url".to_string(), "app_token".to_string(), "the-username", "the-password").await.unwrap();
//login a user, ignoring possible Multi-factor auth
let user = StdUser::login_forced("base_url".to_string(), "app_token", "username", "password").await.unwrap();
//create a group
let group_id = user.create_group().await.unwrap();
//get a group. first check if there are any data that the user need before decrypting the group keys.
let (data, res) = user.prepare_get_group("group_id", None).await.unwrap();
//if no data then just decrypt the group keys
assert!(matches!(res, GroupFetchResult::Ok));
let group = user.done_get_group(data, None).unwrap();
//invite another user to the group. Not here in the example because we only got one user so far
group.invite_auto(user.get_jwt().unwrap(), "user_id_to_invite", user_public_key, None).await.unwrap();
//encrypt a string for the group
let encrypted = group.encrypt_string_sync("hello there!").unwrap();
//now every user in the group can decrypt the string
let decrypted = group.decrypt_string_sync(encrypted, None).unwrap();
//delete a group
group.delete_group(user.get_jwt().unwrap()).await.unwrap();
//delete a user
user.delete("password", None, None).await.unwrap();
}
The protocol is designed for async long-running communication between groups.
The both requirements make perfect forward secrecy impossible. See more at the Protocol how we solved it.
If you want to learn more, just contact me contact@sentclose.com.