|
1 | | -// Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors |
| 1 | +// Copyright 2024-2026 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. |
@@ -76,7 +76,7 @@ extension ScalarType { |
76 | 76 | return nil |
77 | 77 | } |
78 | 78 |
|
79 | | - /// Generates the smallest primitive `degree`'th primitive root for integers mod this value, `p`. |
| 79 | + /// Generates the smallest primitive degree'th primitive root for integers mod this value, p. |
80 | 80 | /// |
81 | 81 | /// This value, `p`, must be prime. |
82 | 82 | /// - Parameter degree: Must be a power of two that divides `p - 1`. |
@@ -104,11 +104,11 @@ extension ScalarType { |
104 | 104 | } |
105 | 105 |
|
106 | 106 | @usableFromInline |
107 | | -struct NttContext<T: ScalarType>: Sendable { |
| 107 | +struct NttContext<T: ScalarType> { |
108 | 108 | @usableFromInline let rootOfUnityPowers: MultiplyConstantArrayModulus<T> |
109 | 109 | @usableFromInline let inverseRootOfUnityPowers: MultiplyConstantArrayModulus<T> |
110 | 110 | @usableFromInline let inverseDegree: MultiplyConstantModulus<T> // degree^{-1} mod modulus |
111 | | - // (degree)^{-1} * w^{-N} mod modulus for `w` a root of unity mod modulus |
| 111 | + /// (degree)^{-1} * w^{-N} mod modulus for `w` a root of unity mod modulus. |
112 | 112 | @usableFromInline let inverseDegreeRootOfUnity: MultiplyConstantModulus<T> |
113 | 113 |
|
114 | 114 | @inlinable |
@@ -408,7 +408,8 @@ extension PolyRq where F == Eval { |
408 | 408 | let kTimesModulus = modulus &<< lazyReductionCounter |
409 | 409 |
|
410 | 410 | if m == 1 { |
411 | | - // Final stage, folding in multiplication by n^{-1} and modular reduction |
| 411 | + // swiftlint:disable:next local_doc_comment |
| 412 | + /// Final stage, folding in multiplication by n^{-1} and modular reduction |
412 | 413 | func applyOp(_ op: (_ x: inout T, _ y: inout T) -> Void) { |
413 | 414 | for xIdx in 0..<nDiv2 { |
414 | 415 | let yIdx = xIdx &+ nDiv2 |
@@ -454,6 +455,7 @@ extension PolyRq where F == Eval { |
454 | 455 | applyOp { _, _ in } |
455 | 456 | } |
456 | 457 | } else { |
| 458 | + @inline(__always) |
457 | 459 | func applyOp(_ op: (_ x: inout T, _ y: inout T) -> Void) { |
458 | 460 | for i in 0..<m { |
459 | 461 | let inverseRootOfUnity = inverseRootOfUnityPowers[rootIdx &+ i] |
|
0 commit comments