1.3.0 • Published 4 months ago

@smartledger/bsv-sdk v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@smartledger/sdk

A comprehensive SDK for Bitcoin SV blockchain operations, providing key management, signatures, encryption, and secret sharing capabilities.

Installation

npm install @smartledger/sdk

Features

  • Key Management: Generate and manage BSV keys with different derivation paths for various purposes
  • Digital Signatures: Sign and verify data using BSV keys
  • Encryption: AES encryption for secure data storage
  • Secret Sharing: Shamir's Secret Sharing implementation for secure key splitting and recovery

Usage

Key Management

import { SmartLedgerSDK } from '@smartledger/sdk';

const sdk = new SmartLedgerSDK();

// Generate a new mnemonic
const mnemonic = sdk.generateMnemonic();

// Generate keys for different purposes
const documentKey = sdk.generateKey(mnemonic, 'document');
const contractKey = sdk.generateKey(mnemonic, 'contractual');
const identityKey = sdk.generateKey(mnemonic, 'identity');

Signatures

// Sign data
const data = "Hello SmartLedger!";
const signature = sdk.sign(data, documentKey);

// Verify signature
const isValid = sdk.verify(data, signature, documentKey.publicKey);

Encryption

// Encrypt data
const encrypted = sdk.encrypt("Secret message", "password123");

// Decrypt data
const decrypted = sdk.decrypt(encrypted, "password123");

Secret Sharing

// Split a secret into shares
const { shares } = sdk.splitSecret("my-secret", 3, 2);

// Recover the secret
const secret = sdk.combineShares(shares.slice(0, 2));

Security

This SDK uses the @smartledger/bsv-fixed package, which includes security fixes for the elliptic dependency. All cryptographic operations use industry-standard implementations and best practices.

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.