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

Pir response to Coeff format #27

Merged
merged 1 commit into from
Jul 24, 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
4 changes: 2 additions & 2 deletions Sources/PrivateInformationRetrieval/IndexPirProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ public struct Query<Scheme: HeScheme>: Sendable {
/// An index PIR response.
public struct Response<Scheme: HeScheme>: Sendable {
/// Ciphertexts in the response.
public let ciphertexts: [[Scheme.CanonicalCiphertext]]
public let ciphertexts: [[Scheme.CoeffCiphertext]]

/// Initializes an index PIR ``Response``.
/// - Parameter ciphertexts: Ciphertexts in the response.
@inlinable
public init(ciphertexts: [[Scheme.CanonicalCiphertext]]) {
public init(ciphertexts: [[Scheme.CoeffCiphertext]]) {
self.ciphertexts = ciphertexts
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/PrivateInformationRetrieval/MulPir.swift
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ extension MulPirServer {
expandedRemainingQuery: ExpandedQueries,
dataChunk: DataChunk,
using evaluationKey: EvaluationKey<Scheme>) throws
-> CanonicalCiphertext
-> Ciphertext<Scheme, Coeff>
where ExpandedQueries: Collection<CanonicalCiphertext>, DataChunk: Collection<Plaintext<Scheme, Eval>?>,
ExpandedQueries.Index == Int, DataChunk.Index == Int
{
Expand Down Expand Up @@ -341,7 +341,7 @@ extension MulPirServer {
intermediateResults.count == 1,
"There should be only 1 ciphertext in the final result for each chunk")
try intermediateResults[0].modSwitchDownToSingle()
return intermediateResults[0]
return try intermediateResults[0].convertToCoeffFormat()
}

@inlinable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ extension Apple_SwiftHomomorphicEncryption_Api_V1_PIRResponse {
/// - Returns: The converted native type.
/// - Throws: Error upon invalid protobuf object.
public func native<Scheme: HeScheme>(context: Context<Scheme>) throws -> Response<Scheme> {
let ciphertexts: [[Scheme.CanonicalCiphertext]] = try replies.map { reply in
let ciphertexts: [[Scheme.CoeffCiphertext]] = try replies.map { reply in
let serializedCiphertexts: [SerializedCiphertext<Scheme.Scalar>] = try reply.native()
return try serializedCiphertexts.map { serialized in
try Scheme.CanonicalCiphertext(deserialize: serialized, context: context, moduliCount: 1)
try Scheme.CoeffCiphertext(deserialize: serialized, context: context, moduliCount: 1)
}
}
return Response(ciphertexts: ciphertexts)
Expand Down