Skip to content

Commit

Permalink
Fix issue in Linux build.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgriebling committed Aug 10, 2023
1 parent 1603987 commit 1dacee1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/BigInt/BigInt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1728,28 +1728,28 @@ public struct BInt: CustomStringConvertible, Comparable, Equatable, Hashable, Co

#if os(Linux)
static internal func randomBytes(_ bytes: inout Bytes) {
for i in bytes.indices { bytes[i] = Byte.random(in: bytes.indices) }
for i in bytes.indices { bytes[i] = Byte.random(in: Byte.min...Byte.max) }
}

static internal func randomLimbs(_ limbs: inout Limbs) {
for i in limbs.indices { limbs[i] = Limb.random(in: limbs.indices) }
for i in limbs.indices { limbs[i] = Limb.random(in: Limb.min...Limb.max) }
}
#else
static internal func randomBytes(_ bytes: inout Bytes) {
guard SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes) == errSecSuccess else {
fatalError("randomBytes failed")
}
}

static internal func randomLimbs(_ limbs: inout Limbs) {
guard SecRandomCopyBytes(kSecRandomDefault, 8 * limbs.count, &limbs) == errSecSuccess else {
fatalError("randomLimbs failed")
}
}
#endif

// Small prime product
static let SPP = BInt("152125131763605")! // = 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 * 31 * 37 * 41
// Small prime product (152125131763605)
static let SPP = BInt(3*5*7*11*13*17*19*23*29*31*37*41) // 12 primes

static func smallPrime(_ bitLength: Int) -> BInt {
let multiple8 = bitLength & 0x7 == 0
Expand Down

0 comments on commit 1dacee1

Please sign in to comment.