8
8
"time"
9
9
10
10
"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"
13
13
)
14
14
15
15
func Init (out io.Writer , nBitsForKeypair int ) (* Config , error ) {
@@ -191,8 +191,8 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity,
191
191
return ident , err
192
192
}
193
193
194
- var sk ci .PrivKey
195
- var pk ci .PubKey
194
+ var sk crypto .PrivKey
195
+ var pk crypto .PubKey
196
196
197
197
switch settings .Algorithm {
198
198
case "rsa" :
@@ -202,7 +202,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity,
202
202
203
203
fmt .Fprintf (out , "generating %d-bit RSA keypair..." , settings .Size )
204
204
205
- priv , pub , err := ci .GenerateKeyPair (ci .RSA , settings .Size )
205
+ priv , pub , err := crypto .GenerateKeyPair (crypto .RSA , settings .Size )
206
206
if err != nil {
207
207
return ident , err
208
208
}
@@ -214,7 +214,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity,
214
214
return ident , fmt .Errorf ("number of key bits does not apply when using ed25519 keys" )
215
215
}
216
216
fmt .Fprintf (out , "generating ED25519 keypair..." )
217
- priv , pub , err := ci .GenerateEd25519Key (rand .Reader )
217
+ priv , pub , err := crypto .GenerateEd25519Key (rand .Reader )
218
218
if err != nil {
219
219
return ident , err
220
220
}
@@ -228,7 +228,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity,
228
228
229
229
// currently storing key unencrypted. in the future we need to encrypt it.
230
230
// TODO(security)
231
- skbytes , err := sk . Bytes ( )
231
+ skbytes , err := crypto . MarshalPrivateKey ( sk )
232
232
if err != nil {
233
233
return ident , err
234
234
}
0 commit comments