Skip to content

Commit

Permalink
fix: temp changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman035 committed May 30, 2024
1 parent d975afe commit d0ea056
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
8 changes: 6 additions & 2 deletions packages/restapi/src/lib/helpers/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down Expand Up @@ -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);
Expand All @@ -539,7 +543,7 @@ export const encryptPGPKey = async (
const LitInstance = await Lit.createInstance(
wallet.signer as SignerType,
wallet.account as string,
'ethereum',
'sepolia',
env
);

Expand Down
27 changes: 16 additions & 11 deletions packages/restapi/src/lib/helpers/lit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,24 +51,28 @@ 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,
statement,
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;
Expand All @@ -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(
{
Expand Down Expand Up @@ -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(
{
Expand Down

0 comments on commit d0ea056

Please sign in to comment.