utils

package
v0.0.0-...-7466076 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2018 License: ISC Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LeaderCertificate tls.Certificate
View Source
var One *big.Int
View Source
var ServerBoxPrivateKeys []*[32]byte
View Source
var ServerBoxPublicKeys []*[32]byte
View Source
var ServerCertificates []tls.Certificate
View Source
var Zero *big.Int

Functions

func BoolToInt64

func BoolToInt64(b bool) int64

func DialHTTPWithTLS

func DialHTTPWithTLS(network, address string,
	client_idx int, acceptCerts []tls.Certificate) (*rpc.Client, error)

func GetUtime

func GetUtime() uint64

func ListenAndServe

func ListenAndServe(server *rpc.Server, address string)

For running RPC over TCP.

func ListenAndServeTLS

func ListenAndServeTLS(server *rpc.Server, address string,
	keyIdx int, acceptCerts []tls.Certificate, debugNet bool)

For running RPC over TLS.

func NextPowerOfTwo

func NextPowerOfTwo(val int) int

func PrintTime

func PrintTime(tag string)

func RandInt

func RandInt(mod *big.Int) *big.Int

Produce a random integer in Z_p where mod is the value p.

func RandPerm

func RandPerm(input []int) []int

Generate a random permutation of the ints specified in input.

func RunForever

func RunForever(f func(), d time.Duration)

func StartBlockProfiling

func StartBlockProfiling(filename string)

func StartMemProfiling

func StartMemProfiling(filename string)

func StartProfiling

func StartProfiling(filename string)

func StopProfiling

func StopProfiling()

Types

type BufPRGReader

type BufPRGReader struct {
	Key PRGKey
	// contains filtered or unexported fields
}

func NewBufPRG

func NewBufPRG(prg *PRGReader) *BufPRGReader

func (*BufPRGReader) RandInt

func (b *BufPRGReader) RandInt(mod *big.Int) *big.Int

type DebugConn

type DebugConn struct {
	io.ReadWriteCloser
	// contains filtered or unexported fields
}

func NewDebugConn

func NewDebugConn(c net.Conn, tag string) *DebugConn

func (*DebugConn) Close

func (d *DebugConn) Close() error

func (*DebugConn) Debug

func (d *DebugConn) Debug()

func (*DebugConn) Read

func (d *DebugConn) Read(p []byte) (int, error)

func (*DebugConn) Write

func (d *DebugConn) Write(p []byte) (int, error)

type PRGKey

type PRGKey [aes.BlockSize]byte

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.

func NewPRG

func NewPRG(key *PRGKey) *PRGReader

func RandomPRG

func RandomPRG() *PRGReader

func (*PRGReader) Read

func (s *PRGReader) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

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