From 18203feb0076ca1f52c8833fb9ce5905e2f94400 Mon Sep 17 00:00:00 2001 From: tcsenpai Date: Fri, 11 Apr 2025 11:38:54 +0200 Subject: [PATCH] updated some readmes --- .gitignore | 1 + README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++-- package.json | 2 +- 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index eea707b..660a84a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules/ package-lock.json bun.lockb +bun.lock yarn.lock pnpm-lock.yaml diff --git a/README.md b/README.md index ec15801..8032e38 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ A TypeScript implementation of the Falcon signature scheme with a custom mnemonic implementation for key management. +This project is based on: https://github.com/pqcsf/falcon-sign-js + +The only purpose of this project is to provide an easy-to-use Typescript module that allows the Falcon implementation of the above repository to be used in TS projects with types included and with some utilities. + ## Overview This project provides a TypeScript implementation of the Falcon signature scheme, along with a custom mnemonic implementation for generating, storing, and recovering Falcon keys using human-readable phrases. @@ -13,9 +17,12 @@ This project provides a TypeScript implementation of the Falcon signature scheme - Key generation, signing, and verification - Mnemonic phrase generation and validation - Key recovery from mnemonic phrases +- Hex and Base64 encoding/decoding utilities ## Installation +This will install https://github.com/pqcsf/falcon-sign-js. + ```bash npm install ``` @@ -25,7 +32,7 @@ npm install ### Basic Falcon Usage ```typescript -import { Falcon } from './src/falcon'; +import { Falcon } from './src'; // Create a Falcon instance const falcon = new Falcon(); @@ -81,13 +88,61 @@ await recoveredFalcon.genkey(recoveredSeed); const recoveredKeypair = await recoveredFalcon.getKeypair(); ``` +### Hex and Base64 Encoding + +The Falcon class provides utilities for working with hex and base64 encoded keys and signatures: + +```typescript +import { Falcon } from './src/falcon'; + +// Create a Falcon instance +const falcon = new Falcon(); +await falcon.init(); + +// Generate a key pair +await falcon.genkey(); + +// Get keys in hex format +const publicKeyHex = await falcon.getPublicKeyHex(); +const privateKeyHex = await falcon.getPrivateKeyHex(); + +// Get keys in base64 format +const publicKeyBase64 = await falcon.getPublicKeyBase64(); +const privateKeyBase64 = await falcon.getPrivateKeyBase64(); + +// Sign a message and get the signature in hex +const message = 'Hello, Falcon!'; +const signatureHex = await falcon.signHex(message); + +// Verify a hex signature +const isValid = await falcon.verifyHex(message, signatureHex); + +// Sign a message and get the signature in base64 +const signatureBase64 = await falcon.signBase64(message); + +// Verify a base64 signature +const isValidBase64 = await falcon.verifyBase64(message, signatureBase64); + +// Create a public key from a private key in hex format +const derivedPublicKeyHex = await falcon.publicKeyCreateHex(privateKeyHex); + +// Set a private key from hex format +const newPublicKeyHex = await falcon.setPrivateKeyHex(privateKeyHex); + +// Create a public key from a private key in base64 format +const derivedPublicKeyBase64 = await falcon.publicKeyCreateBase64(privateKeyBase64); + +// Set a private key from base64 format +const newPublicKeyBase64 = await falcon.setPrivateKeyBase64(privateKeyBase64); +``` + ## Examples Run the examples to see the mnemonic implementation in action: ```bash # Run the basic example -npx ts-node src/example.ts +npx ts-node example.ts # Run the mnemonic example npx ts-node mnemonic_example.ts @@ -110,6 +165,18 @@ The implementation includes the following functions: - `validateMnemonic(mnemonic: string): boolean` - Validates a mnemonic phrase - `generateMnemonic(): string` - Generates a random mnemonic phrase +## Tests + +Run the test suite using: + +```bash +npm test +``` + +## Credits + +This project is a TypeScript wrapper around the [falcon-sign-js](https://github.com/pqcsf/falcon-sign-js) library, which provides the core Falcon signature implementation. We've added TypeScript types, a custom mnemonic implementation, and additional utilities to make it easier to use in TypeScript projects. + ## License MIT \ No newline at end of file diff --git a/package.json b/package.json index 69d1a09..e87e435 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "falcon-ts", "version": "1.0.0", - "description": "A TypeScript implementation of the Falcon signature scheme with a custom mnemonic implementation", + "description": "A TypeScript wrapper around the Falcon signature scheme with a custom mnemonic implementation", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": {