New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@oasisprotocol/deoxysii

Package Overview
Dependencies
Maintainers
6
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oasisprotocol/deoxysii

Deoxys-II-256-128

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
576
increased by35.85%
Maintainers
6
Weekly downloads
 
Created
Source

deoxysii.js - JavaScript Deoxys-II-256-128

GitHub CI version size downloads License: MIT

This package provides a pure-JavaScript implementation of the Deoxys-II-256-128 v1.43 algorithm from the final CAESAR portfolio.

Deoxys is an authenticated encryption scheme based on a 128-bit lightweight ad-hoc tweakable block cipher. It may be used in two modes to handle nonce-respecting users (Deoxys-I) or nonce-reusing user (Deoxys-II).

It has been designed by Jérémy Jean, Ivica Nikolić, Thomas Peyrin and Yannick Seurin.

Usage

Install the package as a dependency of your project:

npm add '@oasisprotocol/deoxysii'

The AEAD class can then be used to encrypt and decrypt, with an optional authenticated data field which can be very useful when constructing protocols.

import { AEAD, KeySize, NonceSize } from '@oasisprotocol/deoxysii';

// Define a key (ensure the size matches requirements)
const key = crypto.getRandomValues(new Uint8Array(KeySize));
const aead = new AEAD(key);

// Encryption
const nonce = crypto.getRandomValues(new Uint8Array(NonceSize));
const plaintext = new TextEncoder().encode("Hello World");
const associatedData = new Uint8Array([0x1, 0x2, 0x3]);

const encrypted = aead.encrypt(nonce, plaintext, associatedData);
console.log('Encrypted:', encrypted);

// Decryption
try {
    const decrypted = aead.decrypt(nonce, encrypted, associatedData);
    console.log('Decrypted:', new TextDecoder().decode(decrypted));
} catch (error) {
    console.error('Decryption failed:', error);
}

Notes

[!WARNING] It is unclear what the various JavaScript implementations will do to the ct32 code or the underlying bitsliced AES round function, and it is quite possible that it may be vulnerable to side channels.

Users that require a more performant and secure implementation are suggested to investigate WebAssembly, or (even better) calling native code.

Development
  • Node.js - version 18+
  • typescript - version 5.x, for type safety
  • pnpm - package manager
  • gh act - run GitHub actions locally
  • vitest - tests, benchmarking & coverage
  • biome - lint & formatting
  • tsup - compilation & bundling
  • publint - packaging checks
License & Acknowledgements

This project is released under the MIT License.

This project utilizes modified code originally developed by Franz X Antesberger. The original code for uint32.js is available at fxa/uint32.js. We have adapted this code for TypeScript. We appreciate the contributions of Franz X Antesberger to the open-source community.

FAQs

Package last updated on 08 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc