toygarble

package
v0.0.0-...-1c1bc02 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LABEL_LEN_BYTES int = 16
)
View Source
const (
	MAX_INPUT_DEGREE int = 2
)

Variables

This section is empty.

Functions

func DecodePlaintextOutputLabels

func DecodePlaintextOutputLabels(outLabels []Label_t) string

this is decoding for a GC scheme where output is NOT encrypted

func GenerateWireLabels

func GenerateWireLabels(labelSet *SimpleWireLabelSet, freeXORDelta Label_t, rand *rand.Rand, isStructured bool) bool

Generates two free-XOR enabled wire labels of length LABEL_LEN_BYTES isStructured refers to how the label is constructed -- in the case of output gates the label must have the last bit correspond to actual output in the case of our scheme being anonymous

func ParseBRISTOLCircuitFile

func ParseBRISTOLCircuitFile(circ *Circuit, inReader io.Reader) bool

Main parsing function

Types

type Ciphertext_t

type Ciphertext_t []byte

type Circuit

type Circuit struct {
	// Total number of input and output wires
	NumInputWires  int
	NumOutputWires int

	// Number of input variables, and how they are divided into wires
	NumInputVars int
	NumWiresIV   []int

	// Number of output variables, and how they are divided into wires
	NumOutputVars int
	NumWiresOV    []int

	Gates []Gate
}

func (*Circuit) DecodeOutputVariables

func (circ *Circuit) DecodeOutputVariables(outWires []bool) [][]byte

Convert an evaluated array of boolean wire values into binary fields, one for each output variable in the circuit

func (*Circuit) EvaluateCircuit

func (circ *Circuit) EvaluateCircuit(inputBits []bool) (bool, []bool)

Circuit evaluation on concrete inputs. Returns success/failure and a list of output bits. Inefficient algorithm used for testing.

func (*Circuit) PadInputsToBoolArray

func (circ *Circuit) PadInputsToBoolArray(inputBufs [][]byte) []bool

Convert an array of []byte values into a boolean array that's bit-aligned with the circuit inputs

type CryptoSource

type CryptoSource struct{}

Assemble a PRNG from the cryptographic CSPRNG, man this is a bad hack I got off the Internet -- TODO make it better <-- Gabby modifiying so that this can be used also in the standalone library

func (CryptoSource) Int63

func (s CryptoSource) Int63() int64

func (CryptoSource) Seed

func (s CryptoSource) Seed(seed int64)

func (CryptoSource) Uint64

func (s CryptoSource) Uint64() (v uint64)

type Gate

type Gate struct {
	GateType GateType_t
	ConstVal bool
	InFrom   []int
}

type GateType_t

type GateType_t int
const (
	GateINPUT  GateType_t = 0
	GateOUTPUT GateType_t = 1
	GateAND    GateType_t = 2
	GateOR     GateType_t = 3
	GateNOT    GateType_t = 4
	GateXOR    GateType_t = 5
	GateCONST  GateType_t = 6
	GateCOPY   GateType_t = 7
)

type Label_t

type Label_t []byte

type SimpleGarbledCircuit

type SimpleGarbledCircuit struct {
	NumInputWires  int
	NumOutputWires int
	GarbledGates   []SimpleGarbledGate
	WireLabels     []SimpleWireLabelSet
	FreeXORDelta   Label_t
}

func (*SimpleGarbledCircuit) EvaluateCircuit

func (garb *SimpleGarbledCircuit) EvaluateCircuit(circ *Circuit, inputLabels []Label_t) (bool, []Label_t)

Evaluate a garbled circuit

func (*SimpleGarbledCircuit) GarbleCircuit

func (garb *SimpleGarbledCircuit) GarbleCircuit(circ *Circuit, rand *rand.Rand) bool

Garble a given circuit

func (*SimpleGarbledCircuit) GetInputLabelsFromBools

func (garb *SimpleGarbledCircuit) GetInputLabelsFromBools(inputs []bool) []Label_t

Get an array of input labels corresponding to a specific set of bits

func (*SimpleGarbledCircuit) GetInputWireLabels

func (garb *SimpleGarbledCircuit) GetInputWireLabels() []SimpleWireLabelSet

Returns the input labels

func (*SimpleGarbledCircuit) PackedMarshal

func (g *SimpleGarbledCircuit) PackedMarshal() []byte

this *generically* packs a circuit W/O input labels packing here is [all wire labels ordered as input wire i, wire label 0 then wire label 1 for i=1 ... NumInputWires ]

func (*SimpleGarbledCircuit) PackedUnmarshal

func (g *SimpleGarbledCircuit) PackedUnmarshal(b []byte, c *Circuit) error

type SimpleGarbledGate

type SimpleGarbledGate struct {
	Table []Ciphertext_t
}

type SimpleWireLabelSet

type SimpleWireLabelSet struct {
	WireLabelPair [2]Label_t
}

Jump to

Keyboard shortcuts

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