A production-grade cryptographic library for XDAG blockchain applications with focus on security, performance, and developer experience.
- Enhanced XDAG Compatibility: Added
PublicKey.fromXCoordinate()
method for XDAG's 32-byte x-coordinate + y-bit format - Simplified HD Wallet API: Direct key pair generation from mnemonic phrases
- Improved Documentation: Fixed Javadoc warnings and enhanced API documentation
- Optimized Dependencies: Removed unnecessary configurations for better performance
<dependency>
<groupId>io.xdag</groupId>
<artifactId>xdagj-crypto</artifactId>
<version>0.1.1</version>
</dependency>
implementation 'io.xdag:xdagj-crypto:0.1.1'
Requirements: Java 21+
import io.xdag.crypto.keys.*;
// Generate key pair and address
ECKeyPair keyPair = ECKeyPair.generate();
String address = keyPair.toBase58Address();
// XDAG compatibility (NEW v0.1.1): Create from x-coordinate + y-bit
PublicKey xdagKey = PublicKey.fromXCoordinate(xCoordinate, yBit);
import io.xdag.crypto.bip.*;
// Generate mnemonic and derive key pairs
String mnemonic = Bip39Mnemonic.generateString();
// NEW v0.1.1: Simplified API for basic use cases
ECKeyPair keyPair = Bip44Wallet.createKeyPairFromMnemonic(mnemonic);
// Advanced: BIP44 derivation path m/44'/586'/0'/0/0
Bytes seed = Bip39Mnemonic.toSeed(mnemonic);
Bip32Key masterKey = Bip44Wallet.createMasterKey(seed.toArrayUnsafe());
Bip32Key accountKey = Bip44Wallet.deriveXdagKey(masterKey, 0, 0);
import io.xdag.crypto.keys.*;
import io.xdag.crypto.encryption.Aes;
// Sign and verify messages
Signature signature = Signer.sign(messageHash, keyPair);
boolean valid = Signer.verify(messageHash, signature, keyPair.getPublicKey());
// AES-256-GCM encryption
Bytes cipherText = Aes.encrypt(plainText, encryptionKey, nonce);
Bytes decrypted = Aes.decrypt(cipherText, encryptionKey, nonce);
- Elliptic Curve Cryptography: ECDSA with secp256k1 curve
- Hierarchical Deterministic Wallets: BIP32/BIP39/BIP44 implementation
- Symmetric Encryption: AES-256-GCM authenticated encryption
- Hash Functions: SHA-256, RIPEMD-160, HMAC operations
- Address Generation: XDAG-compatible Base58 addresses
- XDAG Integration: Native support for XDAG public key formats
- Cryptographic Standards: ECDSA (secp256k1), AES-256-GCM, SHA-256, PBKDF2
- Constant-Time Operations: Prevents timing attacks
- Secure Random Generation: Platform-optimal entropy sources
- Input Validation: Comprehensive validation with detailed error messages
- Thread Safety: All operations are thread-safe by design
- Consensys Tuweni: High-performance byte operations
- Bouncy Castle: Cryptographic implementations
- SLF4J: Logging framework
// Create public key from XDAG's x-coordinate + y-bit format
PublicKey xdagKey = PublicKey.fromXCoordinate(xCoordinate, yBit);
// Direct key pair generation from mnemonic
ECKeyPair keyPair = Bip44Wallet.createKeyPairFromMnemonic(mnemonic);
For complete API documentation, see JavaDoc
# Prerequisites: Java 21+, Maven 3.8+
git clone https://github.com/XDagger/xdagj-crypto.git
cd xdagj-crypto
# Run tests and build
mvn clean test package
We welcome contributions! Please read our Contributing Guidelines for details.
Development Standards:
- Code Coverage: Minimum 95% line coverage
- Documentation: Comprehensive Javadoc for all public APIs
- Testing: Unit tests for all functionality
- Security: Regular dependency vulnerability scanning
Licensed under the MIT License - see LICENSE file for details.
Built with ❤️ by the XDAG Development Team