
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@code-wallet/mnemonic
Advanced tools
[![npm][npm-image]][npm-url] [![npm-downloads][npm-downloads-image]][npm-url]
A TypeScript library to generate and manage cryptographic keys using mnemonics and HD (hierarchical deterministic) paths for the ED25519 curve based on the SLIP-0010 specification.
Learn more about Code at https://getcode.com. See the docs for more information.
Cryptographic keys are essential for maintaining security in digital systems, especially in blockchain and cryptographic applications. This library offers a deterministic approach to key derivation, allowing users to generate a Keypair from a mnemonic phrase, which is a human-readable list of words, following the principles of the SLIP-0010 specification.
Clean, simple, low-dependency library. Passes standard set of tests for SLIP-0010.
Mnemonic Generation: Create mnemonic phrases of either 12 or 24 words.
Mnemonic to Keypair: Derive cryptographic key pairs directly from mnemonic phrases.
Path Parsing: Convert string representations of HD paths into structured formats.
Child Key Derivation: Create child keys based on provided parent keys.
Key Offset: Manage individual indexes in the HD path, including hardened keys.
npm install @code-wallet/mnemonic
Generating a Mnemonic and Keypair
import { MnemonicPhrase, MnemonicType } from '@code-wallet/mnemonic';
const mnemonic = MnemonicPhrase.generate(MnemonicType.Long);
console.log("Mnemonic:", mnemonic.getPhrase());
const keypair = mnemonic.toKeypair();
console.log("Public Key:", keypair.publicKey);
console.log("Private Key:", keypair.privateKey);
import { MnemonicPhrase } from '@code-wallet/mnemonic';
const mnemonic = new MnemonicPhrase("install assume ketchup talk giant bone foster flight situate math hurt border deputy grab mesh hope update dream evolve caught erupt win danger thought");
const keypair = mnemonic.toKeypair(); // Uses default Solana path unless specified
console.log("Public Key:", keypair.publicKey);
console.log("Private Key:", keypair.privateKey);
import { Path } from '@code-wallet/mnemonic';
const path = new Path("m/44'/180'/0'/0'");
console.log(path.toString());
To generate a mnemonic:
import { MnemonicPhrase, MnemonicType } from '@code-wallet/mnemonic';
const mnemonic = MnemonicPhrase.generate(MnemonicType.Short);
console.log(mnemonic.getPhrase());
Once you have a mnemonic, you can derive a keypair:
const keypair = mnemonic.toKeypair();
By default, the library uses a standard path for Solana (m/44'/501'/0'/0'). However, you can specify a custom path:
import { Path } from '@code-wallet/mnemonic';
const customPath = new Path("m/44'/180'/0'/0'");
const keypair = mnemonic.toKeypair(customPath);
Feel free to contribute to the library by submitting pull requests or reporting issues.
This library is licensed under the MIT License.
FAQs
[![npm][npm-image]][npm-url] [![npm-downloads][npm-downloads-image]][npm-url]
We found that @code-wallet/mnemonic demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.