package frodo_test

import "seekia/internal/cryptography/frodo"

import "testing"

func TestEncryptDecryptFrodo(t *testing.T) {

	testPublicKey, testPrivateKey, err := frodo.GetNewRandomPublicPrivateFrodoKeys()
	if (err != nil) {
		t.Fatal("Failed to derive Frodo keys: " + err.Error())
	}

	encryptedKey, encryptedBytes, err := frodo.EncryptNewRandomKeyWithFrodo(testPublicKey)
	if (err != nil) {
		t.Fatal("Failed to encrypt Frodo: " + err.Error())
	}

	ableToDecrypt, decryptedKey, err := frodo.DecryptFrodoEncryptedKey(encryptedBytes, testPrivateKey)
	if (err != nil) {
		t.Fatal("Failed to decrypt Frodo: " + err.Error())
	}
	if (ableToDecrypt == false){
		t.Fatal("Failed to decrypt Frodo.")
	}

	if (decryptedKey != encryptedKey){
		t.Fatal("Frodo decrypted key does not match.") 
	}
}



