diff --git a/.swiftpm/BigInt.xctestplan b/.swiftpm/BigInt.xctestplan new file mode 100644 index 0000000..e272722 --- /dev/null +++ b/.swiftpm/BigInt.xctestplan @@ -0,0 +1,25 @@ +{ + "configurations" : [ + { + "id" : "46597F33-8980-4C78-B801-7249D0CA45D2", + "name" : "Test Scheme Action", + "options" : { + + } + } + ], + "defaultOptions" : { + "codeCoverage" : false + }, + "testTargets" : [ + { + "parallelizable" : true, + "target" : { + "containerPath" : "container:", + "identifier" : "BigIntTests", + "name" : "BigIntTests" + } + } + ], + "version" : 1 +} diff --git a/Sources/BigInt/BigInt.swift b/Sources/BigInt/BigInt.swift index 4206be6..b734cd3 100755 --- a/Sources/BigInt/BigInt.swift +++ b/Sources/BigInt/BigInt.swift @@ -1726,6 +1726,15 @@ public struct BInt: CustomStringConvertible, Comparable, Equatable, Hashable, Co // MARK: Prime number functions + #if os(Linux) + static internal func randomBytes(_ bytes: inout Bytes) { + for i in bytes.indices { bytes[i] = Byte.random(in: bytes.indices) } + } + + static internal func randomLimbs(_ limbs: inout Limbs) { + for i in limbs.indices { limbs[i] = Limb.random(in: limbs.indices) } + } + #else static internal func randomBytes(_ bytes: inout Bytes) { guard SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes) == errSecSuccess else { fatalError("randomBytes failed") @@ -1737,6 +1746,7 @@ public struct BInt: CustomStringConvertible, Comparable, Equatable, Hashable, Co fatalError("randomLimbs failed") } } + #endif // Small prime product static let SPP = BInt("152125131763605")! // = 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 * 31 * 37 * 41