From 73a1417859e1251a93e7157a137ca0d220beb2b2 Mon Sep 17 00:00:00 2001 From: siddharth ravikumar Date: Sun, 14 Aug 2022 14:28:52 -0400 Subject: lib: remove `egcd` No longer needed. --- lib/rsa.go | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) (limited to 'lib/rsa.go') diff --git a/lib/rsa.go b/lib/rsa.go index 3d29bae..1a860eb 100644 --- a/lib/rsa.go +++ b/lib/rsa.go @@ -8,12 +8,6 @@ import ( "math/big" ) -type GCDResult struct { - Gcd *big.Int - X *big.Int // Bézout coefficient 'x' - Y *big.Int // Bézout coefficient 'y' -} - // Represents an RSA key pair. type RSAPair struct { Public *RSAPub @@ -39,48 +33,6 @@ func biCopy(a, b *big.Int) *big.Int { return a } -// Extended Euclidian. -func egcd(a, b *big.Int) GCDResult { - // Initialize. - s0 := big.NewInt(1) - s1 := big.NewInt(0) - r0 := biCopy(big.NewInt(0), a) - r1 := biCopy(big.NewInt(0), b) - - for r1.Cmp(big.NewInt(0)) != 0 { - q := big.NewInt(0) - q.Div(r0, r1) - - tr := big.NewInt(0) - tr = tr.Mul(q, r1) - tr = tr.Sub(r0, tr) - - biCopy(r0, r1) - biCopy(r1, tr) - - tr = big.NewInt(0) - tr = tr.Mul(q, s1) - tr = tr.Sub(s0, tr) - - biCopy(s0, s1) - biCopy(s1, tr) - } - - x := biCopy(big.NewInt(0), s0) - y := big.NewInt(0) - if b.Cmp(big.NewInt(0)) != 0 { - y = y.Mul(s0, a) - y = y.Sub(r0, y) - y = y.Div(y, b) - } - - return GCDResult{ - Gcd: biCopy(big.NewInt(0), r0), - X: x, - Y: y, - } -} - func invmod(a, n *big.Int) (*big.Int, error) { // Initialize. t0 := big.NewInt(0) -- cgit v1.2.3