Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Commit

Permalink
Merge a098fa0 into 2b073d8
Browse files Browse the repository at this point in the history
  • Loading branch information
aricart committed Jan 4, 2019
2 parents 2b073d8 + a098fa0 commit eb4a6f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,26 @@ npm install ts-nkeys
// Seeds are strings, and start with the letter 'S'.
// Seeds need to be kept safe and never shared.
let seed = user.getSeed();
t.is(typeof seed, 'string');
t.is(seed[0], 'S');
t.true(Buffer.isBuffer(seed));
t.is(seed[0], 'S'.charCodeAt(0));

// the second letter in the seed represents its type:
// `U` for user,
// `A` for account,
// `C` for cluster
// `N` for severs
t.is(seed[1], 'U');
t.is(seed[1], 'U'.charCodeAt(0));

// public keys can be shared and can be used to verify signed content
let publicKey = user.getPublicKey();
t.is(typeof publicKey, 'string');
t.true(Buffer.isBuffer(publicKey));
// first letter represents the type of public key
// `U` for user,
// `A` for account,
// `C` for cluster
// `N` for severs
t.is(publicKey[0], 'U');
t.is(publicKey[0], 'U'.charCodeAt(0));

// private keys like seeds shouldn't be shared. In most cases you should
// just save the seed.
let privateKey = user.getPrivateKey();
t.is(typeof privateKey, 'string');
// private keys start with the letter 'P'.
t.is(privateKey[0], 'P');

// To sign data
let data = Buffer.from("HelloWorld");
Expand All @@ -71,5 +65,5 @@ npm install ts-nkeys
t.true(sk.verify(data, sig));
// and can be used to sign
let sig2 = sk.sign(data);
t.true(sk.verify(data, sig))
t.true(sk.verify(data, sig));
```
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-nkeys",
"version": "1.0.8",
"version": "1.0.10",
"description": "A public-key signature system based on Ed25519 for the NATS ecosystem in typescript for ts-nats and node-nats",
"main": "lib/nkeys.js",
"types": "lib/nkeys.d.ts",
Expand Down Expand Up @@ -42,7 +42,6 @@
"typescript": "^3.0.3"
},
"dependencies": {
"npm": "^6.4.1",
"tweetnacl": "^1.0.0"
},
"ava": {
Expand Down
2 changes: 1 addition & 1 deletion src/nkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {KP} from "./kp";
import {PublicKey} from "./public";
import {Codec} from "./codec";

export const VERSION = "1.0.4";
export const VERSION = "1.0.10";

export function createPair(prefix: Prefix): KeyPair {
let rawSeed = ed25519.randomBytes(32).buffer;
Expand Down

0 comments on commit eb4a6f3

Please sign in to comment.