signalapp/Signal-Server · error · JsonParseException

Could not interpret key bytes as a public key

Error message

Could not interpret key bytes as a public key

What it means

Thrown when the Base64 decoding succeeds but the resulting bytes cannot be interpreted as a valid public key by the subclass's deserializePublicKey (e.g., libsignal raises InvalidKeyException for malformed or wrong-length key material). The failure is counted under an 'invalid-key' reason tag and rethrown as a JsonParseException, failing deserialization of the JSON field.

Solutions

  1. Verify the decoded bytes are a valid serialized public key in the format expected by libsignal (e.g. 33-byte CURVE25519 encoding)
  2. Confirm the client sends a complete, uncorrupted key (no truncation or byte mangling)
  3. Check that the key type byte matches the expected key type before deserializing
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at service/src/main/java/org/whispersystems/textsecuregcm/util/AbstractPublicKeyDeserializer.java:38 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of signalapp/Signal-Server@100ab61c82 (2026-09-09). Data as JSON: /api/errors/87f94edf3b89a9a3. Report an issue: GitHub.

Appendix: source

Thrown at service/src/main/java/org/whispersystems/textsecuregcm/util/AbstractPublicKeyDeserializer.java:38

  public K deserialize(final JsonParser parser, final DeserializationContext context) throws IOException {
    final byte[] publicKeyBytes;

    try {
      publicKeyBytes = Base64.getDecoder().decode(parser.getValueAsString());
    } catch (final IllegalArgumentException e) {
      Metrics.counter(invalidKeyCounterName, REASON_TAG_NAME, "illegal-base64").increment();
      throw new JsonParseException(parser, "Could not parse public key as a base64-encoded value", e);
    }

    if (publicKeyBytes.length == 0) {
      return null;
    }

    try {
      return deserializePublicKey(publicKeyBytes);
    } catch (final InvalidKeyException e) {
      Metrics.counter(invalidKeyCounterName, REASON_TAG_NAME, "invalid-key").increment();
      throw new JsonParseException(parser, "Could not interpret key bytes as a public key", e);
    }
  }

  protected abstract K deserializePublicKey(final byte[] publicKeyBytes) throws InvalidKeyException;
}

View on GitHub (pinned to 100ab61c82)