New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

web3keys

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3keys

Web3Keys - Your Gateway to Blockchain | Powered by SmartLedger.Solutions

latest
npmnpm
Version
1.1.11
Version published
Maintainers
1
Created
Source

SmartLedger SDK

A comprehensive JavaScript library for blockchain and cryptographic operations, designed for enterprise-grade biometric identity systems. The SDK integrates BSV blockchain capabilities with advanced cryptographic features and secure storage solutions.

Features

HD Wallet Implementation

  • BIP39 mnemonic generation and validation (12/24 words)
  • BIP32 hierarchical deterministic wallets
  • BIP44 path derivation (m/44'/236'/...)
  • Support for 21 standard derivation paths
  • Comprehensive path information including chain codes

BSV Blockchain Integration

  • Key pair generation
  • Message signing and verification
  • Address generation
  • Public/private key validation
  • BSV transaction support

Cryptographic Operations

  • AES-256 encryption/decryption with CBC mode and PKCS7 padding
  • Multiple hashing algorithms (SHA256, SHA512, MD5)
  • Secure random bytes generation
  • Base64 encoding/decoding

Advanced Security Features

  • Shamir's Secret Sharing implementation
  • UUID v5 generation
  • Secure key storage
  • Cross-platform storage adapter

Implementation Details

Cross-Platform Storage

The SDK implements a flexible storage adapter that automatically switches between:

  • Browser localStorage when available
  • In-memory Map storage as fallback
  • Prefix-based namespacing for key isolation

BSV Integration Details

  • Conditional loading of BSV library for browser compatibility
  • Comprehensive BSV operations including:
    • Address derivation from nodes
    • Message signing with private keys
    • Signature verification with public keys
    • Transaction creation and handling

Security Considerations

  • Secure random number generation for cryptographic operations
  • Automatic memory cleanup for sensitive data
  • Cross-platform storage encryption
  • Support for both synchronous and asynchronous operations

Installation

# Install core SDK and dependencies
npm install smartledger_sdk @bitcoinerlab/secp256k1 bip32 crypto-js uuid shamirs-secret-sharing

Quick Start

Mnemonic and Key Generation

// Generate a new 24-word mnemonic
const mnemonic = SmartLedger.generateMnemonic();

// Validate mnemonic
const isValid = SmartLedger.validateMnemonic(mnemonic);

// Generate seed with optional passphrase
const seed = await SmartLedger.mnemonicToSeedHex(
  mnemonic,
  "optional passphrase"
);

// Derive standard paths
const paths = await SmartLedger.deriveStandardPaths(mnemonic);

Key Storage and Management

// Store encrypted key with metadata
await SmartLedger.storeKey(
  "key-id",
  privateKey,
  {
    label: "My Key",
    description: "Important private key",
  },
  "storage-encryption-key"
);

// Retrieve key
const { key, metadata } = await SmartLedger.retrieveKey(
  "key-id",
  "storage-encryption-key"
);

// Store mnemonic
await SmartLedger.storeMnemonic(
  "mnemonic-id",
  mnemonic,
  {
    label: "Backup Mnemonic",
  },
  "storage-encryption-key"
);

Storage Operations

// Store encrypted key with metadata and custom prefix
await SmartLedger.storeKey(
  "key-id",
  privateKey,
  {
    label: "My Key",
    description: "Important private key",
    customData: { type: "master", version: "1.0" }
  },
  "storage-encryption-key"
);

// Retrieve stored key with metadata
const { key, metadata } = await SmartLedger.retrieveKey(
  "key-id",
  "storage-encryption-key"
);

// Remove stored key
await SmartLedger.removeKey("key-id");

Encryption and Security

// Encrypt data
const encrypted = SmartLedger.encrypt("sensitive data", "secure-key");
const decrypted = SmartLedger.decrypt(encrypted, "secure-key");

// Split secret into shares
const shares = SmartLedger.splitSecret("secret-data", 5, 3);
const reconstructed = SmartLedger.combineShares(shares.slice(0, 3));

Advanced Cryptographic Features

// Split a secret using Shamir's Secret Sharing
const shares = SmartLedger.splitSecret(
  "sensitive-data",
  { shares: 5, threshold: 3 }
);

// Combine shares to recover the secret
const recoveredSecret = SmartLedger.combineShares(shares.slice(0, 3));

// Generate UUIDv5
const namespace = "1b671a64-40d5-491e-99b0-da01ff1f3341";
const uuid = SmartLedger.generateUUID(namespace, "data");

BSV Operations

// Generate key pair
const keyPair = SmartLedger.generateKeyPair();

// Sign message
const signature = SmartLedger.signMessage("message", keyPair.privateKey);

// Verify signature
const isValid = SmartLedger.verifySignature(
  "message",
  signature,
  keyPair.publicKey
);

API Reference

BIP39/32/44 Methods

  • generateMnemonic(strength = 256): Generate mnemonic
  • validateMnemonic(mnemonic): Validate mnemonic phrase
  • mnemonicToSeed(mnemonic, passphrase): Convert mnemonic to seed
  • mnemonicToSeedHex(mnemonic, passphrase): Convert mnemonic to seed hex
  • derivePath(mnemonic, path, passphrase): Derive single HD wallet path
  • deriveStandardPaths(mnemonic, passphrase): Derive all standard paths

Storage Methods

  • storeKey(id, key, metadata, storageKey): Store encrypted key
  • retrieveKey(id, storageKey): Retrieve and decrypt key
  • storeMnemonic(id, mnemonic, metadata, storageKey): Store encrypted mnemonic
  • retrieveMnemonic(id, storageKey): Retrieve and decrypt mnemonic
  • listKeys(): List all stored items
  • removeKey(id): Remove stored item

Cryptographic Methods

  • encrypt(data, key): AES encryption with CBC mode
  • decrypt(encryptedData, key): AES decryption
  • hash(data, algorithm): Multiple hash algorithms
  • splitSecret(secret, shares, threshold): Shamir's Secret Sharing
  • combineShares(shares): Reconstruct secret

BSV Methods

  • generateKeyPair(): Generate BSV key pair
  • signMessage(message, privateKey): Sign message
  • verifySignature(message, signature, publicKey): Verify signature
  • getAddressFromNode(node): Generate BSV address

Security Considerations

Key Management

  • Use strong encryption keys
  • Implement regular key rotation
  • Secure storage of private keys
  • Regular backups of encrypted data

Best Practices

  • Validate inputs thoroughly
  • Handle errors appropriately
  • Regular security audits
  • Keep dependencies updated

Development

Setup

git clone https://github.com/codenlighten/smartledger_sdk.git
cd smartledger_sdk
npm install

Build

npm run build

Test

npm test

Future Enhancements

  • Biometric Integration

    • Secure template storage
    • Biometric encryption
    • Template protection (ISO/IEC 24745)
  • Enterprise Features

    • Multi-signature support
    • Hardware security module (HSM) integration
    • Advanced audit logging
    • Compliance features

License

Proprietary software. Licensed for use by SmartLedger partners only.

Support

  • Email: yourfriends@smartledger.solutions
  • Issues: GitHub Issues
  • Documentation: Wiki

Contributing

This is a private repository. Contributions are by invitation only.

FAQs

Package last updated on 04 Mar 2025

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