@@ -370,26 +370,10 @@ function App() {
370370 return ;
371371 }
372372 const fromAddress = ( await web3 . eth . getAccounts ( ) ) [ 0 ] ;
373- const originalMessage = [
374- {
375- type : "string" ,
376- name : "fullName" ,
377- value : "Satoshi Nakamoto" ,
378- } ,
379- {
380- type : "uint32" ,
381- name : "userId" ,
382- value : "1212" ,
383- } ,
384- ] ;
385- const params = [ originalMessage , fromAddress ] ;
386- const method = "eth_signTypedData" ;
387- const signedMessage = await ( web3 . currentProvider as any ) ?. sendAsync ( {
388- id : 1 ,
389- method,
390- params,
391- fromAddress,
392- } ) ;
373+
374+ const message = "hello" ;
375+ const signedMessage = await web3 . eth . personal . sign ( message , fromAddress , "" ) ;
376+
393377
394378 uiConsole ( signedMessage ) ;
395379 } else if ( coreKitInstance . keyType === "ed25519" ) {
@@ -398,7 +382,35 @@ function App() {
398382 uiConsole ( sig . toString ( "hex" ) ) ;
399383 }
400384 } ;
385+ const signMessageWithPrecomputedTss = async ( ) : Promise < any > => {
386+ if ( coreKitInstance . keyType === "secp256k1" ) {
387+ const precomputedTssClient = await coreKitInstance . precompute_secp256k1 ( ) ;
388+ const msg = Buffer . from ( "hello signer!" ) ;
389+ const sig = await coreKitInstance . sign ( msg , false , precomputedTssClient ) ;
390+ uiConsole ( sig . toString ( "hex" ) ) ;
391+ } else if ( coreKitInstance . keyType === "ed25519" ) {
392+ const msg = Buffer . from ( "hello signer!" ) ;
393+ const sig = await coreKitInstance . sign ( msg ) ;
394+ uiConsole ( sig . toString ( "hex" ) ) ;
395+ }
396+ } ;
397+
398+ const signMultipleMessagesWithPrecomputedTss = async ( ) : Promise < any > => {
399+ if ( coreKitInstance . keyType === "secp256k1" ) {
400+ const [ precomputedTssClient , precomputedTssClient2 ] = await Promise . all ( [ coreKitInstance . precompute_secp256k1 ( ) , coreKitInstance . precompute_secp256k1 ( ) ] ) ;
401+
402+ const msg = Buffer . from ( "hello signer!" ) ;
403+ const sig = await coreKitInstance . sign ( msg , false , precomputedTssClient ) ;
404+ const msg2 = Buffer . from ( "hello signer2!" ) ;
401405
406+ const sig2 = await coreKitInstance . sign ( msg2 , false , precomputedTssClient2 ) ;
407+ uiConsole ( "Sig1: " , sig . toString ( "hex" ) , "Sig2: " , sig2 . toString ( "hex" ) ) ;
408+ } else if ( coreKitInstance . keyType === "ed25519" ) {
409+ const msg = Buffer . from ( "hello signer!" ) ;
410+ const sig = await coreKitInstance . sign ( msg ) ;
411+ uiConsole ( sig . toString ( "hex" ) ) ;
412+ }
413+ } ;
402414 const switchChainSepolia = async ( ) => {
403415 if ( ! provider ) {
404416 uiConsole ( "provider not initialized yet" ) ;
@@ -689,6 +701,14 @@ function App() {
689701 Sign Message
690702 </ button >
691703
704+ < button onClick = { signMessageWithPrecomputedTss } className = "card" >
705+ Sign Msgwith precomputed TSS
706+ </ button >
707+
708+ < button onClick = { signMultipleMessagesWithPrecomputedTss } className = "card" >
709+ Sign Multiple MSGs with precomputed TSS
710+ </ button >
711+
692712 < button onClick = { sendTransaction } className = "card" >
693713 Send Transaction
694714 </ button >
0 commit comments