@decentralized-auth/ntru
v1.0.1
Published
Wrapper around ntrujs NTRUEncrypt. Provides convenience methods to work with the IOTA Tangle's trytes.
Downloads
5
Maintainers
Readme
@decentralized-auth/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.
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~createKeyPair(seed)
⇒ Object~toTrytes(buffer)
⇒ string~toTrytes(trytes)
⇒ Buffer~encrypt(trytes, privateKey)
⇒ string~encrypt(str, publicKey)
⇒ string
ntru~toBytes(str)
⇒ UintArray
Converts string to Uint8Array.
Kind: inner method of ntru
Returns: UintArray - The byte array that represents the string
| Param | Type | Description | | --- | --- | --- | | str | string | String 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
| Param | Type | Description | | --- | --- | --- | | seed | string | IOTA 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
| Param | Type | Description | | --- | --- | --- | | buffer | Buffer | Buffer 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
| Param | Type | Description | | --- | --- | --- | | trytes | string | Buffer 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
| Param | Type | Description | | --- | --- | --- | | trytes | string | Trytes to decrypt | | privateKey | Buffer | Private key |
ntru~encrypt(str, publicKey)
⇒ string
Encrypts string with public key.
Kind: inner method of ntru
Returns: string - Tryte encoded NTRU encrypted MAM data
| Param | Type | Description | | --- | --- | --- | | str | string | String to encrypt | | publicKey | string | Tryte encoded public key |