package keyset import ( "math/rand" "time" ) /* (2) Generates a pseudo-random KeySet * ---------------------------------------------------------*/ func (s *T) generate() { /* (1) Seed randomness */ rand.Seed(time.Now().UTC().UnixNano()) /* (1) Generate new secret ---------------------------------------------------------*/ /* (1) Reset current secret */ s.sec = make([]byte, SecretSize) /* (2) Generate each char. until same length as hash digest */ for i := uint16(0); i < SecretSize; i++ { s.sec[i] = byte(rand.Int() % 256) } /* (2) Manage other attributes ---------------------------------------------------------*/ /* (1) Random depth pick init */ var randMin, randMax = s.ctx.MinDepth() + (s.ctx.MaxDepth()-s.ctx.MinDepth()) / 2, s.ctx.MaxDepth() /* (2) Select "random" depth */ s.depth = randMin + uint16(rand.Intn(int(randMax+1-randMin))) /* (3) Reset comsumption level */ s.mcode = 0 }