Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README's generatePrime(_ width: Int) performances #85

Open
nathanfallet opened this issue Aug 28, 2021 · 1 comment
Open

README's generatePrime(_ width: Int) performances #85

nathanfallet opened this issue Aug 28, 2021 · 1 comment

Comments

@nathanfallet
Copy link

The README's generatePrime(_ width: Int) function is very slow for big numbers (can take up to 10s to generate two primes for a RSA key)

func generatePrime(_ width: Int) -> BigUInt {
    while true {
        var random = BigUInt.randomInteger(withExactWidth: width)
        random |= BigUInt(1)
        if random.isPrime() {
            return random
        }
    }
}

Any way to generate primes quicker?

@kecson
Copy link

kecson commented Nov 15, 2022

The generatePrime(2048) method also take up to a few minutes to generate prime numbers for Paillier Homomorphic Encryption PrivateKey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants