| 1 | package iface |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | |
| 6 | "github.com/ipfs/boxo/path" |
| 7 | |
| 8 | "github.com/ipfs/kubo/core/coreiface/options" |
| 9 | |
| 10 | "github.com/libp2p/go-libp2p/core/peer" |
| 11 | ) |
| 12 | |
| 13 | // Key specifies the interface to Keys in KeyAPI Keystore |
| 14 | type Key interface { |
| 15 | // Key returns key name |
| 16 | Name() string |
| 17 | |
| 18 | // Path returns key path |
| 19 | Path() path.Path |
| 20 | |
| 21 | // ID returns key PeerID |
| 22 | ID() peer.ID |
| 23 | } |
| 24 | |
| 25 | // KeyAPI specifies the interface to Keystore |
| 26 | type KeyAPI interface { |
| 27 | // Generate generates new key, stores it in the keystore under the specified |
| 28 | // name and returns a base58 encoded multihash of it's public key |
| 29 | Generate(ctx context.Context, name string, opts ...options.KeyGenerateOption) (Key, error) |
| 30 | |
| 31 | // Rename renames oldName key to newName. Returns the key and whether another |
| 32 | // key was overwritten, or an error |
| 33 | Rename(ctx context.Context, oldName string, newName string, opts ...options.KeyRenameOption) (Key, bool, error) |
| 34 | |
| 35 | // List lists keys stored in keystore |
| 36 | List(ctx context.Context) ([]Key, error) |
| 37 | |
| 38 | // Self returns the 'main' node key |
| 39 | Self(ctx context.Context) (Key, error) |
| 40 | |
| 41 | // Remove removes keys from keystore. Returns ipns path of the removed key |
| 42 | Remove(ctx context.Context, name string) (Key, error) |
| 43 | |
| 44 | // Sign signs the given data with the key named name. Returns the key used |
| 45 | // for signing, the signature, and an error. |
| 46 | Sign(ctx context.Context, name string, data []byte) (Key, []byte, error) |
| 47 | |
| 48 | // Verify verifies if the given data and signatures match. Returns the key used |
| 49 | // for verification, whether signature and data match, and an error. |
| 50 | Verify(ctx context.Context, keyOrName string, signature, data []byte) (Key, bool, error) |
| 51 | } |