示例#1
0
func generateECDSAKey(t *testing.T) *ecdsa.PrivateKey {
	privateKey, err := keys.GenerateECDSA()
	if err != nil {
		t.Errorf("failed to generate a key")
	}
	return privateKey
}
示例#2
0
func (srv *KeyService) GeneratePrivateKey(r *http.Request, args *GeneratePrivateKeyArgs, reply *GeneratePrivateKeyReply) error {
	key, err := keys.GenerateECDSA()
	if err != nil {
		reply.Success = false
		return err
	}
	err = env.DB.PutKey(args.Alias, key, false)
	if err != nil {
		reply.Success = false
		return err
	}
	reply.PublicKey = keys.ECDSAPublicKeyToString(key.PublicKey)
	reply.Success = true
	return nil
}
示例#3
0
文件: auth.go 项目: linhua55/gitchain
func newKeyAuth() (ka *KeyAuth, e error) {
	pk, e := keys.GenerateECDSA()
	ka = &KeyAuth{key: pk}
	return
}