internal/bigmod: use clear()

This commit is contained in:
Sun Yimin 2025-02-26 10:50:35 +08:00 committed by GitHub
parent 869be23867
commit dc1c5806c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 11 deletions

View File

@ -374,9 +374,7 @@ type zr struct{}
// Read replaces the contents of dst with zeros. It is safe for concurrent use.
func (zr) Read(dst []byte) (n int, err error) {
for i := range dst {
dst[i] = 0
}
clear(dst)
return len(dst), nil
}

View File

@ -85,10 +85,7 @@ func (x *Nat) expand(n int) *Nat {
return x
}
extraLimbs := x.limbs[len(x.limbs):n]
// clear(extraLimbs)
for i := range extraLimbs {
extraLimbs[i] = 0
}
clear(extraLimbs)
x.limbs = x.limbs[:n]
return x
}
@ -99,10 +96,7 @@ func (x *Nat) reset(n int) *Nat {
x.limbs = make([]uint, n)
return x
}
// clear(x.limbs)
for i := range x.limbs {
x.limbs[i] = 0
}
clear(x.limbs)
x.limbs = x.limbs[:n]
return x
}