1.0.1 • Published 6 years ago

@decentralized-auth/ntru v1.0.1

Weekly downloads
2
License
Apache-2.0
Repository
-
Last release
6 years ago

@decentralized-auth/ntru

GitHub license

Wrapper around ntrujs NTRUEncrypt. Provides convenience methods to work with the IOTA Tangle.

  • Create an NTRU key pair based on an IOTA seed.
  • Convert a public key to trytes so it can be send over IOTA.
  • Encrypt to trytes using tryte encoded public key.
  • Decrypt trytes.

Usage

const { createKeyPair, encrypt, decrypt, toTrytes } = require('@decentralized-auth/ntru');
const seed = 'MYIOTASEED';
const keyPair = createKeyPair(seed);
const plainText = Buffer.from('hello', 'utf8');
const encrypted = encrypt(plainText, toTrytes(keyPair.public));
const decrypted = decrypt(encrypted, keyPair.private).toString();

Test

npm run test

Lint

npm run lint

Documentation

Documentation generated from docstrings with jsdoc2md.

ntru

Wrapper around ntrujs NTRUEncrypt. Provides convenience methods to work with the IOTA Tangle.

  • Create an NTRU key pair based on an IOTA seed.
  • Convert a public key to trytes so it can be send over IOTA.
  • Encrypt to trytes using tryte encoded public key.
  • Decrypt trytes.

ntru~toBytes(str)UintArray

Converts string to Uint8Array.

Kind: inner method of ntru
Returns: UintArray - The byte array that represents the string

ParamTypeDescription
strstringString to convert

ntru~createKeyPair(seed)Object

Creates an NTRU key pair based on a seed.

Kind: inner method of ntru
Returns: Object - Key pair with private and public keys

ParamTypeDescription
seedstringIOTA seed to generate key pair with

ntru~toTrytes(buffer)string

Converts a Buffer to trytes. First converts to base64 and then to trytes.

Kind: inner method of ntru
Returns: string - Tryte representation of buffer

ParamTypeDescription
bufferBufferBuffer to convert

ntru~toTrytes(trytes)Buffer

Converts a buffer that was converted to trytes by toTrytes back to a buffer. First converts from trytes to base64 and then to Buffer.

Kind: inner method of ntru
Returns: Buffer - Original buffer

ParamTypeDescription
trytesstringBuffer converted to trytes

ntru~encrypt(trytes, privateKey)string

Decrypts trytes with NTRU encoded cipher text with private key.

Kind: inner method of ntru
Returns: string - Plain text string

ParamTypeDescription
trytesstringTrytes to decrypt
privateKeyBufferPrivate key

ntru~encrypt(str, publicKey)string

Encrypts string with public key.

Kind: inner method of ntru
Returns: string - Tryte encoded NTRU encrypted MAM data

ParamTypeDescription
strstringString to encrypt
publicKeystringTryte encoded public key