vdcs

package
v0.0.0-...-6e8e8a8 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: LGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Decentralization bool

Decentralization indicates whether the central or decentralized directory of service is used

View Source
var DecentralizedDirectoryInfo = struct {
	URL            string
	ActionAccount  string
	PasswordWallet string
}{
	URL:            "",
	ActionAccount:  "",
	PasswordWallet: "",
}

DecentralizedDirectoryInfo Global Variable to store Directory communication info

View Source
var DirctoryInfo = struct {
	Port int
	IP   []byte
}{
	Port: 0,
	IP:   []byte(""),
}

DirctoryInfo Global Variable to store Directory communication info

View Source
var ReadyFlag bool

ReadyFlag is a simulation for channels between the post handler and the eval function

View Source
var ReadyMutex = sync.RWMutex{}

ReadyMutex is a simulation for channels between the post handler and the eval function

Functions

func ByteSliceAdd

func ByteSliceAdd(A []byte, B []byte) (X []byte)

ByteSliceAdd performs addition of (A + B) % P by converting them into Big Ints and storing the byte slice value into X

func ByteSliceMul

func ByteSliceMul(A []byte, B []byte) (X []byte)

ByteSliceMul performs multiplication of (A * B) % P by converting them into Big Ints and storing the byte slice value into X

func BytesFromRSAPrivateKey

func BytesFromRSAPrivateKey(sk *rsa.PrivateKey) []byte

BytesFromRSAPrivateKey returns byte array encoding from an rsa.privatekey

func BytesFromRSAPublicKey

func BytesFromRSAPublicKey(pk *rsa.PublicKey) []byte

BytesFromRSAPublicKey returns byte array encoding from an rsa.publickey

func ClientHTTP

func ClientHTTP()

ClientHTTP Client listeners

func ClientRegister

func ClientRegister()

ClientRegister registers a client to directory of service

func ClientRegisterDecentralized

func ClientRegisterDecentralized(username string, cleosKey string)

ClientRegisterDecentralized registers a client to the decentralized directory of service

func Comm

func Comm(cir string, cID int64, numberOfServers int, feePerGate float64, chVDCSCommCircRes chan<- ChannelContainer)

Comm basically, the channel will need to send the input/output mapping as well

func CompareWires

func CompareWires(gcm GarbledMessage, arrIn [][]byte, arrOut [][]byte) bool

CompareWires Takes a garbled circuit and compares wires to input,output wires provided by the user

func Convert32BytesToByteStream

func Convert32BytesToByteStream(msg [32]byte) []byte

Convert32BytesToByteStream receives a byte array returns the first 32 bytes from it

func CreateAccount

func CreateAccount(URL string, r RegisterationMessage)

CreateAccount to create a new account in the blockchain.

func DecryptAES

func DecryptAES(encKey []byte, cipherText []byte) (plainText []byte, ok bool)

DecryptAES symmetric decryption using AES algorithm

func EncryptAES

func EncryptAES(encKey []byte, plainText []byte) (ciphertext []byte, ok bool)

EncryptAES symmetric encryption using AES algorithm

func GenNRandNumbers

func GenNRandNumbers(n int, length int, r int64, considerR bool) [][]byte

GenNRandNumbers generating random byte arrays

func GenerateElGamalKey

func GenerateElGamalKey(hexS []byte) *elgamal.PrivateKey

GenerateElGamalKey takes a hexadecimal number and generates a private key

func GenerateInputWiresValidate

func GenerateInputWiresValidate(circ Circuit, rArr []Randomness, cID int64) (in [][]byte, out [][]byte)

GenerateInputWiresValidate Given circuit and randomness generate the input wires corresponding to server n-1

func GenerateMessageArray

func GenerateMessageArray(cycleMessage CycleMessage, cID int64, circ Circuit) (mArr MessageArray, rArr []Randomness, keys [][]byte)

GenerateMessageArray Takes a CycleMessage, a cID, and a circuit and creates a message array encrypted and returns it with the corresponding randomness for the user to use

func GenerateRSAKey

func GenerateRSAKey(rsaKeySize int) (*rsa.PrivateKey, *rsa.PublicKey)

GenerateRSAKey generates Public/Private Key pair, advised rsaKeySize = 2048

func GetCircuitSize

func GetCircuitSize(circ Circuit) int

GetCircuitSize get the number of gates in a circuit

func GetFreePort

func GetFreePort() (int, error)

GetFreePort asks the kernel for a free open port that is ready to use.

func GetFromServerEval

func GetFromServerEval(id string) (res [][]byte, ok bool)

GetFromServerEval used in pt2

func GetHandlerClient

func GetHandlerClient(w http.ResponseWriter, r *http.Request)

GetHandlerClient recieves a token challenge and solves it

func GetIP

func GetIP() (net.IP, error)

GetIP getting The IP

func GetInputSizeOutputSize

func GetInputSizeOutputSize(circ Circuit) (inputSize int, outputSize int)

GetInputSizeOutputSize returns the number of inputs and outputs of a given circuit

func IPtoProperByte

func IPtoProperByte(ip net.IP) []byte

IPtoProperByte puts the IP in its proper formatting

func PostHandlerClient

func PostHandlerClient(w http.ResponseWriter, r *http.Request)

PostHandlerClient recieves the result of evaluation

func RSAPrivateDecrypt

func RSAPrivateDecrypt(key *rsa.PrivateKey, data []byte) ([]byte, error)

RSAPrivateDecrypt decrypts encrypted data with a given rsa.privatekey

func RSAPrivateKeyFromBytes

func RSAPrivateKeyFromBytes(key []byte) *rsa.PrivateKey

RSAPrivateKeyFromBytes extracts rsa.privatekey from its byte array encoding

func RSAPrivateSign

func RSAPrivateSign(key *rsa.PrivateKey, data []byte) ([]byte, error)

RSAPrivateSign makes a signature with a private key

func RSAPrivateVerify

func RSAPrivateVerify(key *rsa.PrivateKey, sign, data []byte) error

RSAPrivateVerify verifies a signature made with a private key

func RSAPublicEncrypt

func RSAPublicEncrypt(key *rsa.PublicKey, data []byte) ([]byte, error)

RSAPublicEncrypt encrypts data with a given rsa.publickey

func RSAPublicKeyFromBytes

func RSAPublicKeyFromBytes(key []byte) *rsa.PublicKey

RSAPublicKeyFromBytes extracts rsa.publickey from its byte array encoding

func RSAPublicSign

func RSAPublicSign(key *rsa.PublicKey, data []byte) ([]byte, error)

RSAPublicSign makes a signature with a public key

func RSAPublicVerify

func RSAPublicVerify(key *rsa.PublicKey, sign, data []byte) error

RSAPublicVerify verifies a signature made with a public key

func RandomSymmKeyGen

func RandomSymmKeyGen() (key []byte)

RandomSymmKeyGen Generates a random key for the AES algorithm

func RegisterOnDecentralizedDS

func RegisterOnDecentralizedDS(URL string, ActionAccount string, r RegisterationMessage) error

RegisterOnDecentralizedDS to register in the decentralized Directory of Service

func SHA256Hash

func SHA256Hash(msg []byte) [32]byte

SHA256Hash Hashes a byte array using sha256

func SendToClient

func SendToClient(res ResEval, ip []byte, port int) bool

SendToClient Invokes the post method on the server

func SendToDirectory

func SendToDirectory(k RegisterationMessage, ip []byte, port int) bool

SendToDirectory Invokes the post method on the directory

func SendToServer

func SendToServer(k MessageArray, ip []byte, port int) bool

SendToServer Invokes the post method on the server

func SendToServerEval

func SendToServerEval(k GarbledMessage) bool

SendToServerEval used in pt2

func SendToServerGarble

func SendToServerGarble(k CircuitMessage) bool

SendToServerGarble used in pt2

func ServerRegisterDecentralized

func ServerRegisterDecentralized(username string, cleosKey string, numberOfGates int, feePerGate float64)

ServerRegisterDecentralized registers a client to the decentralized directory of service

func SetDecentralizedDirectoryInfo

func SetDecentralizedDirectoryInfo(url string, actionAccount string, passwordWallet string)

SetDecentralizedDirectoryInfo to set the decentralized dircotry info

func SetDirectoryInfo

func SetDirectoryInfo(ip []byte, port int)

SetDirectoryInfo to set the dircotry info

func SetMyInfo

func SetMyInfo(username string, cleosKey string)

SetMyInfo sets the info of the current node

func UnlockWallet

func UnlockWallet(url string, walletKey string) error

UnlockWallet for a node to unlock its eosio wallet

func YaoGarbledCkt_in

func YaoGarbledCkt_in(rIn int64, length int, inputSize int) [][]byte

YaoGarbledCkt_in input wire garbling

func YaoGarbledCkt_mask

func YaoGarbledCkt_mask(rMask int64, length int, outputSize int) [][]byte

YaoGarbledCkt_mask mask for garbling and rerandomization

func YaoGarbledCkt_out

func YaoGarbledCkt_out(rOut int64, length int, outputSize int) [][]byte

YaoGarbledCkt_out output wire garbling

Types

type ChannelContainer

type ChannelContainer struct {
	InputWires  []Wire `json:"InputWires"`
	OutputWires []Wire `json:"OutputWires"`
	PartyInfo
	Keys [][]byte `json:"Keys"`
}

ChannelContainer contains what is passed through message channels within the client code

type Circuit

type Circuit struct {
	InputGates  []CircuitGate `json:"CircuitInputGates"`
	MiddleGates []CircuitGate `json:"CircuitMiddleGates"`
	OutputGates []CircuitGate `json:"CircuitOutputGates"`
}

Circuit circuit abstraction

type CircuitGate

type CircuitGate struct {
	Gate
	TruthTable []bool `json:"TruthTable"`
}

CircuitGate a gate in a boolean circuit

func DecryptCircuitGatesAES

func DecryptCircuitGatesAES(key []byte, gates []CircuitGate) []CircuitGate

DecryptCircuitGatesAES decrypts an array of circuit gates with a given symmetric key using AES algorithm

func EncryptCircuitGatesAES

func EncryptCircuitGatesAES(key []byte, gates []CircuitGate) []CircuitGate

EncryptCircuitGatesAES encrypts an array of circuit gates with a given symmetric key using AES algorithm

type CircuitMessage

type CircuitMessage struct {
	Circuit
	ComID
	Randomness
}

CircuitMessage a complete circuit message

type ClientInfo

type ClientInfo struct {
	PartyInfo
}

ClientInfo container for client relevant info in Directory of Service

type ComID

type ComID struct {
	CID []byte `json:"ComID"`
}

ComID computation ID abstraction

type Cycle

type Cycle struct {
	ServersCycle []PartyInfo `json:"ServersCycle"`
}

Cycle cycle wrapper

type CycleMessage

type CycleMessage struct {
	Cycle
	TotalFee int `json:"TotalFee"`
}

CycleMessage a complete cycle message reply

func ConstructCycleStruct

func ConstructCycleStruct(outs []byte, size int) (bool, CycleMessage)

ConstructCycleStruct construct the cycle returned from the transaction

func FetchCycleDecentralized

func FetchCycleDecentralized(URL string, ActionAccount string, c CycleRequestMessage) (bool, CycleMessage)

FetchCycleDecentralized fetches a cycle from the decentralized directory of service

func GetFromDirectory

func GetFromDirectory(k CycleRequestMessage, ip []byte, port int) (cyc CycleMessage, ok bool)

GetFromDirectory Invokes the get method on the directory

type CycleRequestMessage

type CycleRequestMessage struct {
	FunctionInfo
}

CycleRequestMessage Wrapping In case we needed to add new request types for failure handling

type FunctionInfo

type FunctionInfo struct {
	Token
	NumberOfServers    int `json:"NumberOfServers"`
	ServerCapabilities     //in this case we describe the capabilities needed to compute the circuit
}

FunctionInfo a container for function requirements

type GarbledCircuit

type GarbledCircuit struct {
	InputGates  []GarbledGate `json:"GarbledInputGates"`
	MiddleGates []GarbledGate `json:"GarbledMiddleGates"`
	OutputGates []GarbledGate `json:"GarbledOutputGates"`
	ComID
}

GarbledCircuit garbled circuit abstraction

type GarbledGate

type GarbledGate struct {
	Gate
	KeyY            [][]byte `json:"EncryptedY"`
	GarbledValuesC1 [][]byte `json:"GarbledValuesC1"`
	GarbledValuesC2 [][]byte `json:"GarbledValuesC2"`

	GarbledValues [][]byte `json:"GarbledValues"` //to be removed later.
}

GarbledGate a gate in a garbled circuit

func DecryptGarbledGatesAES

func DecryptGarbledGatesAES(key []byte, gates []GarbledGate) []GarbledGate

DecryptGarbledGatesAES decrypts an array of garbled gates with a given symmetric key using AES algorithm

func EncryptGarbledGatesAES

func EncryptGarbledGatesAES(key []byte, gates []GarbledGate) []GarbledGate

EncryptGarbledGatesAES encrypts an array of garbled gates with a given symmetric key using AES algorithm

type GarbledMessage

type GarbledMessage struct {
	InputWires []Wire `json:"GarbledInputWires"`
	GarbledCircuit
	OutputWires []Wire `json:"GarbledOutputWires"`
}

GarbledMessage complete garbled circuit message

func Garble

func Garble(circ CircuitMessage) GarbledMessage

Garble circuit garbling. This now supports only 2-input gates

func GetFromServerGarble

func GetFromServerGarble(id string) (k GarbledMessage, ok bool)

GetFromServerGarble used in pt2

func ReRand

ReRand does things for a certain circuit view

type Gate

type Gate struct {
	GateID     []byte   `json:"GateID"`
	GateInputs [][]byte `json:"GateInputs"`
}

Gate gate abstraction

type Message

type Message struct {
	Type []byte `json:"Type"` //Garble, Rerand, Eval
	Circuit
	GarbledMessage
	InputWires []Wire `json:"GeneralInputWires"`
	Randomness
	ComID
	NextServer PartyInfo `json:"NextServer"`
}

Message passed through cycle

func DecryptMessageAES

func DecryptMessageAES(key []byte, msg Message) (nMsg Message)

DecryptMessageAES takes a symmetric key and message, and decrypts the message using that key

func EncryptMessageAES

func EncryptMessageAES(key []byte, msg Message) (nMsg Message)

EncryptMessageAES takes a symmetric key and message, and encrypts the message using that key

type MessageArray

type MessageArray struct {
	Array []Message `json:"Array"`
	Keys  [][]byte  `json:"Keys"`
}

MessageArray container of messages

type MyInfo

type MyInfo struct {
	PartyInfo
	CleosKey   []byte `json:"CleosKey"`
	PrivateKey []byte `json:"PrivateKey"`
}

MyInfo container for general and private information about a node

var MyOwnInfo MyInfo

MyOwnInfo personal info container

type PartyInfo

type PartyInfo struct {
	IP        []byte `json:"IP"`
	Port      int    `json:"Port"`
	PublicKey []byte `json:"PublicKey"`
	UserName  []byte `json:"UserName"`
}

PartyInfo container for general information about a node

func DecryptPartyInfoAES

func DecryptPartyInfoAES(key []byte, pI PartyInfo) (nPI PartyInfo)

DecryptPartyInfoAES decrypts PartyInfo container with a given key using AES Algorithm

func EncryptPartyInfoAES

func EncryptPartyInfoAES(key []byte, pI PartyInfo) (nPI PartyInfo)

EncryptPartyInfoAES encrypts PartyInfo container with a given key using AES Algorithm

func GetPartyInfo

func GetPartyInfo(username string) (PartyInfo, []byte)

GetPartyInfo for a party to extract his own communication info

type Randomness

type Randomness struct {
	Rin       int64 `json:"Rin"`
	Rout      int64 `json:"Rout"`
	Rmask     int64 `json:"Rmask"`
	Rgc       int64 `json:"Rgc"`
	LblLength int   `json:"LblLength"`
}

Randomness container for randomness

func DecryptRandomnessAES

func DecryptRandomnessAES(key []byte, rArr Randomness) Randomness

DecryptRandomnessAES decrypts a randomness container with a given key using AES Algorithm

func EncryptRandomnessAES

func EncryptRandomnessAES(key []byte, rArr Randomness) Randomness

EncryptRandomnessAES encrypts a randomness container with a given key using AES Algorithm

func GenerateRandomness

func GenerateRandomness(numberOfServers int, cID int64) []Randomness

GenerateRandomness generates randomness array corresponding to NumberOfServers with a certain computation ID

type RegisterationMessage

type RegisterationMessage struct {
	Type   []byte     `json:"Type"` //Server, Client
	Server ServerInfo `json:"ServerInfo"`
}

RegisterationMessage a complete registration message

type ResEval

type ResEval struct {
	Res [][]byte `json:"Result"`
	ComID
}

ResEval evaluation result abstraction

var MyResult ResEval

MyResult is a simulation for channels between the post handler and the eval function

func Evaluate

func Evaluate(gc GarbledMessage) (result ResEval)

Evaluate evaluate a garbled circuit

type ServerCapabilities

type ServerCapabilities struct {
	NumberOfGates int     `json:"NumberOfGates"`
	FeePerGate    float64 `json:"FeePerGate"`
}

ServerCapabilities server capabilities abstraction

type ServerInfo

type ServerInfo struct {
	PartyInfo
	ServerCapabilities
}

ServerInfo container for server relevant info in Directory of Service

type Token

type Token struct {
	TokenGen []byte `json:"TokenGen"`
}

Token a token container for the ease of message passing

var MyToken Token

MyToken holds directory sent token

func GetFromClient

func GetFromClient(tokenChallenge Token, ip []byte, port int) (token Token, ok bool)

GetFromClient Invokes the get method on the client

func GetFromServer

func GetFromServer(tokenChallenge Token, ip []byte, port int) (token Token, ok bool)

GetFromServer Invokes the get method on the server

func SolveToken

func SolveToken(token Token) Token

SolveToken recieves a token challenge and solves it

type Wire

type Wire struct {
	WireID    []byte `json:"WireID"`
	WireLabel []byte `json:"WireLabel"`
}

Wire wire abstraction

func DecryptWiresAES

func DecryptWiresAES(key []byte, wArr []Wire) []Wire

DecryptWiresAES decrypts an array of wires with a given key using AES Algorithm

func EncryptWiresAES

func EncryptWiresAES(key []byte, wArr []Wire) []Wire

EncryptWiresAES encrypts an array of wires with a given key using AES Algorithm

Directories

Path Synopsis
Package elgamal implements ElGamal encryption, suitable for OpenPGP, as specified in "A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms," IEEE Transactions on Information Theory, v.
Package elgamal implements ElGamal encryption, suitable for OpenPGP, as specified in "A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms," IEEE Transactions on Information Theory, v.

Jump to

Keyboard shortcuts

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