Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check alllowed pubkey type #723

Closed
4 tasks done
dudong2 opened this issue Oct 17, 2022 · 0 comments · Fixed by #724
Closed
4 tasks done

Check alllowed pubkey type #723

dudong2 opened this issue Oct 17, 2022 · 0 comments · Fixed by #724
Assignees
Labels
A: bug Something isn't working

Comments

@dudong2
Copy link
Contributor

dudong2 commented Oct 17, 2022

Summary

Currently, the ValidateValidatorParams function does not check the pubkey type.
So, no error is returned even if an illegal pubkey type is passed as param.

Problem Definition

func ValidateValidatorParams(i interface{}) error {
	v, ok := i.(ocproto.ValidatorParams)
	if !ok {
		return fmt.Errorf("invalid parameter type: %T", i)
	}

	if len(v.PubKeyTypes) == 0 {
		return errors.New("validator allowed pubkey types must not be empty")
	}

	return nil
}

In the above function, only the length of v.PubKeyTypes is checked, not whether the contents are allowed or not.

t.Run("unsupported-key-type-case", func(t *testing.T) {
    testCases := []struct {
        arg       interface{}
        expectErr bool
    }{
        {ocproto.ValidatorParams{PubKeyTypes: []string{"inventedKeyType"}}, true},
    }

    for _, tc := range testCases {
        require.Equal(t, tc.expectErr, baseapp.ValidateValidatorParams(tc.arg) != nil)
    }
})

the test is passing despite the pubkey type that is not allowed in the above test.

Proposal

Add check that allowed pubkey types are correct.

  • composite(bls12-381,ed25519)
  • ed25519
  • secp256k1
  • bls12-381

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@dudong2 dudong2 added the A: bug Something isn't working label Oct 17, 2022
@dudong2 dudong2 self-assigned this Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant