Solving two-variable linear Diophantine equations has applications in many cryptographic protocols such as RSA and Elliptic curve cryptography. The Extended Euclid's algorithm is a well known algorithm to solve these equations. We revisit two algorithms to solve two-variable linear Diophantine equations. We write the iterative version of one of the revisited algorithms. For another, we do a fine-grained analysis of the number of recursive calls and arrive at a periodic function that represents the number of recursive calls. We find the period and use it to derive multiple upper bounds on the average number of recursive calls. The upper bounds conclude that the average number of recursive calls in the analyzed algorithm is a constant term improvement over the Extended Euclid's algorithm. We propose an iterative variant of the algorithm. We implement this algorithm and find that the average number of iterations by our algorithm is less than that of two existing algorithms. We compare the number of iterations in this algorithm and in Extended Euclid's algorithm. In the comparison, we find that for 100\% of the solvable instances of inputs, the iterations are less than that in Extended Euclid's algorithm.
翻译:求解二元线性丢番图方程在众多密码协议(如RSA和椭圆曲线密码学)中具有应用。扩展欧几里得算法是求解此类方程的经典算法。我们重新审视两种求解二元线性丢番图方程的算法。我们将其中一种被重新审视的算法改写为迭代版本。对于另一种算法,我们对递归调用的次数进行了细粒度分析,并推导出一个表示递归调用次数的周期函数。我们发现该周期,并利用它推导出平均递归调用次数的多个上界。这些上界表明,被分析算法中平均递归调用次数的改进相较于扩展欧几里得算法是一个常数项。我们提出该算法的一个迭代变体。实现该算法后发现,其平均迭代次数少于两种已有算法。我们将该算法与扩展欧几里得算法的迭代次数进行比较。比较结果表明,对于100%可解的输入实例,其迭代次数均少于扩展欧几里得算法。