Exemplo n.º 1
0
func search(c chan *Trial, target *regexp.Regexp) {
	sequence := uint32(0)
	batch := make([]byte, 1024*4)
	for {
		_, err := rand.Read(batch)
		checkErr(err)
		for i := 0; i < len(batch)-16; i++ {
			trial := &Trial{
				Seed: make([]byte, 16),
			}
			copy(trial.Seed, batch[i:])
			if *ed25519key {
				trial.Key, err = crypto.NewEd25519Key(trial.Seed)
			} else {
				trial.Key, err = crypto.NewECDSAKey(trial.Seed)
			}
			checkErr(err)
			if *ed25519key {
				trial.Id, err = crypto.AccountId(trial.Key, nil)
			} else {
				trial.Id, err = crypto.AccountId(trial.Key, &sequence)
			}
			checkErr(err)
			atomic.AddUint64(&count, 1)
			if target.MatchString(trial.Id.String()) {
				c <- trial
			}
		}
	}
}
Exemplo n.º 2
0
func (s *Seed) Key(keyType KeyType) crypto.Key {
	var (
		key crypto.Key
		err error
	)
	switch keyType {
	case Ed25519:
		key, err = crypto.NewEd25519Key(s[:])
	case ECDSA:
		key, err = crypto.NewECDSAKey(s[:])
	}
	if err != nil {
		panic(fmt.Sprintf("bad seed: %v", err))
	}
	return key
}
Exemplo n.º 3
0
Arquivo: tx.go Projeto: rubblelabs/tx
func common(c *cli.Context) error {
	if c.GlobalString("seed") == "" {
		return fmt.Errorf("No seed specified")
	}
	seed, err := crypto.NewRippleHashCheck(c.GlobalString("seed"), crypto.RIPPLE_FAMILY_SEED)
	if err != nil {
		return err
	}
	if c.GlobalBool("ed25519") {
		key, err = crypto.NewEd25519Key(seed.Payload())
	} else {
		key, err = crypto.NewECDSAKey(seed.Payload())
		seq := uint32(0)
		keySequence = &seq
	}
	return err
}