Skip to content

Commit

Permalink
Added Linux support.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgriebling committed Jul 16, 2023
1 parent a70db7b commit 1603987
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .swiftpm/BigInt.xctestplan
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 10 additions & 0 deletions Sources/BigInt/BigInt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down

0 comments on commit 1603987

Please sign in to comment.