Decrypts the encrypted message using the private key. The decryption process is the reverse of encryption, recovering the original message. @param encryptedMessage The encrypted message as an array of ECPoints (R, S) @return The decrypted plain message as a String
(ECPoint[] encryptedMessage)
| 72 | * @return The decrypted plain message as a String |
| 73 | */ |
| 74 | public String decrypt(ECPoint[] encryptedMessage) { |
| 75 | ECPoint rPoint = encryptedMessage[0]; // First part of ciphertext |
| 76 | ECPoint sPoint = encryptedMessage[1]; // Second part of ciphertext |
| 77 | |
| 78 | // Perform decryption: s - r * privateKey |
| 79 | ECPoint decodedMessage = sPoint.subtract(rPoint.multiply(privateKey, curve.getP(), curve.getA()), curve.getP(), curve.getA()); |
| 80 | |
| 81 | BigInteger m = curve.decodeMessage(decodedMessage); // Decode the message from ECPoint |
| 82 | |
| 83 | return new String(m.toByteArray()); // Convert BigInteger back to String |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Generates a new public-private key pair for encryption and decryption. |
nothing calls this directly
no test coverage detected