Skip to content

Commit 9a0cfaa

Browse files
committed
Avoid Scheme argument in processShard
1 parent 0f93db9 commit 9a0cfaa

File tree

5 files changed

+32
-33
lines changed

5 files changed

+32
-33
lines changed

Sources/PIRProcessDatabase/main.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ struct ProcessDatabase: AsyncParsableCommand {
405405
shard: shard,
406406
config: config,
407407
context: context,
408-
processArgs: processArgs, scheme: scheme.self)
408+
processArgs: processArgs)
409409
}
410410
}
411411

@@ -419,7 +419,7 @@ struct ProcessDatabase: AsyncParsableCommand {
419419
shardID: shardID,
420420
shard: shard, config:
421421
config, context: context,
422-
processArgs: processArgs, scheme: scheme.self)
422+
processArgs: processArgs)
423423
evaluationKeyConfig = [evaluationKeyConfig, processedEvaluationKeyConfig].union()
424424
}
425425
}
@@ -433,15 +433,16 @@ struct ProcessDatabase: AsyncParsableCommand {
433433
}
434434
}
435435

436-
// swiftlint:disable:next function_parameter_count
437-
private func processShard<Scheme: HeScheme>(
436+
private func processShard<Context: HeContext>(
438437
shardID: String,
439438
shard: KeywordDatabaseShard,
440439
config: ResolvedArguments,
441-
context: Scheme.Context,
442-
processArgs: ProcessKeywordDatabase.Arguments<Scheme.Scalar>,
443-
scheme _: Scheme.Type) async throws -> EvaluationKeyConfig
440+
context: Context,
441+
processArgs: ProcessKeywordDatabase.Arguments<Context.Scalar>) async throws -> EvaluationKeyConfig
442+
where Context.Scheme.Context == Context
444443
{
444+
typealias Scheme = Context.Scheme
445+
445446
var logger = ProcessDatabase.logger
446447
logger[metadataKey: "shardID"] = .string(shardID)
447448

Sources/TestUtilities/HeApiTestUtils.swift

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,6 @@ public enum HeAPITestHelpers {
128128
securityLevel: SecurityLevel.unchecked))
129129
}
130130

131-
/// test the evaluation key configuration
132-
public static func schemeEvaluationKeyTest(scheme _: (some HeScheme).Type) throws {
133-
do {
134-
let config = EvaluationKeyConfig()
135-
#expect(!config.hasRelinearizationKey)
136-
#expect(config.galoisElements.isEmpty)
137-
#expect(config.keyCount == 0)
138-
}
139-
do {
140-
let config = EvaluationKeyConfig(hasRelinearizationKey: true)
141-
#expect(config.hasRelinearizationKey)
142-
#expect(config.galoisElements.isEmpty)
143-
#expect(config.keyCount == 1)
144-
}
145-
do {
146-
let config = EvaluationKeyConfig(galoisElements: [1, 3], hasRelinearizationKey: true)
147-
#expect(config.hasRelinearizationKey)
148-
#expect(config.galoisElements == [1, 3])
149-
#expect(config.keyCount == 3)
150-
}
151-
}
152-
153131
@inlinable
154132
static func encodingTest<Context: HeContext>(
155133
context: Context,

Sources/TestUtilities/PirUtilities/KeywordPirTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ extension PirTestUtils {
6161
with: testContext)
6262
#expect(processed.pirParameter.dimensions.product() > 1, "trivial PIR")
6363

64-
let server = try KeywordPirServer<PirServer>( context: testContext, processed: processed)
64+
let server = try KeywordPirServer<PirServer>(context: testContext, processed: processed)
6565
let client = KeywordPirClient<PirClient>(
6666
keywordParameter: keywordConfig.parameter, pirParameter: processed.pirParameter,
6767
context: testContext)

Sources/TestUtilities/PnnsUtilities/PlaintextMatrixTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extension PrivateNearestNeighborSearchUtil {
4444
let values = TestUtils.getRandomPlaintextData(
4545
count: encryptionParameters.polyDegree,
4646
in: 0..<encryptionParameters.plaintextModulus)
47-
let plaintext = try context.encode( values: values, format: EncodeFormat.coefficient)
47+
let plaintext = try context.encode(values: values, format: EncodeFormat.coefficient)
4848
#expect(throws: Never.self) { try PlaintextMatrix<Scheme, Coeff>(
4949
dimensions: dims,
5050
packing: packing,

Tests/HomomorphicEncryptionTests/HeAPITests.swift

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ struct HeAPITests {
105105
try await HeAPITestHelpers.schemeCiphertextNegateTest(context: context)
106106
try await HeAPITestHelpers.schemeCiphertextPlaintextInnerProductTest(context: context)
107107
try await HeAPITestHelpers.schemeCiphertextCiphertextInnerProductTest(context: context)
108-
try HeAPITestHelpers.schemeEvaluationKeyTest(scheme: NoOpScheme.self)
109108
try await HeAPITestHelpers.schemeRotationTest(context: context)
110109
try await HeAPITestHelpers.schemeApplyGaloisTest(context: context)
111110
try await HeAPITestHelpers.repeatedAdditionTest(context: context)
@@ -184,7 +183,6 @@ struct HeAPITests {
184183
try await HeAPITestHelpers.schemeCiphertextNegateTest(context: context)
185184
try await HeAPITestHelpers.schemeCiphertextPlaintextInnerProductTest(context: context)
186185
try await HeAPITestHelpers.schemeCiphertextCiphertextInnerProductTest(context: context)
187-
try HeAPITestHelpers.schemeEvaluationKeyTest(scheme: Bfv<T>.self)
188186
try await HeAPITestHelpers.schemeRotationTest(context: context)
189187
try await HeAPITestHelpers.schemeApplyGaloisTest(context: context)
190188
try bfvTestKeySwitching(context: context)
@@ -203,6 +201,28 @@ struct HeAPITests {
203201
func testBfvUInt64() async throws {
204202
try await runBfvTests(UInt64.self)
205203
}
204+
205+
@Test
206+
func schemeEvaluationKeyTest() throws {
207+
do {
208+
let config = EvaluationKeyConfig()
209+
#expect(!config.hasRelinearizationKey)
210+
#expect(config.galoisElements.isEmpty)
211+
#expect(config.keyCount == 0)
212+
}
213+
do {
214+
let config = EvaluationKeyConfig(hasRelinearizationKey: true)
215+
#expect(config.hasRelinearizationKey)
216+
#expect(config.galoisElements.isEmpty)
217+
#expect(config.keyCount == 1)
218+
}
219+
do {
220+
let config = EvaluationKeyConfig(galoisElements: [1, 3], hasRelinearizationKey: true)
221+
#expect(config.hasRelinearizationKey)
222+
#expect(config.galoisElements == [1, 3])
223+
#expect(config.keyCount == 3)
224+
}
225+
}
206226
}
207227

208228
/// This will compile if `Plaintext/decode` is generic across PolyFormat.

0 commit comments

Comments
 (0)