supercop.ts

cross-compiled javascript implementation of ed25519 based on supercop-ref10
git clone git://git.finwo.net/lib/supercop.ts
Log | Files | Refs | README | LICENSE

commit 927fea969481b9fa11e9e4a78cf627dde1f598a7
parent e91becd3c6027925578be2a0e206c48fc6e67ac3
Author: finwo <finwo@pm.me>
Date:   Thu, 18 Jul 2019 14:29:51 +0200

Basic readme to describe what this package does

Diffstat:
AREADME.md | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -0,0 +1,81 @@ +# supercop + +[orlp/ed25519](https://github.com/orlp/ed25519) patched and compiled using [dcodeio/webassembly](https://github.com/dcodeio/webassembly) + +## Examples + +### Signing and verifying data + +```js +const lib = require('supercop'); +const seed = lib.createSeed(); +const keypair = await lib.createKeyPair(seed); +const msg = Buffer.from('hello there'); +const sig = await keypair.sign(msg); + +console.log(await keypair.verify(sig, msg)); // true +``` + +### Storing keypairs + +```js +const lib = require('supercop'); +const fs = require('fs'); +const seed = lib.createSeed(); +const keypair = await lib.createKeyPair(); + +fs.writeFileSync('keys.json', JSON.stringify({ + publicKey: keypair.publicKey.toString('base64'), + secretKey: keypair.secretKey.toString('base64'), +}); +``` + +### Loading keypairs + +```js +const lib = require('supercop'); +const fs = require('fs'); + +const base64keys = require('./keys.json'); +const keypair = lib.keyPairFrom({ + publicKey: Buffer.from(base64keys.publicKey, 'base64'), + secretKey: Buffer.from(base64keys.secretKey, 'base64'), +}); +``` + +## API + +### lib.createSeed() + +Generates 32-byte seed using `Math.random`. Using a different random-generator +which is cryptographically secure is strongly advised. + +### lib.keyPairFrom( data ) + +Generates a keypair containing the `.sign` and `.verify` functions + +### lib.createKeyPair( seed ) + +Generates a keypair from the provided 32-byte seed wieh the following +properties: + +- `keypair.publicKey` - A 32-byte public key as a buffer +- `keypair.secretKey` - A 64-byte secret key as a buffer +- `keypair.sign` - Function to sign a message using the keypair +- `keypair.verify` - Function to verify a signature using the keypair + +### lib.sign( msg, publicKey, secretKey ) + +TODO + +### lib.verify( sig, msg, publicKey ) + +TODO + +### keypair.sign( msg ) + +TODO + +### keypair.verify( sig, msg ) + +TODO