Skip to content

Type eleminiation between Key, PublicKey, PrivateKey, and Subkey #1344

Answered by larabr
alichry asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @alichry ,
Wouldn't checking for Subkey explicitly work in your use case? e.g.

...
    if (key instanceof Subkey) {
      return key.mainKey.isPrivate();
    }
    return key.isPrivate();
}

Also, readKeys returns PublicKey[], so downcasting is only needed if you need a PrivateKey (whether we should keep exporting Key as a type is a valid question though)

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@larabr
Comment options

@alichry
Comment options

@alichry
Comment options

@larabr
Comment options

@alichry
Comment options

Answer selected by alichry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants