From a1a598f7ce91ebfbaf671b0e75eff148f13dfa43 Mon Sep 17 00:00:00 2001 From: Karl Tarbe Date: Fri, 16 Aug 2024 00:25:57 +0300 Subject: [PATCH] Remove client side bug workaround The client side bug was fixed in iOS 18.0 beta 5. --- .../KeywordPirProtocol.swift | 19 --------- .../PrivateInformationRetrieval/MulPir.swift | 6 --- .../KeywordPirTests.swift | 39 ------------------- 3 files changed, 64 deletions(-) diff --git a/Sources/PrivateInformationRetrieval/KeywordPirProtocol.swift b/Sources/PrivateInformationRetrieval/KeywordPirProtocol.swift index 3400d226..e761a7d2 100644 --- a/Sources/PrivateInformationRetrieval/KeywordPirProtocol.swift +++ b/Sources/PrivateInformationRetrieval/KeywordPirProtocol.swift @@ -163,25 +163,6 @@ public final class KeywordPirServer: 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, diff --git a/Sources/PrivateInformationRetrieval/MulPir.swift b/Sources/PrivateInformationRetrieval/MulPir.swift index fb450957..af5795f4 100644 --- a/Sources/PrivateInformationRetrieval/MulPir.swift +++ b/Sources/PrivateInformationRetrieval/MulPir.swift @@ -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)]) } } diff --git a/Tests/PrivateInformationRetrievalTests/KeywordPirTests.swift b/Tests/PrivateInformationRetrievalTests/KeywordPirTests.swift index 9222616e..5aee176e 100644 --- a/Tests/PrivateInformationRetrievalTests/KeywordPirTests.swift +++ b/Tests/PrivateInformationRetrievalTests/KeywordPirTests.swift @@ -368,45 +368,6 @@ class KeywordPirTests: XCTestCase { MulPirServer>.self, client: MulPirClient>.self) } - func testClientBugWorkaround() throws { - func runTest( - rlweParams: PredefinedRlweParameters, - server _: PirServer.Type, - client _: PirClient.Type) throws where PirServer.IndexPir == PirClient.IndexPir - { - let context: Context = 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.process( - database: testDatabase, - config: config, - with: context) - let server = try KeywordPirServer( - context: context, - processed: processed) - let client = KeywordPirClient( - 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>.self, client: MulPirClient>.self) - try runTest(rlweParams: rlweParams, server: - MulPirServer>.self, client: MulPirClient>.self) - } - func testInvalidArguments() throws { let cuckooConfig = try CuckooTableConfig( hashFunctionCount: 2,