diff --git a/Images/image-20231222153440403.png b/Images/image-20231222153440403.png new file mode 100644 index 0000000..17b8e29 Binary files /dev/null and b/Images/image-20231222153440403.png differ diff --git a/Images/image-20231222153453821.png b/Images/image-20231222153453821.png new file mode 100644 index 0000000..b0220d6 Binary files /dev/null and b/Images/image-20231222153453821.png differ diff --git a/README.md b/README.md index 223a3ee..577a9de 100644 --- a/README.md +++ b/README.md @@ -236,19 +236,147 @@ https://github.com/rchak007/plutusAppsJambhala/blob/main/src/Deploy.hs -### OffChain Code +### OffChain Encryption Lucid Code +https://github.com/rchak007/decentralSeedRecover/blob/main/pages/offChainV2.tsx +#### Parameterize the script +Gets the personal info from UI and applies the hash to Plutus script. +```typescript +const decentralSeedPlutus = "59087f5908...." + + const paramInit : Params = [{ + pInfoHash: fromText(hashedDataInString) + }]; + + + const sValidator : SpendingValidator = { + type: "PlutusV2", + script: applyParamsToScript( + decentralSeedPlutus, + paramInit, + Params, + ), + } + +``` + + + +#### Encrypt SeedPhrase into Datum + + + +```typescript + seed23Words = seed23InputValue + ' ' + indexInputValue; + passPhrase = passPhraseinputValue; + + const encryptedS = encryptD( seed23Words, passPhrase) + // const encryptedS = encryptSeedPassInfo( seed23Words, passPhrase); + console.log("encryptedS = ", encryptedS) + // const encryptedString = String(encryptedS) + const encryptedString = "testSample1" + + const datumInit : MyDatum = + { + encryptedWordsWithIndex: fromText(encryptedS) , + ownerPKH: paymentCredential?.hash! // pubkey hash + }; +``` + + + +#### Create UTXO with datum + + + +```typescript + const tx = await lucid.newTx() + .payToContract(sValAddress, {inline: Data.to( datumInit, MyDatum)}, {lovelace: BigInt(2000000)}) + .complete(); + const signedTx = await tx.sign().complete(); + const txHash = await signedTx.submit(); + console.log("Lock Test TxHash: " + txHash) + settxHash(txHash); + return txHash; +``` + + + + + +### OffChain Decryption Lucid Code +#### Get script address +Gets the personal info from UI and applies the hash to Plutus script to get the script address where UTXO is stored + +```typescript +const decentralSeedPlutus = "59087f5908...." + + const paramInit : Params = [{ + pInfoHash: fromText(hashedDataInString) + }]; + + + const sValidator : SpendingValidator = { + type: "PlutusV2", + script: applyParamsToScript( + decentralSeedPlutus, + paramInit, + Params, + ), + } + +``` + + + +#### Get Datum that has encryption + +```typescript +console.log("UTXOs length = ", valUtxos.length) + for ( let i=0; i