diff options
author | Rasmus Dahlberg <rasmus@mullvad.net> | 2021-12-20 14:37:37 +0100 |
---|---|---|
committer | Rasmus Dahlberg <rasmus@mullvad.net> | 2021-12-20 18:23:48 +0100 |
commit | d62b75e067b0fadd5e1066e3b3522959203e0341 (patch) | |
tree | 11c2988d898fcedf52e0d2e53ebbb7b74128fe6c /pkg/requests/requests.go | |
parent | 2171b71e920d286a9527a4dddd05c00eceb6af83 (diff) |
requests: Add request types and tests
Diffstat (limited to 'pkg/requests/requests.go')
-rw-r--r-- | pkg/requests/requests.go | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/pkg/requests/requests.go b/pkg/requests/requests.go new file mode 100644 index 0000000..26a5213 --- /dev/null +++ b/pkg/requests/requests.go @@ -0,0 +1,75 @@ +package requests + +import ( + "io" + + "git.sigsum.org/sigsum-lib-go/pkg/ascii" + "git.sigsum.org/sigsum-lib-go/pkg/types" +) + +type Leaf struct { + types.Statement + Signature types.Signature `ascii:"signature"` + VerificationKey types.PublicKey `ascii:"verification_key"` + DomainHint string `ascii:"domain_hint"` +} + +type Leaves struct { + StartSize uint64 `ascii:"start_size"` + EndSize uint64 `ascii:"end_size"` +} + +type InclusionProof struct { + LeafHash types.Hash `ascii:"leaf_hash"` + TreeSize uint64 `ascii:"tree_size"` +} + +type ConsistencyProof struct { + NewSize uint64 `ascii:"new_size"` + OldSize uint64 `ascii:"old_size"` +} + +type Cosignature struct { + Cosignature types.Signature `ascii:"cosignature"` + KeyHash types.Hash `ascii:"key_hash"` +} + +func (req *Leaf) ToASCII(w io.Writer) error { + return ascii.StdEncoding.Serialize(w, req) +} + +func (req *Leaves) ToASCII(w io.Writer) error { + return ascii.StdEncoding.Serialize(w, req) +} + +func (req *InclusionProof) ToASCII(w io.Writer) error { + return ascii.StdEncoding.Serialize(w, req) +} + +func (req *ConsistencyProof) ToASCII(w io.Writer) error { + return ascii.StdEncoding.Serialize(w, req) +} + +func (req *Cosignature) ToASCII(w io.Writer) error { + return ascii.StdEncoding.Serialize(w, req) +} + +func (req *Leaf) FromASCII(r io.Reader) error { + return ascii.StdEncoding.Deserialize(r, req) +} + +func (req *Leaves) FromASCII(r io.Reader) error { + return ascii.StdEncoding.Deserialize(r, req) +} + +func (req *InclusionProof) FromASCII(r io.Reader) error { + return ascii.StdEncoding.Deserialize(r, req) +} + +func (req *ConsistencyProof) FromASCII(r io.Reader) error { + return ascii.StdEncoding.Deserialize(r, req) +} + +func (req *Cosignature) FromASCII(r io.Reader) error { + return ascii.StdEncoding.Deserialize(r, req) +} |