Skip to content

Commit d00f8a1

Browse files
authored
go-ipfs-config: Merge pull request ipfs#138 from ipfs/fix/deprecation
fix: remove deprecated calls
2 parents ea17b50 + c692e73 commit d00f8a1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

config/init.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"time"
99

1010
"github.com/ipfs/interface-go-ipfs-core/options"
11-
ci "github.com/libp2p/go-libp2p-core/crypto"
12-
peer "github.com/libp2p/go-libp2p-core/peer"
11+
"github.com/libp2p/go-libp2p-core/crypto"
12+
"github.com/libp2p/go-libp2p-core/peer"
1313
)
1414

1515
func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
@@ -191,8 +191,8 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity,
191191
return ident, err
192192
}
193193

194-
var sk ci.PrivKey
195-
var pk ci.PubKey
194+
var sk crypto.PrivKey
195+
var pk crypto.PubKey
196196

197197
switch settings.Algorithm {
198198
case "rsa":
@@ -202,7 +202,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity,
202202

203203
fmt.Fprintf(out, "generating %d-bit RSA keypair...", settings.Size)
204204

205-
priv, pub, err := ci.GenerateKeyPair(ci.RSA, settings.Size)
205+
priv, pub, err := crypto.GenerateKeyPair(crypto.RSA, settings.Size)
206206
if err != nil {
207207
return ident, err
208208
}
@@ -214,7 +214,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity,
214214
return ident, fmt.Errorf("number of key bits does not apply when using ed25519 keys")
215215
}
216216
fmt.Fprintf(out, "generating ED25519 keypair...")
217-
priv, pub, err := ci.GenerateEd25519Key(rand.Reader)
217+
priv, pub, err := crypto.GenerateEd25519Key(rand.Reader)
218218
if err != nil {
219219
return ident, err
220220
}
@@ -228,7 +228,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity,
228228

229229
// currently storing key unencrypted. in the future we need to encrypt it.
230230
// TODO(security)
231-
skbytes, err := sk.Bytes()
231+
skbytes, err := crypto.MarshalPrivateKey(sk)
232232
if err != nil {
233233
return ident, err
234234
}

0 commit comments

Comments
 (0)