Skip to content

Make 'signature::KeyPair::public_key' a public function #741

Closed

Description

@manifest

In the docs key_pair.public_key().as_ref() is used as public function, but implemented as a private.

Activity

  1. briansmith commented on Dec 22, 2018

    @briansmith
    Owner

    It's already public because it is a trait method. Note that rustc will give you a confusing error message if you don't use ring::signature::KeyPair; in the module that you're trying to use it in, indicating that public_key is private. These types each have a private public_key field, and rustc is trying to be helpful by giving you a hint, but unfortunately its hint is the wrong one.

    So, try adding use ring::signature::KeyPair; to the module you're having trouble in.

    Note that the doc tests pass on my machine, as-is.

  2. briansmith commented on Dec 22, 2018

    @briansmith
    Owner

    For reference, here is the error message I get when I remove the use ring::signature::KeyPair from the doctest:

    ---- src\signature.rs - signature (line 129) stdout ----
    error[E0599]: no method named `public_key` found for type `ring::signature::KeyPair` in the current scope
      --> src\signature.rs:153:38
       |
    26 | let peer_public_key_bytes = key_pair.public_key().as_ref();
       |                                      ^^^^^^^^^^ private field, not a method
       |
       = help: items from traits can only be used if the trait is in scope
    help: the following trait is implemented but not in scope, perhaps add a `use` for it:
       |
    3  | use ring::signature::KeyPair;
       |
    
  3. manifest commented on Dec 22, 2018

    @manifest
    Author

    Yes, my fault. Thanks a lot 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions