First commit

This commit is contained in:
tcsenpai 2025-04-11 11:31:57 +02:00
commit 4398166b49
15 changed files with 1269 additions and 0 deletions

6
.gitignore vendored Normal file
View File

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

115
README.md Normal file
View File

@ -0,0 +1,115 @@
# FalconTS
A TypeScript implementation of the Falcon signature scheme with a custom mnemonic implementation for key management.
## 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.
## Features
- Falcon signature scheme implementation
- Custom mnemonic implementation for Falcon keys
- Key generation, signing, and verification
- Mnemonic phrase generation and validation
- Key recovery from mnemonic phrases
## Installation
```bash
npm install
```
## Usage
### Basic Falcon Usage
```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 the key pair
const keypair = await falcon.getKeypair();
const publicKey = keypair.pk;
const privateKey = keypair.sk;
// Sign a message
const message = 'Hello, Falcon!';
const signature = await falcon.sign(message);
// Verify the signature
const isValid = await falcon.verify(message, signature);
console.log('Signature verification:', isValid ? 'Valid' : 'Invalid');
```
### Mnemonic Implementation
```typescript
import { generateMnemonic, mnemonicToUint8Array, uint8ArrayToMnemonic, validateMnemonic } from './src/mnemonic';
import { Falcon } from './src/falcon';
// Generate a random mnemonic
const mnemonic = generateMnemonic();
console.log('Generated mnemonic:', mnemonic);
// Convert mnemonic to seed
const seed = mnemonicToUint8Array(mnemonic);
// Create a Falcon instance
const falcon = new Falcon();
await falcon.init();
// Generate a key pair using the seed
await falcon.genkey(seed);
// Get the key pair
const keypair = await falcon.getKeypair();
const publicKey = keypair.pk;
const privateKey = keypair.sk;
// Later, recover the keys from the mnemonic
const recoveredSeed = mnemonicToUint8Array(mnemonic);
const recoveredFalcon = new Falcon();
await recoveredFalcon.init();
await recoveredFalcon.genkey(recoveredSeed);
const recoveredKeypair = await recoveredFalcon.getKeypair();
```
## Examples
Run the examples to see the mnemonic implementation in action:
```bash
# Run the basic example
npx ts-node src/example.ts
# Run the mnemonic example
npx ts-node mnemonic_example.ts
```
## How It Works
### Falcon Signature Scheme
Falcon is a lattice-based signature scheme that offers strong security with relatively small key and signature sizes. This implementation provides a TypeScript interface to the Falcon signature scheme.
### Custom Mnemonic Implementation
The mnemonic implementation converts between binary data (Uint8Array) and human-readable mnemonic phrases. It uses a list of 2048 common English words, with each word representing 11 bits of entropy. A mnemonic phrase consists of 12 words, providing 132 bits of entropy, which is sufficient for Falcon keys.
The implementation includes the following functions:
- `uint8ArrayToMnemonic(data: Uint8Array): string` - Converts a Uint8Array to a mnemonic phrase
- `mnemonicToUint8Array(mnemonic: string): Uint8Array` - Converts a mnemonic phrase to a Uint8Array
- `validateMnemonic(mnemonic: string): boolean` - Validates a mnemonic phrase
- `generateMnemonic(): string` - Generates a random mnemonic phrase
## License
MIT

141
__tests__/falcon.test.ts Normal file
View File

@ -0,0 +1,141 @@
import Falcon from '../src/falcon';
describe('Falcon', () => {
let falcon: Falcon;
beforeEach(async () => {
falcon = new Falcon();
await falcon.init();
});
describe('Key Generation and Management', () => {
it('should initialize with default algorithm', async () => {
const algid = await falcon.getAlgid();
expect(algid).toBe('falcon512_n3_v1');
});
it('should generate a new keypair', async () => {
await falcon.genkey();
const publicKey = await falcon.getPublicKey();
const privateKey = await falcon.getPrivateKey();
expect(publicKey).toBeDefined();
expect(privateKey).toBeDefined();
expect(publicKey.length).toBeGreaterThan(0);
expect(privateKey.length).toBeGreaterThan(0);
});
it('should convert keys to and from hex format', async () => {
await falcon.genkey();
const publicKeyHex = await falcon.getPublicKeyHex();
const privateKeyHex = await falcon.getPrivateKeyHex();
expect(publicKeyHex).toMatch(/^[0-9a-f]+$/i);
expect(privateKeyHex).toMatch(/^[0-9a-f]+$/i);
});
it('should convert keys to and from base64 format', async () => {
await falcon.genkey();
const publicKeyBase64 = await falcon.getPublicKeyBase64();
const privateKeyBase64 = await falcon.getPrivateKeyBase64();
expect(publicKeyBase64).toMatch(/^[A-Za-z0-9+/=]+$/);
expect(privateKeyBase64).toMatch(/^[A-Za-z0-9+/=]+$/);
// Verify that base64 is shorter than hex
const publicKeyHex = await falcon.getPublicKeyHex();
const privateKeyHex = await falcon.getPrivateKeyHex();
expect(publicKeyBase64.length).toBeLessThan(publicKeyHex.length);
expect(privateKeyBase64.length).toBeLessThan(privateKeyHex.length);
});
});
describe('Signing and Verification', () => {
it('should sign and verify a message', async () => {
await falcon.genkey();
const message = 'Hello, Falcon!';
const signature = await falcon.sign(message);
expect(signature).toBeDefined();
expect(signature.length).toBeGreaterThan(0);
const isValid = await falcon.verify(message, signature);
expect(isValid).toBe(true);
});
it('should sign and verify using hex format', async () => {
await falcon.genkey();
const message = 'Hello, Falcon!';
const signatureHex = await falcon.signHex(message);
expect(signatureHex).toMatch(/^[0-9a-f]+$/i);
const isValid = await falcon.verifyHex(message, signatureHex);
expect(isValid).toBe(true);
});
it('should sign and verify using base64 format', async () => {
await falcon.genkey();
const message = 'Hello, Falcon!';
const signatureBase64 = await falcon.signBase64(message);
expect(signatureBase64).toMatch(/^[A-Za-z0-9+/=]+$/);
const isValid = await falcon.verifyBase64(message, signatureBase64);
expect(isValid).toBe(true);
// Verify that base64 is shorter than hex
const signatureHex = await falcon.signHex(message);
expect(signatureBase64.length).toBeLessThan(signatureHex.length);
});
it('should reject invalid signatures', async () => {
await falcon.genkey();
const message = 'Hello, Falcon!';
const signature = await falcon.sign(message);
// Modify the signature
const modifiedSignature = new Uint8Array(signature);
modifiedSignature[0] = modifiedSignature[0] ^ 1;
const isValid = await falcon.verify(message, modifiedSignature);
expect(isValid).toBe(false);
});
});
describe('Key Import and Export', () => {
it('should create public key from private key', async () => {
await falcon.genkey();
const privateKey = await falcon.getPrivateKey();
const publicKey = await falcon.publicKeyCreate(privateKey);
expect(publicKey).toBeDefined();
expect(publicKey.length).toBeGreaterThan(0);
});
it('should set private key from hex and derive public key', async () => {
await falcon.genkey();
const originalPrivateKeyHex = await falcon.getPrivateKeyHex();
const originalPublicKeyHex = await falcon.getPublicKeyHex();
const falcon2 = new Falcon();
await falcon2.init();
const derivedPublicKeyHex = await falcon2.setPrivateKeyHex(originalPrivateKeyHex);
expect(derivedPublicKeyHex).toBe(originalPublicKeyHex);
});
it('should set private key from base64 and derive public key', async () => {
await falcon.genkey();
const originalPrivateKeyBase64 = await falcon.getPrivateKeyBase64();
const originalPublicKeyBase64 = await falcon.getPublicKeyBase64();
const falcon2 = new Falcon();
await falcon2.init();
const derivedPublicKeyBase64 = await falcon2.setPrivateKeyBase64(originalPrivateKeyBase64);
expect(derivedPublicKeyBase64).toBe(originalPublicKeyBase64);
});
});
});

121
__tests__/mnemonic.test.ts Normal file
View File

@ -0,0 +1,121 @@
import { uint8ArrayToMnemonic, mnemonicToUint8Array, validateMnemonic, generateMnemonic } from '../src/mnemonic';
import Falcon from '../src/falcon';
describe('Mnemonic Implementation', () => {
describe('Basic Functionality', () => {
it('should generate valid mnemonics', () => {
const mnemonic = generateMnemonic();
expect(validateMnemonic(mnemonic)).toBe(true);
// Check mnemonic format
const words = mnemonic.split(' ');
expect(words.length).toBe(12);
});
it('should convert between Uint8Array and mnemonic', () => {
const originalData = new Uint8Array([1, 2, 3, 4, 5]);
const mnemonic = uint8ArrayToMnemonic(originalData);
const recoveredData = mnemonicToUint8Array(mnemonic);
// The recovered data should be 48 bytes (required for Falcon)
expect(recoveredData.length).toBe(48);
});
it('should validate mnemonics correctly', () => {
const validMnemonic = generateMnemonic();
expect(validateMnemonic(validMnemonic)).toBe(true);
const invalidMnemonic = 'not a valid mnemonic phrase';
expect(validateMnemonic(invalidMnemonic)).toBe(false);
});
});
describe('Falcon Integration', () => {
let falcon: Falcon;
let mnemonic: string;
let seed: Uint8Array;
beforeEach(async () => {
// Generate a new mnemonic and initialize Falcon
mnemonic = generateMnemonic();
seed = mnemonicToUint8Array(mnemonic);
falcon = new Falcon();
await falcon.init();
});
it('should generate valid 48-byte seeds', () => {
const seed = mnemonicToUint8Array(mnemonic);
expect(seed.length).toBe(48);
});
it('should generate working key pairs from mnemonic', async () => {
// Generate keys from seed
await falcon.genkey(seed);
const keypair = await falcon.getKeypair();
expect(keypair.pk).toBeDefined();
expect(keypair.sk).toBeDefined();
});
it('should recover working keys from mnemonic', async () => {
// Generate original keys
await falcon.genkey(seed);
const originalKeypair = await falcon.getKeypair();
// Create new instance and recover keys
const recoveredFalcon = new Falcon();
await recoveredFalcon.init();
await recoveredFalcon.genkey(seed);
const recoveredKeypair = await recoveredFalcon.getKeypair();
// Compare keys
expect(Buffer.from(recoveredKeypair.pk).toString('hex'))
.toBe(Buffer.from(originalKeypair.pk).toString('hex'));
expect(Buffer.from(recoveredKeypair.sk).toString('hex'))
.toBe(Buffer.from(originalKeypair.sk).toString('hex'));
});
it('should sign and verify with recovered keys', async () => {
// Generate original keys and sign a message
await falcon.genkey(seed);
const message = 'Test message';
const signature = await falcon.sign(message);
// Verify with original keys
const originalVerification = await falcon.verify(message, signature);
expect(originalVerification).toBe(true);
// Recover keys in new instance
const recoveredFalcon = new Falcon();
await recoveredFalcon.init();
await recoveredFalcon.genkey(seed);
// Sign with recovered keys
const newMessage = 'Another test message';
const newSignature = await recoveredFalcon.sign(newMessage);
// Verify with recovered keys
const recoveredVerification = await recoveredFalcon.verify(newMessage, newSignature);
expect(recoveredVerification).toBe(true);
// Cross-verify: verify new signature with original instance
const crossVerification = await falcon.verify(newMessage, newSignature);
expect(crossVerification).toBe(true);
});
it('should handle invalid mnemonics', () => {
const invalidMnemonics = [
'invalid mnemonic',
'too few words',
'too many words in this mnemonic phrase which should fail',
''
];
invalidMnemonics.forEach(mnemonic => {
expect(validateMnemonic(mnemonic)).toBe(false);
expect(() => mnemonicToUint8Array(mnemonic)).toThrow();
});
});
});
});

13
bun.lock Normal file
View File

@ -0,0 +1,13 @@
{
"lockfileVersion": 1,
"workspaces": {
"": {
"dependencies": {
"falcon-sign": "^1.0.4",
},
},
},
"packages": {
"falcon-sign": ["falcon-sign@1.0.4", "", {}, "sha512-anP6RlcaU8Eaunm7tO1BZfO+OoD6i/eCMOU5ZyqnBPzGYnHAQ6zTR9dmHE9TwsS+g/IEjBQ/gB3oh+LapBeC4A=="],
}
}

66
example.ts Normal file
View File

@ -0,0 +1,66 @@
import { Falcon } from './src';
async function main() {
console.log("=== Falcon Cryptographic Operations ===");
// Create a new Falcon instance with default algorithm (falcon512_n3_v1)
const falcon = new Falcon();
await falcon.init();
console.log("Falcon initialized with algorithm:", await falcon.getAlgid());
// Generate a new key pair
console.log("\n=== Generating new keypair ===");
await falcon.genkey();
// Get the public and private keys in hex format
const publicKeyHex = await falcon.getPublicKeyHex();
const privateKeyHex = await falcon.getPrivateKeyHex();
// Get the public and private keys in base64 format (more compact)
const publicKeyBase64 = await falcon.getPublicKeyBase64();
const privateKeyBase64 = await falcon.getPrivateKeyBase64();
console.log("Public Key (hex):", publicKeyHex);
console.log("Public Key (base64):", publicKeyBase64);
console.log("Private Key (hex):", privateKeyHex);
console.log("Private Key (base64):", privateKeyBase64);
console.log("Size reduction:", Math.round((1 - publicKeyBase64.length / publicKeyHex.length) * 100) + '%');
// Sign a message
console.log("\n=== Signing a message ===");
const message = 'Hello, Falcon!';
const signatureHex = await falcon.signHex(message);
const signatureBase64 = await falcon.signBase64(message);
console.log("Message:", message);
console.log("Signature (hex):", signatureHex);
console.log("Signature (base64):", signatureBase64);
console.log("Size reduction:", Math.round((1 - signatureBase64.length / signatureHex.length) * 100) + '%');
// Verify the signature
console.log("\n=== Verifying signatures ===");
const isValidHex = await falcon.verifyHex(message, signatureHex);
const isValidBase64 = await falcon.verifyBase64(message, signatureBase64);
console.log("Verification (hex):", isValidHex);
console.log("Verification (base64):", isValidBase64);
// Create a new Falcon instance and import the private key
console.log("\n=== Importing private key ===");
const falcon2 = new Falcon();
await falcon2.init();
// Import using hex format
const derivedPublicKeyHex = await falcon2.setPrivateKeyHex(privateKeyHex);
console.log("Derived Public Key (hex):", derivedPublicKeyHex);
console.log("Keys match (hex):", derivedPublicKeyHex === publicKeyHex);
// Import using base64 format
const falcon3 = new Falcon();
await falcon3.init();
const derivedPublicKeyBase64 = await falcon3.setPrivateKeyBase64(privateKeyBase64);
console.log("Derived Public Key (base64):", derivedPublicKeyBase64);
console.log("Keys match (base64):", derivedPublicKeyBase64 === publicKeyBase64);
}
main().catch(console.error);

7
jest.config.js Normal file
View File

@ -0,0 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/__tests__/**/*.test.ts'],
moduleFileExtensions: ['ts', 'js'],
};

92
mnemonic_example.ts Normal file
View File

@ -0,0 +1,92 @@
import { uint8ArrayToMnemonic, mnemonicToUint8Array, validateMnemonic, generateMnemonic } from './src/mnemonic';
import Falcon from './src/falcon';
/**
* Example demonstrating the usage of our custom mnemonic implementation
* for Falcon keys.
*/
async function mnemonicExample() {
console.log('=== Falcon Mnemonic Example ===');
// Generate a random mnemonic
const mnemonic = generateMnemonic();
console.log('Generated mnemonic:', mnemonic);
// Validate the mnemonic
const isValid = validateMnemonic(mnemonic);
console.log('Mnemonic is valid:', isValid);
// Convert mnemonic to Uint8Array (seed)
const seed = mnemonicToUint8Array(mnemonic);
console.log('Seed (first 10 bytes):', Buffer.from(seed.slice(0, 10)).toString('hex'));
// Create a Falcon instance
const falcon = new Falcon();
await falcon.init();
// Generate a key pair using the seed
await falcon.genkey(seed);
// Get the key pair
const keypair = await falcon.getKeypair();
const publicKey = keypair.pk;
const privateKey = keypair.sk;
// Sign a message
const message = 'Hello, Falcon!';
const signature = await falcon.sign(message);
// Verify the signature
const verificationResult = await falcon.verify(message, signature);
console.log('Original signature verification:', verificationResult ? 'Valid' : 'Invalid');
// Export the keys and mnemonic
console.log('Public Key:', Buffer.from(publicKey).toString('hex'));
console.log('Private Key:', Buffer.from(privateKey).toString('hex'));
console.log('Mnemonic:', mnemonic);
// Demonstrate recovery from mnemonic
console.log('\n=== Recovering from mnemonic ===');
const recoveredSeed = mnemonicToUint8Array(mnemonic);
// Create a new Falcon instance
const recoveredFalcon = new Falcon();
await recoveredFalcon.init();
// Generate a key pair using the recovered seed
await recoveredFalcon.genkey(recoveredSeed);
// Get the recovered key pair
const recoveredKeypair = await recoveredFalcon.getKeypair();
const recoveredPublicKey = recoveredKeypair.pk;
const recoveredPrivateKey = recoveredKeypair.sk;
// Verify that the recovered keys match the original
const publicKeysMatch = Buffer.from(publicKey).toString('hex') ===
Buffer.from(recoveredPublicKey).toString('hex');
const privateKeysMatch = Buffer.from(privateKey).toString('hex') ===
Buffer.from(recoveredPrivateKey).toString('hex');
console.log('Recovery successful:', publicKeysMatch && privateKeysMatch);
console.log('Public keys match:', publicKeysMatch);
console.log('Private keys match:', privateKeysMatch);
// Test signing and verification with recovered keys
console.log('\n=== Testing Recovered Keys ===');
const newMessage = 'Testing recovered keys!';
// Sign with recovered keys
const newSignature = await recoveredFalcon.sign(newMessage);
console.log('Signed message with recovered keys');
// Verify with recovered keys
const newVerificationResult = await recoveredFalcon.verify(newMessage, newSignature);
console.log('New signature verification:', newVerificationResult ? 'Valid' : 'Invalid');
// Cross-verify: verify new signature with original instance
const crossVerificationResult = await falcon.verify(newMessage, newSignature);
console.log('Cross-verification (original instance):', crossVerificationResult ? 'Valid' : 'Invalid');
}
// Run the example
mnemonicExample().catch(console.error);

34
package.json Normal file
View File

@ -0,0 +1,34 @@
{
"name": "falcon-ts",
"version": "1.0.0",
"description": "A TypeScript implementation of the Falcon signature scheme with a custom mnemonic implementation",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"test": "jest",
"example": "ts-node src/example.ts",
"mnemonic-example": "ts-node src/mnemonic_example.ts"
},
"keywords": [
"falcon",
"signature",
"cryptography",
"mnemonic",
"typescript"
],
"author": "",
"license": "MIT",
"devDependencies": {
"@types/jest": "^29.5.3",
"@types/node": "^20.4.5",
"jest": "^29.6.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
},
"dependencies": {
"buffer": "^6.0.3",
"falcon-sign": "^1.0.4"
}
}

37
src/falcon-sign.d.ts vendored Normal file
View File

@ -0,0 +1,37 @@
declare module 'falcon-sign' {
export interface FalconKeypair {
genkeySeed: Uint8Array;
pk: Uint8Array;
sk: Uint8Array;
}
export interface FalconKernel {
algid: string;
genkeySeedByte: number;
skByte: number;
pkByte: number;
signByte: number;
signSaltByte: number;
signNonceByte: number;
genkey(genkeySeed?: Uint8Array): FalconKeypair;
publicKeyCreate(sk: Uint8Array): Uint8Array;
sign(message: Uint8Array | string, sk: Uint8Array, salt?: Uint8Array): Uint8Array;
verify(signMsg: Uint8Array, message: Uint8Array | string, pk: Uint8Array): boolean;
}
export function getKernel(algid?: string): Promise<FalconKernel>;
export function getKernelNameList(): string[];
export const util: {
isUint8Array(data: any): boolean;
isUint(data: any): boolean;
uint8ArrayToString(buf: Uint8Array, decode?: string): string;
base64ToUint8Array(data: string): Uint8Array | undefined;
hexStringToUint8Array(data: string): Uint8Array | undefined;
uint8ArrayConcat(bufs: Uint8Array[]): Uint8Array;
uint8ArrayEqual(buf1: Uint8Array, buf2: Uint8Array): boolean;
randomBytes(size: number): Uint8Array;
hexToUint8Array(hex: string): Uint8Array;
uint8ArrayToHex(uint8Array: Uint8Array): string;
};
}

277
src/falcon.ts Normal file
View File

@ -0,0 +1,277 @@
import { getKernel } from 'falcon-sign';
// Define interfaces for the types we observed
interface FalconKernel {
genkey: (seed?: Uint8Array) => FalconKeypair;
publicKeyCreate: (privateKey: Uint8Array) => Uint8Array;
sign: (message: string, privateKey: Uint8Array, salt?: Uint8Array) => Uint8Array;
verify: (signature: Uint8Array, message: string, publicKey: Uint8Array) => boolean;
algid: string;
genkeySeedByte: number;
skByte: number;
pkByte: number;
signByte: number;
signSaltByte: number;
signNonceByte: number;
}
interface FalconKeypair {
genkeySeed: Uint8Array;
sk: Uint8Array;
pk: Uint8Array;
}
export default class Falcon {
private kernel!: FalconKernel;
private keypair!: FalconKeypair;
private algid: string;
constructor(algid?: string) {
if (algid && (algid !== 'falcon512_n3_v1' && algid !== 'falcon1024_n3_v1')) {
throw new Error(`Invalid algorithm ID: ${algid}\nSupported algorithms: falcon512_n3_v1, falcon1024_n3_v1\nLeave blank for default: falcon512_n3_v1`);
}
this.algid = algid || 'falcon512_n3_v1';
}
async init(): Promise<void> {
this.kernel = await getKernel(this.algid);
}
// SECTION: Signing
async genkey(seed?: Uint8Array): Promise<void> {
if (seed) {
this.keypair = this.kernel.genkey(seed);
} else {
this.keypair = this.kernel.genkey();
}
}
async sign(message: string, salt?: Uint8Array): Promise<Uint8Array> {
if (salt) {
return this.kernel.sign(message, this.keypair.sk, salt);
} else {
return this.kernel.sign(message, this.keypair.sk);
}
}
async verify(message: string, signature: Uint8Array): Promise<boolean> {
return this.kernel.verify(signature, message, this.keypair.pk);
}
async publicKeyCreate(privateKey: Uint8Array): Promise<Uint8Array> {
return this.kernel.publicKeyCreate(privateKey);
}
// SECTION: Getters
async getPublicKey(): Promise<Uint8Array> {
return this.keypair.pk;
}
async getPrivateKey(): Promise<Uint8Array> {
return this.keypair.sk;
}
async getAlgid(): Promise<string> {
return this.algid;
}
async getKeypair(): Promise<FalconKeypair> {
return this.keypair;
}
async getKernel(): Promise<FalconKernel> {
return this.kernel;
}
// Helper methods for hex string conversion
/**
* Convert a Uint8Array to a hex string
* @param array The Uint8Array to convert
* @returns A hex string representation of the Uint8Array
*/
static uint8ArrayToHex(array: Uint8Array): string {
return Array.from(array)
.map(b => b.toString(16).padStart(2, '0'))
.join('');
}
/**
* Convert a hex string to a Uint8Array
* @param hex The hex string to convert
* @returns A Uint8Array representation of the hex string
*/
static hexToUint8Array(hex: string): Uint8Array {
// Remove any non-hex characters
hex = hex.replace(/[^0-9a-fA-F]/g, '');
// Ensure the hex string has an even length
if (hex.length % 2 !== 0) {
hex = '0' + hex;
}
const array = new Uint8Array(hex.length / 2);
for (let i = 0; i < hex.length; i += 2) {
array[i / 2] = parseInt(hex.substring(i, i + 2), 16);
}
return array;
}
/**
* Get the public key as a hex string
* @returns A hex string representation of the public key
*/
async getPublicKeyHex(): Promise<string> {
const publicKey = await this.getPublicKey();
return Falcon.uint8ArrayToHex(publicKey);
}
/**
* Get the private key as a hex string
* @returns A hex string representation of the private key
*/
async getPrivateKeyHex(): Promise<string> {
const privateKey = await this.getPrivateKey();
return Falcon.uint8ArrayToHex(privateKey);
}
/**
* Sign a message and return the signature as a hex string
* @param message The message to sign
* @returns A hex string representation of the signature
*/
async signHex(message: string): Promise<string> {
const signature = await this.sign(message);
return Falcon.uint8ArrayToHex(signature);
}
/**
* Verify a signature provided as a hex string
* @param message The message that was signed
* @param signatureHex The signature as a hex string
* @returns True if the signature is valid, false otherwise
*/
async verifyHex(message: string, signatureHex: string): Promise<boolean> {
const signature = Falcon.hexToUint8Array(signatureHex);
return this.verify(message, signature);
}
/**
* Create a public key from a private key provided as a hex string
* @param privateKeyHex The private key as a hex string
* @returns A hex string representation of the public key
*/
async publicKeyCreateHex(privateKeyHex: string): Promise<string> {
const privateKey = Falcon.hexToUint8Array(privateKeyHex);
const publicKey = await this.publicKeyCreate(privateKey);
return Falcon.uint8ArrayToHex(publicKey);
}
/**
* Set a private key from a hex string
* @param privateKeyHex The private key as a hex string
* @returns The public key as a hex string
*/
async setPrivateKeyHex(privateKeyHex: string): Promise<string> {
const privateKey = Falcon.hexToUint8Array(privateKeyHex);
const publicKey = await this.publicKeyCreate(privateKey);
// Update the keypair
this.keypair = {
genkeySeed: new Uint8Array(0), // We don't have the seed
sk: privateKey,
pk: publicKey
};
return Falcon.uint8ArrayToHex(publicKey);
}
/**
* Convert a Uint8Array to a base64 string
* @param array The Uint8Array to convert
* @returns A base64 string representation of the Uint8Array
*/
static uint8ArrayToBase64(array: Uint8Array): string {
return Buffer.from(array).toString('base64');
}
/**
* Convert a base64 string to a Uint8Array
* @param base64 The base64 string to convert
* @returns A Uint8Array representation of the base64 string
*/
static base64ToUint8Array(base64: string): Uint8Array {
return Buffer.from(base64, 'base64');
}
/**
* Get the public key as a base64 string
* @returns A base64 string representation of the public key
*/
async getPublicKeyBase64(): Promise<string> {
const publicKey = await this.getPublicKey();
return Falcon.uint8ArrayToBase64(publicKey);
}
/**
* Get the private key as a base64 string
* @returns A base64 string representation of the private key
*/
async getPrivateKeyBase64(): Promise<string> {
const privateKey = await this.getPrivateKey();
return Falcon.uint8ArrayToBase64(privateKey);
}
/**
* Sign a message and return the signature as a base64 string
* @param message The message to sign
* @returns A base64 string representation of the signature
*/
async signBase64(message: string): Promise<string> {
const signature = await this.sign(message);
return Falcon.uint8ArrayToBase64(signature);
}
/**
* Verify a signature provided as a base64 string
* @param message The message that was signed
* @param signatureBase64 The signature as a base64 string
* @returns True if the signature is valid, false otherwise
*/
async verifyBase64(message: string, signatureBase64: string): Promise<boolean> {
const signature = Falcon.base64ToUint8Array(signatureBase64);
return this.verify(message, signature);
}
/**
* Create a public key from a private key provided as a base64 string
* @param privateKeyBase64 The private key as a base64 string
* @returns A base64 string representation of the public key
*/
async publicKeyCreateBase64(privateKeyBase64: string): Promise<string> {
const privateKey = Falcon.base64ToUint8Array(privateKeyBase64);
const publicKey = await this.publicKeyCreate(privateKey);
return Falcon.uint8ArrayToBase64(publicKey);
}
/**
* Set a private key from a base64 string
* @param privateKeyBase64 The private key as a base64 string
* @returns The public key as a base64 string
*/
async setPrivateKeyBase64(privateKeyBase64: string): Promise<string> {
const privateKey = Falcon.base64ToUint8Array(privateKeyBase64);
const publicKey = await this.publicKeyCreate(privateKey);
// Update the keypair
this.keypair = {
genkeySeed: new Uint8Array(0), // We don't have the seed
sk: privateKey,
pk: publicKey
};
return Falcon.uint8ArrayToBase64(publicKey);
}
}

13
src/index.ts Normal file
View File

@ -0,0 +1,13 @@
// Export Falcon class
export { default as Falcon } from './falcon';
// Export mnemonic functions
export {
uint8ArrayToMnemonic,
mnemonicToUint8Array,
validateMnemonic,
generateMnemonic
} from './mnemonic';
// Export word list
export { wordList } from './wordlist';

120
src/mnemonic.ts Normal file
View File

@ -0,0 +1,120 @@
import { wordList } from './wordlist';
import { createHash } from 'crypto';
/**
* Custom mnemonic implementation for Falcon keys.
* This implementation is designed to work with Falcon's key sizes and doesn't rely on BIP39.
*/
/**
* Convert a Uint8Array to a mnemonic phrase
* @param data The Uint8Array to convert
* @returns A mnemonic phrase (12 words)
*/
export function uint8ArrayToMnemonic(data: Uint8Array): string {
// We'll use 12 words, each representing 11 bits of entropy
// This gives us 132 bits of entropy, which is sufficient for Falcon keys
// Convert the Uint8Array to a binary string
let binary = '';
for (let i = 0; i < data.length; i++) {
binary += data[i].toString(2).padStart(8, '0');
}
// Ensure we have enough bits
while (binary.length < 132) {
binary += '0';
}
// Take the first 132 bits
binary = binary.substring(0, 132);
// Split into 11-bit chunks
const chunks: string[] = [];
for (let i = 0; i < 12; i++) {
chunks.push(binary.substring(i * 11, (i + 1) * 11));
}
// Convert each chunk to a decimal number and use it to select a word
const words: string[] = [];
for (const chunk of chunks) {
const index = parseInt(chunk, 2);
words.push(wordList[index % wordList.length]);
}
return words.join(' ');
}
/**
* Convert a mnemonic phrase to a Uint8Array
* @param mnemonic The mnemonic phrase
* @returns A Uint8Array of 48 bytes (384 bits) suitable for Falcon key generation
*/
export function mnemonicToUint8Array(mnemonic: string): Uint8Array {
// Split the mnemonic into words
const words = mnemonic.trim().split(/\s+/);
if (words.length !== 12) {
throw new Error('Invalid mnemonic phrase: must contain exactly 12 words');
}
// Convert each word to its index in the word list
const indices: number[] = [];
for (const word of words) {
const index = wordList.indexOf(word);
if (index === -1) {
throw new Error(`Invalid word in mnemonic: ${word}`);
}
indices.push(index);
}
// Convert indices to binary
let binary = '';
for (const index of indices) {
binary += index.toString(2).padStart(11, '0');
}
// Convert binary to initial entropy bytes
const entropyBytes: number[] = [];
for (let i = 0; i < binary.length; i += 8) {
const byte = binary.substring(i, i + 8);
entropyBytes.push(parseInt(byte, 2));
}
// Create initial entropy Uint8Array
const entropy = new Uint8Array(entropyBytes);
// Use SHA-512 to expand the entropy to 48 bytes
const hash = createHash('sha512');
hash.update(entropy);
const expandedEntropy = new Uint8Array(hash.digest().buffer.slice(0, 48));
return expandedEntropy;
}
/**
* Validate a mnemonic phrase
* @param mnemonic The mnemonic phrase to validate
* @returns True if the mnemonic is valid, false otherwise
*/
export function validateMnemonic(mnemonic: string): boolean {
try {
mnemonicToUint8Array(mnemonic);
return true;
} catch (error) {
return false;
}
}
/**
* Generate a random mnemonic phrase
* @returns A random mnemonic phrase
*/
export function generateMnemonic(): string {
// Generate a random Uint8Array
const randomBytes = new Uint8Array(16); // 128 bits
crypto.getRandomValues(randomBytes);
// Convert to mnemonic
return uint8ArrayToMnemonic(randomBytes);
}

212
src/wordlist.ts Normal file
View File

@ -0,0 +1,212 @@
/**
* A list of 2048 common English words for mnemonic generation.
* This is a subset of the BIP39 word list, but we're using it differently.
*/
export const wordList = [
"abandon", "ability", "able", "about", "above", "absent", "absorb", "abstract", "absurd", "abuse",
"access", "accident", "account", "accuse", "achieve", "acid", "acoustic", "acquire", "across", "act",
"action", "actor", "actress", "actual", "adapt", "add", "addict", "address", "adjust", "admit",
"adult", "advance", "advice", "aerobic", "affair", "afford", "afraid", "again", "age", "agent",
"agree", "ahead", "aim", "air", "airport", "aisle", "alarm", "album", "alcohol", "alert",
"alien", "all", "alley", "allow", "almost", "alone", "alpha", "already", "also", "alter",
"always", "amateur", "amazing", "among", "amount", "amused", "analyst", "anchor", "ancient", "anger",
"angle", "angry", "animal", "ankle", "announce", "annual", "another", "answer", "antenna", "antique",
"anxiety", "any", "apart", "apology", "appear", "apple", "approve", "april", "arch", "arctic",
"area", "arena", "argue", "arm", "armed", "armor", "army", "around", "arrange", "arrest",
"arrive", "arrow", "art", "artefact", "artist", "artwork", "ask", "aspect", "assault", "asset",
"assist", "assume", "asthma", "athlete", "atom", "attack", "attend", "attitude", "attract", "auction",
"audit", "august", "aunt", "author", "auto", "autumn", "average", "avocado", "avoid", "awake",
"aware", "away", "awesome", "awful", "awkward", "axis", "baby", "bachelor", "bacon", "badge",
"bag", "balance", "balcony", "ball", "bamboo", "banana", "banner", "bar", "barely", "bargain",
"barrel", "base", "basic", "basket", "battle", "beach", "bean", "beauty", "because", "become",
"beef", "before", "begin", "behave", "behind", "believe", "below", "belt", "bench", "benefit",
"best", "betray", "better", "between", "beyond", "bicycle", "bid", "bike", "bind", "biology",
"bird", "birth", "bitter", "black", "blade", "blame", "blanket", "blast", "bleak", "bless",
"blind", "blood", "blossom", "blouse", "blue", "blur", "blush", "board", "boat", "body",
"boil", "bomb", "bone", "bonus", "book", "boost", "border", "boring", "borrow", "boss",
"bottom", "bounce", "box", "boy", "bracket", "brain", "brand", "brass", "brave", "bread",
"breeze", "brick", "bridge", "brief", "bright", "bring", "brisk", "broccoli", "broken", "bronze",
"broom", "brother", "brown", "brush", "bubble", "buddy", "budget", "buffalo", "build", "bulb",
"bulk", "bullet", "bundle", "bunker", "burden", "burger", "burst", "bus", "business", "busy",
"butter", "buyer", "buzz", "cabbage", "cabin", "cable", "cactus", "cage", "cake", "call",
"calm", "camera", "camp", "can", "canal", "cancel", "candy", "cannon", "canoe", "canvas",
"canyon", "capable", "capital", "captain", "car", "carbon", "card", "cargo", "carpet", "carry",
"cart", "case", "cash", "casino", "castle", "casual", "cat", "catalog", "catch", "category",
"cattle", "caught", "cause", "caution", "cave", "ceiling", "celery", "cement", "census", "century",
"cereal", "certain", "chair", "chalk", "champion", "change", "chaos", "chapter", "charge", "chase",
"chat", "cheap", "check", "cheese", "chef", "cherry", "chest", "chicken", "chief", "child",
"chimney", "choice", "choose", "chronic", "chuckle", "chunk", "churn", "cigar", "cinnamon", "circle",
"citizen", "city", "civil", "claim", "clap", "clarify", "claw", "clay", "clean", "clerk",
"clever", "click", "client", "cliff", "climb", "clinic", "clip", "clock", "clog", "close",
"cloth", "cloud", "clown", "club", "clump", "cluster", "clutch", "coach", "coast", "coconut",
"code", "coffee", "coil", "coin", "collect", "color", "column", "combine", "come", "comfort",
"comic", "common", "company", "concert", "conduct", "confirm", "congress", "connect", "consider", "control",
"convince", "cook", "cool", "copper", "copy", "coral", "core", "corn", "correct", "cost",
"cotton", "couch", "country", "couple", "course", "cousin", "cover", "coyote", "crack", "cradle",
"craft", "cram", "crane", "crash", "crater", "crawl", "crazy", "cream", "credit", "creek",
"crew", "cricket", "crime", "crisp", "critic", "crop", "cross", "crouch", "crowd", "crucial",
"cruel", "cruise", "crumble", "crunch", "crush", "cry", "crystal", "cube", "culture", "cup",
"cupboard", "curious", "current", "curtain", "curve", "cushion", "custom", "cute", "cycle", "dad",
"damage", "damp", "dance", "danger", "daring", "dash", "daughter", "dawn", "day", "deal",
"debate", "debris", "decade", "december", "decide", "decline", "decorate", "decrease", "deer", "defense",
"define", "defy", "degree", "delay", "deliver", "demand", "demise", "denial", "dentist", "deny",
"depart", "depend", "deposit", "depth", "deputy", "derive", "describe", "desert", "design", "desk",
"despair", "destroy", "detail", "detect", "develop", "device", "devote", "diagram", "dial", "diamond",
"diary", "dice", "diesel", "diet", "differ", "digital", "dignity", "dilemma", "dinner", "dinosaur",
"direct", "dirt", "disagree", "discover", "disease", "dish", "dismiss", "disorder", "display", "distance",
"divert", "divide", "divorce", "dizzy", "doctor", "document", "dog", "doll", "dolphin", "domain",
"donate", "donkey", "donor", "door", "dose", "double", "dove", "draft", "dragon", "drama",
"drastic", "draw", "dream", "dress", "drift", "drill", "drink", "drip", "drive", "drop",
"drum", "dry", "duck", "dumb", "dune", "during", "dust", "dutch", "duty", "dwarf",
"dynamic", "eager", "eagle", "early", "earn", "earth", "easily", "east", "easy", "echo",
"ecology", "economy", "edge", "edit", "educate", "effort", "egg", "eight", "either", "elbow",
"elder", "electric", "elegant", "element", "elephant", "elevator", "elite", "else", "embark", "embody",
"embrace", "emerge", "emotion", "employ", "empower", "empty", "enable", "enact", "end", "endless",
"endorse", "enemy", "energy", "enforce", "engage", "engine", "enhance", "enjoy", "enlist", "enough",
"enrich", "enroll", "ensure", "enter", "entire", "entry", "envelope", "episode", "equal", "equip",
"era", "erase", "erode", "erosion", "error", "erupt", "escape", "essay", "essence", "estate",
"eternal", "ethics", "evidence", "evil", "evoke", "evolve", "exact", "example", "excess", "exchange",
"excite", "exclude", "excuse", "execute", "exercise", "exhaust", "exhibit", "exile", "exist", "exit",
"exotic", "expand", "expect", "expire", "explain", "expose", "express", "extend", "extra", "eye",
"eyebrow", "fabric", "face", "faculty", "fade", "faint", "faith", "fall", "false", "fame",
"family", "famous", "fan", "fancy", "fantasy", "farm", "fashion", "fat", "fatal", "father",
"fatigue", "fault", "favorite", "feature", "february", "federal", "fee", "feed", "feel", "female",
"fence", "festival", "fetch", "fever", "few", "fiber", "fiction", "field", "figure", "file",
"film", "filter", "final", "find", "fine", "finger", "finish", "fire", "firm", "first",
"fiscal", "fish", "fit", "fitness", "fix", "flag", "flame", "flash", "flat", "flavor",
"flee", "flight", "flip", "float", "flock", "floor", "flower", "fluid", "flush", "fly",
"foam", "focus", "fog", "foil", "fold", "follow", "food", "foot", "force", "forest",
"forget", "fork", "fortune", "forum", "forward", "fossil", "foster", "found", "fox", "fragile",
"frame", "frequent", "fresh", "friend", "fringe", "frog", "front", "frost", "frown", "frozen",
"fruit", "fuel", "fun", "funny", "furnace", "fury", "future", "gadget", "gain", "galaxy",
"gallery", "game", "gap", "garage", "garbage", "garden", "garlic", "garment", "gas", "gasp",
"gate", "gather", "gauge", "gaze", "general", "genius", "genre", "gentle", "genuine", "gesture",
"ghost", "giant", "gift", "giggle", "ginger", "giraffe", "girl", "give", "glad", "glance",
"glare", "glass", "glide", "glimpse", "globe", "gloom", "glory", "glove", "glow", "glue",
"goat", "goddess", "gold", "good", "goose", "gorilla", "gospel", "gossip", "govern", "gown",
"grab", "grace", "grain", "grant", "grape", "grass", "gravity", "great", "green", "grid",
"grief", "grit", "grocery", "group", "grow", "grunt", "guard", "guess", "guide", "guilt",
"guitar", "gun", "gym", "habit", "hair", "half", "hammer", "hamster", "hand", "happy",
"harbor", "hard", "harsh", "harvest", "hat", "have", "hawk", "hazard", "head", "health",
"heart", "heavy", "hedgehog", "height", "hello", "helmet", "help", "hen", "hero", "hidden",
"high", "hill", "hint", "hip", "hire", "history", "hobby", "hockey", "hold", "hole",
"holiday", "hollow", "home", "honey", "hood", "hope", "horn", "horror", "horse", "hospital",
"host", "hotel", "hour", "hover", "hub", "huge", "human", "humble", "humor", "hundred",
"hungry", "hunt", "hurdle", "hurry", "hurt", "husband", "hybrid", "ice", "icon", "idea",
"identify", "idle", "ignore", "ill", "illegal", "illness", "image", "imitate", "immense", "immune",
"impact", "impose", "improve", "impulse", "inch", "include", "income", "increase", "index", "indicate",
"indoor", "industry", "infant", "inflict", "inform", "inhale", "inherit", "initial", "inject", "injury",
"inmate", "inner", "innocent", "input", "inquiry", "insane", "insect", "inside", "inspire", "install",
"intact", "interest", "into", "invest", "invite", "involve", "iron", "island", "isolate", "issue",
"item", "ivory", "jacket", "jaguar", "jar", "jazz", "jealous", "jeans", "jelly", "jewel",
"job", "join", "joke", "journey", "joy", "judge", "juice", "jump", "jungle", "junior",
"junk", "just", "kangaroo", "keen", "keep", "ketchup", "key", "kick", "kid", "kidney",
"kind", "kingdom", "kiss", "kit", "kitchen", "kite", "kitten", "kiwi", "knee", "knife",
"knock", "know", "lab", "label", "labor", "ladder", "lady", "lake", "lamp", "language",
"laptop", "large", "later", "latin", "laugh", "laundry", "lava", "law", "lawn", "lawsuit",
"layer", "lazy", "leader", "leaf", "learn", "leave", "lecture", "left", "leg", "legal",
"legend", "leisure", "lemon", "lend", "length", "lens", "leopard", "lesson", "letter", "level",
"liar", "liberty", "library", "license", "life", "lift", "light", "like", "limb", "limit",
"link", "lion", "liquid", "list", "little", "live", "lizard", "load", "loan", "lobster",
"local", "lock", "logic", "lonely", "long", "loop", "lottery", "loud", "lounge", "love",
"lovely", "lover", "low", "loyal", "lucky", "luggage", "lumber", "lunar", "lunch", "luxury",
"lyrics", "machine", "mad", "magic", "magnet", "maid", "mail", "main", "major", "make",
"mammal", "man", "manage", "mandate", "mango", "mansion", "manual", "maple", "marble", "march",
"margin", "marine", "market", "marriage", "mask", "mass", "master", "match", "material", "math",
"matrix", "matter", "maximum", "maze", "meadow", "mean", "measure", "meat", "mechanic", "medal",
"media", "melody", "melt", "member", "memory", "mention", "menu", "mercy", "merge", "merit",
"merry", "mesh", "message", "metal", "method", "middle", "midnight", "milk", "million", "mimic",
"mind", "minimum", "minor", "minute", "miracle", "mirror", "misery", "miss", "mistake", "mix",
"mixed", "mixture", "mobile", "model", "modify", "mom", "moment", "monitor", "monkey", "monster",
"month", "moon", "moral", "more", "morning", "mosquito", "mother", "motion", "motor", "mountain",
"mouse", "move", "movie", "much", "muffin", "mule", "multiply", "muscle", "museum", "mushroom",
"music", "must", "mutual", "myself", "mystery", "myth", "naive", "name", "napkin", "narrow",
"nasty", "nation", "nature", "near", "neck", "need", "negative", "neglect", "neither", "nephew",
"nerve", "nest", "net", "network", "neutral", "never", "news", "next", "nice", "night",
"noble", "noise", "nominee", "noodle", "normal", "north", "nose", "notable", "note", "nothing",
"notice", "novel", "now", "nuclear", "number", "nurse", "nut", "oak", "obey", "object",
"oblige", "obscure", "observe", "obtain", "obvious", "occur", "ocean", "october", "odor", "off",
"offer", "office", "often", "oil", "okay", "old", "olive", "olympic", "omit", "once",
"one", "onion", "online", "only", "open", "opera", "opinion", "oppose", "option", "orange",
"orbit", "orchard", "order", "ordinary", "organ", "orient", "original", "orphan", "ostrich", "other",
"outdoor", "outer", "output", "outside", "oval", "oven", "over", "own", "owner", "oxygen",
"oyster", "ozone", "pact", "paddle", "page", "pair", "palace", "palm", "panda", "panel",
"panic", "panther", "paper", "parade", "parent", "park", "parrot", "party", "pass", "patch",
"path", "patient", "patrol", "pattern", "pause", "pave", "payment", "peace", "peanut", "pear",
"peasant", "pelican", "pen", "penalty", "pencil", "people", "pepper", "perfect", "permit", "person",
"pet", "phone", "photo", "phrase", "physical", "piano", "picnic", "picture", "piece", "pig",
"pigeon", "pill", "pilot", "pink", "pioneer", "pipe", "pistol", "pitch", "pizza", "place",
"planet", "plastic", "plate", "play", "please", "pledge", "pluck", "plug", "plunge", "poem",
"poet", "point", "polar", "pole", "police", "pond", "pony", "pool", "popular", "portion",
"position", "possible", "post", "potato", "pottery", "poverty", "powder", "power", "practice", "praise",
"predict", "prefer", "prepare", "present", "pretty", "prevent", "price", "pride", "primary", "print",
"priority", "prison", "private", "prize", "problem", "process", "produce", "profit", "program", "project",
"promote", "proof", "property", "prosper", "protect", "proud", "provide", "public", "pudding", "pull",
"pulp", "pulse", "pumpkin", "punch", "pupil", "puppy", "purchase", "purity", "purpose", "purse",
"push", "put", "puzzle", "pyramid", "quality", "quantum", "quarter", "question", "quick", "quit",
"quiz", "quote", "rabbit", "raccoon", "race", "rack", "radar", "radio", "rail", "rain",
"raise", "rally", "ramp", "ranch", "random", "range", "rapid", "rare", "rate", "rather",
"raven", "raw", "razor", "ready", "real", "reason", "rebel", "rebuild", "recall", "receive",
"recipe", "record", "recycle", "reduce", "reflect", "reform", "refuse", "region", "regret", "regular",
"reject", "relax", "release", "relief", "rely", "remain", "remember", "remind", "remove", "render",
"renew", "rent", "reopen", "repair", "repeat", "replace", "report", "require", "rescue", "resemble",
"resist", "resource", "response", "result", "retire", "retreat", "return", "reunion", "reveal", "review",
"reward", "rhythm", "rib", "ribbon", "rice", "rich", "ride", "ridge", "rifle", "right",
"rigid", "ring", "riot", "ripple", "risk", "ritual", "rival", "river", "road", "roast",
"robot", "robust", "rocket", "romance", "roof", "rookie", "room", "rose", "rotate", "rough",
"round", "route", "royal", "rubber", "rude", "rug", "rule", "run", "runway", "rural",
"sad", "saddle", "sadness", "safe", "sail", "salad", "salmon", "salon", "salt", "salute",
"same", "sample", "sand", "satisfy", "satoshi", "sauce", "sausage", "save", "say", "scale",
"scan", "scare", "scatter", "scene", "scheme", "school", "science", "scissors", "scorpion", "scout",
"scrap", "screen", "script", "scrub", "sea", "search", "season", "seat", "second", "secret",
"section", "security", "seed", "seek", "segment", "select", "sell", "seminar", "senior", "sense",
"sentence", "series", "service", "session", "settle", "setup", "seven", "shadow", "shaft", "shallow",
"share", "shed", "shell", "sheriff", "shield", "shift", "shine", "ship", "shiver", "shock",
"shoe", "shoot", "shop", "short", "shoulder", "shove", "shrimp", "shrug", "shuffle", "shy",
"sibling", "sick", "side", "siege", "sight", "sign", "silent", "silk", "silly", "silver",
"similar", "simple", "since", "sing", "siren", "sister", "situate", "six", "size", "skate",
"sketch", "ski", "skill", "skin", "skirt", "skull", "slab", "slam", "sleep", "slender",
"slice", "slide", "slight", "slim", "slogan", "slot", "slow", "slush", "small", "smart",
"smile", "smoke", "smooth", "snack", "snake", "snap", "sniff", "snow", "soap", "soccer",
"social", "sock", "soda", "soft", "solar", "soldier", "solid", "solution", "solve", "someone",
"song", "soon", "sorry", "sort", "soul", "sound", "soup", "source", "south", "space",
"spare", "spatial", "spawn", "speak", "special", "speed", "spell", "spend", "sphere", "spice",
"spider", "spike", "spin", "spirit", "split", "spoil", "sponsor", "spoon", "sport", "spot",
"spray", "spread", "spring", "spy", "square", "squeeze", "squirrel", "stable", "stadium", "staff",
"stage", "stairs", "stamp", "stand", "start", "state", "stay", "steak", "steel", "stem",
"step", "stereo", "stick", "still", "sting", "stock", "stomach", "stone", "stool", "story",
"stove", "strategy", "street", "strike", "strong", "struggle", "student", "stuff", "stumble", "style",
"subject", "submit", "subway", "success", "such", "sudden", "suffer", "sugar", "suggest", "suit",
"summer", "sun", "sunny", "sunset", "super", "supply", "supreme", "sure", "surface", "surge",
"surprise", "surround", "survey", "suspect", "sustain", "swallow", "swamp", "swap", "swarm", "swear",
"sweet", "swift", "swim", "swing", "switch", "sword", "symbol", "symptom", "syrup", "system",
"table", "tackle", "tag", "tail", "talent", "talk", "tank", "tape", "target", "task",
"taste", "tattoo", "taxi", "teach", "team", "tell", "ten", "tenant", "tennis", "tent",
"term", "test", "text", "thank", "that", "theme", "then", "theory", "there", "they",
"thing", "this", "thought", "three", "thrive", "throw", "thumb", "thunder", "ticket", "tide",
"tiger", "tilt", "timber", "time", "tiny", "tip", "tired", "tissue", "title", "toast",
"tobacco", "today", "toddler", "toe", "together", "toilet", "token", "tomato", "tomorrow", "tone",
"tongue", "tonight", "tool", "tooth", "top", "topic", "topple", "torch", "tornado", "tortoise",
"toss", "total", "tourist", "toward", "tower", "town", "toy", "track", "trade", "traffic",
"tragic", "train", "transfer", "trap", "trash", "travel", "tray", "treat", "tree", "trend",
"trial", "tribe", "trick", "trigger", "trim", "trip", "trophy", "trouble", "truck", "true",
"truly", "trumpet", "trust", "truth", "try", "tube", "tuition", "tumble", "tuna", "tunnel",
"turkey", "turn", "turtle", "twelve", "twenty", "twice", "twin", "twist", "two", "type",
"typical", "ugly", "umbrella", "unable", "unaware", "uncle", "uncover", "under", "undo", "unfair",
"unfold", "unhappy", "uniform", "unique", "unit", "universe", "unknown", "unlock", "until", "unusual",
"unveil", "update", "upgrade", "uphold", "upon", "upper", "upset", "urban", "urge", "usage",
"use", "used", "useful", "useless", "usual", "utility", "vacant", "vacuum", "vague", "valid",
"valley", "valve", "van", "vanish", "vapor", "various", "vast", "vault", "vehicle", "velvet",
"vendor", "venture", "venue", "verb", "verify", "version", "very", "vessel", "veteran", "viable",
"vibrant", "vicious", "victory", "video", "view", "village", "vintage", "violin", "virtual", "virus",
"visa", "visit", "visual", "vital", "vivid", "vocal", "voice", "void", "volcano", "volume",
"vote", "voyage", "wage", "wagon", "wait", "walk", "wall", "walnut", "want", "warfare",
"warm", "warrior", "wash", "wasp", "waste", "water", "wave", "way", "wealth", "weapon",
"wear", "weasel", "weather", "web", "wedding", "weekend", "weird", "welcome", "west", "wet",
"whale", "what", "wheat", "wheel", "when", "where", "whip", "whisper", "wide", "width",
"wife", "wild", "will", "win", "window", "wine", "wing", "wink", "winner", "winter",
"wire", "wisdom", "wise", "wish", "witness", "wolf", "woman", "wonder", "wood", "wool",
"word", "work", "world", "worry", "worth", "wrap", "wreck", "wrestle", "wrist", "write",
"wrong", "yard", "year", "yellow", "you", "young", "youth", "zebra", "zero", "zone",
"zoo"
];

15
tsconfig.json Normal file
View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"include": ["src/**/*", "mnemonic_example.ts"],
"exclude": ["node_modules", "**/*.test.ts"]
}