database

package
v0.0.0-...-7dbb591 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateNumRowsAndColumns

func CalculateNumRowsAndColumns(numBlocks int, matrix bool) (numRows, numColumns int)

func CommitScalarToIndex

func CommitScalarToIndex(x group.Scalar, j uint64, g group.Group) group.Element

Raise the group element obtained via index hashing to the scalar

func Digest

func Digest(db *LWE, rows int) *matrix.Matrix

func Digest128

func Digest128(db *LWE128, rows int) *matrix.Matrix128

func HashIndexToGroup

func HashIndexToGroup(j uint64, g group.Group) group.Element

Take the indices (j, l) and hash them to get a group element

func HashToIndex

func HashToIndex(id string, length int) uint32

HashToIndex hashes the given id to an index for a database of the given length

func MarshalGroupElements

func MarshalGroupElements(q []group.Element, marshalledLen int) ([]byte, error)

Marshal a slice of group elements

func PadBlock

func PadBlock(block []byte, blockLen int) []byte

Simple ISO/IEC 7816-4 padding where 0x80 is appended to the block, then zeros to make up to blockLen

func PadWithSignalByte

func PadWithSignalByte(block []byte) []byte

func UnPadBlock

func UnPadBlock(block []byte) []byte

func UnmarshalGroupElements

func UnmarshalGroupElements(q []byte, g group.Group, elemSize int) ([]group.Element, error)

Unmarshal a slice of group elements

Types

type Auth

type Auth struct {
	DigestLWE    *matrix.Matrix
	DigestLWE128 *matrix.Matrix128

	// The global digest that is a hash of all the row digests. Public.
	Digest []byte
	// One digest per row, authenticating all the elements in that row.
	// also used in the integrity amplification scheme to store
	// all the digests
	SubDigests []byte
	// length in bytes of the subdiget
	SubDigestLength int
	// ECC group and hash algorithm used for digest computation and PIR itself
	Group group.Group
	Hash  crypto.Hash
	// Due to lack of the size functions in the lib API, we store it in the db info
	ElementSize int
	ScalarSize  int
}

Auth is authentication information for the single-server setting

type Bytes

type Bytes struct {
	Entries []byte
	Info
}

func CreateRandomBytes

func CreateRandomBytes(rnd io.Reader, dbLen, numRows, blockLen int) *Bytes

CreateRandomBytes return a random bytes database. blockLen must be the number of bytes in a block, as a byte is the element

func CreateRandomMerkle

func CreateRandomMerkle(rnd io.Reader, dbLen, numRows, blockLen int) *Bytes

CreateRandomMerkle blockLen is the number of byte in a block, as byte is viewed as an element in this case

func CreateZeroBytes

func CreateZeroBytes(numRows, numColumns, blockLen int) *Bytes

CreateBitBytes return a random bytes database. blockLen must be the number of bytes in a block, as a byte is the element

func GenerateRealKeyBytes

func GenerateRealKeyBytes(dataPaths []string, rebalanced bool) (*Bytes, error)

func GenerateRealKeyMerkle

func GenerateRealKeyMerkle(dataPaths []string, rebalanced bool) (*Bytes, error)

func InitBytes

func InitBytes(numRows, numColumns, blockLen int) *Bytes

InitBytes return an empty database with a initial zero capacity, to be used when embedding keys into a bytes database. blockLen must be the number of bytes in a block, as a byte is the element

func (*Bytes) SizeGiB

func (b *Bytes) SizeGiB() float64

type DB

type DB struct {
	KeysInfo []*KeyInfo
	Entries  []uint32

	Info
}

func CreateRandomBitsDB

func CreateRandomBitsDB(rnd io.Reader, dbLen, numRows, blockLen int) (*DB, error)

func CreateRandomKeysDB

func CreateRandomKeysDB(rnd io.Reader, numIdentifiers int) (*DB, error)

func GenerateRealKeyDB

func GenerateRealKeyDB(dataPaths []string) (*DB, error)

func NewBitsDB

func NewBitsDB(info Info) *DB

func NewKeysDB

func NewKeysDB(info Info) *DB

func (*DB) SizeGiB

func (d *DB) SizeGiB() float64

type Elliptic

type Elliptic struct {
	Entries []byte
	Info
}

func CreateRandomEllipticWithDigest

func CreateRandomEllipticWithDigest(rnd io.Reader, dbLen int, g group.Group, rebalanced bool) *Elliptic

type Info

type Info struct {
	NumRows      int
	NumColumns   int
	BlockSize    int
	BlockLengths []int // length of data in blocks defined in number of elements

	// PIR type: classical, merkle
	PIRType string

	*Auth
	*Merkle
}

type KeyInfo

type KeyInfo struct {
	UserId       *packet.UserId
	CreationTime time.Time
	PubKeyAlgo   packet.PublicKeyAlgorithm
	BitLength    uint16
}

func GetKeyInfoFromPacket

func GetKeyInfoFromPacket(pkt []byte) (*KeyInfo, error)

GetKeyInfoFromPacket parses packet bytes and returns information about the key

type LWE

type LWE struct {
	Matrix *matrix.MatrixBytes
	Info
}

func CreateRandomBinaryLWE

func CreateRandomBinaryLWE(rnd io.Reader, numRows, numColumns int) *LWE

func CreateRandomBinaryLWEWithLength

func CreateRandomBinaryLWEWithLength(rnd io.Reader, dbLen int) *LWE

type LWE128

type LWE128 struct {
	Matrix *matrix.MatrixBytes
	Info
}

func CreateRandomBinaryLWE128

func CreateRandomBinaryLWE128(rnd io.Reader, numRows, numColumns int) *LWE128

func CreateRandomBinaryLWEWithLength128

func CreateRandomBinaryLWEWithLength128(rnd io.Reader, dbLen int) *LWE128

type Merkle

type Merkle struct {
	Root     []byte
	ProofLen int
}

Merkle is the info needed for the Merkle-tree based approach

Jump to

Keyboard shortcuts

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