File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change 41
41
"buffer" : " ^6.0.3" ,
42
42
"chai" : " ^4.3.4" ,
43
43
"events" : " ^3.3.0" ,
44
+ "libp2p-crypto" : " ^0.19.7" ,
44
45
"microtime" : " ^3.0.0" ,
45
46
"mocha" : " ^9.0.2" ,
46
47
"sinon" : " ^11.1.1"
56
57
"it-pair" : " ^1.0.0" ,
57
58
"it-pb-rpc" : " ^0.1.11" ,
58
59
"it-pipe" : " ^1.1.0" ,
59
- "libp2p-crypto" : " ^0.19.7" ,
60
60
"peer-id" : " ^0.15.3" ,
61
61
"protobufjs" : " ^6.11.2" ,
62
62
"uint8arrays" : " ^3.0.0"
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import { SHA256 } from '@stablelib/sha256'
3
3
import * as x25519 from '@stablelib/x25519'
4
4
import { Buffer } from 'buffer'
5
5
import PeerId from 'peer-id'
6
- import { keys } from 'libp2p-crypto'
7
6
import { KeyPair } from './@types/libp2p'
8
7
import { bytes , bytes32 } from './@types/basic'
9
8
import { Hkdf , INoisePayload } from './@types/handshake'
@@ -92,13 +91,13 @@ export async function verifySignedPayload (
92
91
}
93
92
const generatedPayload = getHandshakePayload ( noiseStaticKey )
94
93
// Unmarshaling from PublicKey protobuf
95
- const publicKey = keys . unmarshalPublicKey ( identityKey )
94
+ const peerId = await PeerId . createFromPubKey ( identityKey )
96
95
// TODO remove this after libp2p-crypto ships proper types
97
96
// eslint-disable-next-line @typescript-eslint/no-misused-promises
98
- if ( ! payload . identitySig || ! publicKey . verify ( generatedPayload , Buffer . from ( payload . identitySig ) ) ) {
97
+ if ( ! payload . identitySig || ! peerId . pubKey . verify ( generatedPayload , Buffer . from ( payload . identitySig ) ) ) {
99
98
throw new Error ( "Static key doesn't match to peer that signed payload!" )
100
99
}
101
- return await PeerId . createFromPubKey ( identityKey )
100
+ return peerId
102
101
}
103
102
104
103
export function getHkdf ( ck : bytes32 , ikm : bytes ) : Hkdf {
You can’t perform that action at this time.
0 commit comments