Skip to content
Open
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
29 changes: 29 additions & 0 deletions vdaf/prio3/arith/fp64/vector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vdaf/prio3/internal/prio3/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package prio3

import (
"errors"
"github.com/cloudflare/circl/internal/conv"
"github.com/cloudflare/circl/vdaf/prio3/arith"
"golang.org/x/crypto/cryptobyte"
Expand Down Expand Up @@ -360,6 +361,32 @@ func (s *OutShare[V, E]) Unmarshal(str *cryptobyte.String) bool {
return s.share.Unmarshal(str)
}

// ExportBytes returns the portable binary encoding of the OutShare.
func (s *OutShare[V, E]) ExportBytes() ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is equivalent to calling s.MarshalBinary directly. So no need to have the ExportBytes and ImportBytes methods.

return s.MarshalBinary()
}

// ImportBytes sets the OutShare from a portable binary encoding.
func (s *OutShare[V, E]) ImportBytes(data []byte) error {
return s.UnmarshalBinary(data)
}

// ExportRaw returns the underlying vector as a byte slice.
func (s *OutShare[V, E]) ExportRaw() ([]byte, error) {
if b, ok := any(s.share).(interface{ ExportRaw() ([]byte, error) }); ok {
return b.ExportRaw()
}
return nil, errors.New("ExportRaw: underlying vector does not support ExportRaw")
}

// ImportRaw sets the underlying vector from a byte slice.
func (s *OutShare[V, E]) ImportRaw(data []byte) error {
if b, ok := any(&s.share).(interface{ ImportRaw([]byte) error }); ok {
return b.ImportRaw(data)
}
return errors.New("ImportRaw: underlying vector does not support ImportRaw")
}

// AggShare represents the following structure.
//
// struct {
Expand Down