Skip to content

Commit 218d8e3

Browse files
Remove debug print statements from sign/ecdsa package
- Clean up fmt.Printf debug statements from rawDecodePrivateKey method - Clean up debug statements from Equals method - Code is now ready for review without debugging output Co-Authored-By: Tarak Ben Youssef <benyoussef.tarak@gmail.com>
1 parent 896c9f5 commit 218d8e3

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

sign/ecdsa/ecdsa.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ func (a *ecdsaAlgo) rawDecodePrivateKey(der []byte) (sign.PrivateKey, error) {
261261
}
262262
var d big.Int
263263
d.SetBytes(der)
264-
fmt.Printf("DEBUG: rawDecodePrivateKey - input bytes: %x, decoded D: %s, algo: %v, curve: %p\n", der, d.String(), a.algo, a.curve)
265264

266265
if d.Cmp(n) >= 0 {
267266
return nil, invalidInputsErrorf("input is larger than the curve order of %s", a.algo)
@@ -276,14 +275,12 @@ func (a *ecdsaAlgo) rawDecodePrivateKey(der []byte) (sign.PrivateKey, error) {
276275
// error is not expected at this point
277276
return nil, fmt.Errorf("building the private key failed: %w", err)
278277
}
279-
fmt.Printf("DEBUG: rawDecodePrivateKey - after goecdsaPrivateKey, priv.D: %s\n", priv.D.String())
280278

281279
result := &prKeyECDSA{
282280
alg: a,
283281
goPrKey: priv,
284282
pubKey: nil, // public key is not constructed
285283
}
286-
fmt.Printf("DEBUG: rawDecodePrivateKey - result key algo: %v, curve: %p\n", result.alg.algo, result.alg.curve)
287284
return result, nil
288285
}
289286

@@ -457,26 +454,19 @@ func (sk *prKeyECDSA) Equals(other sign.PrivateKey) bool {
457454
// check the key type
458455
otherECDSA, ok := other.(*prKeyECDSA)
459456
if !ok {
460-
fmt.Printf("DEBUG: Type check failed\n")
461457
return false
462458
}
463459
// check the algorithm instead of curve pointer
464460
if sk.alg.algo != otherECDSA.alg.algo {
465-
fmt.Printf("DEBUG: Algorithm check failed: %v vs %v\n", sk.alg.algo, otherECDSA.alg.algo)
466461
return false
467462
}
468463
if sk.goPrKey == nil || sk.goPrKey.D == nil {
469-
fmt.Printf("DEBUG: sk.goPrKey or sk.goPrKey.D is nil\n")
470464
return false
471465
}
472466
if otherECDSA.goPrKey == nil || otherECDSA.goPrKey.D == nil {
473-
fmt.Printf("DEBUG: otherECDSA.goPrKey or otherECDSA.goPrKey.D is nil\n")
474467
return false
475468
}
476-
fmt.Printf("DEBUG: Equals - sk algo: %v, curve: %p, other algo: %v, curve: %p\n", sk.alg.algo, sk.alg.curve, otherECDSA.alg.algo, otherECDSA.alg.curve)
477-
cmpResult := sk.goPrKey.D.Cmp(otherECDSA.goPrKey.D)
478-
fmt.Printf("DEBUG: D comparison result: %d (sk.D=%s, other.D=%s)\n", cmpResult, sk.goPrKey.D.String(), otherECDSA.goPrKey.D.String())
479-
return cmpResult == 0
469+
return sk.goPrKey.D.Cmp(otherECDSA.goPrKey.D) == 0
480470
}
481471

482472
// String returns the hex string representation of the key.

0 commit comments

Comments
 (0)