diff --git a/src/SignatureKeyPair.php b/src/SignatureKeyPair.php index 1dd4890..81980be 100644 --- a/src/SignatureKeyPair.php +++ b/src/SignatureKeyPair.php @@ -120,6 +120,19 @@ public function __construct(Key ...$keys) } } + /** + * @return EncryptionKeyPair + * @throws InvalidKey + * @throws \TypeError + */ + public function getEncryptionKeyPair(): EncryptionKeyPair + { + return new EncryptionKeyPair( + $this->secretKey->getEncryptionSecretKey(), + $this->publicKey->getEncryptionPublicKey() + ); + } + /** * Set up our key pair * diff --git a/test/unit/KeyPairTest.php b/test/unit/KeyPairTest.php index 3c5eaaf..b34ff93 100644 --- a/test/unit/KeyPairTest.php +++ b/test/unit/KeyPairTest.php @@ -236,6 +236,7 @@ public function testFileStorage() public function testMutation() { $sign_kp = KeyFactory::generateSignatureKeyPair(); + $box_kp = $sign_kp->getEncryptionKeyPair(); $sign_sk = $sign_kp->getSecretKey(); $sign_pk = $sign_kp->getPublicKey(); @@ -245,6 +246,10 @@ public function testMutation() Hex::encode($enc_pk->getRawKeyMaterial()), Hex::encode($enc_sk->derivePublicKey()->getRawKeyMaterial()) ); + $this->assertSame( + Hex::encode($enc_sk->getRawKeyMaterial()), + Hex::encode($box_kp->getSecretKey()->getRawKeyMaterial()) + ); } /**