# @chainsafe/as-chacha20poly1305

> An AssemblyScript implementation of chacha20poly1305

Latest version **0.1.0** (published 2022-11-21) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @chainsafe/as-chacha20poly1305
pnpm add @chainsafe/as-chacha20poly1305
yarn add @chainsafe/as-chacha20poly1305
bun add @chainsafe/as-chacha20poly1305
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-11-21 |
| First published | 2022-11-21 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 323.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ChainSafe Systems |
| Maintainers | dapplion, wemeetagain, mpetrunic |

## Links

- npm: https://www.npmjs.com/package/@chainsafe/as-chacha20poly1305
- Repository: https://github.com/chainsafe/as-chacha20poly1305
- Homepage: https://github.com/ChainSafe/as-chacha20poly1305#readme
- Issues: https://github.com/ChainSafe/as-chacha20poly1305/issues
- npm.io page: https://npm.io/package/@chainsafe/as-chacha20poly1305

## Recent versions

- 0.1.0 (latest) — 2022-11-21

## README

# 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`

```typescript
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

---
_Source: https://npm.io/package/@chainsafe/as-chacha20poly1305 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
