Commit 2391566d authored by masala's avatar masala

Merge remote-tracking branch 'origin/master' into voting_release

parents 57ed6c22 b65b3b7b
language: go
go:
- 1.8
- 1.9
- tip
- "1.10"
- "1.11"
install:
- go get -v -t ./...
- git config --global http.https://gopkg.in.followRedirects true
- go get -v -t ./...
script:
- go test -v ./...
......@@ -45,17 +45,16 @@ type Document struct {
Epoch uint64
SendRatePerMinute uint64
MixLambda float64
MixMaxDelay uint64
SendLambda float64
SendShift uint64
SendMaxInterval uint64
DropLambda float64
DropShift uint64
DropMaxInterval uint64
LoopLambda float64
LoopShift uint64
LoopMaxInterval uint64
Topology [][][]byte
......@@ -107,16 +106,14 @@ func VerifyAndParseDocument(b []byte, verifier cert.Verifier) (*pki.Document, er
// everything.
doc := new(pki.Document)
doc.Epoch = d.Epoch
doc.SendRatePerMinute = d.SendRatePerMinute
doc.MixLambda = d.MixLambda
doc.MixMaxDelay = d.MixMaxDelay
doc.SendLambda = d.SendLambda
doc.SendShift = d.SendShift
doc.SendMaxInterval = d.SendMaxInterval
doc.DropLambda = d.DropLambda
doc.DropShift = d.DropShift
doc.DropMaxInterval = d.DropMaxInterval
doc.LoopLambda = d.LoopLambda
doc.LoopShift = d.LoopShift
doc.LoopMaxInterval = d.LoopMaxInterval
doc.Topology = make([][]*pki.MixDescriptor, len(d.Topology))
doc.Providers = make([]*pki.MixDescriptor, 0, len(d.Providers))
......
......@@ -72,15 +72,17 @@ func TestDocument(t *testing.T) {
k, err := eddsa.NewKeypair(rand.Reader)
require.NoError(err, "eddsa.NewKeypair()")
testSendRate := uint64(3)
// Generate a Document.
doc := &Document{
Epoch: debugTestEpoch,
Topology: make([][][]byte, 3),
MixLambda: 0.42,
MixMaxDelay: 23,
SendLambda: 0.69,
SendShift: 15000,
SendMaxInterval: 17,
Epoch: debugTestEpoch,
SendRatePerMinute: testSendRate,
Topology: make([][][]byte, 3),
MixLambda: 0.42,
MixMaxDelay: 23,
SendLambda: 0.69,
SendMaxInterval: 17,
}
idx := 1
for l := 0; l < 3; l++ {
......@@ -108,11 +110,10 @@ func TestDocument(t *testing.T) {
ddoc, err := VerifyAndParseDocument([]byte(signed), k.PublicKey())
require.NoError(err, "VerifyAndParseDocument()")
require.Equal(doc.Epoch, ddoc.Epoch, "VerifyAndParseDocument(): Epoch")
require.Equal(doc.SendRatePerMinute, testSendRate, "VerifyAndParseDocument(): SendRatePerMinute")
require.Equal(doc.MixLambda, ddoc.MixLambda, "VerifyAndParseDocument(): MixLambda")
require.Equal(doc.MixMaxDelay, ddoc.MixMaxDelay, "VerifyAndParseDocument(): MixMaxDelay")
require.Equal(doc.SendLambda, ddoc.SendLambda, "VerifyAndParseDocument(): SendLambda")
require.Equal(doc.SendShift, ddoc.SendShift, "VerifyAndParseDocument(): SendShift")
require.Equal(doc.SendMaxInterval, ddoc.SendMaxInterval, "VerifyAndParseDocument(): SendMaxInterval")
t.Logf("Deserialized document: '%v'", ddoc)
......
......@@ -42,16 +42,17 @@ const (
// Note: These values are picked primarily for debugging and need to
// be changed to something more suitable for a production deployment
// at some point.
defaultMixLambda = 0.00025
defaultMixMaxPercentile = 0.99999
defaultMixLambda = 0.00025
defaultMixMaxPercentile = 0.99999
// rate limiting of client connections
defaultSendRatePerMinute = 100
defaultSendLambda = 0.00006
defaultSendShift = 15000 // 15 seconds.
defaultSendMaxPercentile = 0.95
defaultDropLambda = 0.00006
defaultDropShift = 15000 // 15 seconds.
defaultDropMaxPercentile = 0.95
defaultLoopLambda = 0.00006
defaultLoopShift = 15000 // 15 seconds.
defaultLoopMaxPercentile = 0.95
)
......@@ -121,6 +122,9 @@ func (lCfg *Logging) validate() error {
// Parameters is the network parameters.
type Parameters struct {
// SendRatePerMinute is the rate per minute.
SendRatePerMinute uint64
// MixLambda is the inverse of the mean of the exponential distribution
// that the Sphinx packet per-hop mixing delay will be sampled from.
MixLambda float64
......@@ -134,10 +138,6 @@ type Parameters struct {
// or drop decoy messages.
SendLambda float64
// SendShift is the shift applied to the client send timing samples in
// milliseconds.
SendShift uint64
// SendMaxInterval is the maximum send interval in milliseconds, enforced
// prior to (excluding) SendShift.
SendMaxInterval uint64
......@@ -146,10 +146,6 @@ type Parameters struct {
// that clients will sample to determine send timing of drop decoy messages.
DropLambda float64
// DropShift is the shift applied to the client send timing samples in
// milliseconds.
DropShift uint64
// DropMaxInterval is the maximum send interval in milliseconds, enforced
// prior to (excluding) DropShift.
DropMaxInterval uint64
......@@ -158,10 +154,6 @@ type Parameters struct {
// that clients will sample to determine send timing of loop decoy messages.
LoopLambda float64
// LoopShift is the shift applied to the client send timing samples in
// milliseconds.
LoopShift uint64
// LoopMaxInterval is the maximum send interval in milliseconds, enforced
// prior to (excluding) LoopShift.
LoopMaxInterval uint64
......@@ -193,8 +185,8 @@ func (pCfg *Parameters) applyDefaults() {
if pCfg.SendLambda == 0 {
pCfg.SendLambda = defaultSendLambda
}
if pCfg.SendShift == 0 {
pCfg.SendShift = defaultSendShift
if pCfg.SendRatePerMinute == 0 {
pCfg.SendRatePerMinute = defaultSendRatePerMinute
}
if pCfg.SendMaxInterval == 0 {
pCfg.SendMaxInterval = uint64(rand.ExpQuantile(pCfg.SendLambda, defaultSendMaxPercentile))
......@@ -202,18 +194,12 @@ func (pCfg *Parameters) applyDefaults() {
if pCfg.DropLambda == 0 {
pCfg.DropLambda = defaultDropLambda
}
if pCfg.DropShift == 0 {
pCfg.DropShift = defaultDropShift
}
if pCfg.DropMaxInterval == 0 {
pCfg.DropMaxInterval = uint64(rand.ExpQuantile(pCfg.DropLambda, defaultDropMaxPercentile))
}
if pCfg.LoopLambda == 0 {
pCfg.LoopLambda = defaultLoopLambda
}
if pCfg.LoopShift == 0 {
pCfg.LoopShift = defaultLoopShift
}
if pCfg.LoopMaxInterval == 0 {
pCfg.LoopMaxInterval = uint64(rand.ExpQuantile(pCfg.LoopLambda, defaultLoopMaxPercentile))
}
......
......@@ -193,20 +193,18 @@ func (s *state) generateDocument(epoch uint64) {
// Build the Document.
doc := &s11n.Document{
Epoch: epoch,
MixLambda: s.s.cfg.Parameters.MixLambda,
MixMaxDelay: s.s.cfg.Parameters.MixMaxDelay,
SendLambda: s.s.cfg.Parameters.SendLambda,
SendShift: s.s.cfg.Parameters.SendShift,
SendMaxInterval: s.s.cfg.Parameters.SendMaxInterval,
DropLambda: s.s.cfg.Parameters.DropLambda,
DropShift: s.s.cfg.Parameters.DropShift,
DropMaxInterval: s.s.cfg.Parameters.DropMaxInterval,
LoopLambda: s.s.cfg.Parameters.LoopLambda,
LoopShift: s.s.cfg.Parameters.LoopShift,
LoopMaxInterval: s.s.cfg.Parameters.LoopMaxInterval,
Topology: topology,
Providers: providers,
Epoch: epoch,
SendRatePerMinute: s.s.cfg.Parameters.SendRatePerMinute,
MixLambda: s.s.cfg.Parameters.MixLambda,
MixMaxDelay: s.s.cfg.Parameters.MixMaxDelay,
SendLambda: s.s.cfg.Parameters.SendLambda,
SendMaxInterval: s.s.cfg.Parameters.SendMaxInterval,
DropLambda: s.s.cfg.Parameters.DropLambda,
DropMaxInterval: s.s.cfg.Parameters.DropMaxInterval,
LoopLambda: s.s.cfg.Parameters.LoopLambda,
LoopMaxInterval: s.s.cfg.Parameters.LoopMaxInterval,
Topology: topology,
Providers: providers,
}
// Serialize and sign the Document.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment