Documentation ¶
Overview ¶
Copyright (c) 2021-2023 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.
SPDX-License-Identifier: Apache-2.0
Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.
SPDX-License-Identifier: Apache-2.0
Copyright (c) 2021-2023 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.
SPDX-License-Identifier: Apache-2.0
Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.
SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func GetTupleFileName(tt castor.TupleType, conf *SPDZEngineTypedConfig, threadNr int) string
- type AbstractCarrier
- type AmphoraFeeder
- type Carrier
- type CastorTupleStreamer
- type ConnectionInfo
- type Feeder
- type Packer
- type Parcel
- type PipeWriter
- type PipeWriterFactory
- type PlaintextConverter
- type ResponseConverter
- type Result
- type SPDZPacker
- type SecretSharesConverter
- type TuplePipeWriter
- type TupleStreamer
Constants ¶
const BodySize = 32
BodySize equals to 32 = 16 bytes secret share + 16 bytes MAC.
const ErrInvalidBodySize = "Body size must be a multiple of 32"
ErrInvalidBodySize is thrown when a message of invalid length is provided.
const ErrInvalidResponseSize = "Response size must be equal to 20"
ErrInvalidResponseSize is thrown when a message of invalid length is returned.
const ErrInvalidWordSize = "plain text message size must be a multiple of 16"
ErrInvalidWordSize is thrown when a SPDZ runtime socket response is not equal to word size.
const ErrMarshal = "at 1 object must be provided to marshal"
ErrMarshal is thrown when provided input is < 1.
const ErrParcelToSPDZ = "parcelsToSPDZ error: "
ErrParcelToSPDZ is thrown when an error in parcelsToSPDZ method has occured.
const ErrSPDZToParcel = "spdzToParcels error: "
ErrSPDZToParcel is thrown when an error in spdzToParcels method has occured.
const ErrSizeTooBig = "size array must be <= 32 bits"
ErrSizeTooBig is thrown when the size of the parameters is exceeded.
const MessageSize = 36
MessageSize equals to 36 = 4 bytes Length + 32 bytes of message
const ParcelSizeLength = 4
ParcelSizeLength is the length of the Parcel size header in bytes.
const ResponseSizeCipher = 36
ResponseSizeCipher is the size of a byte array containing plain text.
const WordSize = 16
WordSize is the size of a single word in SPDZ runtime notation, e.g. secret share or MAC.
Variables ¶
var MaxLength = int(math.Pow(2, 32))
MaxLength is the max size of Param's octet.
Functions ¶
Types ¶
type AbstractCarrier ¶
type AbstractCarrier interface { Connect(context.Context, int32, string, string) error Close() error Send([]amphora.SecretShare) error Read(ResponseConverter, bool) (*Result, error) }
AbstractCarrier is the carriers interface.
type AmphoraFeeder ¶
type AmphoraFeeder struct {
// contains filtered or unexported fields
}
AmphoraFeeder provides parameters to the SPDZ execution based on the given activation.
func NewAmphoraFeeder ¶
func NewAmphoraFeeder(l *zap.SugaredLogger, conf *SPDZEngineTypedConfig) *AmphoraFeeder
NewAmphoraFeeder returns a new instance of amphora feeder.
func (*AmphoraFeeder) Close ¶
func (f *AmphoraFeeder) Close() error
Close closes the underlying socket connection.
func (*AmphoraFeeder) LoadFromRequestAndFeed ¶
func (f *AmphoraFeeder) LoadFromRequestAndFeed(act *Activation, feedPort string, ctx *CtxConfig) ([]byte, error)
LoadFromRequestAndFeed loads input parameteters from the request body.
func (*AmphoraFeeder) LoadFromSecretStoreAndFeed ¶
func (f *AmphoraFeeder) LoadFromSecretStoreAndFeed(act *Activation, feedPort string, ctx *CtxConfig) ([]byte, error)
LoadFromSecretStoreAndFeed loads input parameters from Amphora.
type Carrier ¶
type Carrier struct { Dialer func(ctx context.Context, addr, port string) (net.Conn, error) Conn net.Conn Packer Packer Logger *zap.SugaredLogger // contains filtered or unexported fields }
Carrier is a TCP client for TCP sockets.
func (*Carrier) Connect ¶
Connect establishes a TCP connection to a socket on a given host and port.
type CastorTupleStreamer ¶
type CastorTupleStreamer struct {
// contains filtered or unexported fields
}
CastorTupleStreamer provides tuples to the SPDZ execution for the given type and configuration.
func NewCastorTupleStreamer ¶
func NewCastorTupleStreamer(l *zap.SugaredLogger, tt castor.TupleType, conf *SPDZEngineTypedConfig, playerDataDir string, gameID uuid.UUID, threadNr int) (*CastorTupleStreamer, error)
NewCastorTupleStreamer returns a new instance of castor tuple streamer.
func NewCastorTupleStreamerWithWriterFactory ¶
func NewCastorTupleStreamerWithWriterFactory(l *zap.SugaredLogger, tt castor.TupleType, conf *SPDZEngineTypedConfig, playerDataDir string, gameID uuid.UUID, threadNr int, pipeWriterFactory PipeWriterFactory) (*CastorTupleStreamer, error)
NewCastorTupleStreamerWithWriterFactory returns a new instance of castor tuple streamer.
func (*CastorTupleStreamer) StartStreamTuples ¶
func (ts *CastorTupleStreamer) StartStreamTuples(terminateCh chan struct{}, errCh chan error, wg *sync.WaitGroup)
StartStreamTuples repeatedly downloads a given type of tuples from castor and streams it to the according file as required by MP-SPDZ
type ConnectionInfo ¶
type Feeder ¶
type Feeder interface { LoadFromSecretStoreAndFeed(act *Activation, feedPort string, ctx *CtxConfig) ([]byte, error) LoadFromRequestAndFeed(act *Activation, feedPort string, ctx *CtxConfig) ([]byte, error) Close() error }
Feeder is an interface.
type Packer ¶
type Packer interface { Marshal([]string, *[]byte) error Unmarshal(*[]byte, ResponseConverter, bool) ([]string, error) }
Packer is an interface to marshal and unmarshal strings to the format specified by a given MPC runtime.
type PipeWriter ¶
PipeWriter provides methods to access and write to pipes
func DefaultPipeWriterFactory ¶
func DefaultPipeWriterFactory(l *zap.SugaredLogger, filePath string, writeDeadline time.Duration) (PipeWriter, error)
DefaultPipeWriterFactory constructs a new PipeWriter instance
type PipeWriterFactory ¶
type PipeWriterFactory func(l *zap.SugaredLogger, filePath string, writeDeadline time.Duration) (PipeWriter, error)
PipeWriterFactory is a factory method to create new PipeWriter.
It accepts a logger, filepath of the pipe to write to and a deadline for write operations. It either returns a PipeWriter or an error if creation failed.
type PlaintextConverter ¶
type PlaintextConverter struct {
Params []interface{}
}
PlaintextConverter expects plain-text response from SPDZ and converts it into a human readable base64 encoded int64 param. base64 encoding is used to comply with the format we use when storing objects in Amphora.
type ResponseConverter ¶
type ResponseConverter interface {
// contains filtered or unexported methods
}
ResponseConverter is an interface for a struct that mutates the response from SPDZ runtime to a required format.
type Result ¶
type Result struct {
Response []string `json:"response"`
}
Result contains the response from SPDZ runtime computation.
type SPDZPacker ¶
type SPDZPacker struct { // maxBulkSize is the maximum size of bulk objects received as parameters. MaxBulkSize int32 }
SPDZPacker is an implementation of Packer interface for SPDZ runtime.
func (*SPDZPacker) Marshal ¶
func (p *SPDZPacker) Marshal(b64 []string, dst *[]byte) (err error)
Marshal converts a base64 encoded string into a byte array consumable by SPDZ runtime.
func (*SPDZPacker) Unmarshal ¶
func (p *SPDZPacker) Unmarshal(in *[]byte, conv ResponseConverter, bulkSecrets bool) ([]string, error)
Unmarshal converts a byte sequence to a base64 encoded secret share representation consumable by Amphora.
type SecretSharesConverter ¶
type SecretSharesConverter struct {
}SecretSharesConverter is to be used for encoding base64 secret shared responses received from SPDZ runtime.
type TuplePipeWriter ¶
type TuplePipeWriter struct {
// contains filtered or unexported fields
}
TuplePipeWriter implements PipeWriter
func NewTuplePipeWriter ¶
func NewTuplePipeWriter(l *zap.SugaredLogger, filePath string, writeDeadline time.Duration) (*TuplePipeWriter, error)
NewTuplePipeWriter returns a new TuplePipeWriter with the given configuration. It will create a new pipe with the given path. If a file with this path already exists, it will be deleted first.
func (*TuplePipeWriter) Close ¶
func (tpw *TuplePipeWriter) Close() error
Close calls File.Close() on the tuple file pipe
func (*TuplePipeWriter) Open ¶
func (tpw *TuplePipeWriter) Open() error
Open opens a file as write only pipe.
This function should be called within a go routine as opening a pipe as write-only is a blocking call until opposing side opens the file to read. This is especially important when streaming tuples to MP-SPDZ, as it does open only those tuple files that are actually required for the current computation.
type TupleStreamer ¶
type TupleStreamer interface {
StartStreamTuples(terminateCh chan struct{}, errCh chan error, wg *sync.WaitGroup)
}
TupleStreamer is an interface.