From 1349e560b342ce574e194ffbb394c3fa96606b57 Mon Sep 17 00:00:00 2001 From: David Florness Date: Thu, 18 Feb 2021 21:33:28 -0500 Subject: [PATCH] Delete old Nonce implementation This was left over from the libp2p implementation. --- election/merkle.go | 29 ----------------------------- go.mod | 1 - go.sum | 2 -- 3 files changed, 32 deletions(-) diff --git a/election/merkle.go b/election/merkle.go index b0feab4..360600a 100644 --- a/election/merkle.go +++ b/election/merkle.go @@ -1,11 +1,9 @@ package election import ( - "crypto/rand" "crypto/sha256" "github.com/cbergoon/merkletree" - "github.com/mr-tron/base58/base58" ) type Candidate string @@ -21,30 +19,3 @@ func (eo Candidate) CalculateHash() ([]byte, error) { func (eo Candidate) Equals(other merkletree.Content) (bool, error) { return eo == other.(Candidate), nil } - -type Nonce string - -func NewNonce() Nonce { - randBytes := make([]byte, 128) - _, err := rand.Read(randBytes) - if err != nil { - panic(err) - } - return Nonce(base58.Encode(randBytes)) -} - -func (n Nonce) CalculateHash() ([]byte, error) { - h := sha256.New() - b, err := base58.Decode(string(n)) - if err != nil { - return nil, err - } - if _, err = h.Write(b); err != nil { - return nil, err - } - return h.Sum(nil), nil -} - -func (n Nonce) Equals(other merkletree.Content) (bool, error) { - return n == other.(Nonce), nil -} diff --git a/go.mod b/go.mod index a621127..9377839 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( github.com/kyoh86/xdg v1.2.0 github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/magefile/mage v1.11.0 // indirect - github.com/mr-tron/base58 v1.2.0 github.com/rivo/tview v0.0.0-20210217110421-8a8f78a6dd01 github.com/sirupsen/logrus v1.8.0 golang.org/x/crypto v0.0.0-20210218145215-b8e89b74b9df diff --git a/go.sum b/go.sum index a89e80b..b6bff36 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,6 @@ github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRR github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA= github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= -github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= -github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -- 2.38.4