Coding/decoding, key generation