Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions crypto/merklesignature/merkleSignatureScheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,9 @@ func (s *Secrets) GetVerifier() *Verifier {

// GetVerifier can be used to store the commitment and verifier for this signer.
func (s *SignerContext) GetVerifier() *Verifier {
ver := [MerkleSignatureSchemeRootSize]byte{}
ss := s.Tree.Root().ToSlice()
copy(ver[:], ss)
return (*Verifier)(&ver)
var ver Verifier
copy(ver[:], s.Tree.Root())
return &ver
}

// Sign signs a hash of a given message. The signature is valid on a specific round
Expand Down
17 changes: 17 additions & 0 deletions crypto/merklesignature/merkleSignatureScheme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,20 @@ func copyProof(proof merklearray.SingleLeafProof) merklearray.SingleLeafProof {
}

//#endregion

func TestTreeRootHashLength(t *testing.T) {
partitiontest.PartitionTest(t)
a := require.New(t)
interval := uint64(256)
numOfKeys := uint64(1 << 8)
validPeriod := numOfKeys*interval - 1

firstValid := uint64(1000)
lastValid := validPeriod + 1000
s, err := New(firstValid, lastValid, interval)
a.NoError(err)
a.Equal(numOfKeys, uint64(len(s.ephemeralKeys)))

a.Equal(MerkleSignatureSchemeRootSize, len(s.Tree.Root()))
a.Equal(MerkleSignatureSchemeRootSize, len(Verifier{}))
}
5 changes: 4 additions & 1 deletion libgoal/participation.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,12 @@ func (c *Client) GenParticipationKeysTo(address string, firstValid, lastValid, k
return
}
_, err = os.Stat(partKeyPath)
if !os.IsNotExist(err) {
if err == nil {
err = fmt.Errorf("ParticipationKeys exist for the range %d to %d", firstRound, lastRound)
return
} else if !os.IsNotExist(err) {
err = fmt.Errorf("participation key file '%s' cannot be accessed : %w", partKeyPath, err)
return
}

partdb, err := db.MakeErasableAccessor(partKeyPath)
Expand Down