예제 #1
0
파일: config.go 프로젝트: mlncn/cothority
// SImply adds all the public keys we give to it
func aggregateKeys(pubs []string) abstract.Point {
	k0 := suite.Point().Null()
	for i, ki := range pubs {
		// convert from string to public key
		kip, _ := cliutils.ReadPub64(suite, strings.NewReader(ki))
		k0 = k0.Add(k0, kip)
		dbg.Lvl2("Public key n#", i, ":", kip)
	}
	dbg.Lvl1("Aggregated public key:", k0)
	return k0
}
예제 #2
0
func (sr *StampSignature) Open(file string) error {
	// Read in the toml-file
	sigStr := &sigFile{}
	err := app.ReadTomlConfig(sigStr, file)
	if err != nil {
		return err
	}
	suite := app.GetSuite(sigStr.SuiteStr)

	sr.Timestamp = sigStr.Timestamp
	for _, pr := range sigStr.Proof {
		pro, err := base64.StdEncoding.DecodeString(pr)
		if err != nil {
			dbg.Lvl1("Couldn't decode proof:", pr)
			return err
		}
		sr.Prf = append(sr.Prf, pro)
	}
	// Read the root, the challenge and response
	sr.MerkleRoot, err = base64.StdEncoding.DecodeString(sigStr.MerkleRoot)
	if err != nil {
		fmt.Errorf("Could not decode Merkle Root from sig file:", err)
	}
	sr.Response, err = cliutils.ReadSecret64(suite, strings.NewReader(sigStr.Response))
	if err != nil {
		fmt.Errorf("Could not read secret challenge:", err)
	}
	if sr.Challenge, err = cliutils.ReadSecret64(suite, strings.NewReader(sigStr.Challenge)); err != nil {
		fmt.Errorf("Could not read the aggregate commitment:", err)
	}
	if sr.AggCommit, err = cliutils.ReadPub64(suite, strings.NewReader(sigStr.AggCommitment)); err != nil {
		return err
	}
	if sr.AggPublic, err = cliutils.ReadPub64(suite, strings.NewReader(sigStr.AggPublic)); err != nil {
		return err
	}

	return nil
}
예제 #3
0
파일: peer.go 프로젝트: mlncn/cothority
// Simple ephemeral helper for compatibility issues
// From base64 => hexadecimal
func convertTree(suite abstract.Suite, t *graphs.Tree) {
	if t.PubKey != "" {
		point, err := cliutils.ReadPub64(suite, strings.NewReader(t.PubKey))
		if err != nil {
			dbg.Fatal("Could not decode base64 public key")
		}

		str, err := cliutils.PubHex(suite, point)
		if err != nil {
			dbg.Fatal("Could not encode point to hexadecimal")
		}
		t.PubKey = str
	}
	for _, c := range t.Children {
		convertTree(suite, c)
	}
}