|
| 1 | +// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +syntax = "proto3"; |
| 16 | +package apple.swift_homomorphic_encryption.pnns.v1; |
| 17 | + |
| 18 | +// Pre-computed values for matrix-vector multiplication using baby-step, giant-step algorithm. |
| 19 | +// See Section 6.3 of <https://eprint.iacr.org/2018/244.pdf>. |
| 20 | +message BabyStepGiantStep { |
| 21 | + // Dimension of the vector; "D" in the reference. |
| 22 | + uint32 vector_dimension = 1; |
| 23 | + // Baby step; "g" in the reference. |
| 24 | + uint32 baby_step = 2; |
| 25 | + // Giant step; "h" in the reference. |
| 26 | + uint32 giant_step = 3; |
| 27 | +} |
| 28 | + |
| 29 | +// Different algorithms for packing a matrix of scalar values into plaintexts / ciphertexts. |
| 30 | +message MatrixPacking { |
| 31 | + // Different packing formats. |
| 32 | + oneof plaintext_packing_type { |
| 33 | + // Dense row packing. |
| 34 | + MatrixPackingDenseRow dense_row = 1; |
| 35 | + |
| 36 | + /// Packs the values using a generalized diagonal packing. |
| 37 | + /// |
| 38 | + /// Includes modifications for the baby-step, giant-step algorithm from Section 6.3 of |
| 39 | + /// <https://eprint.iacr.org/2018/244.pdf>. |
| 40 | + MatrixPackingDiagonal diagonal = 2; |
| 41 | + |
| 42 | + /// As many rows of data are packed sequentially into each SIMD plaintext |
| 43 | + /// row as possible, such that no data row is split across multiple SIMD rows, and |
| 44 | + /// each data row is zero-padded to the next power of two length. |
| 45 | + /// The rows in the final plaintext are repeated as many times as possible within the plaintext, |
| 46 | + /// with the constraint that either all or none of the entries stored within the last plaintext |
| 47 | + /// row are repeated. |
| 48 | + MatrixPackingDenseColumn dense_column = 3; |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +// As many rows of data are packed sequentially into each SIMD row as possible, |
| 53 | +// such that no data row is split across multiple SIMD rows, and |
| 54 | +// each data row is zero-padded to the next power of two length. |
| 55 | +// The rows in the final plaintext/ciphertext are repeated as many times as possible within the plaintext/ciphertext, |
| 56 | +// with the constraint that either all or none of the entries stored within the last plaintext/ciphertext |
| 57 | +// row are repeated. |
| 58 | +message MatrixPackingDenseRow {} |
| 59 | + |
| 60 | +// Packs the values using a generalized diagonal packing. |
| 61 | +message MatrixPackingDiagonal { |
| 62 | + reserved 1; |
| 63 | + // Diagonals are rotated according to the baby-step, giant-step algorithm from Section 6.3 of <https://eprint.iacr.org/2018/244.pdf>. |
| 64 | + BabyStepGiantStep baby_step_giant_step = 2; |
| 65 | +} |
| 66 | + |
| 67 | +// As many columns of data are packed sequentially into each SIMD row as possible, such that no SIMD row |
| 68 | +// contains data from multiple columns. |
| 69 | +message MatrixPackingDenseColumn {} |
0 commit comments