File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @wireio/core" ,
33 "description" : " Library for working with Wire powered blockchains." ,
4- "version" : " 0.0.9-3 " ,
4+ "version" : " 0.0.9-4 " ,
55 "homepage" : " https://github.com/Wire-Network/sdk-core" ,
66 "license" : " FSL-1.1-Apache-2.0" ,
77 "main" : " lib/core.js" ,
Original file line number Diff line number Diff line change 11import { ABISerializableObject } from './serializer/serializable' ;
22import rand from 'brorand' ;
33import { Base58 } from './base58' ;
4+ import { getCurve } from './crypto/curves' ;
45
56export function arrayEquals ( a : ArrayLike < number > , b : ArrayLike < number > ) {
67 const len = a . length ;
@@ -174,4 +175,25 @@ export function evmSigToWire(eth_sig: string, prefix = 'EM') {
174175 ) ;
175176
176177 return `SIG_${ prefix } _${ payload } ` ;
177- }
178+ }
179+
180+ const ec = getCurve ( 'K1' )
181+
182+ /**
183+ * Get the public key in compressed format from a public or private key.
184+ *
185+ * @param key Either a public or private key
186+ * @param isPrivate Boolean indicating if the key is private, defaults to false.
187+ * @returns The public key in compressed format.
188+ */
189+
190+ export const getCompressedPublicKey = (
191+ key : string ,
192+ isPrivate = false
193+ ) : string => {
194+ if ( key . startsWith ( '0x' ) ) key = key . slice ( 2 ) ;
195+ const keyPair = isPrivate
196+ ? ec . keyFromPrivate ( key )
197+ : ec . keyFromPublic ( key , 'hex' ) ;
198+ return keyPair . getPublic ( true , 'hex' ) ;
199+ } ;
You can’t perform that action at this time.
0 commit comments