feat: Remove herodo from monorepo and update dependencies
Some checks are pending
Rhai Tests / Run Rhai Tests (push) Waiting to run

- Removed the `herodo` binary from the monorepo. This was
  done as part of the monorepo conversion process.
- Updated the `Cargo.toml` file to reflect the removal of
  `herodo` and adjust dependencies accordingly.
- Updated `src/lib.rs` and `src/rhai/mod.rs` to use the new
  `sal-vault` crate for vault functionality.  This improves
  the modularity and maintainability of the project.
This commit is contained in:
Mahmoud-Emad
2025-06-23 14:56:03 +03:00
parent c94467c205
commit 6dead402a2
56 changed files with 1074 additions and 1671 deletions

View File

@@ -0,0 +1,83 @@
// basic_crypto.rhai
// Basic cryptographic operations test
print("=== Testing Basic Cryptographic Operations ===");
// Test symmetric encryption
print("Testing symmetric encryption...");
let key = generate_key();
let message = "Hello, World!";
let encrypted = encrypt(key, message);
let decrypted = decrypt(key, encrypted);
if decrypted != message {
throw "Symmetric encryption/decryption failed";
}
print("✓ Symmetric encryption works correctly");
// Test keyspace creation
print("Testing keyspace creation...");
clear_session();
let created = create_key_space("test_space", "secure_password");
if !created {
throw "Failed to create keyspace";
}
print("✓ Keyspace created successfully");
// Test keyspace selection
print("Testing keyspace selection...");
let selected = select_keyspace("test_space");
if !selected {
throw "Failed to select keyspace";
}
print("✓ Keyspace selected successfully");
// Test keypair creation
print("Testing keypair creation...");
let keypair_created = create_keypair("test_keypair");
if !keypair_created {
throw "Failed to create keypair";
}
print("✓ Keypair created successfully");
// Test keypair selection
print("Testing keypair selection...");
let keypair_selected = select_keypair("test_keypair");
if !keypair_selected {
throw "Failed to select keypair";
}
print("✓ Keypair selected successfully");
// Test public key retrieval
print("Testing public key retrieval...");
let pub_key = keypair_pub_key();
if pub_key == "" {
throw "Failed to get public key";
}
print("✓ Public key retrieved: " + pub_key);
// Test signing and verification
print("Testing digital signatures...");
let test_message = "This is a test message for signing";
let signature = sign(test_message);
if signature == "" {
throw "Failed to sign message";
}
let is_valid = verify(test_message, signature);
if !is_valid {
throw "Signature verification failed";
}
print("✓ Digital signature works correctly");
// Test with wrong message
let wrong_valid = verify("Wrong message", signature);
if wrong_valid {
throw "Signature should not be valid for wrong message";
}
print("✓ Signature correctly rejects wrong message");
print("=== All basic crypto tests passed! ===");

View File

@@ -0,0 +1,122 @@
// keyspace_management.rhai
// Advanced keyspace and keypair management test
print("=== Testing Keyspace Management ===");
// Clear any existing session
clear_session();
// Test creating multiple keyspaces
print("Creating multiple keyspaces...");
let space1_created = create_key_space("personal", "personal_password");
let space2_created = create_key_space("business", "business_password");
let space3_created = create_key_space("testing", "testing_password");
if !space1_created || !space2_created || !space3_created {
throw "Failed to create one or more keyspaces";
}
print("✓ Multiple keyspaces created successfully");
// Test listing keyspaces
print("Testing keyspace listing...");
let spaces = list_keyspaces();
if spaces.len() < 3 {
throw "Should have at least 3 keyspaces";
}
print("✓ Keyspaces listed: " + spaces.len() + " found");
// Test working with personal keyspace
print("Working with personal keyspace...");
select_keyspace("personal");
// Create multiple keypairs in personal space
create_keypair("main_key");
create_keypair("backup_key");
create_keypair("signing_key");
let personal_keypairs = list_keypairs();
if personal_keypairs.len() != 3 {
throw "Personal keyspace should have 3 keypairs";
}
print("✓ Personal keyspace has " + personal_keypairs.len() + " keypairs");
// Test working with business keyspace
print("Working with business keyspace...");
select_keyspace("business");
// Create keypairs in business space
create_keypair("company_key");
create_keypair("contract_key");
let business_keypairs = list_keypairs();
if business_keypairs.len() != 2 {
throw "Business keyspace should have 2 keypairs";
}
print("✓ Business keyspace has " + business_keypairs.len() + " keypairs");
// Test switching between keypairs
print("Testing keypair switching...");
select_keypair("company_key");
let company_pubkey = keypair_pub_key();
select_keypair("contract_key");
let contract_pubkey = keypair_pub_key();
if company_pubkey == contract_pubkey {
throw "Different keypairs should have different public keys";
}
print("✓ Keypair switching works correctly");
// Test signing with different keypairs
print("Testing signatures with different keypairs...");
let message = "Business contract data";
select_keypair("company_key");
let company_signature = sign(message);
select_keypair("contract_key");
let contract_signature = sign(message);
if company_signature == contract_signature {
throw "Different keypairs should produce different signatures";
}
print("✓ Different keypairs produce different signatures");
// Test cross-verification (should fail)
select_keypair("company_key");
let company_valid = verify(message, contract_signature);
if company_valid {
throw "Company key should not verify contract key signature";
}
print("✓ Cross-verification correctly fails");
// Test correct verification
let correct_valid = verify(message, company_signature);
if !correct_valid {
throw "Company key should verify its own signature";
}
print("✓ Self-verification works correctly");
// Test session isolation
print("Testing session isolation...");
select_keyspace("testing");
let testing_keypairs = list_keypairs();
if testing_keypairs.len() != 0 {
throw "Testing keyspace should be empty";
}
print("✓ Keyspaces are properly isolated");
// Test error handling
print("Testing error handling...");
let invalid_select = select_keyspace("non_existent");
if invalid_select {
throw "Should not be able to select non-existent keyspace";
}
let invalid_keypair = select_keypair("non_existent");
if invalid_keypair {
throw "Should not be able to select non-existent keypair";
}
print("✓ Error handling works correctly");
print("=== All keyspace management tests passed! ===");