Documentation ¶
Index ¶
- Variables
- func ByteSliceToUint32Slice(in []byte) []uint32
- func ByteToBits(data []byte) []bool
- func GaussSample() int64
- func IncreaseToNextSquare(num *int)
- func LoadServersCertificates() (credentials.TransportCredentials, error)
- func MathRand() *mrand.Rand
- func MaxBytesLength(in map[int][]byte) int
- func RandInt(mod *big.Int) *big.Int
- func Randate() time.Time
- func Ranstring(n int) string
- func StartBlockProfiling(filename string)
- func StartMemProfiling(filename string)
- func StartProfiling(filename string)
- func StopProfiling()
- func Uint32SliceToByteSlice(in []uint32) []byte
- func VectorToMatrixIndices(i, numColumns int) (int, int)
- type BufPRGReader
- type Config
- type PRGKey
- type PRGReader
- type ParamsLWE
- type Server
Constants ¶
This section is empty.
Variables ¶
var SeedMatrixA = [aes.BlockSize]byte{19, 177, 222, 148, 155, 239, 159, 227, 155, 99, 246, 214, 220, 162, 30, 66}
WARNING: DO NOT USE THESE KEYS IN PRODUCTION!
var ServerCertificates []tls.Certificate
ServerCertificates holds the certificates for the servers
var ServerPublicKeys = [...]string{
`-----BEGIN CERTIFICATE-----
MIIDXjCCAcagAwIBAgIQaQ6ZT/eUnVj3yI0zDmu1zDANBgkqhkiG9w0BAQsFADBl
MR4wHAYDVQQKExVta2NlcnQgZGV2ZWxvcG1lbnQgQ0ExHTAbBgNVBAsMFHNtc2Nv
bG9tQGRlZGlzMjAwMjA0MSQwIgYDVQQDDBtta2NlcnQgc21zY29sb21AZGVkaXMy
MDAyMDQwHhcNMjQxMDEyMTAzMTE0WhcNMjcwMTEyMTEzMTE0WjBEMScwJQYDVQQK
Ex5ta2NlcnQgZGV2ZWxvcG1lbnQgY2VydGlmaWNhdGUxGTAXBgNVBAsMEHNtc2Nv
bG9tQGRlZGlzcGMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARFOsBHZVaVxg3l
pIxFyzdB8wt+xDB1GOlBYG4ODWvDLWiYfcgcBCQeuhgA2CVGBYqBj7vabgIRMQuA
OPMnlKdoo3YwdDAOBgNVHQ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CsIPbYuDP0a7pwlKCfvv894nTblbXpAYmnjgTK39
Sy70Ugfx/DG/8enWYX17kDrqL38zpXZk/qul1nJn96P0Hue5xe00Qquw7rHeFsuT
9neYS36PYuCcf0yx4ADe2wNu4XirB0pwf+VpvRL7bbi/err31JAY6kUu90L2liWR
KQPTGlp0i+G5sEwqPbjT0FTmXDNEYZx4fykmiBEDe27Tyjsx3LSXXgJjk5gSx0kE
pPY=
-----END CERTIFICATE-----`,
}
Functions ¶
func ByteSliceToUint32Slice ¶
func ByteToBits ¶
func GaussSample ¶
func GaussSample() int64
The function below is modeled on Martin Albrecht's discrete-Gaussian sampler included in his dgs library:
https://github.com/malb/dgs
func IncreaseToNextSquare ¶
func IncreaseToNextSquare(num *int)
Increase num to the next perfect square. If the square root is a whole number, do not modify anything. Otherwise, return the square of the square root + 1.
func LoadServersCertificates ¶
func LoadServersCertificates() (credentials.TransportCredentials, error)
func MaxBytesLength ¶
MaxBytesLength get maximal []byte length in map[int][]byte
func Randate ¶
source: https://stackoverflow.com/questions/43495745/how-to-generate-random-date-in-go-lang/43497333 this is probably biased, but we don't care since it is only for tests
func StartBlockProfiling ¶
func StartBlockProfiling(filename string)
func StartMemProfiling ¶
func StartMemProfiling(filename string)
func StartProfiling ¶
func StartProfiling(filename string)
func StopProfiling ¶
func StopProfiling()
func Uint32SliceToByteSlice ¶
func VectorToMatrixIndices ¶
Given a vector index returns the indices for the matrix representation of the vector
Types ¶
type BufPRGReader ¶
func NewBufPRG ¶
func NewBufPRG(prg *PRGReader) *BufPRGReader
func (*BufPRGReader) Int63 ¶
func (b *BufPRGReader) Int63() int64
func (*BufPRGReader) Seed ¶
func (b *BufPRGReader) Seed(int64)
func (*BufPRGReader) Uint64 ¶
func (b *BufPRGReader) Uint64() uint64
type Config ¶
func LoadConfig ¶
type PRGKey ¶
func GetDefaultSeedMatrixA ¶
func GetDefaultSeedMatrixA() *PRGKey
func RandomPRGKey ¶
func RandomPRGKey() *PRGKey
type PRGReader ¶
type PRGReader struct { Key PRGKey // contains filtered or unexported fields }
We use the AES-CTR to generate pseudo-random numbers using a stream cipher. Go's native rand.Reader is extremely slow because it makes tons of system calls to generate a small number of pseudo-random bytes.
We pay the overhead of using a sync.Mutex to synchronize calls to AES-CTR, but this is relatively cheap.
type ParamsLWE ¶
type ParamsLWE struct { P uint32 // plaintext modulus N int // lattice/secret dimension Sigma float64 // Error parameter L int // number of rows of database M int // number of columns of database B uint32 // bound used in reconstruction SeedA *PRGKey // matrix used to generate digest BytesMod int // bytes of the modulo }
func ParamsDefault ¶
func ParamsDefault() *ParamsLWE
func ParamsDefault128 ¶
func ParamsDefault128() *ParamsLWE