| /* | |
| * Copyright 2017 Google Inc. | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * https://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| * See the License for the specific language governing permissions and | |
| * limitations under the License. | |
| */ | |
| syntax = "proto2"; | |
| option optimize_for = LITE_RUNTIME; | |
| package rlwe; | |
| option go_package = "github.com/google/shell-encryption"; | |
| // NTT Polynomial | |
| message SerializedNttPolynomial { | |
| // Coefficients of the polynomial | |
| optional bytes coeffs = 1; | |
| // Number of coefficients of the polynomial. | |
| optional int32 num_coeffs = 2; | |
| } | |
| // RLWE Ciphertext | |
| message SerializedSymmetricRlweCiphertext { | |
| // Polynomials composing the ciphertext | |
| repeated SerializedNttPolynomial c = 1; | |
| // The power of the secret key that the ciphertext is encrypted with. | |
| optional int32 power_of_s = 2; | |
| // A heuristic on the amount of error in the ciphertext. | |
| optional double error = 3; | |
| } | |
| // Type of PRNG used to generate randomness. | |
| enum PrngType { | |
| PRNG_TYPE_INVALID = 0; | |
| PRNG_TYPE_HKDF = 1; | |
| PRNG_TYPE_CHACHA = 2; | |
| } | |
| // RLWE RelinearizationKey | |
| message SerializedRelinearizationKey { | |
| // Polynomial composing the matrix | |
| repeated SerializedNttPolynomial c = 1; | |
| // The modulus used to decompose the coefficients of the polynomials. Ranges | |
| // from 1 to the number of bits of the modulus. | |
| optional int32 log_decomposition_modulus = 2; | |
| // For n parts, the key can relinearize an n-component ciphertext to a | |
| // 2-component ciphertext. | |
| optional int32 num_parts = 3; | |
| // Seed used to compress this key. | |
| optional bytes prng_seed = 4; // Required | |
| // Type of PRNG used to generate randomness. | |
| optional PrngType prng_type = 6; // Required | |
| // The power of s that corresponds to the key. The field is 1 if the key is | |
| // RelinearizationKey. | |
| optional int32 power_of_s = 5; | |
| } | |
| // RLWE GaloisKeys. | |
| message SerializedGaloisKey { | |
| // The key-switching matrix | |
| optional SerializedRelinearizationKey key = 1; | |
| } | |
| // RLWE Public Key | |
| message SerializedPublicRlweKey { | |
| // Seed used to generate the random polynomial "a" in the public key | |
| optional bytes prng_seed = 1; | |
| // Type of PRNG used to generate the random polynomial "a" | |
| optional PrngType prng_type = 2; | |
| // The polynomial "b" of the public key | |
| optional SerializedNttPolynomial b = 3; | |
| } | |
| // RLWE AuxModRelinearizationKey | |
| message SerializedAuxModRelinearizationKey { | |
| // Polynomials (both mod-q and mod-p) composing the "b" part of the key matrix | |
| repeated SerializedNttPolynomial b = 1; | |
| // For n parts, the key can relinearize an (n+1)-component ciphertext (if | |
| // `power_of_s` == 1) or an n-component ciphertext to a 2-component ciphertext | |
| optional int32 num_components = 2; | |
| // Seed used to generate the random components in the key. | |
| optional bytes prng_seed = 3; // Required | |
| // Type of PRNG used to generate randomness. | |
| optional PrngType prng_type = 4; // Required | |
| // The power of s that corresponds to the key. The field is 1 if the key is | |
| // AuxModRelinearizationKey. | |
| optional int32 power_of_s = 5; | |
| } | |
| // RLWE AuxModRelinearizationKey | |
| message SerializedAuxModGaloisKey { | |
| // The underlying key-switching key | |
| optional SerializedAuxModRelinearizationKey key = 1; | |
| } |