Beispiel #1
0
// ListNeighs lists the public keys of the neighbors of the node
func (clnt *Client) ListNeighs() ([]natrium.EdDSAPublic, error) {
	req := textprot.TextReq{
		Verb: "NEIGH_LIST",
	}
	resp, err := clnt.execCmd(req)
	var ninf textprot.NeighInfo
	err = ninf.FromString(resp.Blob)
	if err != nil {
		clnt.sok.Close()
		return nil, ErrBadSocket
	}
	// do the checks
	pubkey := directory.DefaultProvider("").PublicKey()
	err = pubkey.Verify(ninf.Json.HashValue(), ninf.Signat)
	if err != nil {
		clnt.sok.Close() // this server is really bad, go away now
		return nil, ErrBadCrypto
	}
	if ninf.Json.Expires < int(time.Now().Unix()) ||
		subtle.ConstantTimeCompare(clnt.CurrentPublic(), ninf.Json.IssuedTo) != 1 {
		clnt.sok.Close()
		return nil, ErrBadCrypto
	}
	// return the val
	var toret []natrium.EdDSAPublic
	for _, v := range ninf.Json.NeighList {
		toret = append(toret, natrium.EdDSAPublic(v))
	}
	return toret, nil
}
Beispiel #2
0
func (dpv dftProv) PublicKey() natrium.EdDSAPublic {
	bts, err := hex.DecodeString("cb937d2d15fdc254d06c13229ef1823179b953a0ca4a6db5b027b2f99b9a0269")
	if err != nil {
		panic("wtf wtf")
	}
	return natrium.EdDSAPublic(bts)
}