io

package
v0.0.0-...-b7fd0f1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

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 - 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 - 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

View Source
const BodySize = 32

BodySize equals to 32 = 16 bytes secret share + 16 bytes MAC.

View Source
const ErrInvalidBodySize = "Body size must be a multiple of 32"

ErrInvalidBodySize is thrown when a message of invalid length is provided.

View Source
const ErrInvalidResponseSize = "Response size must be equal to 20"

ErrInvalidResponseSize is thrown when a message of invalid length is returned.

View Source
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.

View Source
const ErrMarshal = "at 1 object must be provided to marshal"

ErrMarshal is thrown when provided input is < 1.

View Source
const ErrParcelToSPDZ = "parcelsToSPDZ error: "

ErrParcelToSPDZ is thrown when an error in parcelsToSPDZ method has occured.

View Source
const ErrSPDZToParcel = "spdzToParcels error: "

ErrSPDZToParcel is thrown when an error in spdzToParcels method has occured.

View Source
const ErrSizeTooBig = "size array must be <= 32 bits"

ErrSizeTooBig is thrown when the size of the parameters is exceeded.

View Source
const MessageSize = 36

MessageSize equals to 36 = 4 bytes Length + 32 bytes of message

View Source
const ParcelSizeLength = 4

ParcelSizeLength is the length of the Parcel size header in bytes.

View Source
const ResponseSizeCipher = 36

ResponseSizeCipher is the size of a byte array containing plain text.

View Source
const WordSize = 16

WordSize is the size of a single word in SPDZ runtime notation, e.g. secret share or MAC.

Variables

View Source
var MaxLength = int(math.Pow(2, 32))

MaxLength is the max size of Param's octet.

Functions

This section is empty.

Types

type AbstractCarrier

type AbstractCarrier interface {
	Connect(context.Context, 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
	// contains filtered or unexported fields
}

Carrier is a TCP client for TCP sockets.

func (*Carrier) Close

func (c *Carrier) Close() error

Close closes the underlying TCP connection.

func (*Carrier) Connect

func (c *Carrier) Connect(ctx context.Context, host, port string) error

Connect establishes a TCP connection to a socket on a given host and port.

func (*Carrier) Read

func (c *Carrier) Read(conv ResponseConverter, bulkObjects bool) (*Result, error)

Read reads the response from the TCP connection and unmarshals it.

func (*Carrier) Send

func (c *Carrier) Send(secret []amphora.SecretShare) error

Send transmits Amphora secret shares to a TCP socket opened by an MPC runtime.

type Config

type Config struct {
	Port string
	Host string
}

Config contains TCP connection properties of Carrier.

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 Parcel

type Parcel struct {
	Size       []byte
	Body       []byte
	BodyBase64 string
}

Parcel is an internal representation of a message consumed by SPDZ.

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 {
	Params []interface{}
}

SecretSharesConverter is to be used for encoding base64 secret shared responses received from SPDZ runtime.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL