> For the complete documentation index, see [llms.txt](https://alien-3.gitbook.io/alien/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alien-3.gitbook.io/alien/alienheyoukoso/aliennosekyuritikitekucha/onchn.md).

# オンチェーン暗号化

オンチェーン暗号化は、ブロックチェーン技術を利用してメッセージの伝送および保存過程を記録および検証し、データの改ざん防止と透明性を保証します。

* ブロックチェーン記録：各メッセージのハッシュ値およびメタデータ（タイムスタンプ、送信者および受信者のIDなど）はブロックチェーンに記録され、不変のログを形成します。
* スマートコントラクト：スマートコントラクトを使用してデータ伝送過程を管理および検証し、データの完全性と真正性を確保します。

// Example: On-Chain Records

import { ethers } from 'ethers';

const provider = new ethers.providers.JsonRpcProvider('<http://localhost:8545>');

const contractAddress = '0xYourContractAddress';

const abi = \[

&#x20; // contract ABI

];

const contract = new ethers.Contract(contractAddress, abi, provider);

<br>

// Storing Message Hashes

async function storeMessageHash(hash) {

&#x20; const signer = provider.getSigner();

&#x20; const tx = await contract.connect(signer).storeMessageHash(hash);

&#x20; await tx.wait();

&#x20; console.log('Message hash stored on blockchain');

}
