Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

pqc-mnemonic

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pqc-mnemonic

BIP-39 mnemonic library with ECDSA, PQC, and hybrid address schemes

latest
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

PQC-Mnemonic

BIP-39 니모닉을 사용하여 ECDSA-only, PQC-only, 하이브리드 주소를 생성하는 TypeScript 라이브러리입니다.

특징

  • BIP-39 니모닉 지원: 표준 니모닉 생성 및 검증
  • 다양한 주소 체계: ECDSA-only, PQC-only, 하이브리드 지원
  • 모듈화된 설계: 주소 체계를 모듈처럼 교체 가능
  • 동일 인덱스 지원: 같은 니모닉과 인덱스로 모든 주소 타입 생성 가능

설치

npm install pqc-mnemonic

사용법

니모닉 단어 수 선택 (12단어/24단어)

BIP-39 니모닉은 엔트로피 강도에 따라 단어 수가 결정됩니다:

  • 12단어 (128비트 엔트로피): 기본값, 대부분의 사용 사례에 충분

    • 보안 수준: 2^128 조합 (약 3.4 × 10^38)
    • 입력 편의성: 더 짧고 기억하기 쉬움
    • 권장: 일반적인 지갑 사용
  • 24단어 (256비트 엔트로피): 더 높은 보안 수준

    • 보안 수준: 2^256 조합 (약 1.2 × 10^77)
    • 입력 편의성: 더 길지만 더 안전
    • 권장: 고가치 자산이나 장기 보관이 필요한 경우

참고: 두 경우 모두 seed는 64바이트(512비트)로 동일하게 생성됩니다. 차이는 엔트로피의 무작위성 강도입니다.

import { generateMnemonic, createWallet } from 'pqc-mnemonic';

// 12단어 니모닉 생성 (기본값, 128비트)
const mnemonic12 = generateMnemonic(); // 또는 generateMnemonic(128)
console.log(mnemonic12); // 12개 단어

// 24단어 니모닉 생성 (256비트)
const mnemonic24 = generateMnemonic(256);
console.log(mnemonic24); // 24개 단어

// 12단어로 지갑 생성 (기본값)
const wallet12 = createWallet();
console.log(wallet12.mnemonic.split(' ').length); // 12개 단어

// 24단어로 지갑 생성 (256비트 엔트로피)
const wallet24 = createWallet({ mnemonicStrength: 256 });
console.log(wallet24.mnemonic.split(' ').length); // 24개 단어

기본 사용

import { createWallet, restoreWallet } from 'pqc-mnemonic';

// 새 지갑 생성
const wallet = createWallet();

// 니모닉 확인
console.log(wallet.mnemonic);

// 주소 생성 (인덱스 0)
const addressInfo = wallet.getAddress(0);
console.log(addressInfo.address);

ECDSA-only 주소 체계

import { createWallet, ECDSAOnlyScheme } from 'pqc-mnemonic';

const wallet = createWallet({
    addressScheme: new ECDSAOnlyScheme("m/44'/0'/0'"),
});

const addressInfo = wallet.getAddress(0);
// addressInfo.ecdsaKeyPair 사용

PQC-only 주소 체계

import { createWallet, PQCONlyScheme } from 'pqc-mnemonic';

const wallet = createWallet({
    addressScheme: new PQCONlyScheme('pqc-keygen'),
});

const addressInfo = wallet.getAddress(0);
// addressInfo.pqcKeyPair 사용

하이브리드 주소 체계 (기본값)

import { createWallet, HybridScheme } from 'pqc-mnemonic';

const wallet = createWallet({
    addressScheme: new HybridScheme("m/44'/0'/0'", 'pqc-hybrid'),
});

const addressInfo = wallet.getAddress(0);
// addressInfo.ecdsaKeyPair와 addressInfo.pqcKeyPair 모두 사용 가능

니모닉으로 지갑 복구

import { restoreWallet } from 'pqc-mnemonic';

const mnemonic = 'your twelve word mnemonic phrase here...';
const wallet = restoreWallet(mnemonic);

// 같은 인덱스로 모든 주소 타입 생성 가능
const addressInfo = wallet.getAddress(0);

주소 체계 커스터마이징

주소 체계가 바뀔 수 있으므로 AddressScheme 또는 HybridAddressScheme 인터페이스를 구현하여 교체할 수 있습니다:

import { AddressScheme, KeyPair, Address } from 'pqc-mnemonic';

class CustomAddressScheme implements AddressScheme {
    readonly name = 'custom';

    deriveKeyPair(seed: Uint8Array, index: number): KeyPair {
        // 커스텀 키 파생 로직
    }

    publicKeyToAddress(publicKey: Uint8Array): Address {
        // 커스텀 주소 생성 로직
    }

    validateAddress(address: Address): boolean {
        // 커스텀 주소 검증 로직
    }
}

const wallet = createWallet({
    addressScheme: new CustomAddressScheme(),
});

API

니모닉 관련

  • generateMnemonic(strength?: number): string - 새 니모닉 생성
    • strength: 엔트로피 비트 수 (128=12단어, 256=24단어, 기본값: 128)
    • 지원 값: 128, 160, 192, 224, 256
  • validateMnemonic(mnemonic: string): boolean - 니모닉 검증
  • mnemonicToSeed(mnemonic: string, passphrase?: string): Uint8Array - 니모닉에서 seed 생성

지갑 관련

  • createWallet(options?: WalletOptions): Wallet - 새 지갑 생성
    • options.mnemonicStrength: 니모닉 엔트로피 비트 수 (128=12단어, 256=24단어, 기본값: 128)
    • options.addressScheme: 주소 체계 (기본값: HybridScheme)
    • options.bip44Path: BIP-44 경로 (기본값: "m/44'/0'/0'")
    • options.pqcDomain: PQC 도메인 분리 문자열 (기본값: "pqc-domain")
  • restoreWallet(mnemonic: string, options?: WalletOptions): Wallet - 니모닉으로 지갑 복구
  • wallet.getAddress(index: number): AddressInfo - 인덱스별 주소 생성

라이선스

MIT

Keywords

bip39

FAQs

Package last updated on 15 Jan 2026

Did you know?

Socket

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.

Install

Related posts