diff --git a/.gitignore b/.gitignore index 38e5445..fdb30b8 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ yarn-error.log* # Storacha proof and keys .storacha +encrypted_proof.bin.test diff --git a/dapp/encrypted_proof.bin b/dapp/encrypted_proof.bin index 34dec10..bb71be7 100644 --- a/dapp/encrypted_proof.bin +++ b/dapp/encrypted_proof.bin @@ -1,6 +1,6 @@ { - "nonce": "p0V6xMr0gyaDanKoJOmxEQ==", - "header": "c3RvcmFjaGFQcm9vZg==", - "ciphertext": "0DaT2IcvtPI5ptfSGfN4dve0tZlL1XyVd0FEi8LFk1ZBmRoidvO5x3pckKUv/xh1teCohg5eI7JXM8ttrOm2h/kNUbCT83+rPRKQtaCMHOMCaYBQ/QoDYSR+Y0M+fyYDCYG1dLynDxJJ9/04d/nbfFIK0mQANjTG4MVhDBz/BtTiUW6JUoOhvrypi1Y2P4CX0arm5/4oyrr6279Amc2HPERbT0C+9id6Qdx0C3GjIn6EyHXKyJDr43KYHuxa5jDcYB1g9Mr/NT5XRJ7hOpbdOee9OYfT+7RUvP2ElDSWkFfRUy3QMzQfREo5tnsKkGHnXpXfLYmGpVT80VBwgotiFZBrn3F+53azXYqFmoneVLcr4uLgUt+V+ztXUKEgRMes0Gdvh/qGgSGzYyhuAVlZTRV6eLGoKQ7IqtigMbUPKziUOoGRgNPC3Ow9kZQU9brqOYhGYv5h2UTLeXQljKu7Yl1PO5EXpC1Jrw9XSYoHMPR+5rwj/PxIYM1sYOI+zJ/AJcc7s314mCswQRBaN2rtXR41bG/iRHJYoHLKK3UxDpl2nade4Xd67eOMaXS+dZDPqZe9W3KrdkWJp+E59zyhfommDbl5Q/MuzAPtz5gFSruUiqzG9kXKs62QdtDNGUXk4A9vNQAI7fRWY6157XbW3lAqg/HufP2aWJmO4caYmPsRkDY4EzG344r09BWBk5PoiDAs1ZeROeWBUF0VMWtqv7ebXzX/3iNS497HZLKuhRrlkctDTC7vN+KZhKloBhze+kCyj6ljYoDABwjIo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SgKhr09Bnr0FXtrBcb1Yd0DwJo2fTIvD99rcNxW8DHk7L4VUUol6sUy3dt+/NX8u7ZVIjGiO3S8X06EaNPs9g92kTWyQ3vVgbW15GyaCax5jNPVaSVsqOgOdeLRMbdAweFVIKalnywxkyAhwahpidyd891kWAMe1M2hVkqOUPcuGAshITOoEFhrquM2isgwbrKFKPxYR1CKbI0fX7zjoWxMBbQNyMBOw==", + "tag": "tETKAp8LXBYe/fM8vmL5dg==" } \ No newline at end of file diff --git a/dapp/package.json b/dapp/package.json index 1a26de3..67b7a07 100644 --- a/dapp/package.json +++ b/dapp/package.json @@ -9,6 +9,7 @@ "@mdxeditor/editor": "^3.20.0", "@nanostores/react": "^0.8.2", "@stellar/stellar-sdk": "^13.0.0", + "@stellar/stellar-xdr-json": "^22.0.0-rc.1.1", "@web3-storage/w3up-client": "^16.5.2", "astro": "4.16.17", "astro-seo": "^0.8.4", @@ -16,6 +17,7 @@ "github-markdown-css": "^5.8.1", "install": "^0.13.0", "js-sha3": "^0.9.3", + "lossless-json": "^4.0.2", "markdown-to-jsx": "^7.7.1", "nanostores": "^0.11.3", "react18-json-view": "^0.2.8", diff --git a/dapp/src/components/page/governance/ProposalForm.tsx b/dapp/src/components/page/governance/ProposalForm.tsx index b104325..2b59e47 100644 --- a/dapp/src/components/page/governance/ProposalForm.tsx +++ b/dapp/src/components/page/governance/ProposalForm.tsx @@ -203,7 +203,6 @@ const ProposalForm: React.FC = () => { cause: delegation.error, }); } - console.log("Delegation successfully extracted from server"); const space = await client.addSpace(delegation.ok); @@ -249,7 +248,6 @@ const ProposalForm: React.FC = () => { } const directoryCid = await client.uploadDirectory(files); - console.log("Proposal successfully uploaded to IPFS"); if (!directoryCid) { alert("Failed to upload proposal"); diff --git a/dapp/src/components/page/proposal/ExecuteProposalModal.tsx b/dapp/src/components/page/proposal/ExecuteProposalModal.tsx index 8e0c78f..9264633 100644 --- a/dapp/src/components/page/proposal/ExecuteProposalModal.tsx +++ b/dapp/src/components/page/proposal/ExecuteProposalModal.tsx @@ -1,9 +1,10 @@ import React from "react"; import { useState, useEffect } from "react"; import JsonView from "react18-json-view"; -import { modifySlashInXdr, processDecodedData } from "utils/utils"; +import { modifySlashInXdr } from "utils/utils"; import { stellarLabViewXdrLink } from "constants/serviceLinks"; -import { demoOutcomeData } from "constants/demoProposalData"; +import * as StellarXdr from "utils/stellarXdr"; +import { parseToLosslessJson } from "utils/passToLosslessJson"; interface VotersModalProps { xdr: string; @@ -18,9 +19,8 @@ const VotersModal: React.FC = ({ xdr, onClose }) => { const getContentFromXdr = async (_xdr: string) => { try { if (_xdr) { - const decoded = processDecodedData(_xdr); - console.log("decode:", decoded); - setContent(demoOutcomeData); + const decoded = StellarXdr.decode("TransactionEnvelope", _xdr); + setContent(parseToLosslessJson(decoded)); } } catch (error) { console.error("Error decoding XDR:", error); diff --git a/dapp/src/components/page/proposal/ProposalDetail.tsx b/dapp/src/components/page/proposal/ProposalDetail.tsx index b2d6dfe..70ded54 100644 --- a/dapp/src/components/page/proposal/ProposalDetail.tsx +++ b/dapp/src/components/page/proposal/ProposalDetail.tsx @@ -1,19 +1,19 @@ import React from "react"; import { useState, useEffect } from "react"; +import * as StellarXdr from "utils/stellarXdr"; import Markdown from "markdown-to-jsx"; import "github-markdown-css"; import JsonView from "react18-json-view"; import "react18-json-view/src/style.css"; import { capitalizeFirstLetter, - processDecodedData, modifySlashInXdr, getProposalLinkFromIpfs, getOutcomeLinkFromIpfs, } from "utils/utils"; -import { demoOutcomeData } from "constants/demoProposalData"; import { stellarLabViewXdrLink } from "constants/serviceLinks"; import type { ProposalOutcome, ProposalViewStatus } from "types/proposal"; +import { parseToLosslessJson } from "utils/passToLosslessJson"; interface ProposalDetailProps { ipfsLink: string | null; description: string; @@ -27,6 +27,17 @@ const ProposalDetail: React.FC = ({ outcome, status, }) => { + const [isReady, setIsReady] = useState(false); + + useEffect(() => { + const init = async () => { + await StellarXdr.initialize(); + setIsReady(true); + }; + + init(); + }, []); + return (
@@ -91,6 +102,7 @@ const ProposalDetail: React.FC = ({ type={key} detail={value} proposalStatus={status} + isXdrInit={isReady} /> ))}
@@ -107,7 +119,8 @@ export const OutcomeDetail: React.FC<{ type: string; detail: { description: string; xdr: string }; proposalStatus: ProposalViewStatus | null; -}> = ({ type, detail, proposalStatus }) => { + isXdrInit: boolean; +}> = ({ type, detail, proposalStatus, isXdrInit }) => { const [content, setContent] = useState(null); const [isExpanded, setIsExpanded] = useState(false); @@ -117,10 +130,13 @@ export const OutcomeDetail: React.FC<{ const getContentFromXdr = async (_xdr: string) => { try { + if (!isXdrInit) { + return; + } + if (_xdr) { - const decoded = processDecodedData(_xdr); - console.log("decode:", decoded); - setContent(demoOutcomeData); + const decoded = StellarXdr.decode("TransactionEnvelope", _xdr); + setContent(parseToLosslessJson(decoded)); } } catch (error) { console.error("Error decoding XDR:", error); @@ -129,7 +145,7 @@ export const OutcomeDetail: React.FC<{ useEffect(() => { getContentFromXdr(detail.xdr); - }, [detail]); + }, [detail, isXdrInit]); return (
diff --git a/dapp/src/constants/demoProposalData.ts b/dapp/src/constants/demoProposalData.ts deleted file mode 100644 index 6bfff95..0000000 --- a/dapp/src/constants/demoProposalData.ts +++ /dev/null @@ -1,136 +0,0 @@ -export const demoOutcomeData: any = { - tx: { - tx: { - source_account: - "GBU764PFZXKZUORAUK3IG36Y6OXSLYM6ZERLJA2BZ2Y2GSKNKWL4KKC5", - fee: 5312486, - seq_num: 221608492723602976, - cond: { - time: { - min_time: 0, - max_time: 0, - }, - }, - memo: "none", - operations: [ - { - source_account: null, - body: { - invoke_host_function: { - host_function: { - invoke_contract: { - contract_address: - "CC5TSJ3E26YUYGYQKOBNJQLPX4XMUHUY7Q26JX53CJ2YUIZB5HVXXRV6", - function_name: "mine", - args: [ - { - bytes: - "000000ea80a23b9340abb81e22ebe2c84783896eab4ab047ebc006f9ca54fb66", - }, - { - string: "TANSU28", - }, - { - u64: 1188896, - }, - { - address: - "GBU764PFZXKZUORAUK3IG36Y6OXSLYM6ZERLJA2BZ2Y2GSKNKWL4KKC5", - }, - ], - }, - }, - auth: [ - { - credentials: "source_account", - root_invocation: { - function: { - contract_fn: { - contract_address: - "CC5TSJ3E26YUYGYQKOBNJQLPX4XMUHUY7Q26JX53CJ2YUIZB5HVXXRV6", - function_name: "mine", - args: [ - { - bytes: - "000000ea80a23b9340abb81e22ebe2c84783896eab4ab047ebc006f9ca54fb66", - }, - { - string: "TANSU28", - }, - { - u64: 1188896, - }, - { - address: - "GBU764PFZXKZUORAUK3IG36Y6OXSLYM6ZERLJA2BZ2Y2GSKNKWL4KKC5", - }, - ], - }, - }, - sub_invocations: [], - }, - }, - ], - }, - }, - }, - ], - ext: { - v1: { - ext: "v0", - resources: { - footprint: { - read_only: [ - { - contract_data: { - contract: - "CC2D4LQAWPMGD5A7XJHF5KN3A5QYJGQJS3VSFXR6TKTH6ZUR5RUFCYCW", - key: "ledger_key_contract_instance", - durability: "persistent", - }, - }, - ], - read_write: [ - { - trustline: { - account_id: - "GDNMPUEOS27LYEG4HS74RHLFWO325JMIDEAP67QOVYJBJC6XSGE4E5ST", - asset: { - credit_alphanum4: { - asset_code: "FCM", - issuer: - "GD765M4FIG4C4CGWUFDPD2QCWKISYRLBRIYMLSILCCTPY7DEGGUKPFBE", - }, - }, - }, - }, - { - contract_data: { - contract: - "CC5TSJ3E26YUYGYQKOBNJQLPX4XMUHUY7Q26JX53CJ2YUIZB5HVXXRV6", - key: { - vec: [ - { - symbol: "Block", - }, - { - u64: 4211, - }, - ], - }, - durability: "persistent", - }, - }, - ], - }, - instructions: 5000000, - read_bytes: 25000, - write_bytes: 1200, - }, - resource_fee: 5312386, - }, - }, - }, - signatures: [], - }, -}; diff --git a/dapp/src/pages/api/w3up-delegation.js b/dapp/src/pages/api/w3up-delegation.js index 5c13ad5..01226de 100644 --- a/dapp/src/pages/api/w3up-delegation.js +++ b/dapp/src/pages/api/w3up-delegation.js @@ -13,6 +13,7 @@ import { getProjectFromName, } from "@service/ReadContractService"; import crypto from "crypto"; +import decryptProof from "../../utils/decryptAES256"; import pkg from "js-sha3"; const { keccak256 } = pkg; @@ -86,11 +87,9 @@ const getProjectMaintainers = async (projectName) => { async function generateDelegation(did) { const key = import.meta.env.STORACHA_SING_PRIVATE_KEY; - const storachaProof = import.meta.env.STORACHA_PROOF; - + let storachaProof = import.meta.env.STORACHA_PROOF; if (storachaProof.length === 64) { - // storachaProof is a AES256 key in that case - return null; + storachaProof = await decryptProof(storachaProof); } const proof = await Proof.parse(storachaProof); @@ -117,11 +116,6 @@ async function generateDelegation(did) { expiration, }); - console.log( - "delegation expire time:", - new Date(delegation.expiration * 1000).toUTCString(), - ); - const archive = await delegation.archive(); return archive.ok; } diff --git a/dapp/src/types/types.ts b/dapp/src/types/types.ts new file mode 100644 index 0000000..aeb1c09 --- /dev/null +++ b/dapp/src/types/types.ts @@ -0,0 +1 @@ +export type AnyObject = { [key: string]: any }; diff --git a/dapp/src/utils/decryptAES256.ts b/dapp/src/utils/decryptAES256.ts new file mode 100644 index 0000000..0f30d90 --- /dev/null +++ b/dapp/src/utils/decryptAES256.ts @@ -0,0 +1,79 @@ +import { promises as fs } from "fs"; + +export default async function decryptProof(keyHex: string): Promise { + const key = await getKeyFromHex(keyHex); + const fileContent = await fs.readFile("encrypted_proof.bin", "utf-8"); + const payload: { + nonce: string; + header: string; + ciphertext: string; + tag: string; + } = JSON.parse(fileContent); + + const decrypted = await decryptData(key, payload); + return new TextDecoder().decode(decrypted); +} + +async function getKeyFromHex(keyHex: string): Promise { + const keyBytes = hexToArrayBuffer(keyHex); + const key = await globalThis.crypto.subtle.importKey( + "raw", + keyBytes, + { name: "AES-GCM", length: 256 }, + true, + ["encrypt", "decrypt"], + ); + + return key; +} + +function hexToArrayBuffer(hex: string): ArrayBuffer { + if (hex.length % 2 !== 0) { + throw new Error("Invalid hex string"); + } + const byteArray = new Uint8Array(hex.length / 2); + for (let i = 0; i < byteArray.length; i++) { + byteArray[i] = parseInt(hex.substr(i * 2, 2), 16); + } + return byteArray.buffer; +} + +function atob(base64: string): string { + return Buffer.from(base64, "base64").toString("binary"); +} + +function base64ToArrayBuffer(base64: string): ArrayBuffer { + const binaryString = atob(base64); + const bytes = new Uint8Array(binaryString.length); + for (let i = 0; i < binaryString.length; i++) { + bytes[i] = binaryString.charCodeAt(i); + } + return bytes.buffer; +} + +async function decryptData( + key: CryptoKey, + payload: { nonce: string; header: string; ciphertext: string; tag: string }, +): Promise { + const nonce = new Uint8Array(base64ToArrayBuffer(payload.nonce)); + const header = new Uint8Array(base64ToArrayBuffer(payload.header)); + const ciphertext = new Uint8Array(base64ToArrayBuffer(payload.ciphertext)); + const tag = new Uint8Array(base64ToArrayBuffer(payload.tag)); + + const encryptedCombined = new Uint8Array(ciphertext.length + tag.length); + encryptedCombined.set(ciphertext, 0); + encryptedCombined.set(tag, ciphertext.length); + + const decrypted = await globalThis.crypto.subtle.decrypt( + { + name: "AES-GCM", + iv: nonce, + additionalData: header, + tagLength: 128, + }, + key, + encryptedCombined.buffer, + ); + + return new Uint8Array(decrypted); +} diff --git a/dapp/src/utils/passToLosslessJson.ts b/dapp/src/utils/passToLosslessJson.ts new file mode 100644 index 0000000..c47beec --- /dev/null +++ b/dapp/src/utils/passToLosslessJson.ts @@ -0,0 +1,12 @@ +import { parse, isNumber } from "lossless-json"; +import type { AnyObject } from "../types/types"; + +export const parseToLosslessJson = (stringObj: string) => { + return parse(stringObj, null, (value: any) => { + if (isNumber(value)) { + return BigInt(value); + } + + return value; + }) as AnyObject; +}; diff --git a/dapp/src/utils/stellarXdr.ts b/dapp/src/utils/stellarXdr.ts new file mode 100644 index 0000000..1aeb858 --- /dev/null +++ b/dapp/src/utils/stellarXdr.ts @@ -0,0 +1,23 @@ +import init, { + decode, + decode_stream, + encode, + guess, +} from "@stellar/stellar-xdr-json"; +import wasmUrl from "@stellar/stellar-xdr-json/stellar_xdr_json_bg.wasm?url"; + +// A wrapper for the Stellar XDR JSON +declare global { + interface Window { + __STELLAR_XDR_INIT__?: boolean; + } +} + +const initialize = async () => { + if (!window.__STELLAR_XDR_INIT__) { + await init(wasmUrl); + window.__STELLAR_XDR_INIT__ = true; + } +}; + +export { initialize, decode, decode_stream, encode, guess }; diff --git a/tools/AES256-encrypt.js b/tools/AES256-encrypt.js new file mode 100644 index 0000000..af439f0 --- /dev/null +++ b/tools/AES256-encrypt.js @@ -0,0 +1,72 @@ +import { writeFileSync } from "fs"; +import { webcrypto } from "crypto"; + +const { subtle } = webcrypto; + +function arrayBufferToBase64(buffer) { + return Buffer.from(new Uint8Array(buffer)).toString("base64"); +} + +function arrayBufferToHex(buffer) { + const bytes = new Uint8Array(buffer); + return [...bytes].map((b) => b.toString(16).padStart(2, "0")).join(""); +} + +async function generateKey() { + return subtle.generateKey( + { + name: "AES-GCM", + length: 256, + }, + true, + ["encrypt", "decrypt"] + ); +} + +async function encryptData(key, data, header) { + // Generate a random nonce (12 bytes for AES-GCM) + const nonce = new Uint8Array(12); + webcrypto.getRandomValues(nonce); + + const encrypted = await subtle.encrypt( + { + name: "AES-GCM", + iv: nonce, + additionalData: header, + tagLength: 128, + }, + key, + data + ); + + const encryptedBytes = new Uint8Array(encrypted); + // Last 16 bytes are the authentication tag + const tag = encryptedBytes.slice(encryptedBytes.length - 16); + const ciphertext = encryptedBytes.slice(0, encryptedBytes.length - 16); + + return { + nonce: arrayBufferToBase64(nonce.buffer), + header: arrayBufferToBase64(header.buffer), + ciphertext: arrayBufferToBase64(ciphertext.buffer), + tag: arrayBufferToBase64(tag.buffer), + }; +} + +async function getKeyHex(key) { + const rawKey = await subtle.exportKey("raw", key); + return arrayBufferToHex(rawKey); +} + +(async () => { + const data = new TextEncoder().encode("This is some secret data..."); // This is our data to encrypt. + const header = new TextEncoder().encode("storachaProof"); + + const key = await generateKey(); + const keyHex = await getKeyHex(key); + console.log("This is our key in hex:", keyHex); + + const payload = await encryptData(key, data, header); + + writeFileSync("encrypted_proof.bin", JSON.stringify(payload, null, 4), "utf8"); + console.log("Encrypted data written to encrypted_proof.bin"); +})();