refactor general crt algorithm into separate function
This commit is contained in:
@@ -63,6 +63,23 @@ func CRTSolution(a1, n1, a2, n2 *big.Int) (*big.Int, *big.Int) {
|
||||
return x, N
|
||||
}
|
||||
|
||||
func CRTSolutionGeneral(remainders, moduli []*big.Int) (*big.Int, *big.Int) {
|
||||
n1 := new(big.Int)
|
||||
a1 := new(big.Int)
|
||||
for i, n2 := range moduli {
|
||||
a2 := remainders[i]
|
||||
if i == 0 {
|
||||
a1.Set(a2)
|
||||
n1.Set(n2)
|
||||
continue
|
||||
}
|
||||
|
||||
a1, n1 = CRTSolution(a1, n1, a2, n2)
|
||||
}
|
||||
|
||||
return a1, n1
|
||||
}
|
||||
|
||||
func ArePairwiseCoprime(moduli []*big.Int) bool {
|
||||
z := new(big.Int)
|
||||
for i, a := range moduli {
|
||||
|
||||
Reference in New Issue
Block a user