diff --git a/docs/olm.rst b/docs/olm.rst
index 9f82c8efda61d89fb45d630cea0ca0663a6073ad..9c1347868b98543f09bc5f07bd7180d31a64db68 100644
--- a/docs/olm.rst
+++ b/docs/olm.rst
@@ -72,7 +72,7 @@ info.
 Advancing the chain key
 ~~~~~~~~~~~~~~~~~~~~~~~
 
-Advancing a chain key takes the previous chain key, :math:`C_{i,j-i}`. The next
+Advancing a chain key takes the previous chain key, :math:`C_{i,j-1}`. The next
 chain key, :math:`C_{i,j}`, is the HMAC-SHA-256_ of ``"\x02"`` using the
 previous chain key as the key.
 
diff --git a/src/pk.cpp b/src/pk.cpp
index b8fe95be7339061a9c0c36c7e25041f3d213ecb6..e646dc433fce5a38a47f22aeb91d723399dc33b7 100644
--- a/src/pk.cpp
+++ b/src/pk.cpp
@@ -189,7 +189,7 @@ size_t olm_pk_generate_key(
     void * pubkey, size_t pubkey_length,
     void * random, size_t random_length
 ) {
-    if (pubkey_length < CURVE25519_KEY_LENGTH) {
+    if (pubkey_length < olm_pk_key_length()) {
         decryption->last_error =
             OlmErrorCode::OLM_OUTPUT_BUFFER_TOO_SMALL;
         return std::size_t(-1);