4
4
publicKeyCreate,
5
5
publicKeyVerify,
6
6
publicKeyConvert,
7
- } = require ( 'ethereum-cryptography/shims/hdkey-secp256k1v3 ' )
7
+ } = require ( 'ethereum-cryptography/secp256k1 ' )
8
8
import * as assert from 'assert'
9
9
import * as BN from 'bn.js'
10
10
import { zeros , bufferToHex , toBuffer } from './bytes'
@@ -156,7 +156,7 @@ export const isValidPublic = function(publicKey: Buffer, sanitize: boolean = fal
156
156
export const pubToAddress = function ( pubKey : Buffer , sanitize : boolean = false ) : Buffer {
157
157
assertIsBuffer ( pubKey )
158
158
if ( sanitize && pubKey . length !== 64 ) {
159
- pubKey = toBuffer ( publicKeyConvert ( pubKey , false ) . slice ( 1 ) )
159
+ pubKey = Buffer . from ( publicKeyConvert ( pubKey , false ) . slice ( 1 ) )
160
160
}
161
161
assert ( pubKey . length === 64 )
162
162
// Only take the lower 160bits of the hash
@@ -179,7 +179,7 @@ export const privateToAddress = function(privateKey: Buffer): Buffer {
179
179
export const privateToPublic = function ( privateKey : Buffer ) : Buffer {
180
180
assertIsBuffer ( privateKey )
181
181
// skip the type flag and use the X, Y points
182
- return toBuffer ( publicKeyCreate ( privateKey , false ) . slice ( 1 ) )
182
+ return Buffer . from ( publicKeyCreate ( privateKey , false ) ) . slice ( 1 )
183
183
}
184
184
185
185
/**
@@ -188,7 +188,7 @@ export const privateToPublic = function(privateKey: Buffer): Buffer {
188
188
export const importPublic = function ( publicKey : Buffer ) : Buffer {
189
189
assertIsBuffer ( publicKey )
190
190
if ( publicKey . length !== 64 ) {
191
- publicKey = toBuffer ( publicKeyConvert ( publicKey , false ) . slice ( 1 ) )
191
+ publicKey = Buffer . from ( publicKeyConvert ( publicKey , false ) . slice ( 1 ) )
192
192
}
193
193
return publicKey
194
194
}
0 commit comments