@@ -168,8 +168,6 @@ func encryptFile(filename string) error {
168168 return fmt .Errorf ("error reading passphrase: %w" , err )
169169 }
170170 fmt .Print ("Generating the seed for KDF ... " )
171- // Get the public key from the server
172- publicKey , _ := keys .NewECDSAKeyFromPEM (nil )
173171 // Convert the public key to a byte slice
174172 pubKeyBytes := []byte (publicKey )
175173 // Convert the passphrase to a byte slice
@@ -178,7 +176,7 @@ func encryptFile(filename string) error {
178176 seedKDF := append (pubKeyBytes [:], passphraseBytes ... )
179177 // Derive a key using a KDF (e.g., SHA-256)
180178 kdfKey := sha256 .Sum256 (seedKDF )
181- fmt .Println ("KDF For symmetric keygen: " , kdfKey )
179+ fmt .Println ("KDF For symmetric keygen: \n " , kdfKey )
182180 fmt .Print ("Generating the symmetric key... \n " )
183181 encryptedKey := hex .EncodeToString (kdfKey [:])
184182 art_link .PrintFileSlowly ("encrypting.txt" )
@@ -253,7 +251,7 @@ func decryptFile(filename string) error {
253251 return fmt .Errorf ("error retrieving file from IPFS: %w" , err )
254252 }
255253
256- // Get the Keycard public key
254+ // Get the Keycard public key
257255 art_link .PrintFileSlowly ("scannow.txt" )
258256 art_link .PrintFileSlowly ("flex_implant.txt" )
259257
@@ -262,18 +260,25 @@ func decryptFile(filename string) error {
262260 return fmt .Errorf ("error getting Keycard public key: %w" , err )
263261 }
264262
265- // Read the passphrase
266263 passphrase , err := keycard_link .ReadPassphrase ()
267264 if err != nil {
268265 return fmt .Errorf ("error reading passphrase: %w" , err )
269266 }
270- // Generate the symmetric key
267+ fmt .Print ("Generating the seed for KDF ... " )
268+ // Convert the public key to a byte slice
269+ pubKeyBytes := []byte (publicKey )
270+ // Convert the passphrase to a byte slice
271+ passphraseBytes := []byte (passphrase )
272+ // Concatenate the two byte slices
273+ seedKDF := append (pubKeyBytes [:], passphraseBytes ... )
274+ // Derive a key using a KDF (e.g., SHA-256)
275+ kdfKey := sha256 .Sum256 (seedKDF )
276+ fmt .Println ("KDF For symmetric keygen: \n " , kdfKey )
271277 fmt .Print ("Generating the symmetric key... \n " )
272- seedKDF := publicKey + passphrase
273- kdfKey := sha256 .Sum256 ([]byte (seedKDF ))
274- decryptedKey := fmt .Sprintf ("%x" , kdfKey )
278+ decryptedKey := hex .EncodeToString (kdfKey [:])
275279 art_link .PrintFileSlowly ("decrypting.txt" )
276280
281+
277282 // Decrypt the file using GPG
278283 decryptedFilePath := "decrypted_" + filename // This is the path where the decrypted file will be saved
279284 cmd := exec .Command ("gpg" , "--decrypt" , "--batch" , "--passphrase" , decryptedKey , "--output" , decryptedFilePath , ipfsFilePath )
@@ -287,4 +292,3 @@ func decryptFile(filename string) error {
287292 fmt .Printf ("File decrypted successfully: %s\n " , decryptedFilePath )
288293 return nil
289294}
290-
0 commit comments