-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
User
Mark Nadal edited this page Jul 20, 2018
·
38 revisions
This page will explain SEA's user API as well as explain architectural decisions underneath each method for security purposes.
Assume:
gun = Gun();
user = gun.user(); user.create(alias, passphrase, cb)
- coming soon
See SEA for algorithm choices.
Essentially, it works like this:
//<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
//<script src="https://cdn.jsdelivr.net/npm/gun/sea.js"></script>
var sea = Gun.SEA;
var pair = await sea.pair(); // generate a new key pair
console.log(pair);
var alias = "alice"
var pass = "secret";
var salt = 1; // random
var proof = await sea.work(alias, pass); // don't do this! (pass, salt) instead!
var auth = await sea.encrypt(pair, proof);
console.log(auth); // data saved in a cryptographically linked user graph
// now on another machine...
var login = await sea.work(alias, pass);
var keys = await sea.decrypt(auth, login); // encrypted auth loaded from graph
console.log(keys); // equal to the original key pair