diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2021-06-06 11:06:17 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2021-06-06 11:06:17 +0200 |
commit | 0285454c34b0b3003bc8ede3e304b843ad949be8 (patch) | |
tree | 630b89c85defa3aaf8f4cc2037f31dab0f3d2cbd /types | |
parent | ebd9efbf32065baa261b2af1625991100ed23bf7 (diff) |
added state manager with tests
Diffstat (limited to 'types')
-rw-r--r-- | types/types.go | 10 | ||||
-rw-r--r-- | types/types_test.go | 6 |
2 files changed, 9 insertions, 7 deletions
diff --git a/types/types.go b/types/types.go index 405c825..9ca7db8 100644 --- a/types/types.go +++ b/types/types.go @@ -2,11 +2,10 @@ package types import ( "crypto" - "fmt" - "strings" - "crypto/ed25519" "crypto/sha256" + "fmt" + "strings" ) const ( @@ -138,7 +137,10 @@ func (th *TreeHead) Sign(signer crypto.Signer) (*SignedTreeHead, error) { } // Verify verifies the tree head signature using the log's signature scheme -func (th *TreeHead) Verify(pub crypto.PublicKey) error { // TODO +func (th *TreeHead) Verify(vk *[VerificationKeySize]byte, sig *[SignatureSize]byte) error { + if !ed25519.Verify(ed25519.PublicKey(vk[:]), th.Marshal(), sig[:]) { + return fmt.Errorf("invalid tree head signature") + } return nil } diff --git a/types/types_test.go b/types/types_test.go index 22a03d4..da89c59 100644 --- a/types/types_test.go +++ b/types/types_test.go @@ -52,7 +52,7 @@ func TestEndpointPath(t *testing.T) { } } -func TestTreeHeadSign(t *testing.T) {} -func TestTreeHeadVerify(t *testing.T) {} -func TestInclusionProofVerify(t *testing.T) {} +func TestTreeHeadSign(t *testing.T) {} +func TestTreeHeadVerify(t *testing.T) {} +func TestInclusionProofVerify(t *testing.T) {} func TestConsistencyProofVerify(t *testing.T) {} |