メインコンテンツまでスキップ

アカウント

患者とプロバイダーはレジストリスマートコントラクトに登録でき、デバイスを作成してそのデバイスを使用して登録します。1つのアカウントは複数のデバイスを持つことができます。

DEVICE
Device 1
ETH Wallet + NaCl Keypair
0x1a2b...3c4d
SMART CONTRACT
EDHAccountRegistry
registerAccount()
Factory
WALLET CONTRACT
EDHAccount
Multi-owner Wallet — Address, PublicKey
onlyActiveDeviceEIP-1271ERC-2771
DEVICES
DeviceA
PublicKeyA
active
DeviceB
PublicKeyB
register
derive
SEED VAULT
SeedVault
Encrypted SEED per device
DeviceA seed: nacl.box(SEED, pubKeyA)
DeviceB seed: nacl.box(SEED, pubKeyB)
Account Registration Flow

Blockchain Network

EDH Smart Contracts can be deployed on any EVM-compatible blockchain, such as Polygon, Ethereum, Base, Arbitrum, or other networks that support Solidity.

ItemDetails
NetworkEVM-compatible (Polygon, Ethereum, Base, etc.)
Contract StandardSolidity ^0.8.0
Meta-TransactionERC-2771 via EverTrustedForwarder

EDHAccountRegistry

レジストリコントラクトは、ブロックチェーン上の公開鍵データを管理するためのスマートコントラクトです。主な機能はアカウント登録であり、最初のアカウントとデバイスの公開鍵登録です。EDHAccountスマートコントラクトはブロックチェーン上に作成されます。

インターフェース:アカウント登録

contract EDHAccountRegistry {
event EDHAccountRegistered(address indexed _account, address indexed _device);

function precomputeAccountAddress(
bytes32 salt,
address device,
bytes32 accountEncryptionPubKey
) public view returns (address);

function registerAccount(
bytes32 salt,
bytes32 accountEncryptionPubKey,
bytes32 deviceEncryptionPubKey,
bytes calldata boxedDeviceName
) public returns (address _address);

}

Event EDHAccountRegistered : アカウント登録が成功したときに発生するイベントです。

precomputeAccountAddress : ユーザーアカウントのアドレスを事前に計算するためのビュー関数です。ブロックチェーンのトランザクション関数では結果を返せないため、この関数が作成されました。毎回ランダムに生成されるsalt値、デバイスのアドレス、登録するアカウントの公開鍵値に応じてアカウントアドレスを計算します。

registerAccount : スマートコントラクトの形式でEDHAccountアカウントを作成し、アカウントを作成したデバイスにアカウントを管理する権限を与えるトランザクション関数です。アカウント作成が成功すると、EDHAccountRegisteredイベントが生成されます。同じデバイスアドレス、ランダムなsalt、公開鍵を指定すると、precomputeAccountAddressの結果と同じアドレスにアカウントコントラクトが作成されます。

EDHAccount

EDHAccountは、EDHシステムにおけるユーザーアカウントを表すスマートコントラクトです。Multiowner Walletコントラクトと同様に機能し、デバイスオーナーのEthereumアカウントがEDHAccountを管理できます。

Walletコントラクトであるため、EDHAccountアカウントは将来的にBlockchainシステムとよく連携できます。例えば:

  • NFT、トークンなどのさまざまな資産を受け取るデスティネーションアカウントになれます。
  • 「EIP-1271:コントラクトの標準署名検証メソッド」を通じて署名を検証できます。

EDHAccountの主な機能は以下の通りです:

  • デバイス管理
  • アカウント公開鍵暗号化履歴の保存
  • 現在のデバイスによって署名された署名の検証。
  • 同一アカウントのすべてのデバイスの集中設定の保持。
  • アカウントを使用して他のスマートコントラクトと通信するための機能。

インターフェース:アカウント管理

contract EDHAccount {
event EDHAccountCreated(bytes32 accountPublicKey);
event EDHDeviceRegistered(address indexed device, bytes32 devicePublicKey, address approverDevice);
event EDHDeviceRevoked(address indexed device, bytes32 devicePublicKey, address approverDevice);
event EDHAccountKeyUpdated(address indexed device, bytes32 newPublicKey, bytes32 prevPublicKey);

function encryptionPublicKey() public view returns (bytes32 key);
function encryptionPublicKeys() public view returns (bytes32[] memory keys);

function isValidSignature(
bytes32 _hash, bytes memory _signature
) public view returns (bytes4 magicValue);

function isRevokedSignature(
bytes32 _hash, bytes memory _signature
) public view returns (bool);

function updateEncryptionPublicKey(bytes32 key) public onlyActiveDevice;

function registerDevice(
bytes32 accountEncryptionPubKey,
address deviceAddress,
bytes32 deviceEncryptionPubKey,
bytes memory deviceName
) public onlyActiveDevice;

function revokeDevice(address deviceAddress) public onlyActiveDevice;

function isActiveDevice(address _address) public view returns (bool);
function isRevokedDevice(address _address) public view returns (bool);

uint constant public DEVICE_STATUS_UNLINKED = 0;
uint constant public DEVICE_STATUS_ACTIVE = 1;
uint constant public DEVICE_STATUS_REVOKED = 2;
function getDeviceStatus(address _address) public view returns (uint);
function getActiveDevice(address _address) public view returns (DeviceItemView memory device);
function getActiveDevices() public view returns (DeviceItemView[] memory devices);
function getRevokedDevice(address _address) public view returns (DeviceItemView memory device);

function execute(address target, bytes memory callData) public onlyActiveDevice returns (bytes memory);
function multicall(bytes[] memory data) public returns (bytes[] memory results);

}

event EDHAccountCreated : このアカウントが作成されたときのイベントログです。

event EDHDeviceRegistered/EDHDeviceRevoked : 新しいデバイスがこのアカウントに登録されたとき、または古い機器が失効されたときのイベントです。

event EDHAccountKeyUpdated : アカウントの暗号化公開鍵が更新されたときのイベントログです。

registerDevice : アカウントを管理する権限を持つデバイスを追加し、アクティブなデバイスにするトランザクション関数です。

revokeDevice : アカウントを管理する権限を持つデバイスを失効させ、失効デバイスにするトランザクション関数です。

注記

デバイスの追加または削除は、EDHAccountアカウントを操作するデバイスのEthereumウォレット権限にのみ影響します。将来的にSeedVaultで更新する必要があるアカウントシークレットの共有には影響しません。

encryptionPublicKey/encryptionPublicKeys : アカウントの現在の公開鍵とすべての過去の公開鍵のリストを返すビュー関数です。

updateEncryptionPublicKey : 最新の公開鍵を更新するための関数です。

isActiveDevice/isRevokedDevice : EDHAccountアカウントにリンクされたデバイスのステータスを確認するビュー関数です。

getActiveDevices/getRevokedDevices : アカウントにリンクされたデバイスの情報(Ethereumアカウントアドレス、デバイス間の接続を暗号化するための公開鍵など)を表示するビュー関数です。

isValidSignature/isRevokedSignature : デジタル署名がアカウントに関連付けられたデバイスに属しているかどうかを確認するビュー関数です。

execute/multicall : デバイスがアカウントに別のトランザクションの実行を指示するトランザクション関数です。スマートコントラクトアカウントがシステム内の他のスマートコントラクト関数を呼び出せるようにし、アカウントがデバイスエージェントとして機能することを可能にします。

アカウント定数データの保存と読み取りのための関数もあります。これについてはファイルストレージセクションで説明します。

BioAnchorRegistry

BioAnchorRegistry is a smart contract for registering Biological Identity Attestation (BIA) commitments on the blockchain. It uses Poseidon hashing to bind a did:bio Decentralized Identifier to the user's genomic identity.

Key features:

  • One anchor per address: Each Ethereum address can register only one genomic commitment.
  • Sybil resistance: Prevents a single person from creating multiple identities.
  • Assurance levels 0--3: Ranging from self-attested to multi-source lab verification.
  • Revocation: Can be revoked if data is compromised.

For details on the Solidity interface and gas costs, see BioAnchorRegistry.

Meta-Transaction (ERC-2771)

EDH Smart Contracts support ERC-2771 Meta-Transactions via EverTrustedForwarder, allowing users to interact without paying gas fees themselves.

How It Works

  1. The user signs a message digest according to the EIP-712 Typed Data standard using the device's private key.
  2. The application sends the signed message to Ever's Gas Payer Service.
  3. The Gas Payer Service submits the transaction through the EverTrustedForwarder contract.
  4. The Forwarder verifies the signature and forwards the call to the EDH contract, appending the real user's address.
  5. The EDH contract uses msg.sender from the forwarder context to verify permissions.

ByAdmin Functions

Functions called via meta-transaction include an additional signature parameter, which is an EIP-712 signed message digest containing:

  • The function call data to be executed
  • The account owner's address
  • A nonce to prevent replay attacks

For details about the Gas Payer Wallet, see Ever Services.

Account Recovery

If a user loses all their devices, the account can be recovered using a backup SEED.

Recovery Steps

  1. Create a new device: Generate a new Ethereum keypair and NaCl keypair on the new device.
  2. Import the backup SEED: Use the backed-up SEED (32 bytes) to derive the account's central keys.
  3. Register the new device: Call registerDevice on the EDHAccount contract (at least one active device is required).
  4. Update the SeedVault: Add the encrypted SEED for the new device to the SeedVault.
危険

If all active devices are lost and there is no backup SEED, account recovery is impossible. Users should always store their SEED in a safe place, such as written on paper and kept in a secure safe.

Emergency Guardian

Users can designate an Emergency Guardian, which is another EDH account authorized to help recover data access. If the account owner cannot access their data, the Emergency Guardian can approve the registration of a new device through a social recovery mechanism.

Estimated Gas Costs

Actual costs depend on the chosen network. Below are approximate gas estimates:

OperationGas (approx.)
registerAccount~200,000
registerDevice~100,000
revokeDevice~50,000
updateEncryptionPublicKey~45,000
execute~60,000+
setDataBytes~60,000

See Also