mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-06 16:58:11 +08:00
coreapi: key tests
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@ed5f040416 This commit was moved from ipfs/boxo@6527d6e063
This commit is contained in:
parent
1caf71766f
commit
89776d9be7
@ -148,13 +148,13 @@ type KeyAPI interface {
|
||||
// name and returns a base58 encoded multihash of it's public key
|
||||
Generate(ctx context.Context, name string, opts ...options.KeyGenerateOption) (Key, error)
|
||||
|
||||
// WithAlgorithm is an option for Generate which specifies which algorithm
|
||||
// WithType is an option for Generate which specifies which algorithm
|
||||
// should be used for the key. Default is options.RSAKey
|
||||
//
|
||||
// Supported algorithms:
|
||||
// Supported key types:
|
||||
// * options.RSAKey
|
||||
// * options.Ed25519Key
|
||||
WithAlgorithm(algorithm string) options.KeyGenerateOption
|
||||
WithType(algorithm string) options.KeyGenerateOption
|
||||
|
||||
// WithSize is an option for Generate which specifies the size of the key to
|
||||
// generated. Default is 0
|
||||
|
||||
@ -3,6 +3,8 @@ package options
|
||||
const (
|
||||
RSAKey = "rsa"
|
||||
Ed25519Key = "ed25519"
|
||||
|
||||
DefaultRSALen = 2048
|
||||
)
|
||||
|
||||
type KeyGenerateSettings struct {
|
||||
@ -20,7 +22,7 @@ type KeyRenameOption func(*KeyRenameSettings) error
|
||||
func KeyGenerateOptions(opts ...KeyGenerateOption) (*KeyGenerateSettings, error) {
|
||||
options := &KeyGenerateSettings{
|
||||
Algorithm: RSAKey,
|
||||
Size: 0,
|
||||
Size: -1,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
@ -48,7 +50,7 @@ func KeyRenameOptions(opts ...KeyRenameOption) (*KeyRenameSettings, error) {
|
||||
|
||||
type KeyOptions struct{}
|
||||
|
||||
func (api *KeyOptions) WithAlgorithm(algorithm string) KeyGenerateOption {
|
||||
func (api *KeyOptions) WithType(algorithm string) KeyGenerateOption {
|
||||
return func(settings *KeyGenerateSettings) error {
|
||||
settings.Algorithm = algorithm
|
||||
return nil
|
||||
|
||||
Loading…
Reference in New Issue
Block a user