diff --git a/packages/restapi/src/lib/helpers/crypto.ts b/packages/restapi/src/lib/helpers/crypto.ts index 4d907a9e3..11fab3101 100644 --- a/packages/restapi/src/lib/helpers/crypto.ts +++ b/packages/restapi/src/lib/helpers/crypto.ts @@ -251,7 +251,7 @@ export const decryptPGPKey = async (options: decryptPgpKeyProps) => { const LitInstance = await Lit.createInstance( wallet.signer as SignerType, wallet.account as string, - 'ethereum', + 'sepolia', env ); @@ -522,6 +522,10 @@ export const encryptPGPKey = async ( PARTS, QUORUM ); + + console.info('Shards'); + console.info(shard1, shard2, shard3); + // 3. Encrypt private key with secret const enc = new TextEncoder(); const encodedPrivateKey = enc.encode(privateKey); @@ -539,7 +543,7 @@ export const encryptPGPKey = async ( const LitInstance = await Lit.createInstance( wallet.signer as SignerType, wallet.account as string, - 'ethereum', + 'sepolia', env ); diff --git a/packages/restapi/src/lib/helpers/lit.ts b/packages/restapi/src/lib/helpers/lit.ts index e90e5b71e..4fabd486f 100644 --- a/packages/restapi/src/lib/helpers/lit.ts +++ b/packages/restapi/src/lib/helpers/lit.ts @@ -4,6 +4,7 @@ import { SignerType } from '../types'; import { ENV } from '../constants'; import { isValidSCWCAIP, pCAIP10ToWallet } from './address'; import * as viem from 'viem'; +import { Signer } from './signer'; export class Lit { public static LitInstance: Lit; @@ -50,6 +51,8 @@ export class Lit { const domain = 'push.org'; const origin = 'https://app.push.org'; const statement = 'Enable Push Profile'; + const nonce = await this.litNodeClient.getLatestBlockhash(); + const siweMessage = new siwe.SiweMessage({ domain, address, @@ -57,17 +60,19 @@ export class Lit { uri: origin, version: '1', chainId, + nonce, expirationTime: new Date(Date.now() + 1000 * 60 * 60 * 24).toISOString(), }); const messageToSign = siweMessage.prepareMessage(); // Sign the message and format the authSig - const signature = await signer.signMessage(messageToSign as any); + const pushSigner = new Signer(signer); + const signature = await pushSigner.signMessage(messageToSign as any); const authSig = { sig: signature, derivedVia: 'EIP1271', - signedMessage: viem.hashMessage(messageToSign), + signedMessage: messageToSign, address, }; return authSig; @@ -80,10 +85,10 @@ export class Lit { chainId ); - console.log(authSig); - console.log(this.accessControlConditions); - console.log(this.chain); - console.log(dataToEncrypt); + console.info(authSig); + console.info(this.accessControlConditions); + console.info(this.chain); + console.info(dataToEncrypt); const { ciphertext, dataToEncryptHash } = await LitJsSdk.encryptString( { @@ -113,11 +118,11 @@ export class Lit { chainId ); - console.log(authSig); - console.log(this.accessControlConditions); - console.log(this.chain); - console.log(dataToEncryptHash); - console.log(ciphertext); + console.info(authSig); + console.info(this.accessControlConditions); + console.info(this.chain); + console.info(dataToEncryptHash); + console.info(ciphertext); return await LitJsSdk.decryptToString( {