Skip to content

Commit

Permalink
Unify installation instructions to use experimental-install (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
fboemer authored Oct 23, 2024
1 parent 99833cf commit c7becf0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ Keyword PIR database generation
## Overview

`PIRGenerateDatabase` is an executable which generates a sample database for testing.
The resulting database can be processed with the `PIRProcessDatabase` executable or sharded with the `PIRShardDatabase` executable.
The resulting database can be sharded with the [PIRShardDatabase](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/pirsharddatabase) executable and processed with the [PIRProcessDatabase](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/pirprocessdatabase) executable.

### Requirements
* Build the `PIRGenerateDatabase` executable by running:
To install the `PIRGenerateDatabase` executable, first make sure that the `~/.swiftpm/bin` directory is on your `$PATH`. To do
so, add the following line to your `~/.zshrc` or appropriate shell configuration file.
```sh
swift build -c release --target PIRGenerateDatabase
export PATH="$HOME/.swiftpm/bin:$PATH"
```
The binary will be generated in `.build/release/PIRGenerateDatabase`.
Make sure to reload it (`source ~/.zshrc`) or by restarting your terminal emulator. Then we are going to use the
`experimental-install` feature of Swift Package Manager.

* Install the binary, e.g., by adding it to your path.
Change directory to a checkout of this repository and run the following command.
```sh
swift package experimental-install -c release --product PIRGenerateDatabase
```

### Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ Keyword PIR database processing will transform a database in preparation for hos
The `PIRProcessDatabase` binary performs the processing.

### Requirements
Build the `PIRProcessDatabase` executable by running:
To install the `PIRProcessDatabase` executable, first make sure that the `~/.swiftpm/bin` directory is on your `$PATH`. To do
so, add the following line to your `~/.zshrc` or appropriate shell configuration file.
```sh
swift build -c release --target PIRProcessDatabase
export PATH="$HOME/.swiftpm/bin:$PATH"
```
Make sure to reload it (`source ~/.zshrc`) or by restarting your terminal emulator. Then we are going to use the
`experimental-install` feature of Swift Package Manager.

Change directory to a checkout of this repository and run the following command.
```sh
swift package experimental-install -c release --product PIRProcessDatabase
```
The binary will be generated in `.build/release/PIRProcessDatabase`.

### Processing
Keyword PIR's database processing is determined by its parameters.
Expand All @@ -31,7 +38,7 @@ e.g., `n_4096_logq_27_28_28_logt_5`.
2. `inputDatabase` is the path to the unprocessed input database. It must be a
serialized [Apple_SwiftHomomorphicEncryption_Pir_V1_KeywordDatabase](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/privateinformationretrievalprotobuf/apple_swifthomomorphicencryption_pir_v1_keyworddatabase).

> Note: The `PIRGenerateDatabase` binary can be used to generate a sample database.
> Note: The [PIRGenerateDatabase](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/pirgeneratedatabase) binary can be used to generate a sample database.
3. `outputDatabase` is the path to where the processed database’s shards will be
written. This string must contain `SHARD_ID`, unless `sharding` is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Database updates may lead to different PIR configurations, which need to be sync
We can configure the database processing to yield the same PIR configuration across database updates.

### Requirements
This example assumes that you have the following binaries available on your `$PATH`.
The binaries are:
This example assumes that you have the following binaries available on your `$PATH`:
- `PIRGenerateDatabase`
- `PIRProcessDatabase`

Expand All @@ -22,8 +21,7 @@ Make sure to reload it (`source ~/.zshrc`) or by restarting your terminal emulat

Change directory to a checkout of this repository and run the following command.
```sh
swift package experimental-install -c release --product PIRGenerateDatabase
swift package experimental-install -c release --product PIRProcessDatabase
swift package experimental-install -c release --product PIRGenerateDatabase --product PIRProcessDatabase
```

### Example
Expand Down
21 changes: 14 additions & 7 deletions Sources/PIRShardDatabase/PIRShardDatabase.docc/PIRShardDatabase.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,23 @@ Each resulting shard is suitable for processing with the [PIRProcessDatabase](ht
* `entryCountPerShard` shards the database using enough shards such that the average shard contains the specified number of entries.

### Requirements
Build the [PIRProcessDatabase](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/pirprocessdatabase) executable by running:
This example assumes that you have the following binaries available on your `$PATH`:
- `PIRGenerateDatabase`
- `PIRShardDatabase`
- `PIRProcessDatabase`

The way to add these to your path is by first making sure that the `~/.swiftpm/bin` directory is on your `$PATH`. To do
so, add the following line to your `~/.zshrc` or appropriate shell configuration file.
```sh
swift build -c release --target PIRProcessDatabase
export PATH="$HOME/.swiftpm/bin:$PATH"
```
The binary will be generated in `.build/release/PIRProcessDatabase`.
Make sure to reload it (`source ~/.zshrc`) or by restarting your terminal emulator. Then we are going to use the
`experimental-install` feature of Swift Package Manager.

For the example below, you'll also need to install the
[PIRGenerateDatabase](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/pirgeneratedatabse)
executable in a similar manner as
[PIRShardDatabase](https://swiftpackageindex.com/apple/swift-homomorphic-encryption/main/documentation/pirsharddatabase).
Change directory to a checkout of this repository and run the following command.
```sh
swift package experimental-install -c release --product PIRGenerateDatabase --product PIRShardDatabase --product PIRProcessDatabase
```

### Example

Expand Down
3 changes: 3 additions & 0 deletions Sources/PrivateInformationRetrieval/KeywordPirProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public struct KeywordPirConfig: Hashable, Codable, Sendable {
/// Strategy for ``EvaluationKey`` compression.
@usableFromInline let keyCompression: PirKeyCompressionStrategy

/// When set to true, entry size will be equal to ``CuckooTableConfig/maxSerializedBucketSize``.
///
/// Otherwise the largest serialized bucket size is used instead.
@usableFromInline let useMaxSerializedBucketSize: Bool

/// Keyword PIR parameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Database updates may lead to different PIR configurations, which need to be sync
We can configure the database processing to yield the same PIR configuration on small database updates.

### Requirements
This example assumes that you have the following binaries available on your `$PATH`.
The binaries are:
This example assumes that you have the following binaries available on your `$PATH`:
- `PIRGenerateDatabase`
- `PIRProcessDatabase`

Expand All @@ -22,8 +21,7 @@ Make sure to reload it (`source ~/.zshrc`) or by restarting your terminal emulat

Change directory to a checkout of this repository and run the following command.
```sh
swift package experimental-install -c release --product PIRGenerateDatabase
swift package experimental-install -c release --product PIRProcessDatabase
swift package experimental-install -c release --product PIRGenerateDatabase --product PIRProcessDatabase
```

### Example
Expand Down

0 comments on commit c7becf0

Please sign in to comment.