Revert "feat: adds secp256k1 keypair type to key gen command, adds test cases"
This reverts commit 67e1a173fcde1b7c4b09464184aea8ef86bedab2.
Henrique Dias committed
Jun 12, 2023 at 15:35 UTC
e2128107f632a828c8234ce79079e79756d3ccb6
5 files changed
+3
-65
core/commands/keystore.go
+3
-3
@@ -83,7 +83,7 @@ var keyGenCmd = &cmds.Command{
83
Tagline: "Create a new keypair",
84
},
85
Options: []cmds.Option{
86
- cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519, secp256k1").WithDefault(keyStoreAlgorithmDefault),
86
+ cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519").WithDefault(keyStoreAlgorithmDefault),
87
cmds.IntOption(keyStoreSizeOptionName, "s", "size of the key to generate"),
88
ke.OptionIPNSBase,
89
},
@@ -398,7 +398,7 @@ The PEM format allows for key generation outside of the IPFS node:
398
allowAnyKeyType, _ := req.Options[keyAllowAnyTypeOptionName].(bool)
399
if !allowAnyKeyType {
400
switch t := sk.(type) {
401
- case *crypto.RsaPrivateKey, *crypto.Ed25519PrivateKey, *crypto.Secp256k1PrivateKey:
401
+ case *crypto.RsaPrivateKey, *crypto.Ed25519PrivateKey:
402
default:
403
return fmt.Errorf("key type %T is not allowed to be imported, only RSA or Ed25519;"+
404
" use flag --%s if you are sure of what you're doing",
@@ -604,7 +604,7 @@ environment variable:
604
Arguments: []cmds.Argument{},
605
Options: []cmds.Option{
606
cmds.StringOption(oldKeyOptionName, "o", "Keystore name to use for backing up your existing identity"),
607
- cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519, secp256k1").WithDefault(keyStoreAlgorithmDefault),
607
+ cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519").WithDefault(keyStoreAlgorithmDefault),
608
cmds.IntOption(keyStoreSizeOptionName, "s", "size of the key to generate"),
609
},
610
NoRemote: true,
core/coreapi/key.go
-8
@@ -82,14 +82,6 @@ func (api *KeyAPI) Generate(ctx context.Context, name string, opts ...caopts.Key
82
return nil, err
83
}
84
85
- sk = priv
86
- pk = pub
87
- case "secp256k1":
88
- priv, pub, err := crypto.GenerateSecp256k1Key(rand.Reader)
89
- if err != nil {
90
- return nil, err
91
- }
92
-
85
sk = priv
86
pk = pub
87
default:
test/sharness/lib/test-lib.sh
-16
@@ -486,14 +486,6 @@ test_check_ed25519_b58mh_peerid() {
486
}
487
}
488
489
-test_check_secp256k1_b58mh_peerid() {
490
- peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") &&
491
- test "$peeridlen" = "53" || {
492
- echo "Bad SECP256K1 B58MH peerid '$1' with len '$peeridlen'"
493
- return 1
494
- }
495
-}
496
-
489
test_check_rsa2048_base36_peerid() {
490
peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") &&
491
test "$peeridlen" = "56" || {
@@ -510,14 +502,6 @@ test_check_ed25519_base36_peerid() {
502
}
503
}
504
513
-test_check_secp256k1_base36_peerid() {
514
- peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") &&
515
- test "$peeridlen" = "63" || {
516
- echo "Bad SECP256K1 B36CID peerid '$1' with len '$peeridlen'"
517
- return 1
518
- }
519
-}
520
-
505
convert_tcp_maddr() {
506
echo $1 | awk -F'/' '{ printf "%s:%s", $3, $5 }'
507
}
test/sharness/t0027-rotate.sh
-7
@@ -87,19 +87,12 @@ test_rotate() {
87
}
88
test_rotate 'rsa' ''
89
test_rotate 'ed25519' ''
90
-test_rotate 'secp256k1' ''
90
test_rotate '' ''
91
test_rotate 'rsa' 'rsa'
92
test_rotate 'ed25519' 'rsa'
94
-test_rotate 'secp256k1' 'rsa'
93
test_rotate '' 'rsa'
94
test_rotate 'rsa' 'ed25519'
95
test_rotate 'ed25519' 'ed25519'
98
-test_rotate 'secp256k1' 'ed25519'
96
test_rotate '' 'ed25519'
100
-test_rotate 'rsa' 'secp256k1'
101
-test_rotate 'ed25519' 'secp256k1'
102
-test_rotate 'secp256k1' 'secp256k1'
103
-test_rotate '' 'secp256k1'
97
98
test_done
test/sharness/t0165-keystore.sh
-31
@@ -55,29 +55,6 @@ PEERID=$(ipfs key list --ipns-base=base36 -l | grep key_ed25519 | head -n 1 | cu
55
test_check_ed25519_base36_peerid $PEERID &&
56
ipfs key rm key_ed25519
57
'
58
-
59
-test_expect_success "create an SECP256k1 key and test B58MH/B36CID output formats" '
60
-PEERID=$(ipfs key gen --ipns-base=b58mh --type=secp256k1 key_secp256k1) &&
61
-test_check_secp256k1_b58mh_peerid $PEERID &&
62
-ipfs key rm key_secp256k1 &&
63
-PEERID=$(ipfs key gen --ipns-base=base36 --type=secp256k1 key_secp256k1) &&
64
-test_check_secp256k1_base36_peerid $PEERID
65
-'
66
-
67
-test_expect_success "test SECP256k1 key sk export format" '
68
-ipfs key export key_secp256k1 &&
69
-test_check_ed25519_sk key_secp256k1.key &&
70
-rm key_secp256k1.key
71
-'
72
-
73
-test_expect_success "test SECP256k1 key B58MH/B36CID multihash format" '
74
-PEERID=$(ipfs key list --ipns-base=b58mh -l | grep key_secp256k1 | head -n 1 | cut -d " " -f1) &&
75
-test_check_secp256k1_b58mh_peerid $PEERID &&
76
-PEERID=$(ipfs key list --ipns-base=base36 -l | grep key_secp256k1 | head -n 1 | cut -d " " -f1) &&
77
-test_check_secp256k1_base36_peerid $PEERID &&
78
-ipfs key rm key_secp256k1
79
-'
80
-
58
# end of format test
59
60
@@ -95,11 +72,6 @@ ipfs key rm key_secp256k1
72
73
test_key_import_export_all_formats ed25519_key
74
98
- test_expect_success "create a new secp256k1 key" '
99
- k1hash=$(ipfs key gen generated_secp256k1_key --type=secp256k1)
100
- echo $k1hash > secp256k1_key_id
101
- '
102
-
75
test_openssl_compatibility_all_types
76
77
INVALID_KEY=../t0165-keystore-data/openssl_secp384r1.pem
@@ -144,7 +116,6 @@ ipfs key rm key_secp256k1
116
test_expect_success "all keys show up in list output" '
117
echo generated_ed25519_key > list_exp &&
118
echo generated_rsa_key >> list_exp &&
147
- echo generated_secp256k1_key >> list_exp &&
119
echo quxel >> list_exp &&
120
echo self >> list_exp
121
ipfs key list > list_out &&
@@ -164,7 +135,6 @@ ipfs key rm key_secp256k1
135
test_expect_success "key rm remove a key" '
136
ipfs key rm generated_rsa_key
137
echo generated_ed25519_key > list_exp &&
167
- echo generated_secp256k1_key >> list_exp &&
138
echo quxel >> list_exp &&
139
echo self >> list_exp
140
ipfs key list > list_out &&
@@ -179,7 +149,6 @@ ipfs key rm key_secp256k1
149
test_expect_success "key rename rename a key" '
150
ipfs key rename generated_ed25519_key fooed
151
echo fooed > list_exp &&
182
- echo generated_secp256k1_key >> list_exp &&
152
echo quxel >> list_exp &&
153
echo self >> list_exp
154
ipfs key list > list_out &&