Commit baab6821 authored by rayan.annabi's avatar rayan.annabi
Browse files

remis des uint32 car permet de payer moins de gas pour les fonctions (mais + de gas au déploiement)

parent 17d8c4be
......@@ -5,20 +5,18 @@ import "./ownable.sol";
contract Plateform is Ownable { // myOwnable va nous permettre de restreindre l'utilisation de certaines fonctions
// Nous n'utilisons plus safeMath, car dépassement de capcité pris en compte par défaut depuis Solitiy 0.8.0
// !!! regrouper les string et les uint à l'intérieur des structs permet d'optimiser les ressources
struct Transac { // Structure d'une transaction
uint idsp; // id du Service Provider que l'on souhaite utilisé
uint idtr; // id de la transaction
uint blocknumber; // numéro du bloc au moment de la transaction (utile pour le remboursement)
uint32 idsp; // id du Service Provider que l'on souhaite utilisé
uint32 idtr; // id de la transaction
uint32 blocknumber; // numéro du bloc au moment de la transaction (utile pour le remboursement)
string message; // représente la donnée qu'on veut signer.
bytes signature; // champs pour la signature
bytes32 hashMessage; // hash du message qui ne sera pas chiffrer
}
struct ServiceProvider { // Structure d'un Service Provider
uint id; //unique
uint32 id; //unique
string name;
string pubKey; // clé publique du SP
string noTel;
......@@ -27,7 +25,7 @@ contract Plateform is Ownable { // myOwnable va nous permettre de restreindre
//////////////AFFICHAGE//////////////////
struct DisplaySp { //
uint id; //unique //
uint32 id; //unique //
string name;
string noTel; //
} //
......@@ -39,32 +37,32 @@ contract Plateform is Ownable { // myOwnable va nous permettre de restreindre
DisplaySp[] private displaySp; // Seulement pour l'affichage
mapping (uint => address) transacToOwner;
mapping (address => uint) addressServiceProvider; // pour connaître l'adresse des services providers
mapping (uint32 => address) transacToOwner;
mapping (address => uint32) addressServiceProvider; // pour connaître l'adresse des services providers
uint id = 0; // Pour différencier les transactions
uint idSp = 1; // Pour différencier les ServiceProvider
uint32 id = 0; // Pour différencier les transactions
uint32 idSp = 1; // Pour différencier les ServiceProvider
uint frais = 0.001 ether; // Prix d'utlisation de la fonction fixé arbitrairement (environ 2.91 CHF)
uint duration = 2; // Nombre de blocs avant que le client puisse demander un remboursement.
uint32 duration = 2; // Nombre de blocs avant que le client puisse demander un remboursement.
// Évenements pour que le service provider sache qu'il a des Transactions a traiter
event NewTransac(uint indexed idsp, string message, uint id);
event NewTransac(uint32 indexed idsp, string message, uint32 id);
/****************************LISTE DE FONCTIONS*******************************************/
/*************************************************************************************** */
// Fonction payable pour l'utilisateur (il paye le service)
function payTransac (uint _idsp, string memory _message, bytes32 _messageHash) external payable {
function payTransac (uint32 _idsp, string memory _message, bytes32 _messageHash) external payable {
require(msg.value == frais); //vérification que la somme a bien été payé
require(services[_idsp - 1].id != 0);
transactions.push(Transac(_idsp, id, block.number, _message, "", _messageHash));
transactions.push(Transac(_idsp, id, uint32(block.number), _message, "", _messageHash));
transacToOwner[id] = msg.sender;
emit NewTransac(_idsp,_message,id); // émission de l'événement
id += 1; // nous n'utilisons plus safemath car solidity 0.8.4 gère les overflows par défaut
id += 1; // Nous n'utilisons plus safemath car solidity 0.8.4
}
function registrationSp(string memory _name, string memory _pubKey, string memory _noTel) external{ // Pour s'inscrire en tant que Service Provider.
......@@ -73,13 +71,14 @@ contract Plateform is Ownable { // myOwnable va nous permettre de restreindre
services.push(newService);
displaySp.push(DisplaySp(idSp,_name, _noTel)); // Seulement pour l'affichage
addressServiceProvider[msg.sender] = idSp; // important pour la sécurité
idSp += 1;
idSp += 1; // Utilisation de SafeMath pour éviter les dépassements
}
//fonction qui vérifie la signature puis l'envoie dans le champ "signature" de la transac et paye le SP
function registreSig(uint _idsp, uint _idtr, bytes memory sig) external{
function registreSig(uint32 _idsp, uint32 _idtr, bytes memory sig) external{
require(_idsp == addressServiceProvider[msg.sender]); // vérifie que l'appel de la fonction est fait par le vrai Service Provider
(uint8 v, bytes32 r, bytes32 s) = _split((sig));
//require(verifyHash(hash,v,r,s) == verifyHash(transactions[_idtr].hashMessage,v,r,s)); // vérifie que les bonnes données ont été signées
require(verifyHash(transactions[_idtr].hashMessage,v,r,s) == msg.sender); // Vérifie si la signature est valide
transactions[_idtr].signature = sig;
......@@ -105,7 +104,7 @@ contract Plateform is Ownable { // myOwnable va nous permettre de restreindre
}
// Fonction permettant au client de récupérer son argent si son message n'a pas été signé après un certains temps
function refund(uint _idtr) external { // Utilisation de external car pas utiliser par le smart contract et coûte moins cher en gas.
function refund(uint32 _idtr) external { // Utilisation de external car pas utiliser par le smart contract et coûte moins cher en gas.
//Checks-Effects-Interactions Pattern
require(transacToOwner[_idtr] == msg.sender); // vérifie que c'est le bon client
require(keccak256(abi.encodePacked(transactions[_idtr].signature)) == keccak256(abi.encodePacked(""))); // Vérifie qu'il n y a pas de signature
......@@ -119,35 +118,35 @@ contract Plateform is Ownable { // myOwnable va nous permettre de restreindre
}
// permet de récupérer l'id d'un service provider
function getIdsp(address _myaddr) external view returns (uint) { //les fonctions view ne coûtent rien en gas si appelé de l'exterieur
function getIdsp(address _myaddr) external view returns (uint32) { //les fonctions view ne coûtent rien en gas si appelé de l'exterieur
require(addressServiceProvider[_myaddr] != 0); // vérifie si la valeur existe dans le mapping
return addressServiceProvider[_myaddr];
}
function getSig(uint _idtr) external view returns (bytes memory) { // Pour récupérer la signature
function getSig(uint32 _idtr) external view returns (bytes memory) { // Pour récupérer la signature
require(transactions[_idtr].idsp == addressServiceProvider[msg.sender]);
return transactions[_idtr].signature;
}
// permet de récupérer le hash du messgae pour la vérification
function getMessageHash(uint _id) external view returns (bytes32) {
function getMessageHash(uint32 _id) external view returns (bytes32) {
return transactions[_id].hashMessage;
}
// permet de récupérer le message chiffrer d'une transaction
function getMessage(uint _id) external view returns (string memory) {
function getMessage(uint32 _id) external view returns (string memory) {
return transactions[_id].message;
}
// permet au client de récupérer sa signature
function getSignature(uint _id) external view returns (bytes memory) {
function getSignature(uint32 _id) external view returns (bytes memory) {
require(transacToOwner[_id] == msg.sender); // vérification du propriétaire.
return transactions[_id].signature;
}
function getListSp() external view returns (DisplaySp[] memory) { // Permet de lister tous les Services Provider inscrit
DisplaySp[] memory ret = new DisplaySp[](idSp - 1);
for (uint i = 0; i < idSp - 1; i++) {
for (uint32 i = 0; i < idSp - 1; i++) {
ret[i] = displaySp[i];
}
return ret;
......@@ -155,13 +154,13 @@ contract Plateform is Ownable { // myOwnable va nous permettre de restreindre
function getAll() external view returns (Transac[] memory) { // Permet de lister tous les Messages
Transac[] memory ret = new Transac[](id);
for (uint i = 0; i < id; i++) {
for (uint32 i = 0; i < id; i++) {
ret[i] = transactions[i];
}
return ret;
}
function getSp(uint _id) external view returns (string memory) { // Pour récupérer la clé publique du SP
function getSp(uint32 _id) external view returns (string memory) { // Pour récupérer la clé publique du SP
return services[_id].pubKey;
}
......@@ -169,21 +168,21 @@ contract Plateform is Ownable { // myOwnable va nous permettre de restreindre
return frais;
}
function getDuration() external view returns (uint){ // permet de savoir le nombre de blocs avant remboursement
function getDuration() external view returns (uint32){ // permet de savoir le nombre de blocs avant remboursement
return duration;
}
////////////////////// FONCTIONS ADMIN /////////////////////////////////
function setFrais(uint _frais) external onlyOwner { // permet au propriétaire(avec onlyowner) de changer le prix des frais
function setFrais(uint32 _frais) external onlyOwner { // permet au propriétaire(avec onlyowner) de changer le prix des frais
frais = _frais;
}
function setDuration(uint _duration) external onlyOwner { // permet au propriétaire(avec onlyowner) de changer le nombre de blocs avant remboursement
function setDuration(uint32 _duration) external onlyOwner { // permet au propriétaire(avec onlyowner) de changer le nombre de blocs avant remboursement
duration = _duration;
}
function deleteSP(uint _idSp) external onlyOwner { // permet de supprimer un Service Provider
function deleteSP(uint32 _idSp) external onlyOwner { // permet de supprimer un Service Provider
require(_idSp > 0);
require(services[_idSp - 1].id != 0);
delete services[_idSp - 1]; // On supprime le Service Provider
......@@ -193,5 +192,9 @@ contract Plateform is Ownable { // myOwnable va nous permettre de restreindre
// function getEth() external onlyOwner { // permet de retirer des ethers du contrat à l adresse "owner"
// payable(owner).transfer();
// }
}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"/home/rayan/bachelor/bachelor_project/provider/myclient/src/components/SetKey.js\",\n _s = $RefreshSig$();\n\nimport React, { useState } from 'react';\nimport { Button, Form, Badge, Alert } from \"react-bootstrap\";\nimport { ethers } from 'ethers';\nimport Plateform from '../contracts/Plateform.json';\nimport \"bootstrap/dist/css/bootstrap.min.css\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nvar CryptoJS = require(\"crypto-js\");\n\nvar forge = require('node-forge');\n\nlet addr;\nvar lock = true;\n\nconst SetKey = () => {\n _s();\n\n const contractAddress = '0xa4B885C34848b79A13Df1DeEA8A04847136f9913';\n const [defaultAccount, setDefaultAccount] = useState(\"...\");\n const [connButtonText, setConnButtonText] = useState('Se connecter');\n const [errorMessage, setErrorMessage] = useState(null);\n const [, setProvider] = useState(window.ethereum);\n const [, setSigner] = useState(null);\n const [contract, setContract] = useState(null);\n const [showAlert, setShowAlert] = useState(false);\n\n const connectWalletHandler = () => {\n if (window.ethereum) {\n window.ethereum.request({\n method: 'eth_requestAccounts'\n }).then(result => {\n accountChangedHandler(result[0]);\n setConnButtonText('Connecté au Wallet');\n });\n } else {\n setErrorMessage('Need to install MetaMask!');\n }\n };\n\n const accountChangedHandler = newAccount => {\n setDefaultAccount(newAccount);\n updateEthers();\n addr = newAccount;\n\n if (sessionStorage.getItem(newAccount + \"bl\") === \"false\") {\n lock = false; //bloque l'utilisation d'une nouvelle clée\n\n setShowAlert(true); // Pour l'alerte\n }\n };\n\n const updateEthers = () => {\n let tempProvider = new ethers.providers.Web3Provider(window.ethereum);\n setProvider(tempProvider);\n let tempSigner = tempProvider.getSigner();\n setSigner(tempSigner);\n let tempContract = new ethers.Contract(contractAddress, Plateform.abi, tempSigner);\n setContract(tempContract);\n };\n\n const setPrivateKey = event => {\n // permet de stocker une paire de clée de manière sécurisé\n if (contract != null) {\n event.preventDefault();\n console.log(lock);\n\n if (lock === true) {\n let privKey = event.target.key.value;\n let myPassphrase = event.target.passphrase.value; //Récupère la passphrase entré par le client\n\n const encryptedKey = CryptoJS.AES.encrypt(privKey, myPassphrase).toString(); //On chiffre la clé privé avec une passphrase\n\n var forgePrivateKey = forge.pki.privateKeyFromPem(privKey); // convert PEM-formatted private key to a Forge private key\n\n var forgePublicKey = forge.pki.setRsaPublicKey(forgePrivateKey.n, forgePrivateKey.e); // get a Forge public key from the Forge private key\n\n var publicKey = forge.pki.publicKeyToPem(forgePublicKey); // convert the Forge public key to a PEM-formatted public key\n\n sessionStorage.setItem(addr, encryptedKey); // Stock la clée privée dans le local storage\n\n sessionStorage.setItem(addr + \"pb\", publicKey); // Stock la clée privée dans le local storage\n } else {\n console.log(\"Cette addresse à déjà été inscrite avec une autre clé\");\n setShowAlert(true); // Pour l'alerte\n }\n }\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"container bg-light\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"col-md-12 text-center\",\n children: [/*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 30\n }, this), /*#__PURE__*/_jsxDEV(\"h3\", {\n children: [\" Adresse du wallet : \", /*#__PURE__*/_jsxDEV(Badge, {\n bg: \"dark\",\n children: [defaultAccount, \" \"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 46\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n variant: \"dark\",\n onClick: connectWalletHandler,\n children: connButtonText\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 21\n }, this), showAlert && /*#__PURE__*/_jsxDEV(Alert, {\n variant: \"danger\",\n onClose: () => setShowAlert(false),\n dismissible: true,\n children: \"Impossible d'utiliser une autre cl\\xE9 pour cette adresse\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 94,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 30\n }, this), /*#__PURE__*/_jsxDEV(Form, {\n onSubmit: setPrivateKey,\n children: [/*#__PURE__*/_jsxDEV(Form.Group, {\n className: \"mb-3\",\n controlId: \"key\",\n children: [/*#__PURE__*/_jsxDEV(Form.Label, {\n children: \"Entrez votre cl\\xE9 priv\\xE9e RSA (format PEM):\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 101,\n columnNumber: 29\n }, this), /*#__PURE__*/_jsxDEV(Form.Control, {\n type: \"text\",\n placeholder: \"-----BEGIN PRIVATE KEY-----.....\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 102,\n columnNumber: 29\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(Form.Group, {\n className: \"mb-3\",\n controlId: \"passphrase\",\n children: [/*#__PURE__*/_jsxDEV(Form.Label, {\n children: \"Entrez une passphrase :\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 105,\n columnNumber: 29\n }, this), /*#__PURE__*/_jsxDEV(Form.Control, {\n type: \"text\",\n placeholder: \"Ma passphrase ...\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 106,\n columnNumber: 29\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 104,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n variant: \"dark\",\n type: \"submit\",\n children: \" Stocker une cl\\xE9 priv\\xE9 \"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 108,\n columnNumber: 25\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 99,\n columnNumber: 21\n }, this), errorMessage]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 17\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 9\n }, this);\n};\n\n_s(SetKey, \"p+0uYoJo35sTPY6tHa+TdwdntuA=\");\n\n_c = SetKey;\nexport default SetKey;\n\nvar _c;\n\n$RefreshReg$(_c, \"SetKey\");","map":{"version":3,"names":["React","useState","Button","Form","Badge","Alert","ethers","Plateform","CryptoJS","require","forge","addr","lock","SetKey","contractAddress","defaultAccount","setDefaultAccount","connButtonText","setConnButtonText","errorMessage","setErrorMessage","setProvider","window","ethereum","setSigner","contract","setContract","showAlert","setShowAlert","connectWalletHandler","request","method","then","result","accountChangedHandler","newAccount","updateEthers","sessionStorage","getItem","tempProvider","providers","Web3Provider","tempSigner","getSigner","tempContract","Contract","abi","setPrivateKey","event","preventDefault","console","log","privKey","target","key","value","myPassphrase","passphrase","encryptedKey","AES","encrypt","toString","forgePrivateKey","pki","privateKeyFromPem","forgePublicKey","setRsaPublicKey","n","e","publicKey","publicKeyToPem","setItem"],"sources":["/home/rayan/bachelor/bachelor_project/provider/myclient/src/components/SetKey.js"],"sourcesContent":["import React, {useState} from 'react'\nimport { Button, Form, Badge, Alert} from \"react-bootstrap\";\nimport { ethers } from 'ethers';\nimport Plateform from '../contracts/Plateform.json';\nimport \"bootstrap/dist/css/bootstrap.min.css\";\n\nvar CryptoJS = require(\"crypto-js\");\nvar forge = require('node-forge');\nlet addr;\nvar lock = true;\n\nconst SetKey = () => {\n\n const contractAddress = '0xa4B885C34848b79A13Df1DeEA8A04847136f9913';\n\n const [defaultAccount, setDefaultAccount] = useState(\"...\");\n const [connButtonText, setConnButtonText] = useState('Se connecter');\n const [errorMessage, setErrorMessage] = useState(null);\n const [, setProvider] = useState(window.ethereum);\n const [, setSigner] = useState(null);\n const [contract, setContract] = useState(null);\n const [showAlert, setShowAlert] = useState(false);\n\n const connectWalletHandler = () => {\n \n if (window.ethereum){\n window.ethereum.request({method: 'eth_requestAccounts'})\n .then(result => {\n accountChangedHandler(result[0]);\n setConnButtonText('Connecté au Wallet');\n })\n }else{\n setErrorMessage('Need to install MetaMask!');\n } \n }\n\n const accountChangedHandler = (newAccount) => {\n setDefaultAccount(newAccount);\n updateEthers();\n addr = newAccount;\n if(sessionStorage.getItem(newAccount + \"bl\") === \"false\"){\n lock = false; //bloque l'utilisation d'une nouvelle clée\n setShowAlert(true); // Pour l'alerte\n }\n }\n\n const updateEthers = () => { \n let tempProvider = new ethers.providers.Web3Provider(window.ethereum);\n setProvider(tempProvider);\n\n let tempSigner = tempProvider.getSigner();\n setSigner(tempSigner);\n\n let tempContract = new ethers.Contract(contractAddress, Plateform.abi, tempSigner);\n setContract(tempContract);\n }\n\n\n const setPrivateKey = (event) => { // permet de stocker une paire de clée de manière sécurisé\n\n if(contract != null){\n event.preventDefault();\n console.log(lock);\n if(lock === true){\n\n let privKey = event.target.key.value;\n let myPassphrase = event.target.passphrase.value; //Récupère la passphrase entré par le client\n const encryptedKey = CryptoJS.AES.encrypt(privKey, myPassphrase).toString(); //On chiffre la clé privé avec une passphrase\n \n var forgePrivateKey = forge.pki.privateKeyFromPem(privKey); // convert PEM-formatted private key to a Forge private key\n var forgePublicKey = forge.pki.setRsaPublicKey(forgePrivateKey.n, forgePrivateKey.e);// get a Forge public key from the Forge private key\n var publicKey = forge.pki.publicKeyToPem(forgePublicKey);// convert the Forge public key to a PEM-formatted public key\n \n sessionStorage.setItem(addr, encryptedKey); // Stock la clée privée dans le local storage\n sessionStorage.setItem(addr + \"pb\", publicKey); // Stock la clée privée dans le local storage\n \n }else{\n console.log(\"Cette addresse à déjà été inscrite avec une autre clé\");\n setShowAlert(true); // Pour l'alerte\n }\n \n }\n }\n\n return (\n <div>\n <div className=\"container bg-light\">\n <div className=\"col-md-12 text-center\">\n <br></br><br></br>\n <h3> Adresse du wallet : <Badge bg=\"dark\">{defaultAccount} </Badge></h3>\n <Button variant=\"dark\" onClick={connectWalletHandler}>{connButtonText}</Button>\n <br></br>\n {showAlert && (\n <Alert variant=\"danger\" onClose={() => setShowAlert(false)} dismissible>\n Impossible d'utiliser une autre clé pour cette adresse\n </Alert>\n )}\n <br></br><br></br>\n <Form onSubmit={setPrivateKey}>\n <Form.Group className=\"mb-3\" controlId=\"key\">\n <Form.Label>Entrez votre clé privée RSA (format PEM):</Form.Label>\n <Form.Control type=\"text\" placeholder=\"-----BEGIN PRIVATE KEY-----.....\" />\n </Form.Group>\n <Form.Group className=\"mb-3\" controlId=\"passphrase\">\n <Form.Label>Entrez une passphrase :</Form.Label>\n <Form.Control type=\"text\" placeholder=\"Ma passphrase ...\" />\n </Form.Group>\n <Button variant=\"dark\" type={\"submit\"}> Stocker une clé privé </Button>\n </Form>\n {errorMessage}\n </div>\n </div>\n </div>\n )\n}\nexport default SetKey;"],"mappings":";;;AAAA,OAAOA,KAAP,IAAeC,QAAf,QAA8B,OAA9B;AACA,SAASC,MAAT,EAAiBC,IAAjB,EAAuBC,KAAvB,EAA8BC,KAA9B,QAA0C,iBAA1C;AACA,SAASC,MAAT,QAAuB,QAAvB;AACA,OAAOC,SAAP,MAAsB,6BAAtB;AACA,OAAO,sCAAP;;;AAEA,IAAIC,QAAQ,GAAGC,OAAO,CAAC,WAAD,CAAtB;;AACA,IAAIC,KAAK,GAAGD,OAAO,CAAC,YAAD,CAAnB;;AACA,IAAIE,IAAJ;AACA,IAAIC,IAAI,GAAG,IAAX;;AAEA,MAAMC,MAAM,GAAG,MAAM;EAAA;;EAEjB,MAAMC,eAAe,GAAG,4CAAxB;EAEA,MAAM,CAACC,cAAD,EAAiBC,iBAAjB,IAAsCf,QAAQ,CAAC,KAAD,CAApD;EACA,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,QAAC,IAAD,CAAM,KAAN;YAAY,SAAS,EAAC,MAAtB;YAA6B,SAAS,EAAC,YAAvC;YAAA,wBACI,QAAC,IAAD,CAAM,KAAN;cAAA;YAAA;cAAA;cAAA;cAAA;YAAA,QADJ,eAEI,QAAC,IAAD,CAAM,OAAN;cAAc,IAAI,EAAC,MAAnB;cAA0B,WAAW,EAAC;YAAtC;cAAA;cAAA;cAAA;YAAA,QAFJ;UAAA;YAAA;YAAA;YAAA;UAAA,QALJ,eASI,QAAC,MAAD;YAAQ,OAAO,EAAC,MAAhB;YAAuB,IAAI,EAAE,QAA7B;YAAA;UAAA;YAAA;YAAA;YAAA;UAAA,QATJ;QAAA;UAAA;UAAA;UAAA;QAAA,QAXJ,EAsBK5B,YAtBL;MAAA;QAAA;QAAA;QAAA;MAAA;IADJ;MAAA;MAAA;MAAA;IAAA;EADJ;IAAA;IAAA;IAAA;EAAA,QADJ;AA8BH,CAvGD;;GAAMN,M;;KAAAA,M;AAwGN,eAAeA,MAAf"},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"/home/rayan/bachelor/bachelor_project/provider/myclient/src/components/SetKey.js\",\n _s = $RefreshSig$();\n\nimport React, { useState } from 'react';\nimport { Button, Form, Badge, Alert } from \"react-bootstrap\";\nimport { ethers } from 'ethers';\nimport Plateform from '../contracts/Plateform.json';\nimport \"bootstrap/dist/css/bootstrap.min.css\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nvar CryptoJS = require(\"crypto-js\");\n\nvar forge = require('node-forge');\n\nlet addr;\nvar lock = true;\n\nconst SetKey = () => {\n _s();\n\n const contractAddress = '0x92f0f71Da9Cc09B998372dCB2aa8AFc0B69552eD';\n const [defaultAccount, setDefaultAccount] = useState(\"...\");\n const [connButtonText, setConnButtonText] = useState('Se connecter');\n const [errorMessage, setErrorMessage] = useState(null);\n const [, setProvider] = useState(window.ethereum);\n const [, setSigner] = useState(null);\n const [contract, setContract] = useState(null);\n const [showAlert, setShowAlert] = useState(false);\n\n const connectWalletHandler = () => {\n if (window.ethereum) {\n window.ethereum.request({\n method: 'eth_requestAccounts'\n }).then(result => {\n accountChangedHandler(result[0]);\n setConnButtonText('Connecté au Wallet');\n });\n } else {\n setErrorMessage('Need to install MetaMask!');\n }\n };\n\n const accountChangedHandler = newAccount => {\n setDefaultAccount(newAccount);\n updateEthers();\n addr = newAccount;\n\n if (sessionStorage.getItem(newAccount + \"bl\") === \"false\") {\n lock = false; //bloque l'utilisation d'une nouvelle clée\n\n setShowAlert(true); // Pour l'alerte\n }\n };\n\n const updateEthers = () => {\n let tempProvider = new ethers.providers.Web3Provider(window.ethereum);\n setProvider(tempProvider);\n let tempSigner = tempProvider.getSigner();\n setSigner(tempSigner);\n let tempContract = new ethers.Contract(contractAddress, Plateform.abi, tempSigner);\n setContract(tempContract);\n };\n\n const setPrivateKey = event => {\n // permet de stocker une paire de clée de manière sécurisé\n if (contract != null) {\n event.preventDefault();\n console.log(lock);\n\n if (lock === true) {\n let privKey = event.target.key.value;\n let myPassphrase = event.target.passphrase.value; //Récupère la passphrase entré par le client\n\n const encryptedKey = CryptoJS.AES.encrypt(privKey, myPassphrase).toString(); //On chiffre la clé privé avec une passphrase\n\n var forgePrivateKey = forge.pki.privateKeyFromPem(privKey); // convert PEM-formatted private key to a Forge private key\n\n var forgePublicKey = forge.pki.setRsaPublicKey(forgePrivateKey.n, forgePrivateKey.e); // get a Forge public key from the Forge private key\n\n var publicKey = forge.pki.publicKeyToPem(forgePublicKey); // convert the Forge public key to a PEM-formatted public key\n\n sessionStorage.setItem(addr, encryptedKey); // Stock la clée privée dans le local storage\n\n sessionStorage.setItem(addr + \"pb\", publicKey); // Stock la clée privée dans le local storage\n } else {\n console.log(\"Cette addresse à déjà été inscrite avec une autre clé\");\n setShowAlert(true); // Pour l'alerte\n }\n }\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"container bg-light\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"col-md-12 text-center\",\n children: [/*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 30\n }, this), /*#__PURE__*/_jsxDEV(\"h3\", {\n children: [\" Adresse du wallet : \", /*#__PURE__*/_jsxDEV(Badge, {\n bg: \"dark\",\n children: [defaultAccount, \" \"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 46\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n variant: \"dark\",\n onClick: connectWalletHandler,\n children: connButtonText\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 21\n }, this), showAlert && /*#__PURE__*/_jsxDEV(Alert, {\n variant: \"danger\",\n onClose: () => setShowAlert(false),\n dismissible: true,\n children: \"Impossible d'utiliser une autre cl\\xE9 pour cette adresse\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 94,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 30\n }, this), /*#__PURE__*/_jsxDEV(Form, {\n onSubmit: setPrivateKey,\n children: [/*#__PURE__*/_jsxDEV(Form.Group, {\n className: \"mb-3\",\n controlId: \"key\",\n children: [/*#__PURE__*/_jsxDEV(Form.Label, {\n children: \"Entrez votre cl\\xE9 priv\\xE9e RSA (format PEM):\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 101,\n columnNumber: 29\n }, this), /*#__PURE__*/_jsxDEV(Form.Control, {\n type: \"text\",\n placeholder: \"-----BEGIN PRIVATE KEY-----.....\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 102,\n columnNumber: 29\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(Form.Group, {\n className: \"mb-3\",\n controlId: \"passphrase\",\n children: [/*#__PURE__*/_jsxDEV(Form.Label, {\n children: \"Entrez une passphrase :\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 105,\n columnNumber: 29\n }, this), /*#__PURE__*/_jsxDEV(Form.Control, {\n type: \"text\",\n placeholder: \"Ma passphrase ...\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 106,\n columnNumber: 29\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 104,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n variant: \"dark\",\n type: \"submit\",\n children: \" Stocker une cl\\xE9 priv\\xE9 \"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 108,\n columnNumber: 25\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 99,\n columnNumber: 21\n }, this), errorMessage]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 17\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 9\n }, this);\n};\n\n_s(SetKey, \"p+0uYoJo35sTPY6tHa+TdwdntuA=\");\n\n_c = SetKey;\nexport default SetKey;\n\nvar _c;\n\n$RefreshReg$(_c, \"SetKey\");","map":{"version":3,"names":["React","useState","Button","Form","Badge","Alert","ethers","Plateform","CryptoJS","require","forge","addr","lock","SetKey","contractAddress","defaultAccount","setDefaultAccount","connButtonText","setConnButtonText","errorMessage","setErrorMessage","setProvider","window","ethereum","setSigner","contract","setContract","showAlert","setShowAlert","connectWalletHandler","request","method","then","result","accountChangedHandler","newAccount","updateEthers","sessionStorage","getItem","tempProvider","providers","Web3Provider","tempSigner","getSigner","tempContract","Contract","abi","setPrivateKey","event","preventDefault","console","log","privKey","target","key","value","myPassphrase","passphrase","encryptedKey","AES","encrypt","toString","forgePrivateKey","pki","privateKeyFromPem","forgePublicKey","setRsaPublicKey","n","e","publicKey","publicKeyToPem","setItem"],"sources":["/home/rayan/bachelor/bachelor_project/provider/myclient/src/components/SetKey.js"],"sourcesContent":["import React, {useState} from 'react'\nimport { Button, Form, Badge, Alert} from \"react-bootstrap\";\nimport { ethers } from 'ethers';\nimport Plateform from '../contracts/Plateform.json';\nimport \"bootstrap/dist/css/bootstrap.min.css\";\n\nvar CryptoJS = require(\"crypto-js\");\nvar forge = require('node-forge');\nlet addr;\nvar lock = true;\n\nconst SetKey = () => {\n\n const contractAddress = '0x92f0f71Da9Cc09B998372dCB2aa8AFc0B69552eD';\n\n const [defaultAccount, setDefaultAccount] = useState(\"...\");\n const [connButtonText, setConnButtonText] = useState('Se connecter');\n const [errorMessage, setErrorMessage] = useState(null);\n const [, setProvider] = useState(window.ethereum);\n const [, setSigner] = useState(null);\n const [contract, setContract] = useState(null);\n const [showAlert, setShowAlert] = useState(false);\n\n const connectWalletHandler = () => {\n \n if (window.ethereum){\n window.ethereum.request({method: 'eth_requestAccounts'})\n .then(result => {\n accountChangedHandler(result[0]);\n setConnButtonText('Connecté au Wallet');\n })\n }else{\n setErrorMessage('Need to install MetaMask!');\n } \n }\n\n const accountChangedHandler = (newAccount) => {\n setDefaultAccount(newAccount);\n updateEthers();\n addr = newAccount;\n if(sessionStorage.getItem(newAccount + \"bl\") === \"false\"){\n lock = false; //bloque l'utilisation d'une nouvelle clée\n setShowAlert(true); // Pour l'alerte\n }\n }\n\n const updateEthers = () => { \n let tempProvider = new ethers.providers.Web3Provider(window.ethereum);\n setProvider(tempProvider);\n\n let tempSigner = tempProvider.getSigner();\n setSigner(tempSigner);\n\n let tempContract = new ethers.Contract(contractAddress, Plateform.abi, tempSigner);\n setContract(tempContract);\n }\n\n\n const setPrivateKey = (event) => { // permet de stocker une paire de clée de manière sécurisé\n\n if(contract != null){\n event.preventDefault();\n console.log(lock);\n if(lock === true){\n\n let privKey = event.target.key.value;\n let myPassphrase = event.target.passphrase.value; //Récupère la passphrase entré par le client\n const encryptedKey = CryptoJS.AES.encrypt(privKey, myPassphrase).toString(); //On chiffre la clé privé avec une passphrase\n \n var forgePrivateKey = forge.pki.privateKeyFromPem(privKey); // convert PEM-formatted private key to a Forge private key\n var forgePublicKey = forge.pki.setRsaPublicKey(forgePrivateKey.n, forgePrivateKey.e);// get a Forge public key from the Forge private key\n var publicKey = forge.pki.publicKeyToPem(forgePublicKey);// convert the Forge public key to a PEM-formatted public key\n \n sessionStorage.setItem(addr, encryptedKey); // Stock la clée privée dans le local storage\n sessionStorage.setItem(addr + \"pb\", publicKey); // Stock la clée privée dans le local storage\n \n }else{\n console.log(\"Cette addresse à déjà été inscrite avec une autre clé\");\n setShowAlert(true); // Pour l'alerte\n }\n \n }\n }\n\n return (\n <div>\n <div className=\"container bg-light\">\n <div className=\"col-md-12 text-center\">\n <br></br><br></br>\n <h3> Adresse du wallet : <Badge bg=\"dark\">{defaultAccount} </Badge></h3>\n <Button variant=\"dark\" onClick={connectWalletHandler}>{connButtonText}</Button>\n <br></br>\n {showAlert && (\n <Alert variant=\"danger\" onClose={() => setShowAlert(false)} dismissible>\n Impossible d'utiliser une autre clé pour cette adresse\n </Alert>\n )}\n <br></br><br></br>\n <Form onSubmit={setPrivateKey}>\n <Form.Group className=\"mb-3\" controlId=\"key\">\n <Form.Label>Entrez votre clé privée RSA (format PEM):</Form.Label>\n <Form.Control type=\"text\" placeholder=\"-----BEGIN PRIVATE KEY-----.....\" />\n </Form.Group>\n <Form.Group className=\"mb-3\" controlId=\"passphrase\">\n <Form.Label>Entrez une passphrase :</Form.Label>\n <Form.Control type=\"text\" placeholder=\"Ma passphrase ...\" />\n </Form.Group>\n <Button variant=\"dark\" type={\"submit\"}> Stocker une clé privé </Button>\n </Form>\n {errorMessage}\n </div>\n </div>\n </div>\n )\n}\nexport default SetKey;"],"mappings":";;;AAAA,OAAOA,KAAP,IAAeC,QAAf,QAA8B,OAA9B;AACA,SAASC,MAAT,EAAiBC,IAAjB,EAAuBC,KAAvB,EAA8BC,KAA9B,QAA0C,iBAA1C;AACA,SAASC,MAAT,QAAuB,QAAvB;AACA,OAAOC,SAAP,MAAsB,6BAAtB;AACA,OAAO,sCAAP;;;AAEA,IAAIC,QAAQ,GAAGC,OAAO,CAAC,WAAD,CAAtB;;AACA,IAAIC,KAAK,GAAGD,OAAO,CAAC,YAAD,CAAnB;;AACA,IAAIE,IAAJ;AACA,IAAIC,IAAI,GAAG,IAAX;;AAEA,MAAMC,MAAM,GAAG,MAAM;EAAA;;EAEjB,MAAMC,eAAe,GAAG,4CAAxB;EAEA,MAAM,CAACC,cAAD,EAAiBC,iBAAjB,IAAsCf,QAAQ,CAAC,KAAD,CAApD;EACA,MAAM,CAACgB,cAAD,EAAiBC,iBAAjB,IAAsCjB,QAAQ,CAAC,cAAD,CAApD;EACA,MAAM,CAACkB,YAAD,EAAeC,eAAf,IAAkCnB,QAAQ,CAAC,IAAD,CAAhD;EACA,MAAM,GAAGoB,WAAH,IAAkBpB,QAAQ,CAACqB,MAAM,CAACC,QAAR,CAAhC;EACA,MAAM,GAAGC,SAAH,IAAgBvB,QAAQ,CAAC,IAAD,CAA9B;EACA,MAAM,CAACwB,QAAD,EAAWC,WAAX,IAA0BzB,QAAQ,CAAC,IAAD,CAAxC;EACA,MAAM,CAAC0B,SAAD,EAAYC,YAAZ,IAA4B3B,QAAQ,CAAC,KAAD,CAA1C;;EAEA,MAAM4B,oBAA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XJ,EAsBK5B,YAtBL;MAAA;QAAA;QAAA;QAAA;MAAA;IADJ;MAAA;MAAA;MAAA;IAAA;EADJ;IAAA;IAAA;IAAA;EAAA,QADJ;AA8BH,CAvGD;;GAAMN,M;;KAAAA,M;AAwGN,eAAeA,MAAf"},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"/home/rayan/bachelor/bachelor_project/provider/myclient/src/components/SetKey.js\",\n _s = $RefreshSig$();\n\nimport React, { useState } from 'react';\nimport { Button, Form, Badge, Alert } from \"react-bootstrap\";\nimport { ethers } from 'ethers';\nimport Plateform from '../contracts/Plateform.json';\nimport \"bootstrap/dist/css/bootstrap.min.css\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nvar CryptoJS = require(\"crypto-js\");\n\nvar forge = require('node-forge');\n\nlet addr;\nvar lock = true;\n\nconst SetKey = () => {\n _s();\n\n const contractAddress = '0xf324cFd3e313F2BD32E4fA141E44771D5c1912AD';\n const [defaultAccount, setDefaultAccount] = useState(\"...\");\n const [connButtonText, setConnButtonText] = useState('Se connecter');\n const [errorMessage, setErrorMessage] = useState(null);\n const [, setProvider] = useState(window.ethereum);\n const [, setSigner] = useState(null);\n const [contract, setContract] = useState(null);\n const [showAlert, setShowAlert] = useState(false);\n\n const connectWalletHandler = () => {\n if (window.ethereum) {\n window.ethereum.request({\n method: 'eth_requestAccounts'\n }).then(result => {\n accountChangedHandler(result[0]);\n setConnButtonText('Connecté au Wallet');\n });\n } else {\n setErrorMessage('Need to install MetaMask!');\n }\n };\n\n const accountChangedHandler = newAccount => {\n setDefaultAccount(newAccount);\n updateEthers();\n addr = newAccount;\n\n if (sessionStorage.getItem(newAccount + \"bl\") === \"false\") {\n lock = false; //bloque l'utilisation d'une nouvelle clée\n\n setShowAlert(true); // Pour l'alerte\n }\n };\n\n const updateEthers = () => {\n let tempProvider = new ethers.providers.Web3Provider(window.ethereum);\n setProvider(tempProvider);\n let tempSigner = tempProvider.getSigner();\n setSigner(tempSigner);\n let tempContract = new ethers.Contract(contractAddress, Plateform.abi, tempSigner);\n setContract(tempContract);\n };\n\n const setPrivateKey = event => {\n // permet de stocker une paire de clée de manière sécurisé\n if (contract != null) {\n event.preventDefault();\n console.log(lock);\n\n if (lock === true) {\n let privKey = event.target.key.value;\n let myPassphrase = event.target.passphrase.value; //Récupère la passphrase entré par le client\n\n const encryptedKey = CryptoJS.AES.encrypt(privKey, myPassphrase).toString(); //On chiffre la clé privé avec une passphrase\n\n var forgePrivateKey = forge.pki.privateKeyFromPem(privKey); // convert PEM-formatted private key to a Forge private key\n\n var forgePublicKey = forge.pki.setRsaPublicKey(forgePrivateKey.n, forgePrivateKey.e); // get a Forge public key from the Forge private key\n\n var publicKey = forge.pki.publicKeyToPem(forgePublicKey); // convert the Forge public key to a PEM-formatted public key\n\n sessionStorage.setItem(addr, encryptedKey); // Stock la clée privée dans le local storage\n\n sessionStorage.setItem(addr + \"pb\", publicKey); // Stock la clée privée dans le local storage\n } else {\n console.log(\"Cette addresse à déjà été inscrite avec une autre clé\");\n setShowAlert(true); // Pour l'alerte\n }\n }\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"container bg-light\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"col-md-12 text-center\",\n children: [/*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 30\n }, this), /*#__PURE__*/_jsxDEV(\"h3\", {\n children: [\" Adresse du wallet : \", /*#__PURE__*/_jsxDEV(Badge, {\n bg: \"dark\",\n children: [defaultAccount, \" \"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 46\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 90,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n variant: \"dark\",\n onClick: connectWalletHandler,\n children: connButtonText\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 92,\n columnNumber: 21\n }, this), showAlert && /*#__PURE__*/_jsxDEV(Alert, {\n variant: \"danger\",\n onClose: () => setShowAlert(false),\n dismissible: true,\n children: \"Impossible d'utiliser une autre cl\\xE9 pour cette adresse\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 94,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 98,\n columnNumber: 30\n }, this), /*#__PURE__*/_jsxDEV(Form, {\n onSubmit: setPrivateKey,\n children: [/*#__PURE__*/_jsxDEV(Form.Group, {\n className: \"mb-3\",\n controlId: \"key\",\n children: [/*#__PURE__*/_jsxDEV(Form.Label, {\n children: \"Entrez votre cl\\xE9 priv\\xE9e RSA (format PEM):\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 101,\n columnNumber: 29\n }, this), /*#__PURE__*/_jsxDEV(Form.Control, {\n type: \"text\",\n placeholder: \"-----BEGIN PRIVATE KEY-----.....\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 102,\n columnNumber: 29\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(Form.Group, {\n className: \"mb-3\",\n controlId: \"passphrase\",\n children: [/*#__PURE__*/_jsxDEV(Form.Label, {\n children: \"Entrez une passphrase :\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 105,\n columnNumber: 29\n }, this), /*#__PURE__*/_jsxDEV(Form.Control, {\n type: \"text\",\n placeholder: \"Ma passphrase ...\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 106,\n columnNumber: 29\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 104,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n variant: \"dark\",\n type: \"submit\",\n children: \" Stocker une cl\\xE9 priv\\xE9 \"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 108,\n columnNumber: 25\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 99,\n columnNumber: 21\n }, this), errorMessage]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 17\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 9\n }, this);\n};\n\n_s(SetKey, \"p+0uYoJo35sTPY6tHa+TdwdntuA=\");\n\n_c = SetKey;\nexport default SetKey;\n\nvar _c;\n\n$RefreshReg$(_c, \"SetKey\");","map":{"version":3,"names":["React","useState","Button","Form","Badge","Alert","ethers","Plateform","CryptoJS","require","forge","addr","lock","SetKey","contractAddress","defaultAccount","setDefaultAccount","connButtonText","setConnButtonText","errorMessage","setErrorMessage","setProvider","window","ethereum","setSigner","contract","setContract","showAlert","setShowAlert","connectWalletHandler","request","method","then","result","accountChangedHandler","newAccount","updateEthers","sessionStorage","getItem","tempProvider","providers","Web3Provider","tempSigner","getSigner","tempContract","Contract","abi","setPrivateKey","event","preventDefault","console","log","privKey","target","key","value","myPassphrase","passphrase","encryptedKey","AES","encrypt","toString","forgePrivateKey","pki","privateKeyFromPem","forgePublicKey","setRsaPublicKey","n","e","publicKey","publicKeyToPem","setItem"],"sources":["/home/rayan/bachelor/bachelor_project/provider/myclient/src/components/SetKey.js"],"sourcesContent":["import React, {useState} from 'react'\nimport { Button, Form, Badge, Alert} from \"react-bootstrap\";\nimport { ethers } from 'ethers';\nimport Plateform from '../contracts/Plateform.json';\nimport \"bootstrap/dist/css/bootstrap.min.css\";\n\nvar CryptoJS = require(\"crypto-js\");\nvar forge = require('node-forge');\nlet addr;\nvar lock = true;\n\nconst SetKey = () => {\n\n const contractAddress = '0xf324cFd3e313F2BD32E4fA141E44771D5c1912AD';\n\n const [defaultAccount, setDefaultAccount] = useState(\"...\");\n const [connButtonText, setConnButtonText] = useState('Se connecter');\n const [errorMessage, setErrorMessage] = useState(null);\n const [, setProvider] = useState(window.ethereum);\n const [, setSigner] = useState(null);\n const [contract, setContract] = useState(null);\n const [showAlert, setShowAlert] = useState(false);\n\n const connectWalletHandler = () => {\n \n if (window.ethereum){\n window.ethereum.request({method: 'eth_requestAccounts'})\n .then(result => {\n accountChangedHandler(result[0]);\n setConnButtonText('Connecté au Wallet');\n })\n }else{\n setErrorMessage('Need to install MetaMask!');\n } \n }\n\n const accountChangedHandler = (newAccount) => {\n setDefaultAccount(newAccount);\n updateEthers();\n addr = newAccount;\n if(sessionStorage.getItem(newAccount + \"bl\") === \"false\"){\n lock = false; //bloque l'utilisation d'une nouvelle clée\n setShowAlert(true); // Pour l'alerte\n }\n }\n\n const updateEthers = () => { \n let tempProvider = new ethers.providers.Web3Provider(window.ethereum);\n setProvider(tempProvider);\n\n let tempSigner = tempProvider.getSigner();\n setSigner(tempSigner);\n\n let tempContract = new ethers.Contract(contractAddress, Plateform.abi, tempSigner);\n setContract(tempContract);\n }\n\n\n const setPrivateKey = (event) => { // permet de stocker une paire de clée de manière sécurisé\n\n if(contract != null){\n event.preventDefault();\n console.log(lock);\n if(lock === true){\n\n let privKey = event.target.key.value;\n let myPassphrase = event.target.passphrase.value; //Récupère la passphrase entré par le client\n const encryptedKey = CryptoJS.AES.encrypt(privKey, myPassphrase).toString(); //On chiffre la clé privé avec une passphrase\n \n var forgePrivateKey = forge.pki.privateKeyFromPem(privKey); // convert PEM-formatted private key to a Forge private key\n var forgePublicKey = forge.pki.setRsaPublicKey(forgePrivateKey.n, forgePrivateKey.e);// get a Forge public key from the Forge private key\n var publicKey = forge.pki.publicKeyToPem(forgePublicKey);// convert the Forge public key to a PEM-formatted public key\n \n sessionStorage.setItem(addr, encryptedKey); // Stock la clée privée dans le local storage\n sessionStorage.setItem(addr + \"pb\", publicKey); // Stock la clée privée dans le local storage\n \n }else{\n console.log(\"Cette addresse à déjà été inscrite avec une autre clé\");\n setShowAlert(true); // Pour l'alerte\n }\n \n }\n }\n\n return (\n <div>\n <div className=\"container bg-light\">\n <div className=\"col-md-12 text-center\">\n <br></br><br></br>\n <h3> Adresse du wallet : <Badge bg=\"dark\">{defaultAccount} </Badge></h3>\n <Button variant=\"dark\" onClick={connectWalletHandler}>{connButtonText}</Button>\n <br></br>\n {showAlert && (\n <Alert variant=\"danger\" onClose={() => setShowAlert(false)} dismissible>\n Impossible d'utiliser une autre clé pour cette adresse\n </Alert>\n )}\n <br></br><br></br>\n <Form onSubmit={setPrivateKey}>\n <Form.Group className=\"mb-3\" controlId=\"key\">\n <Form.Label>Entrez votre clé privée RSA (format PEM):</Form.Label>\n <Form.Control type=\"text\" placeholder=\"-----BEGIN PRIVATE KEY-----.....\" />\n </Form.Group>\n <Form.Group className=\"mb-3\" controlId=\"passphrase\">\n <Form.Label>Entrez une passphrase :</Form.Label>\n <Form.Control type=\"text\" placeholder=\"Ma passphrase ...\" />\n </Form.Group>\n <Button variant=\"dark\" type={\"submit\"}> Stocker une clé privé </Button>\n </Form>\n {errorMessage}\n </div>\n </div>\n </div>\n )\n}\nexport default SetKey;"],"mappings":";;;AAAA,OAAOA,KAAP,IAAeC,QAAf,QAA8B,OAA9B;AACA,SAASC,MAAT,EAAiBC,IAAjB,EAAuBC,KAAvB,EAA8BC,KAA9B,QAA0C,iBAA1C;AACA,SAASC,MAAT,QAAuB,QAAvB;AACA,OAAOC,SAAP,MAAsB,6BAAtB;AAC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aAAhB;UAAA,wBACI,QAAC,IAAD,CAAM,KAAN;YAAY,SAAS,EAAC,MAAtB;YAA6B,SAAS,EAAC,KAAvC;YAAA,wBACI,QAAC,IAAD,CAAM,KAAN;cAAA;YAAA;cAAA;cAAA;cAAA;YAAA,QADJ,eAEI,QAAC,IAAD,CAAM,OAAN;cAAc,IAAI,EAAC,MAAnB;cAA0B,WAAW,EAAC;YAAtC;cAAA;cAAA;cAAA;YAAA,QAFJ;UAAA;YAAA;YAAA;YAAA;UAAA,QADJ,eAKI,QAAC,IAAD,CAAM,KAAN;YAAY,SAAS,EAAC,MAAtB;YAA6B,SAAS,EAAC,YAAvC;YAAA,wBACI,QAAC,IAAD,CAAM,KAAN;cAAA;YAAA;cAAA;cAAA;cAAA;YAAA,QADJ,eAEI,QAAC,IAAD,CAAM,OAAN;cAAc,IAAI,EAAC,MAAnB;cAA0B,WAAW,EAAC;YAAtC;cAAA;cAAA;cAAA;YAAA,QAFJ;UAAA;YAAA;YAAA;YAAA;UAAA,QALJ,eASI,QAAC,MAAD;YAAQ,OAAO,EAAC,MAAhB;YAAuB,IAAI,EAAE,QAA7B;YAAA;UAAA;YAAA;YAAA;YAAA;UAAA,QATJ;QAAA;UAAA;UAAA;UAAA;QAAA,QAXJ,EAsBK5B,YAtBL;MAAA;QAAA;QAAA;QAAA;MAAA;IADJ;MAAA;MAAA;MAAA;IAAA;EADJ;IAAA;IAAA;IAAA;EAAA,QADJ;AA8BH,CAvGD;;GAAMN,M;;KAAAA,M;AAwGN,eAAeA,MAAf"},"metadata":{},"sourceType":"module"}
\ No newline at end of file
{"ast":null,"code":"var _jsxFileName = \"/home/rayan/bachelor/bachelor_project/provider/myclient/src/components/Refund.js\",\n _s = $RefreshSig$();\n\nimport React, { useState } from 'react';\nimport { Button, Form, Badge, Alert } from \"react-bootstrap\";\nimport { ethers } from 'ethers';\nimport Plateform from '../contracts/Plateform.json';\nimport \"bootstrap/dist/css/bootstrap.min.css\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst Refund = () => {\n _s();\n\n const contractAddress = '0xf324cFd3e313F2BD32E4fA141E44771D5c1912AD';\n const [defaultAccount, setDefaultAccount] = useState(\"...\");\n const [connButtonText, setConnButtonText] = useState('Se connecter');\n const [errorMessage, setErrorMessage] = useState(null);\n const [provider, setProvider] = useState(window.ethereum);\n const [, setSigner] = useState(null);\n const [contract, setContract] = useState(null);\n const [showAlert, setShowAlert] = useState(false);\n const [currentContractVal, setCurrentContractVal] = useState(null);\n\n const connectWalletHandler = () => {\n if (window.ethereum) {\n window.ethereum.request({\n method: 'eth_requestAccounts'\n }).then(result => {\n accountChangedHandler(result[0]);\n setConnButtonText('Connecté au Wallet');\n });\n } else {\n setErrorMessage('Need to install MetaMask!');\n }\n };\n\n const accountChangedHandler = newAccount => {\n setDefaultAccount(newAccount);\n updateEthers();\n };\n\n const updateEthers = () => {\n let tempProvider = new ethers.providers.Web3Provider(window.ethereum);\n setProvider(tempProvider);\n let tempSigner = tempProvider.getSigner();\n setSigner(tempSigner);\n let tempContract = new ethers.Contract(contractAddress, Plateform.abi, tempSigner);\n setContract(tempContract);\n };\n\n const refund = async event => {\n // Pour demander un remboursement\n if (contract != null) {\n event.preventDefault();\n await contract.refund(event.target.id.value).catch(e => {\n // Si la transaction est annulée\n if (e.code === -32603 || e.code === 4001) {\n console.log(\"Remboursement échoué, Réessayer dans quelques instants\");\n setShowAlert(true); // Pour l'alerte\n }\n });\n }\n };\n\n const balance = async () => {\n //permet d'obtenir le solde du contract\n if (contract != null) {\n provider.getBalance(contractAddress).then(balance => {\n // convert a currency unit from wei to ether\n const balanceInEth = ethers.utils.formatEther(balance);\n setCurrentContractVal(balanceInEth + \" ETH\");\n });\n }\n };\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"container bg-light\",\n children: /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"col-md-12 text-center\",\n children: [/*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 77,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 77,\n columnNumber: 30\n }, this), /*#__PURE__*/_jsxDEV(\"h3\", {\n children: [\" Adresse du wallet : \", /*#__PURE__*/_jsxDEV(Badge, {\n bg: \"secondary\",\n children: [defaultAccount, \" \"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 78,\n columnNumber: 46\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 78,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n variant: \"secondary\",\n onClick: connectWalletHandler,\n children: connButtonText\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 79,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 80,\n columnNumber: 21\n }, this), showAlert && /*#__PURE__*/_jsxDEV(Alert, {\n variant: \"danger\",\n onClose: () => setShowAlert(false),\n dismissible: true,\n children: \"Remboursement impossible, R\\xE9essayer ult\\xE9rieurement\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 82,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 30\n }, this), /*#__PURE__*/_jsxDEV(Form, {\n onSubmit: refund,\n children: [/*#__PURE__*/_jsxDEV(Form.Group, {\n className: \"mb-2\",\n controlId: \"id\",\n children: /*#__PURE__*/_jsxDEV(Form.Control, {\n type: \"number\",\n placeholder: \"Entrer l'ID de la transaction dont vous souhaiter vous faire rembourser\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 89,\n columnNumber: 29\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 88,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n variant: \"secondary\",\n type: \"submit\",\n children: \" Remboursement \"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 91,\n columnNumber: 25\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 87,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 93,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 93,\n columnNumber: 30\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n variant: \"secondary\",\n onClick: balance,\n children: \" Solde du contrat \"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 94,\n columnNumber: 21\n }, this), /*#__PURE__*/_jsxDEV(\"h3\", {\n children: [\" \", currentContractVal]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 95,\n columnNumber: 25\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 96,\n columnNumber: 21\n }, this), errorMessage]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 76,\n columnNumber: 17\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 75,\n columnNumber: 13\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 74,\n columnNumber: 9\n }, this);\n};\n\n_s(Refund, \"hQSYwdyj2JrCdK1KpRn5FrFDfcU=\");\n\n_c = Refund;\nexport default Refund;\n\nvar _c;\n\n$RefreshReg$(_c, \"Refund\");","map":{"version":3,"names":["React","useState","Button","Form","Badge","Alert","ethers","Plateform","Refund","contractAddress","defaultAccount","setDefaultAccount","connButtonText","setConnButtonText","errorMessage","setErrorMessage","provider","setProvider","window","ethereum","setSigner","contract","setContract","showAlert","setShowAlert","currentContractVal","setCurrentContractVal","connectWalletHandler","request","method","then","result","accountChangedHandler","newAccount","updateEthers","tempProvider","providers","Web3Provider","tempSigner","getSigner","tempContract","Contract","abi","refund","event","preventDefault","target","id","value","catch","e","code","console","log","balance","getBalance","balanceInEth","utils","formatEther"],"sources":["/home/rayan/bachelor/bachelor_project/provider/myclient/src/components/Refund.js"],"sourcesContent":["import React, {useState} from 'react'\nimport { Button, Form, Badge, Alert} from \"react-bootstrap\";\nimport { ethers } from 'ethers';\nimport Plateform from '../contracts/Plateform.json';\nimport \"bootstrap/dist/css/bootstrap.min.css\";\n\nconst Refund = () => {\n\n const contractAddress = '0xf324cFd3e313F2BD32E4fA141E44771D5c1912AD';\n\n const [defaultAccount, setDefaultAccount] = useState(\"...\");\n const [connButtonText, setConnButtonText] = useState('Se connecter');\n const [errorMessage, setErrorMessage] = useState(null);\n const [provider, setProvider] = useState(window.ethereum);\n const [, setSigner] = useState(null);\n const [contract, setContract] = useState(null);\n const [showAlert, setShowAlert] = useState(false);\n const [currentContractVal, setCurrentContractVal] = useState(null);\n\n const connectWalletHandler = () => {\n \n if (window.ethereum){\n window.ethereum.request({method: 'eth_requestAccounts'})\n .then(result => {\n accountChangedHandler(result[0]);\n setConnButtonText('Connecté au Wallet');\n })\n }else{\n setErrorMessage('Need to install MetaMask!');\n } \n }\n\n const accountChangedHandler = (newAccount) => {\n setDefaultAccount(newAccount);\n updateEthers();\n }\n\n const updateEthers = () => { \n\n let tempProvider = new ethers.providers.Web3Provider(window.ethereum);\n setProvider(tempProvider);\n\n let tempSigner = tempProvider.getSigner();\n setSigner(tempSigner);\n\n let tempContract = new ethers.Contract(contractAddress, Plateform.abi, tempSigner);\n setContract(tempContract);\n }\n\n const refund = async (event) => { // Pour demander un remboursement\n if(contract != null){\n event.preventDefault();\n await contract.refund(event.target.id.value)\n .catch(e => { // Si la transaction est annulée\n if (e.code === -32603 || e.code === 4001){\n console.log(\"Remboursement échoué, Réessayer dans quelques instants\");\n setShowAlert(true); // Pour l'alerte\n } \n });\n }\n }\n\n const balance = async () => { //permet d'obtenir le solde du contract\n if(contract != null){\n provider.getBalance(contractAddress).then((balance) => {\n // convert a currency unit from wei to ether\n const balanceInEth = ethers.utils.formatEther(balance)\n setCurrentContractVal(balanceInEth + \" ETH\")\n })\n }\n }\n\n return (\n <div>\n <div className=\"container bg-light\">\n <div className=\"col-md-12 text-center\">\n <br></br><br></br>\n <h3> Adresse du wallet : <Badge bg=\"secondary\">{defaultAccount} </Badge></h3>\n <Button variant=\"secondary\" onClick={connectWalletHandler}>{connButtonText}</Button>\n <br></br>\n {showAlert && (\n <Alert variant=\"danger\" onClose={() => setShowAlert(false)} dismissible>\n Remboursement impossible, Réessayer ultérieurement\n </Alert>\n )}\n <br></br><br></br>\n <Form onSubmit={refund}>\n <Form.Group className=\"mb-2\" controlId=\"id\">\n <Form.Control type=\"number\" placeholder=\"Entrer l'ID de la transaction dont vous souhaiter vous faire rembourser\" />\n </Form.Group>\n <Button variant=\"secondary\" type=\"submit\"> Remboursement </Button>\n </Form>\n <br></br><br></br>\n <Button variant=\"secondary\" onClick={balance}> Solde du contrat </Button>\n <h3> {currentContractVal}</h3>\n <br></br>\n {errorMessage}\n </div>\n </div>\n </div>\n )\n}\nexport default Refund;"],"mappings":";;;AAAA,OAAOA,KAAP,IAAeC,QAAf,QAA8B,OAA9B;AACA,SAASC,MAAT,EAAiBC,IAAjB,EAAuBC,KAAvB,EAA8BC,KAA9B,QAA0C,iBAA1C;AACA,SAASC,MAAT,QAAuB,QAAvB;AACA,OAAOC,SAAP,MAAsB,6BAAtB;AACA,OAAO,sCAAP;;;AAEA,MAAMC,MAAM,GAAG,MAAM;EAAA;;EAEjB,MAAMC,eAAe,GAAG,4CAAxB;EAEA,MAAM,CAACC,cAAD,EAAiBC,iBAAjB,IAAsCV,QAAQ,CAAC,KAAD,CAApD;EACA,MAAM,CAACW,cAAD,EAAiBC,iBAAjB,IAAsCZ,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;AA6BH,CA/FD;;GAAMN,M;;KAAAA,M;AAgGN,eAAeA,MAAf"},"metadata":{},"sourceType":"module"}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment