Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/agustinsrg/crystals-dilithium-js
Javascript implementation of post-quantum signature algorithm: CRYSTALS-Dilithium
https://github.com/agustinsrg/crystals-dilithium-js
Last synced: 24 days ago
JSON representation
Javascript implementation of post-quantum signature algorithm: CRYSTALS-Dilithium
- Host: GitHub
- URL: https://github.com/agustinsrg/crystals-dilithium-js
- Owner: AgustinSRG
- License: apache-2.0
- Created: 2022-08-31T07:55:32.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-29T09:48:54.000Z (6 months ago)
- Last Synced: 2024-11-24T05:05:21.007Z (29 days ago)
- Language: TypeScript
- Size: 673 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CRYSTALS-Dilithium (Javascript implementation)
[![npm version](https://badge.fury.io/js/%40asanrom%2Fdilithium.svg)](https://badge.fury.io/js/%40asanrom%2Fdilithium)
Javascript implementation of post-quantum signature algorithm: [CRYSTALS-Dilithium](https://pq-crystals.org/dilithium).
Note: This is an experimental implementation. I do not recommend using it in production until the algorithm is standarized.
## Installation
If you are using a npm managed project use:
```
npm install @asanrom/dilithium
```If you are using it in the browser, download the minified file from the [Releases](https://github.com/AgustinSRG/crystals-dilithium-js/tags) section and import it to your html:
```html
```
The browser library exports all artifacts to the window global: `DilithiumAlgorithm`
## Usage
```ts
import { DilithiumKeyPair, DilithiumLevel, DilithiumLevelNumber, DilithiumSignature } from "@asanrom/dilithium";const level = DilithiumLevel.get(2); // Get the security level config (2, 3, or 5)
// Generate a key pair
const keyPair = DilithiumKeyPair.generate(level);// Get the private key
const privateKey = keyPair.getPrivateKey();// Sign a message
const message = new Uint8Array(Buffer.from("Joy!", "utf8"));
const signature = privateKey.sign(message);// Get the public key
const publicKey = keyPair.getPublicKey();// Validate signature
const valid = publicKey.verifySignature(message, signature);
```## Documentation
- [Library documentation (Auto-generated)](https://agustinsrg.github.io/crystals-dilithium-js/)
- [Test in the browser](https://agustinsrg.github.io/crystals-dilithium-js/test.html)