Skip to content

Commit

Permalink
Remove the encrypted Key
Browse files Browse the repository at this point in the history
  • Loading branch information
Segue21 committed May 24, 2024
1 parent 6b253fe commit 7b12ff5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: echo "VITE_APP_BASE_URL=/zama_bounty/" >> $GITHUB_ENV

- name: Install dependencies
run: npm ci --only=production
run: npm ci

- name: Build project
run: npm run build
Expand Down
6 changes: 0 additions & 6 deletions src/components/Gallery/Gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,6 @@ export const Gallery = () => {
const encryptedFile = await getEncryptedFileCidHash(cidHash);
if (!encryptedFile) throw new Error("Dencrypting data failed.");

console.log("cid: ", cidHash);
console.log("Encrypted FIle: ", encryptedFile);

// const encryptedKeys = deserializeEncryptedKeyParts(encryptedFile.encryptedFileKey);


const reEncryptedFileKey = await contract.reencrypt(tokenId, publicKey, signature);
const decryptedKey: bigint[] = [];

Expand Down
4 changes: 1 addition & 3 deletions src/components/Mint/Mint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ export const Mint = () => {

const encryptedFileKey = await fileKeyEncryption(fileKey);

const encryptedFile = { ...ciphFile, encryptedFileKey };

const cidHash = await uploadFileToIPFS(encryptedFile);
const cidHash = await uploadFileToIPFS(ciphFile);

toast.info("Your file is currently being minted as an NFT. This may take a few moments.");

Expand Down
12 changes: 6 additions & 6 deletions src/components/Utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export interface CiphFile {
};
}

export interface EncryptedFile extends CiphFile {
encryptedFileKey: Uint8Array[]; // Array of Uint8Array, each representing a key segment resulting from instance.encrypt64
}
// export interface EncryptedFile extends CiphFile {
// encryptedFileKey: Uint8Array[]; // Array of Uint8Array, each representing a key segment resulting from instance.encrypt64
// }

export interface DecryptedFileMetaData {
file: File;
Expand Down Expand Up @@ -121,7 +121,7 @@ export async function decryptFile(ciphFile: CiphFile, key: CryptoKey): Promise<D
}


export const uploadFileToIPFS = async (encryptedFile: EncryptedFile): Promise<string> => {
export const uploadFileToIPFS = async (encryptedFile: CiphFile): Promise<string> => {
const pinataJWT = import.meta.env.VITE_PINATA_JWT as string;
const PINATA_API_URL = "https://api.pinata.cloud/pinning/pinFileToIPFS";
const LOCAL_IPFS_URL = (import.meta.env.VITE_LOCAL_IPFS_URL || 'http://localhost:5001') as string;
Expand Down Expand Up @@ -187,7 +187,7 @@ export const uploadFileToIPFS = async (encryptedFile: EncryptedFile): Promise<st
};


export async function getEncryptedFileCidHash(cidHash: string): Promise<EncryptedFile> {
export async function getEncryptedFileCidHash(cidHash: string): Promise<CiphFile> {

try {
const response = await fetch(cidHash, {
Expand All @@ -201,7 +201,7 @@ export async function getEncryptedFileCidHash(cidHash: string): Promise<Encrypte
}

const data = await response.json();
return data as EncryptedFile;
return data as CiphFile;
} catch (error) {
console.error("Error fetching data:", error);
throw error;
Expand Down

0 comments on commit 7b12ff5

Please sign in to comment.