You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-9Lines changed: 21 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ This is a client and server implementation of 1Password's [fantastic SRP library
8
8
9
9
SRP is a fascinating protocol. I highly recommend reading through [1Password's explainer](https://blog.1password.com/developers-how-we-use-srp-and-you-can-too/) to get familiar with its innerworkings and processes first.
10
10
11
-
## Step 1: Pick a group
11
+
###Step 1: Pick a group
12
12
13
13
This library uses RFC 5054 groups between 2048 and 8192 bits. 4096 and above are highly recommended. Any lower is unlikely to be secure for the near future.
14
14
@@ -20,19 +20,31 @@ import { knownGroups } from "secure-remote-password-js";
20
20
const group =knownGroups[4096];
21
21
```
22
22
23
-
## Step 2: Pick a KDF
23
+
###Step 2: Pick a KDF
24
24
25
25
You'll need a Key Derivation Function (KDF) to convert your password into a secure format. While this library includes a simple KDF for testing, you should use a strong KDF like Argon2id, bcrypt, or scrypt in production.
26
26
27
27
[@phi-ag/argon2](https://github.com/phi-ag/argon2) is a great library for Argon2 in TS.
28
28
29
29
```typescript
30
-
import { argon2id } from"@phi-ag/argon2";
31
-
32
-
const x =argon2id.hash(password, salt);
30
+
import { Argon2Type } from"@phi-ag/argon2";
31
+
importwasmfrom"@phi-ag/argon2/argon2.wasm?url";
32
+
importinitializefrom"@phi-ag/argon2/fetch";
33
+
34
+
const argon2 =awaitinitialize(wasm);
35
+
const hash =argon2.hash(password, {
36
+
salt,
37
+
memoryCost: 64*1024,
38
+
timeCost: 1,
39
+
parallelism: 4,
40
+
hashLength: 32,
41
+
type: Argon2Type.Argon2id,
42
+
});
43
+
44
+
returnhash;
33
45
```
34
46
35
-
## Step 3: Initialize SRP Client
47
+
###Step 3: Initialize SRP Client
36
48
37
49
Create an SRP client instance for both server and client sides:
38
50
@@ -47,7 +59,7 @@ const verifier = client.verifier(); // Generate this during registration
47
59
const server =newSrpClient(knownGroups[4096], verifier, undefined, "server");
48
60
```
49
61
50
-
## Step 4: Exchange Public Keys
62
+
###Step 4: Exchange Public Keys
51
63
52
64
Exchange ephemeral public keys between client and server:
0 commit comments