@chainsafe/as-chacha20poly1305
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

as-chacha20poly1305

AssemblyScript implementation of chacha20poly1305, it's 20% - 60% faster compared to stablelib with no memory allocation in the middle.

This was ported from the typescript version https://github.com/StableLib/stablelib/tree/master/packages/chacha20poly1305

Usage

yarn add @chainsafe/as-chacha20poly1305

const ctx = newInstance();
const asImpl = new ChaCha20Poly1305(ctx);
const key = new Uint8Array(crypto.randomBytes(KEY_LENGTH));
const nonce = new Uint8Array(crypto.randomBytes(NONCE_LENGTH));
const plainText = new Uint8Array(crypto.randomBytes(512));
const ad = new Uint8Array(crypto.randomBytes(32))
const asSealed = asImpl.seal(key, nonce, plainText, ad);
// overwrite sealed to save memory allocation
const plainText2 = asImpl.open(key, nonce, sealed, true, ad);
expect(plainText2).to.be.deep.equal(plainText);

License

Apache 2.0

Readme

Keywords

none

Package Sidebar

Install

npm i @chainsafe/as-chacha20poly1305

Weekly Downloads

6,339

Version

0.1.0

License

Apache-2.0

Unpacked Size

331 kB

Total Files

39

Last publish

Collaborators

  • wemeetagain
  • mpetrunic