updated some readmes

This commit is contained in:
tcsenpai 2025-04-11 11:38:54 +02:00
parent 4398166b49
commit 18203feb00
3 changed files with 71 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
node_modules/
package-lock.json
bun.lockb
bun.lock
yarn.lock
pnpm-lock.yaml

View File

@ -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

View File

@ -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": {