Skip to content

Commit

Permalink
Adds PNNS API protos (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
fboemer authored Aug 26, 2024
1 parent df7f4f7 commit d639913
Show file tree
Hide file tree
Showing 10 changed files with 1,488 additions and 664 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: apple/swift_homomorphic_encryption/api/v1/api_evaluation_key.proto
//
// For information on using the generated types, please see the documentation:
// https://github.com/apple/swift-protobuf/

// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
//
// 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
//
// http://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.

import Foundation
import SwiftProtobuf

import HomomorphicEncryptionProtobuf

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that you are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
typealias Version = _2
}

/// Evaluation key metadata.
public struct Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKeyMetadata: @unchecked Sendable {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

/// Timestamp of the (secret) key generation, seconds from Unix epoch.
public var timestamp: UInt64 = 0

/// Key identifier (SHA256 of `EvaluationKeyConfig`).
public var identifier: Data = Data()

public var unknownFields = SwiftProtobuf.UnknownStorage()

public init() {}
}

/// Status of the evaluation key.
public struct Apple_SwiftHomomorphicEncryption_Api_V1_KeyStatus: Sendable {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

/// When was this key last updated (seconds from Unix epoch), 0 when key is missing.
public var timestamp: UInt64 = 0

/// Configuration for the key.
public var keyConfig: HomomorphicEncryptionProtobuf.Apple_SwiftHomomorphicEncryption_V1_EvaluationKeyConfig {
get {return _keyConfig ?? HomomorphicEncryptionProtobuf.Apple_SwiftHomomorphicEncryption_V1_EvaluationKeyConfig()}
set {_keyConfig = newValue}
}
/// Returns true if `keyConfig` has been explicitly set.
public var hasKeyConfig: Bool {return self._keyConfig != nil}
/// Clears the value of `keyConfig`. Subsequent reads from it will return its default value.
public mutating func clearKeyConfig() {self._keyConfig = nil}

public var unknownFields = SwiftProtobuf.UnknownStorage()

public init() {}

fileprivate var _keyConfig: HomomorphicEncryptionProtobuf.Apple_SwiftHomomorphicEncryption_V1_EvaluationKeyConfig? = nil
}

/// Container for multiple evaluation keys.
public struct Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKeys: Sendable {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

/// Evaluation keys.
public var keys: [Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKey] = []

public var unknownFields = SwiftProtobuf.UnknownStorage()

public init() {}
}

/// Evaluation key upload.
public struct Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKey: Sendable {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

/// Metadata for the key.
public var metadata: Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKeyMetadata {
get {return _metadata ?? Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKeyMetadata()}
set {_metadata = newValue}
}
/// Returns true if `metadata` has been explicitly set.
public var hasMetadata: Bool {return self._metadata != nil}
/// Clears the value of `metadata`. Subsequent reads from it will return its default value.
public mutating func clearMetadata() {self._metadata = nil}

/// Evaluation key.
public var evaluationKey: HomomorphicEncryptionProtobuf.Apple_SwiftHomomorphicEncryption_V1_SerializedEvaluationKey {
get {return _evaluationKey ?? HomomorphicEncryptionProtobuf.Apple_SwiftHomomorphicEncryption_V1_SerializedEvaluationKey()}
set {_evaluationKey = newValue}
}
/// Returns true if `evaluationKey` has been explicitly set.
public var hasEvaluationKey: Bool {return self._evaluationKey != nil}
/// Clears the value of `evaluationKey`. Subsequent reads from it will return its default value.
public mutating func clearEvaluationKey() {self._evaluationKey = nil}

public var unknownFields = SwiftProtobuf.UnknownStorage()

public init() {}

fileprivate var _metadata: Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKeyMetadata? = nil
fileprivate var _evaluationKey: HomomorphicEncryptionProtobuf.Apple_SwiftHomomorphicEncryption_V1_SerializedEvaluationKey? = nil
}

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "apple.swift_homomorphic_encryption.api.v1"

extension Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKeyMetadata: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".EvaluationKeyMetadata"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "timestamp"),
2: .same(proto: "identifier"),
]

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch fieldNumber {
case 1: try { try decoder.decodeSingularUInt64Field(value: &self.timestamp) }()
case 2: try { try decoder.decodeSingularBytesField(value: &self.identifier) }()
default: break
}
}
}

public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if self.timestamp != 0 {
try visitor.visitSingularUInt64Field(value: self.timestamp, fieldNumber: 1)
}
if !self.identifier.isEmpty {
try visitor.visitSingularBytesField(value: self.identifier, fieldNumber: 2)
}
try unknownFields.traverse(visitor: &visitor)
}

public static func ==(lhs: Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKeyMetadata, rhs: Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKeyMetadata) -> Bool {
if lhs.timestamp != rhs.timestamp {return false}
if lhs.identifier != rhs.identifier {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Apple_SwiftHomomorphicEncryption_Api_V1_KeyStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".KeyStatus"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "timestamp"),
2: .standard(proto: "key_config"),
]

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch fieldNumber {
case 1: try { try decoder.decodeSingularUInt64Field(value: &self.timestamp) }()
case 2: try { try decoder.decodeSingularMessageField(value: &self._keyConfig) }()
default: break
}
}
}

public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every if/case branch local when no optimizations
// are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
// https://github.com/apple/swift-protobuf/issues/1182
if self.timestamp != 0 {
try visitor.visitSingularUInt64Field(value: self.timestamp, fieldNumber: 1)
}
try { if let v = self._keyConfig {
try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
} }()
try unknownFields.traverse(visitor: &visitor)
}

public static func ==(lhs: Apple_SwiftHomomorphicEncryption_Api_V1_KeyStatus, rhs: Apple_SwiftHomomorphicEncryption_Api_V1_KeyStatus) -> Bool {
if lhs.timestamp != rhs.timestamp {return false}
if lhs._keyConfig != rhs._keyConfig {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKeys: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".EvaluationKeys"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "keys"),
]

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch fieldNumber {
case 1: try { try decoder.decodeRepeatedMessageField(value: &self.keys) }()
default: break
}
}
}

public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if !self.keys.isEmpty {
try visitor.visitRepeatedMessageField(value: self.keys, fieldNumber: 1)
}
try unknownFields.traverse(visitor: &visitor)
}

public static func ==(lhs: Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKeys, rhs: Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKeys) -> Bool {
if lhs.keys != rhs.keys {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".EvaluationKey"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "metadata"),
2: .standard(proto: "evaluation_key"),
]

public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch fieldNumber {
case 1: try { try decoder.decodeSingularMessageField(value: &self._metadata) }()
case 2: try { try decoder.decodeSingularMessageField(value: &self._evaluationKey) }()
default: break
}
}
}

public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every if/case branch local when no optimizations
// are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
// https://github.com/apple/swift-protobuf/issues/1182
try { if let v = self._metadata {
try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
} }()
try { if let v = self._evaluationKey {
try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
} }()
try unknownFields.traverse(visitor: &visitor)
}

public static func ==(lhs: Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKey, rhs: Apple_SwiftHomomorphicEncryption_Api_V1_EvaluationKey) -> Bool {
if lhs._metadata != rhs._metadata {return false}
if lhs._evaluationKey != rhs._evaluationKey {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}
Loading

0 comments on commit d639913

Please sign in to comment.