Keys

Signing and encryption solve different problems. A signature lets the recipient check who produced a message and whether it changed. Encryption limits who can read its contents. The SDK PKI libraries provide both, using separate key pairs so an application can publish the keys needed by its peers while retaining its private keys. The Account API describes the public JWKs mesgd accepts.

Key pairs

UseAlgorithmPublic fields you publish
SigningECDSA P-256kty=EC, crv=P-256, use=sig, x, y
EncryptionRSA-2048 in the samples. mesgd accepts 2048 to 8192kty=RSA, use=enc, n, e

Coordinates and integers are base64url. Private fields stay in the client key file.

Message formats

Message signatures in mesgd-sdk are JSON:

{"r":"<base64url>","s":"<base64url>"}

Encryption is RSA-OAEP with SHA-256 and MGF1-SHA-256. Erlang and the Python client interoperate on that encryption.

With RSA-2048 and SHA-256, a single OAEP operation can encrypt at most 190 bytes. A serialized public key set exceeds that limit. Implementations with hybrid registration support use RSA-OAEP to protect an AES key and A256GCM to encrypt the larger payload. Python and JavaScript registration still require a payload small enough for a single OAEP operation.

These registration helpers construct encrypted messages; the current server does not store them through /mesgd/pki. Publish an account's public keys with PUT /auth/keys, or include public_keys at signup.

mesgd forge returns a server token, ciphertext.signature. That is not this signature encoding. Do not verify a forged claim token with an SDK verify that expects {"r","s"}.

Cryptographic operations

OperationWhat your program uses it for
signSign with the signing private key
verifyCheck a signature
encryptEncrypt to a public encryption key
decryptDecrypt with the encryption private key
import / exportRead and write the key file
public / privateExport the half you mean to share, or the half you keep

Names differ by language. The cross-language tests call these helpers:

LanguagePublic JWKEncrypt to a keyVerify with a public key
Pythonpub_jwkencrypt_withverify_with_pub
JavaScriptpubJwkencryptWithverifyWithPub
GoPubJWKEncryptWithVerifyWithPub
Ruston the crate mesgd-pkiencrypt_withverify_with_pub
Rubythe names in ruby/pki.rbencrypt_withverify_with_pub
Cpki_pub_jwkpki_encrypt_withpki_verify_with_pub

C helpers take JSON strings. Go's EncryptWith and VerifyWithPub are package functions, and PubJWK is a method. The Rust library is rust/pki.rs.

Erlang also has seal and open for a JWK that does not fit in one OAEP block.

Languages that still need a protocol helper, or a PKI rewrite, are listed in Languages. The samples show the call sequence that ships. See Samples.