Skip to content

Commit e8db9a7

Browse files
authored
Neighbors -> Neighbor in PNNS (#115)
1 parent efe2ed1 commit e8db9a7

File tree

61 files changed

+106
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+106
-96
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ repos:
4545
- //
4646
- --allow-past-years
4747
- --use-current-year
48-
- --detect-license-in-X-top-lines=10
48+
- --detect-license-in-X-top-lines=11
4949
- id: insert-license
5050
name: insert-license-yaml
5151
'types_or': [yaml]

.spi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ builder:
2525
- PNNSProcessDatabase
2626
- PrivateInformationRetrieval
2727
- PrivateInformationRetrievalProtobuf
28-
- PrivateNearestNeighborsSearch
29-
- PrivateNearestNeighborsSearchProtobuf
28+
- PrivateNearestNeighborSearch
29+
- PrivateNearestNeighborSearchProtobuf
3030
swift_version: 6.0
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import Benchmark
1919
import Foundation
2020
import HomomorphicEncryption
2121
import HomomorphicEncryptionProtobuf
22-
import PrivateNearestNeighborsSearch
23-
import PrivateNearestNeighborsSearchProtobuf
22+
import PrivateNearestNeighborSearch
23+
import PrivateNearestNeighborSearchProtobuf
2424

2525
@usableFromInline nonisolated(unsafe) let benchmarkConfiguration = Benchmark.Configuration(
2626
metrics: [
@@ -93,7 +93,7 @@ extension EncryptionParameters {
9393

9494
let noiseBudgetScale = 10
9595

96-
extension PrivateNearestNeighborsSearch.Response {
96+
extension PrivateNearestNeighborSearch.Response {
9797
func scaledNoiseBudget(using secretKey: Scheme.SecretKey) throws -> Int {
9898
try Int(
9999
noiseBudget(using: secretKey, variableTime: true) * Double(

Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ let package = Package(
4242
name: "PrivateInformationRetrievalProtobuf",
4343
targets: ["PrivateInformationRetrievalProtobuf"]),
4444
.library(
45-
name: "PrivateNearestNeighborsSearch",
46-
targets: ["PrivateNearestNeighborsSearch"]),
45+
name: "PrivateNearestNeighborSearch",
46+
targets: ["PrivateNearestNeighborSearch"]),
4747
.library(
48-
name: "PrivateNearestNeighborsSearchProtobuf",
49-
targets: ["PrivateNearestNeighborsSearchProtobuf"]),
48+
name: "PrivateNearestNeighborSearchProtobuf",
49+
targets: ["PrivateNearestNeighborSearchProtobuf"]),
5050
.executable(name: "PIRGenerateDatabase", targets: ["PIRGenerateDatabase"]),
5151
.executable(name: "PIRProcessDatabase", targets: ["PIRProcessDatabase"]),
5252
.executable(name: "PIRShardDatabase", targets: ["PIRShardDatabase"]),
@@ -59,7 +59,7 @@ let package = Package(
5959
.package(url: "https://github.com/apple/swift-crypto.git", from: "3.4.0"),
6060
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
6161
.package(url: "https://github.com/apple/swift-numerics", from: "1.0.0"),
62-
.package(url: "https://github.com/apple/swift-protobuf", from: "1.27.0"), // Keep version in sync with README
62+
.package(url: "https://github.com/apple/swift-protobuf", from: "1.28.1"), // Keep version in sync with README
6363
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.1.0"),
6464
],
6565
targets: [
@@ -99,15 +99,15 @@ let package = Package(
9999
exclude: ["generated/README.md", "protobuf_module_mappings.txtpb"],
100100
swiftSettings: librarySettings),
101101
.target(
102-
name: "PrivateNearestNeighborsSearch",
102+
name: "PrivateNearestNeighborSearch",
103103
dependencies: [
104104
.product(name: "Algorithms", package: "swift-algorithms"),
105105
"HomomorphicEncryption",
106106
],
107107
swiftSettings: librarySettings),
108108
.target(
109-
name: "PrivateNearestNeighborsSearchProtobuf",
110-
dependencies: ["PrivateNearestNeighborsSearch",
109+
name: "PrivateNearestNeighborSearchProtobuf",
110+
dependencies: ["PrivateNearestNeighborSearch",
111111
"HomomorphicEncryption",
112112
"HomomorphicEncryptionProtobuf",
113113
.product(name: "SwiftProtobuf", package: "swift-protobuf")],
@@ -151,15 +151,15 @@ let package = Package(
151151
dependencies: [
152152
.product(name: "ArgumentParser", package: "swift-argument-parser"),
153153
"HomomorphicEncryption",
154-
"PrivateNearestNeighborsSearchProtobuf",
154+
"PrivateNearestNeighborSearchProtobuf",
155155
],
156156
swiftSettings: executableSettings),
157157
.executableTarget(
158158
name: "PNNSProcessDatabase",
159159
dependencies: [
160160
.product(name: "ArgumentParser", package: "swift-argument-parser"),
161161
"HomomorphicEncryptionProtobuf",
162-
"PrivateNearestNeighborsSearchProtobuf",
162+
"PrivateNearestNeighborSearchProtobuf",
163163
"HomomorphicEncryption",
164164
.product(name: "Logging", package: "swift-log"),
165165
],
@@ -201,15 +201,15 @@ let package = Package(
201201
"TestUtilities",
202202
], swiftSettings: executableSettings),
203203
.testTarget(
204-
name: "PrivateNearestNeighborsSearchTests",
204+
name: "PrivateNearestNeighborSearchTests",
205205
dependencies: [
206-
"PrivateNearestNeighborsSearch", "HomomorphicEncryption", "TestUtilities",
206+
"PrivateNearestNeighborSearch", "HomomorphicEncryption", "TestUtilities",
207207
], swiftSettings: executableSettings),
208208
.testTarget(
209-
name: "PrivateNearestNeighborsSearchProtobufTests",
209+
name: "PrivateNearestNeighborSearchProtobufTests",
210210
dependencies: [
211-
"PrivateNearestNeighborsSearch",
212-
"PrivateNearestNeighborsSearchProtobuf",
211+
"PrivateNearestNeighborSearch",
212+
"PrivateNearestNeighborSearchProtobuf",
213213
], swiftSettings: executableSettings),
214214
])
215215

@@ -261,10 +261,10 @@ package.targets += [
261261
.product(name: "Benchmark", package: "package-benchmark"),
262262
"HomomorphicEncryption",
263263
"HomomorphicEncryptionProtobuf",
264-
"PrivateNearestNeighborsSearch",
265-
"PrivateNearestNeighborsSearchProtobuf",
264+
"PrivateNearestNeighborSearch",
265+
"PrivateNearestNeighborSearchProtobuf",
266266
],
267-
path: "Benchmarks/PrivateNearestNeighborsSearchBenchmark",
267+
path: "Benchmarks/PrivateNearestNeighborSearchBenchmark",
268268
swiftSettings: benchmarkSettings,
269269
plugins: [
270270
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ For more information, refer to documentation for the libraries:
1212
* [HomomorphicEncryption](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/homomorphicencryption)
1313
* [PrivateInformationRetrievalProtobuf](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privateinformationretrievalprotobuf)
1414
* [PrivateInformationRetrieval](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privateinformationretrieval)
15-
* [PrivateNearestNeighborsSearchProtobuf](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privatenearestneighborssearchprotobuf)
16-
* [PrivateNearestNeighborsSearch](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privatenearestneighborssearch)
15+
* [PrivateNearestNeighborSearchProtobuf](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privatenearestneighborsearchprotobuf)
16+
* [PrivateNearestNeighborSearch](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privatenearestneighborsearch)
1717

1818
and executables:
1919
* [PIRGenerateDatabase](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/pirgeneratedatabase)
@@ -63,11 +63,11 @@ The PIR implementation in Swift Homomorphic Encryption uses HE to improve upon t
6363
> PIR is asymmetric, meaning the client may learn keyword-value pairs not requested, as happens in trivial PIR for instance.
6464
> A variant of PIR, known as *symmetric PIR*, would be required to ensure the client does not learn anything about values it did not request.
6565
66-
### Private Nearest Neighbors Search (PNNS)
67-
Private nearest neighbors search (PNNS) enables a client with a private vector to search for the nearest vectors in a database hosted by a server, *without the server learning the client's vector.*.
66+
### Private Nearest Neighbor Search (PNNS)
67+
Private nearest neighbor search (PNNS) enables a client with a private vector to search for the nearest vectors in a database hosted by a server, *without the server learning the client's vector.*.
6868
Each row in the database is a *vector* with an associated *entry identifier* and *entry metadata*.
69-
During the PNNS protocol, the client issues a query using its private vector, and learns the nearest neighbors according to a ``DistanceMetric``.
70-
Specifically, the client learns the distances between the client's query vector to the nearest neighbors, as well as the entry identifier and entry metadata of the nearest neighbors.
69+
During the PNNS protocol, the client issues a query using its private vector, and learns the nearest neighbor according to a ``DistanceMetric``.
70+
Specifically, the client learns the distances between the client's query vector to the nearest neighbor, as well as the entry identifier and entry metadata of the nearest neighbor.
7171

7272
A trivial implementation of PNNS is to have the client issue a generic "fetch database" request, independent of its private vector.
7373
Then the server sends the entire database to the client, who computes the distances locally.
@@ -141,7 +141,7 @@ Additionally, developing Swift Homomorphic Encryption requires:
141141
* [Nick Lockwood SwiftFormat](https://github.com/nicklockwood/SwiftFormat), v0.54.0
142142
* [pre-commit](https://pre-commit.com)
143143
* [swift-format](https://github.com/apple/swift-format), v510.1.0
144-
* [swift-protobuf](https://github.com/apple/swift-protobuf), v1.27.0
144+
* [swift-protobuf](https://github.com/apple/swift-protobuf), v1.28.1
145145
* [SwiftLint](https://github.com/realm/SwiftLint), v0.55.1
146146

147147
### Building

Sources/HomomorphicEncryption/HomomorphicEncryption.docc/HomomorphicEncryption.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ For more information, refer to documentation for the libraries:
99
* [HomomorphicEncryption](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/homomorphicencryption)
1010
* [PrivateInformationRetrievalProtobuf](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privateinformationretrievalprotobuf)
1111
* [PrivateInformationRetrieval](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privateinformationretrieval)
12-
* [PrivateNearestNeighborsSearchProtobuf](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privatenearestneighborssearchprotobuf)
13-
* [PrivateNearestNeighborsSearch](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privatenearestneighborssearch)
12+
* [PrivateNearestNeighborSearchProtobuf](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privatenearestneighborsearchprotobuf)
13+
* [PrivateNearestNeighborSearch](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privatenearestneighborsearch)
1414

1515
and executables:
1616
* [PIRGenerateDatabase](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/pirgeneratedatabase)

Sources/HomomorphicEncryptionProtobuf/generated/apple_swift_homomorphic_encryption_v1_error_stddev.pb.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// DO NOT EDIT.
22
// swift-format-ignore-file
3+
// swiftlint:disable all
34
//
45
// Generated by the Swift generator plugin for the protocol buffer compiler.
56
// Source: apple/swift_homomorphic_encryption/v1/error_stddev.proto
@@ -21,7 +22,6 @@
2122
// See the License for the specific language governing permissions and
2223
// limitations under the License.
2324

24-
import Foundation
2525
import SwiftProtobuf
2626

2727
// If the compiler emits an error on this type, it is because this file

Sources/HomomorphicEncryptionProtobuf/generated/apple_swift_homomorphic_encryption_v1_he.pb.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// DO NOT EDIT.
22
// swift-format-ignore-file
3+
// swiftlint:disable all
34
//
45
// Generated by the Swift generator plugin for the protocol buffer compiler.
56
// Source: apple/swift_homomorphic_encryption/v1/he.proto

Sources/PNNSGenerateDatabase/GenerateDatabase.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import ArgumentParser
1616
import Foundation
1717
import HomomorphicEncryption
18-
import PrivateNearestNeighborsSearch
19-
import PrivateNearestNeighborsSearchProtobuf
18+
import PrivateNearestNeighborSearch
19+
import PrivateNearestNeighborSearchProtobuf
2020

2121
enum VectorTypeArguments: String, CaseIterable, ExpressibleByArgument {
2222
/// Each vector's entry is uniform random from `[-1.0, 1.0]`

0 commit comments

Comments
 (0)