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

Remove client side bug workaround #62

Merged
merged 1 commit into from
Aug 15, 2024
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
19 changes: 0 additions & 19 deletions Sources/PrivateInformationRetrieval/KeywordPirProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,6 @@ public final class KeywordPirServer<PirServer: IndexPirServer>: KeywordPirProtoc
maxEntrySize = cuckooTableConfig.maxSerializedBucketSize
}

// if we would hit the client side bug, reprocess with modified `maxSerializedBucketSize`
if maxEntrySize.isMultiple(of: context.bytesPerPlaintext)
|| context.bytesPerPlaintext.isMultiple(of: maxEntrySize)
{
let newCuckooTableConfig = try CuckooTableConfig(
hashFunctionCount: cuckooTableConfig.hashFunctionCount,
maxEvictionCount: cuckooTableConfig.maxEvictionCount,
maxSerializedBucketSize: maxEntrySize - 1,
bucketCount: cuckooTableConfig.bucketCount,
multipleTables: cuckooTableConfig.multipleTables)

let newConfig = try KeywordPirConfig(
dimensionCount: config.dimensionCount,
cuckooTableConfig: newCuckooTableConfig,
unevenDimensions: config.unevenDimensions,
keyCompression: config.keyCompression)
return try Self.process(database: database, config: newConfig, with: context)
}

let indexPirConfig = try IndexPirConfig(
entryCount: cuckooTable.bucketsPerTable,
entrySizeInBytes: maxEntrySize,
Expand Down
6 changes: 0 additions & 6 deletions Sources/PrivateInformationRetrieval/MulPir.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,6 @@ extension MulPirClient {
bitsPerCoeff: context.plaintextModulus.log2)
}

// this is a copy of the client side bug
let accessRange = computeResponseRangeInBytes(at: entryIndex)
guard accessRange.upperBound < bytes.count else {
throw PirError.validationError("Client side bug hit!")
}

return Array(bytes[computeResponseRangeInBytes(at: entryIndex)])
}
}
Expand Down
39 changes: 0 additions & 39 deletions Tests/PrivateInformationRetrievalTests/KeywordPirTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -368,45 +368,6 @@ class KeywordPirTests: XCTestCase {
MulPirServer<Bfv<UInt64>>.self, client: MulPirClient<Bfv<UInt64>>.self)
}

func testClientBugWorkaround() throws {
func runTest<PirServer: IndexPirServer, PirClient: IndexPirClient>(
rlweParams: PredefinedRlweParameters,
server _: PirServer.Type,
client _: PirClient.Type) throws where PirServer.IndexPir == PirClient.IndexPir
{
let context: Context<PirServer.Scheme> = try Context(encryptionParameters: .init(from: rlweParams))

var testRng = TestRng()
let testDatabase = PirTestUtils.getTestTable(rowCount: 1000, valueSize: 1, using: &testRng)
let config = try KeywordPirConfig(
dimensionCount: 2,
cuckooTableConfig: .defaultKeywordPir(maxSerializedBucketSize: 1024),
unevenDimensions: true, keyCompression: .noCompression)
let processed = try KeywordPirServer<PirServer>.process(
database: testDatabase,
config: config,
with: context)
let server = try KeywordPirServer<PirServer>(
context: context,
processed: processed)
let client = KeywordPirClient<PirClient>(
keywordParameter: config.parameter,
pirParameter: processed.pirParameter,
context: context)
let secretKey = try context.generateSecretKey()
let evaluationKey = try client.generateEvaluationKey(using: secretKey)
let query = try client.generateQuery(at: [], using: secretKey)
let response = try server.computeResponse(to: query, using: evaluationKey)
let result = try client.decrypt(response: response, at: [], using: secretKey)
XCTAssertNil(result)
}
let rlweParams = PredefinedRlweParameters.n_4096_logq_27_28_28_logt_5
try runTest(rlweParams: rlweParams, server:
MulPirServer<Bfv<UInt32>>.self, client: MulPirClient<Bfv<UInt32>>.self)
try runTest(rlweParams: rlweParams, server:
MulPirServer<Bfv<UInt64>>.self, client: MulPirClient<Bfv<UInt64>>.self)
}

func testInvalidArguments() throws {
let cuckooConfig = try CuckooTableConfig(
hashFunctionCount: 2,
Expand Down
Loading