paragonie / paserk-php

PHP Implementation of PASERK
Other
12 stars 1 forks source link

Code demo doesn't work #14

Closed iamcaptaincode closed 4 months ago

iamcaptaincode commented 1 year ago

Hi there,

I'm exploring implementing PASETOs in a new API implementation, however when I try to utilize your demo code in the readme for PASERK, I'm getting a PHP error (just copying and pasting). Specifically it gives a Type error that the requirement for the seal constructor is a SealingKey. However the static method on SealingPublicKey::fromEncodedString returns an AsymmetricPublicKey instead.

I'm running PHP 8.1

seyfahni commented 1 year ago

The reason for that seems to be that SealingPublicKey extends AsymmetricPublicKey, but nothing is overwritten. The AsymmetricPublicKey implements fromEncodedString (and other static helpers for creation) but uses new self() instead of new static, thus always instantiating AsymmetricPublicKey and not the child class.

paragonie-security commented 4 months ago

We fixed this in v2.3.0. Thanks for pointing it out.