From fbc5f37d0b78e83e37678178b4b5bea1b1cd8028 Mon Sep 17 00:00:00 2001 From: Tadge Dryja Date: Mon, 21 Dec 2015 22:36:28 -0500 Subject: [PATCH] remove dependencies on mathematics --- revocation/shachain.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/revocation/shachain.go b/revocation/shachain.go index 52d724ad3..d262a3559 100644 --- a/revocation/shachain.go +++ b/revocation/shachain.go @@ -72,6 +72,12 @@ func derive(from, to uint64, startingHash [32]byte) [32]byte { numBranches := from ^ to toDerive := uint64(math.Log2(float64(numBranches))) // uh..... + // math? floats? nahhh! :) bit-flipp-y way to do it: + for toDerive = 0; numBranches>>toDerive > 0; toDerive++ { + } + // ^^^this rounds up instead of down, may be off by 1? + toDerive-- // needed? + for i := int(toDerive - 1); i >= 0; i-- { if (numBranches>>uint(i))&1 == 1 { // Flip the ith bit, then hash the current state to