aboutsummaryrefslogtreecommitdiff
path: root/pkg/requests
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/requests')
-rw-r--r--pkg/requests/requests.go9
-rw-r--r--pkg/requests/requests_test.go9
2 files changed, 10 insertions, 8 deletions
diff --git a/pkg/requests/requests.go b/pkg/requests/requests.go
index 7d7437d..6b74184 100644
--- a/pkg/requests/requests.go
+++ b/pkg/requests/requests.go
@@ -8,12 +8,13 @@ import (
"git.sigsum.org/sigsum-go/pkg/ascii"
"git.sigsum.org/sigsum-go/pkg/hex"
+ "git.sigsum.org/sigsum-go/pkg/merkle"
"git.sigsum.org/sigsum-go/pkg/types"
)
type Leaf struct {
ShardHint uint64 `ascii:"shard_hint"`
- Message types.Hash `ascii:"message"`
+ Message merkle.Hash `ascii:"message"`
Signature types.Signature `ascii:"signature"`
PublicKey types.PublicKey `ascii:"public_key"`
DomainHint string `ascii:"domain_hint"`
@@ -26,7 +27,7 @@ type Leaves struct {
type InclusionProof struct {
TreeSize uint64
- LeafHash types.Hash
+ LeafHash merkle.Hash
}
type ConsistencyProof struct {
@@ -36,7 +37,7 @@ type ConsistencyProof struct {
type Cosignature struct {
Cosignature types.Signature `ascii:"cosignature"`
- KeyHash types.Hash `ascii:"key_hash"`
+ KeyHash merkle.Hash `ascii:"key_hash"`
}
func (req *Leaf) ToASCII(w io.Writer) error {
@@ -97,7 +98,7 @@ func (req *InclusionProof) FromURL(url string) (err error) {
if err != nil {
return err
}
- if n := len(b); n != types.HashSize {
+ if n := len(b); n != merkle.HashSize {
return fmt.Errorf("invalid hash size %d", n)
}
copy(req.LeafHash[:], b)
diff --git a/pkg/requests/requests_test.go b/pkg/requests/requests_test.go
index e439774..db809c0 100644
--- a/pkg/requests/requests_test.go
+++ b/pkg/requests/requests_test.go
@@ -7,6 +7,7 @@ import (
"reflect"
"testing"
+ "git.sigsum.org/sigsum-go/pkg/merkle"
"git.sigsum.org/sigsum-go/pkg/types"
)
@@ -32,7 +33,7 @@ func TestLeavesToURL(t *testing.T) {
func TestInclusionProofToURL(t *testing.T) {
url := types.EndpointGetInclusionProof.Path("https://poc.sigsum.org/sigsum/v0")
- req := InclusionProof{1, types.Hash{}}
+ req := InclusionProof{1, merkle.Hash{}}
want := url + "1/0000000000000000000000000000000000000000000000000000000000000000"
if got := req.ToURL(url); got != want {
t.Errorf("got url %s but wanted %s", got, want)
@@ -137,7 +138,7 @@ func TestInclusionProofFromURL(t *testing.T) {
{"invalid: tree size is empty", "some-url//" + zeroHash, InclusionProof{}, true},
{"invalid: leaf hash is not lower-case hex", "some-url/1/" + badHex, InclusionProof{}, true},
{"invalid: leaf hash is hex but too short", "some-url/1/" + shortHex, InclusionProof{}, true},
- {"valid", "some-url/1/" + zeroHash, InclusionProof{1, types.Hash{}}, false},
+ {"valid", "some-url/1/" + zeroHash, InclusionProof{1, merkle.Hash{}}, false},
} {
var req InclusionProof
err := req.FromURL(table.input)
@@ -303,10 +304,10 @@ func validCosignatureASCII(t *testing.T) string {
)
}
-func newHashBufferInc(t *testing.T) *types.Hash {
+func newHashBufferInc(t *testing.T) *merkle.Hash {
t.Helper()
- var buf types.Hash
+ var buf merkle.Hash
for i := 0; i < len(buf); i++ {
buf[i] = byte(i)
}