circuit

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XOR Gate = "XOR"
	AND Gate = "AND"
	INV Gate = "INV" // Also called NOT
	EQ  Gate = "EQ"

	KBitMod8 = 16 // 8*16=128
	AES128   = 128
	AES256   = 256
)

Variables

View Source
var (

	// ErrNONSUPPORTGATE is returned if the gate is not supportted.
	ErrNONSUPPORTGATE = errors.New("the gate is not supportted")
	// ErrPARSEFAILURE is returned if the parse failures.
	ErrPARSEFAILURE = errors.New("the parse failures")
	// ErrNONIMPLEMENT is returned if the gate is not implemented.
	ErrNONIMPLEMENT = errors.New("the gate is not implemented")
	// ErrInputBit is returned if the bit input is wrong.
	ErrInputBit = errors.New("the bit input is wrong")
	// ErrInputSize is returned if the size of input is wrong.
	ErrInputSize = errors.New("the size of input is wrong")
)
View Source
var File_github_com_getamis_alice_crypto_circuit_message_proto protoreflect.FileDescriptor

Functions

func DecodeBristolFashionOutput

func DecodeBristolFashionOutput(binaryOutput []uint8) (string, error)

To Hex

func Decrypt

func Decrypt(d []int32, Y [][]byte) []uint8

func SetShaStateBristolInput

func SetShaStateBristolInput(state []uint64) ([]uint8, error)

Types

type Circuit

type Circuit struct {
	// contains filtered or unexported fields
}

----

func LoadBristol

func LoadBristol(path string) (*Circuit, error)

func (*Circuit) Garbled

func (cir *Circuit) Garbled(kBit int, input []uint8, f EncFunc) (*GarbleCircuit, *GarbleCircuitMessage, error)

Garbled Circuit: Two Halves Make a Whole Reducing data Transfer in Garbled Circuits using Half Gates Fig-2. The permitted inputs of Kbit are 128 or 256

type EncFunc

type EncFunc func(*GarbleCircuit, []uint8) ([][]byte, error)

func EncryptFunc

func EncryptFunc(startIndex int) EncFunc

type GarbleCircuit

type GarbleCircuit struct {
	E [][]byte

	R []byte
	// contains filtered or unexported fields
}

func (*GarbleCircuit) Encrypt

func (garcir *GarbleCircuit) Encrypt(startIndex int, input []uint8) [][]byte

func (*GarbleCircuit) EvaluateGarbleCircuit

func (garcir *GarbleCircuit) EvaluateGarbleCircuit(garbledMsg *GarbleCircuitMessage, input [][]byte) ([][]byte, error)

Evaluate: procedure Ev

func (*GarbleCircuit) GenerateGarbleWire

func (garcir *GarbleCircuit) GenerateGarbleWire(startIndex, endIndex int) ([][]byte, [][]byte)

func (*GarbleCircuit) GetOutputWire

func (garcir *GarbleCircuit) GetOutputWire() [][][]byte

type GarbleCircuitMessage

type GarbleCircuitMessage struct {
	F            []*HalfGateMessage `protobuf:"bytes,1,rep,name=f,proto3" json:"f,omitempty"`
	D            []int32            `protobuf:"varint,2,rep,packed,name=d,proto3" json:"d,omitempty"`
	HOutputWire0 [][]byte           `protobuf:"bytes,3,rep,name=HOutputWire0,proto3" json:"HOutputWire0,omitempty"`
	HOutputWire1 [][]byte           `protobuf:"bytes,4,rep,name=HOutputWire1,proto3" json:"HOutputWire1,omitempty"`
	StartCount   []byte             `protobuf:"bytes,5,opt,name=startCount,proto3" json:"startCount,omitempty"`
	X            [][]byte           `protobuf:"bytes,6,rep,name=x,proto3" json:"x,omitempty"`
	// contains filtered or unexported fields
}

func (*GarbleCircuitMessage) Descriptor deprecated

func (*GarbleCircuitMessage) Descriptor() ([]byte, []int)

Deprecated: Use GarbleCircuitMessage.ProtoReflect.Descriptor instead.

func (*GarbleCircuitMessage) GetD

func (x *GarbleCircuitMessage) GetD() []int32

func (*GarbleCircuitMessage) GetF

func (*GarbleCircuitMessage) GetHOutputWire0

func (x *GarbleCircuitMessage) GetHOutputWire0() [][]byte

func (*GarbleCircuitMessage) GetHOutputWire1

func (x *GarbleCircuitMessage) GetHOutputWire1() [][]byte

func (*GarbleCircuitMessage) GetStartCount

func (x *GarbleCircuitMessage) GetStartCount() []byte

func (*GarbleCircuitMessage) GetX

func (x *GarbleCircuitMessage) GetX() [][]byte

func (*GarbleCircuitMessage) ProtoMessage

func (*GarbleCircuitMessage) ProtoMessage()

func (*GarbleCircuitMessage) ProtoReflect

func (x *GarbleCircuitMessage) ProtoReflect() protoreflect.Message

func (*GarbleCircuitMessage) Reset

func (x *GarbleCircuitMessage) Reset()

func (*GarbleCircuitMessage) String

func (x *GarbleCircuitMessage) String() string

type Gate

type Gate string

type HalfGateMessage

type HalfGateMessage struct {
	TG        []byte `protobuf:"bytes,1,opt,name=tG,proto3" json:"tG,omitempty"`
	TE        []byte `protobuf:"bytes,2,opt,name=tE,proto3" json:"tE,omitempty"`
	WireIndex int32  `protobuf:"varint,3,opt,name=wireIndex,proto3" json:"wireIndex,omitempty"`
	// contains filtered or unexported fields
}

func (*HalfGateMessage) Descriptor deprecated

func (*HalfGateMessage) Descriptor() ([]byte, []int)

Deprecated: Use HalfGateMessage.ProtoReflect.Descriptor instead.

func (*HalfGateMessage) GetTE

func (x *HalfGateMessage) GetTE() []byte

func (*HalfGateMessage) GetTG

func (x *HalfGateMessage) GetTG() []byte

func (*HalfGateMessage) GetWireIndex

func (x *HalfGateMessage) GetWireIndex() int32

func (*HalfGateMessage) ProtoMessage

func (*HalfGateMessage) ProtoMessage()

func (*HalfGateMessage) ProtoReflect

func (x *HalfGateMessage) ProtoReflect() protoreflect.Message

func (*HalfGateMessage) Reset

func (x *HalfGateMessage) Reset()

func (*HalfGateMessage) String

func (x *HalfGateMessage) String() string

Jump to

Keyboard shortcuts

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