|
1 |
| -// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors |
| 1 | +// Copyright 2024-2025 Apple Inc. and the Swift Homomorphic Encryption project authors |
2 | 2 | //
|
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
4 | 4 | // you may not use this file except in compliance with the License.
|
@@ -75,6 +75,24 @@ class SerializationTests: XCTestCase {
|
75 | 75 | let decrypted = try deserialized.decrypt(using: secretKey)
|
76 | 76 | XCTAssertEqual(decrypted, plaintext)
|
77 | 77 | }
|
| 78 | + // serialize for decryption eval format |
| 79 | + do { |
| 80 | + var ciphertext = ciphertext |
| 81 | + try ciphertext.modSwitchDownToSingle() |
| 82 | + let evalCiphertext = try ciphertext.convertToEvalFormat() |
| 83 | + let serialized = evalCiphertext.serialize(forDecryption: true) |
| 84 | + if case let .full(_, skipLSBs, _) = serialized { |
| 85 | + XCTAssertTrue(skipLSBs.allSatisfy { $0 == 0 }) |
| 86 | + } else { |
| 87 | + XCTFail("Must be full serialization") |
| 88 | + } |
| 89 | + let deserialized: Scheme.CanonicalCiphertext = try Ciphertext( |
| 90 | + deserialize: serialized, |
| 91 | + context: context, |
| 92 | + moduliCount: ciphertext.moduli.count) |
| 93 | + let decrypted = try deserialized.decrypt(using: secretKey) |
| 94 | + XCTAssertEqual(decrypted, plaintext) |
| 95 | + } |
78 | 96 | // serialize indices for decryption
|
79 | 97 | do {
|
80 | 98 | var ciphertext = ciphertext
|
|
0 commit comments