Added generic big to 256 method. Implemented new iterator

This commit is contained in:
obscuren
2014-10-10 17:00:06 +02:00
parent 9b494c6869
commit e02c0fa808
8 changed files with 151 additions and 120 deletions

View File

@ -39,12 +39,14 @@ func BigD(data []byte) *big.Int {
// "cast" the big int to a 256 big int (i.e., limit to)
var tt256 = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(1))
func To256(x *big.Int) {
func To256(x *big.Int) *big.Int {
x.And(x, tt256)
if x.Cmp(new(big.Int)) < 0 {
x.SetInt64(0)
}
return x
}
// Big to bytes