common

package
v0.0.0-...-ebe581b Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CostFromBytes

func CostFromBytes(encCostByes []byte) (map[int]*big.Int, error)

CostFromBytes retrieve costs from bytes

func CostToBytes

func CostToBytes(encCost map[int]*big.Int) ([]byte, error)

CostToBytes convert costs to bytes

func EncryptSampleIDSet

func EncryptSampleIDSet(IDSet []string, publicKey *ecdsa.PublicKey) ([]byte, error)

EncryptSampleIDSet encrypt local sample ID set by own public key IDSet is retrieved from local sample file, encrypted by local public key

func GenerateHomoKeyPair

func GenerateHomoKeyPair() (*paillier.PrivateKey, []byte, error)

GenerateHomoKeyPair generate paillier key pair, return private key and public key bytes(for transfer)

func GeneratePSIKeyPair

func GeneratePSIKeyPair() (*ecdsa.PrivateKey, error)

GeneratePSIKeyPair generate ecc private and public key pair for PSI using default elliptic curve key pair is used for ID list encryption and intersection

func GetBatchSetBySize

func GetBatchSetBySize(trainSet [][]float64, params pb_common.TrainParams, round int, needCheckReorder bool) ([][]float64, [][]float64)

GetBatchSetBySize get train set for specific round by batch size - trainSet is sample set for training - params is training task params - round is loop round for training task - needCheckReorder indicates whether reorder is needed

func GradListFromBytes

func GradListFromBytes(gradsBytes []byte) ([]map[int]*big.Int, error)

GradListFromBytes retrieve gradient list from bytes

func GradListToBytes

func GradListToBytes(grads []map[int]*big.Int) ([]byte, error)

GradListToBytes convert gradient list to bytes

func HomoPubkeyFromBytes

func HomoPubkeyFromBytes(keyBytes []byte) (*paillier.PublicKey, error)

HomoPubkeyFromBytes retrieve homomorphic public key from bytes

func HomoPubkeyToBytes

func HomoPubkeyToBytes(key *paillier.PublicKey) ([]byte, error)

HomoPubkeyToBytes convert homomorphic public key to bytes

func IntersectTwoParts

func IntersectTwoParts(sampleID []string, reEncSetLocal []byte, reEncSetOthers []byte) ([]string, error)

IntersectTwoParts get intersection of two parts' ID set sampleID is ID list retrieved from local sample file reEncSetLocal is local ID list that was already encrypted twice reEncSetOthers is other party's ID list that was already encrypted twice

func LinearEncGradientPartFromBytes

func LinearEncGradientPartFromBytes(encPartBytes []byte) (*linear_vertical.EncLocalGradientPart, error)

LinearEncGradientPartFromBytes retrieve enc gradient part from bytes

func LinearEncGradientPartToBytes

func LinearEncGradientPartToBytes(encPart *linear_vertical.EncLocalGradientPart) ([]byte, error)

LinearEncGradientPartToBytes convert enc gradient part to bytes

func LogicEncGradAndCostPartFromBytes

func LogicEncGradAndCostPartFromBytes(encPartBytes []byte) (*logic_vertical.EncLocalGradAndCostPart, error)

LogicEncGradAndCostPartFromBytes retrieve enc gradientAndCost part from bytes

func LogicEncGradAndCostPartToBytes

func LogicEncGradAndCostPartToBytes(encPart *logic_vertical.EncLocalGradAndCostPart) ([]byte, error)

LogicEncGradAndCostPartToBytes convert enc gradientAndCost part to bytes

func PSIEncSetFromBytes

func PSIEncSetFromBytes(setBytes []byte) (*linear_vertical.EncSet, error)

PSIEncSetFromBytes retrieve enc set from bytes

func PSIEncSetToBytes

func PSIEncSetToBytes(set *linear_vertical.EncSet) ([]byte, error)

PSIEncSetToBytes convert enc set to bytes

func PredictResultFromBytes

func PredictResultFromBytes(resultBytes []byte) ([][]string, error)

PredictResultFromBytes retrieve predict values from bytes

func PredictResultToBytes

func PredictResultToBytes(idName string, IDs []string, values []float64) ([]byte, error)

PredictResultToBytes convert ID and predict values to bytes for storage

func ReEncryptIDSet

func ReEncryptIDSet(encSet []byte, privateKey *ecdsa.PrivateKey) ([]byte, error)

ReEncryptIDSet re-encrypt others ID set by own private key encSet is the encryption of ID list, received from other party, already encrypted once encrypt encSet once more using local private key

func RearrangeFileWithIntersectIDs

func RearrangeFileWithIntersectIDs(fileRows [][]string, idName string, IDs []string) ([][]string, error)

RearrangeFileWithIntersectIDs re-arrange file by hash(ID) ascending order fileRows is original sample rows, including feature list and sample values idName is the name of ID feature IDs is the ID list after PSI

func RetrieveIDsFromFile

func RetrieveIDsFromFile(fileRows [][]string, idName string) ([]string, error)

RetrieveIDsFromFile retrieve ID set from file rows by id name fileRows is original sample rows, including feature list and sample values idName is the name of ID feature, like "id", "card_number"...

func TrainModelsFromBytes

func TrainModelsFromBytes(modelsBytes []byte) (*pb_common.TrainModels, error)

TrainModelsFromBytes retrieve train models from bytes

func TrainModelsToBytes

func TrainModelsToBytes(thetas []float64, trainDataSet *ml_common.TrainDataSet, params pb_common.TrainParams) ([]byte, error)

TrainModelsToBytes convert train models to bytes for transfer and save

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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