Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OPRF proto messages #18

Merged
merged 1 commit into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Ignore generated files
*.pb.swift

.DS_Store
.idea
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ repos:
- copyright-header.txt
- --allow-past-years
- --use-current-year
- id: insert-license
name: insert-license-sh
files: \.sh$
args:
- --license-filepath
- copyright-header.txt
- --allow-past-years
- --use-current-year
- repo: https://github.com/bufbuild/buf
rev: v1.48.0
hooks:
Expand Down
6 changes: 5 additions & 1 deletion apple/swift_homomorphic_encryption/api/pir/v1/api.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
// Copyright 2024-2025 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.
Expand Down Expand Up @@ -69,6 +69,8 @@ message Request {
oneof request {
// PIR request.
apple.swift_homomorphic_encryption.api.pir.v1.PIRRequest pir_request = 2;
// OPRF request.
apple.swift_homomorphic_encryption.api.pir.v1.OPRFRequest oprf_request = 4;
}
reserved 3;
}
Expand All @@ -79,6 +81,8 @@ message Response {
oneof response {
// Response to a `PIRRequest`.
apple.swift_homomorphic_encryption.api.pir.v1.PIRResponse pir_response = 1;
// Response to `OPRFRequest`.
apple.swift_homomorphic_encryption.api.pir.v1.OPRFResponse oprf_response = 3;
}
reserved 2;
}
18 changes: 17 additions & 1 deletion apple/swift_homomorphic_encryption/api/pir/v1/pir.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
// Copyright 2024-2025 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.
Expand Down Expand Up @@ -93,3 +93,19 @@ message PIRResponse {
// Encrypted replies, each of which is a ciphertext vector.
repeated apple.swift_homomorphic_encryption.v1.SerializedCiphertextVec replies = 1;
}

// PIR OPRF Request.
message OPRFRequest {
// Serialized query.
bytes query_element = 1;
// Identifier for PirConfig used to construct this request.
bytes config_id = 2;
}

// PIR OPRF Response.
message OPRFResponse {
// Serialized output of OPRF.
bytes evaluated_element = 1;
// Proof of OPRF evaluation.
bytes proof = 2;
}
4 changes: 3 additions & 1 deletion apple/swift_homomorphic_encryption/api/pnns/v1/api.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
// Copyright 2024-2025 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.
Expand Down Expand Up @@ -71,6 +71,7 @@ message Request {
// PNNS request.
apple.swift_homomorphic_encryption.api.pnns.v1.PNNSRequest pnns_request = 3;
}
reserved 4;
}

// Generic response.
Expand All @@ -81,4 +82,5 @@ message Response {
// Response to a `PNNSRequest`.
apple.swift_homomorphic_encryption.api.pnns.v1.PNNSResponse pnns_response = 2;
}
reserved 3;
}
6 changes: 5 additions & 1 deletion apple/swift_homomorphic_encryption/api/v1/api.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
// Copyright 2024-2025 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.
Expand Down Expand Up @@ -73,6 +73,8 @@ message Request {
apple.swift_homomorphic_encryption.api.pir.v1.PIRRequest pir_request = 2;
// PNNS request.
apple.swift_homomorphic_encryption.api.pnns.v1.PNNSRequest pnns_request = 3;
// OPRF request.
apple.swift_homomorphic_encryption.api.pir.v1.OPRFRequest oprf_request = 4;
}
}

Expand All @@ -84,5 +86,7 @@ message Response {
apple.swift_homomorphic_encryption.api.pir.v1.PIRResponse pir_response = 1;
// Response to a `PNNSRequest`.
apple.swift_homomorphic_encryption.api.pnns.v1.PNNSResponse pnns_response = 2;
// Response to `OPRFRequest`.
apple.swift_homomorphic_encryption.api.pir.v1.OPRFResponse oprf_response = 3;
}
}
24 changes: 21 additions & 3 deletions apple/swift_homomorphic_encryption/pir/v1/pir.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
// Copyright 2024-2025 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.
Expand Down Expand Up @@ -51,14 +51,16 @@ message PirParameters {
apple.swift_homomorphic_encryption.v1.EvaluationKeyConfig evaluation_key_config = 8;
// Key compression strategy.
KeyCompressionStrategy key_compression_strategy = 9;
reserved 10, 11;
reserved 10, 11, 12;
}

// Parameters for keyword PIR.
message KeywordPirParameters {
// The number of hash functions used.
uint64 num_hash_functions = 1;
reserved 2, 3;
reserved 2;
// Symmetric PIR configuration
SymmetricPirClientConfig symmetric_pir_client_config = 3;
// The sharding function to use.
PIRShardingFunction sharding_function = 4;
}
Expand Down Expand Up @@ -94,3 +96,19 @@ message EncryptedIndices {
// Number of PIR calls.
uint64 num_pir_calls = 2;
}

// Scheme used for encrypting database entries in Symmetric PIR.
enum SymmetricPirConfigType {
// Unspecified config type.
SYMMETRIC_PIR_CONFIG_TYPE_UNSPECIFIED = 0;
// OPRF P384 AES-192-GCM, 96-bit nonce, 128-bit tag
SYMMETRIC_PIR_CONFIG_TYPE_OPRF_P384_AES_GCM_192_NONCE_96_TAG_128 = 1;
}

// Client specific PIR configuration for Symmetric PIR
message SymmetricPirClientConfig {
// Server public key
bytes server_public_key = 1;
// Symmetric PIR config type
SymmetricPirConfigType config_type = 2;
}
7 changes: 3 additions & 4 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
# Copyright 2024-2025 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.
Expand All @@ -12,15 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

version: v1
version: v2
breaking:
use:
- FILE
- WIRE

lint:
use:
- DEFAULT
- STANDARD
- COMMENTS
- PACKAGE_NO_IMPORT_CYCLE
ignore_only:
Expand Down
Loading