@@ -66,11 +66,13 @@ func shuffleValidators(
6666 "num_proofs" , len (vrf .Pi ),
6767 )
6868
69- baseHasher := newBetaHasher (
70- []byte ("oasis-core:vrf/validator" ),
71- tmBeacon .MustGetChainContext (ctx ),
72- epoch ,
73- )
69+ baseHasher := func () * tuplehash.Hasher {
70+ return newBetaHasher (
71+ []byte ("oasis-core:vrf/validator" ),
72+ tmBeacon .MustGetChainContext (ctx ),
73+ epoch ,
74+ )
75+ }
7476
7577 // Do the cryptographic sortition.
7678 ret := sortNodesByHashedBeta (
@@ -426,13 +428,15 @@ func electCommitteeMembers( //nolint: gocyclo
426428 idxs = rng .Perm (nrNodes )
427429 case true :
428430 // Use the VRF proofs to do the elections.
429- baseHasher := newCommitteeBetaHasher (
430- tmBeacon .MustGetChainContext (ctx ),
431- epoch ,
432- rt .ID ,
433- kind ,
434- role ,
435- )
431+ baseHasher := func () * tuplehash.Hasher {
432+ return newCommitteeBetaHasher (
433+ tmBeacon .MustGetChainContext (ctx ),
434+ epoch ,
435+ rt .ID ,
436+ kind ,
437+ role ,
438+ )
439+ }
436440
437441 idxs = committeeVRFBetaIndexes (
438442 vrf ,
@@ -521,7 +525,7 @@ func electCommitteeMembers( //nolint: gocyclo
521525
522526func committeeVRFBetaIndexes (
523527 vrf * beacon.PrevVRFState ,
524- baseHasher * tuplehash.Hasher ,
528+ baseHasher func () * tuplehash.Hasher ,
525529 nodes []* node.Node ,
526530) []int {
527531 indexByNode := make (map [signature.PublicKey ]int )
@@ -545,7 +549,7 @@ func committeeVRFBetaIndexes(
545549
546550func sortNodesByHashedBeta (
547551 vrf * beacon.PrevVRFState ,
548- baseHasher * tuplehash.Hasher ,
552+ baseHasher func () * tuplehash.Hasher ,
549553 nodes []* node.Node ,
550554) []* node.Node {
551555 // Accumulate the hashed betas.
@@ -584,12 +588,12 @@ func sortNodesByHashedBeta(
584588type hashedBeta [32 ]byte
585589
586590func hashBeta (
587- h * tuplehash.Hasher ,
591+ baseHasher func () * tuplehash.Hasher ,
588592 beta []byte ,
589593) hashedBeta {
590- hh := h . Clone ()
591- _ , _ = hh .Write (beta )
592- digest := hh .Sum (nil )
594+ h := baseHasher ()
595+ _ , _ = h .Write (beta )
596+ digest := h .Sum (nil )
593597
594598 var ret hashedBeta
595599 copy (ret [:], digest )
@@ -658,13 +662,15 @@ func dedupEntityNodesByHashedBeta(
658662 return nodes
659663 }
660664
661- baseHasher := newCommitteeDedupBetaHasher (
662- chainContext ,
663- epoch ,
664- runtimeID ,
665- kind ,
666- role ,
667- )
665+ baseHasher := func () * tuplehash.Hasher {
666+ return newCommitteeDedupBetaHasher (
667+ chainContext ,
668+ epoch ,
669+ runtimeID ,
670+ kind ,
671+ role ,
672+ )
673+ }
668674
669675 // Do the cryptographic sortition.
670676 shuffled := sortNodesByHashedBeta (
0 commit comments