From 1369d9137557ef9200d860a4242dd8cf23fe2d67 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 25 Aug 2020 23:24:49 -0600 Subject: [PATCH] return false by default --- hashcash.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hashcash.go b/hashcash.go index b80b367..0e12c82 100644 --- a/hashcash.go +++ b/hashcash.go @@ -216,6 +216,10 @@ func (h *Hashcash) Verify(subject string) error { } func verifyBits(hash []byte, bits, n int) bool { + if 0 == bits { + return true + } + for i := 0; i < n; i++ { if bits > 8 { bits -= 8 @@ -227,15 +231,12 @@ func verifyBits(hash []byte, bits, n int) bool { // (bits % 8) == bits pad := 8 - bits - if 0 != hash[i]>>pad { - return false + if 0 == hash[i]>>pad { + return true } - - return true } - // 0 == bits - return true + return false } // Solve will search for a solution, returning an error if the difficulty is