Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -73,9 +73,10 @@ object CryptoManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate key pair from private key using secp256k1 curve
|
||||
* Generate key pair from seed phrase using secp256k1 curve
|
||||
*/
|
||||
fun generateKeyPairFromSeed(privateKeyHex: String): KeyPairData {
|
||||
fun generateKeyPairFromSeed(seedPhrase: List<String>): KeyPairData {
|
||||
val privateKeyHex = seedPhraseToPrivateKey(seedPhrase)
|
||||
val ecSpec = ECNamedCurveTable.getParameterSpec("secp256k1")
|
||||
|
||||
// Use first 32 bytes of private key for secp256k1
|
||||
@@ -109,7 +110,7 @@ object CryptoManager {
|
||||
/**
|
||||
* Encrypt data with password using PBKDF2 + AES
|
||||
*/
|
||||
fun encryptWithPassword(password: String, data: String): String {
|
||||
fun encryptWithPassword(data: String, password: String): String {
|
||||
// Compress data
|
||||
val compressed = compress(data.toByteArray())
|
||||
|
||||
@@ -139,7 +140,7 @@ object CryptoManager {
|
||||
/**
|
||||
* Decrypt data with password
|
||||
*/
|
||||
fun decryptWithPassword(password: String, encryptedData: String): String? {
|
||||
fun decryptWithPassword(encryptedData: String, password: String): String? {
|
||||
return try {
|
||||
val parts = encryptedData.split(":")
|
||||
if (parts.size != 2) return null
|
||||
|
||||
Reference in New Issue
Block a user