Ethereum Name Service 백서

Ethereum Name Service

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 29쪽

oinType) >> 0 } ``` #### Implementation An implementation of this interface is provided in the [ensdomains/address-encoder](https://github.com/ensdomains/address-encoder/) repository. #### Example To compute the new coin type for EVM chains, call `convertEVMChainIdToCoinType(chainId)` ```javascript const encoder = require('@ensdomains/address-encoder') > encoder.convertEVMChainIdToCoinType(61) 2147483709 > encoder.convertCoinTypeToEVMChainId(2147483709) 61 ``` You can also use existing functions formatsByName and formatsByCoinType to derive these chain IDs ```javascript > encoder.formatsByName['XDAI'] { coinType: 2147483748, decoder: [Function (anonymous)], encoder: [Function (anonymous)], name: 'XDAI' } > encoder.formatsByCoinType[2147483748] { coinType: 2147483748, decoder: [Function (anonymous)], encoder: [Function (anonymous)], name: 'XDAI' } ``` #### Exceptions The following EVM chains are the exception to this standard. * AVAX = AVAX has multiple chain address formats, and only c chain is EVM compatible * RSK = RSK has its own additional validation They will continue using coinType defined at SLIP44 #### Backwards Compatibility The following EVM compatible cointypes existed before introducing this new standard. * NRG * POA * TT * CELO * CLO * TOMO * EWT * THETA * GO * FTM * XDAI * ETC When you display them for backward compatibility purposes, append `_LEGACY` to the cointype and make them read only. ### Copyright Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). import { EnsipHeader } from "../../components/EnsipHeader"; ## ENSIP-12: Avatar Text Records <EnsipHeader authors={["nick.eth","matoken.eth"]} created="January 18, 2022" status="final" /> A standard for storage of the avatar text record in ENS. ### Abstract This ENSIP defines a process for retrieving avatar URIs from ENS, several [URI](https://datatracker.ietf.org/doc/html/rfc3986) schemes for the ENS 'avatar' text field, and how they should be interpreted by clients wishing to display a user's avatar image. ### Motivation ENS primary name (formerly known as reverse record) has been widely integrated as a de facto web3 user name across many Ethereum based applications. As multiple apps started specifying avatar profile image as well as let users pick NFT as pfp (profile image), it became obvious to store such information within ENS so that the avatar information can be shared across different applications. This specification standardises a way to store and retrieve this information using [ENSIP-5: Text Records](https://docs.ens.domains/ensip/5) ### Specification #### Retrieving the avatar URI The process for retrieving the avatar URI depends on whether the client has an Ethereum address or an ENS name to start with. #### ENS Name To determine the avatar URI for an ENS name, the client MUST first look up the resolver for the name and call `.text(namehash(name), 'avatar')` on it to retrieve the avatar URI for the name. The client MUST treat the absence of a resolver, an revert when calling the `addr` method on the resolver, or an empty string returned by the resolver identically, as a failure to find a valid avatar URI. #### Ethereum Address To determine the avatar URI for an Ethereum address, the client MUST reverse-resolve the address by querying the ENS registry for the resolver of `&lt;address&gt;.addr.reverse`, where `&lt;address&gt;` is the lowercase hex-encoded Ethereum address, without leading '0x'. Then, the client calls `.text(namehash(&lt;address&gt;.addr.reverse'), 'avatar')` to retrieve the avatar URI for the address. If a resolver is returned for the reverse record, but calling `text` causes a revert or returns an empty string, the client MUST call `.name(namehash('&lt;address&gt;.addr.reverse'))`. If this method returns a valid ENS name, the client MUST: 1. Validate that the reverse record is valid, by resolving the returned name and calling `addr` on the resolver, checking it matches the original Ethereum address. 2. Perform the process described under 'ENS Name' to look for a valid avatar URI on the name. A failure at any step of this process MUST be treated by the client identically as a failure to find a valid avatar URI. #### General Format The 'avatar' text field MUST be formatted as a URI. Clients MUST ignore URI types they do not recognise, treating them the same as if no value was set for the field. #### Image Types Clients MUST support images with mime types of `image/jpeg`, `image/png`, and `image/svg+xml`. Clients MAY support additional image types. #### URI Types All clients SHOULD support the URI schemes defined below. They MAY implement additional schemes not defined in this specification. **`https`** If an https URI is provided, it MUST resolve to an avatar image directly. https URLs MUST NOT resolve to HTML pages, metadata, or other content containing the avatar image. **`ipfs`** If an [ipfs URI](https://docs.ipfs.io/how-to/address-ipfs-on-web/#native-urls) is provided, it MUST resolve to an avatar image directly. Clients without built-in IPFS support MAY rewrite the URI to an https URL referencing an IPFS gateway as described in [this document](https://docs.ipfs.io/how-to/address-ipfs-on-web/) before resolving it as an https URL. **`data`** If a [data URL](https://datatracker.ietf.org/doc/html/rfc2397) is provided, it MUST resolve to an avatar image directly. **NFTs** A reference to an NFT may be used as an avatar URI, following the standards defined in [CAIP-22](https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-22.md) and [CAIP-29](https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-29.md). Clients MUST support at least ERC721 and ERC1155 type NFTs, and MAY support additional types of NFT. To resolve an NFT URI, a client follows this process: 1. Retrieve the metadata URI for the token specified in the `avatar` field URI. 2. Resolve the metadata URI, fetching the ERC721 or ERC1155 metadata. 3. Extract the image URL specified in the NFT metadata. 4. Resolve the image URL and use it as the avatar. Clients MUST support at least `https` and `ipfs` URIs for resolving the metadata URI and the avatar image, and MAY support additional schemes. Clients MAY implement `ifps` scheme support by rewriting the URI to an HTTPS URL referencing an IPFS gateway as described above. Clients SHOULD additionally take the following verification steps: 1. Where the avatar URI was retrieved via forward resolution (starting from an ENS name), call the `addr` function on the same resolver and for the same name to retrieve the Ethereum address to which the name resolves. Otherwise, if the avatar URI was retrieved via reverse resolution (starting from an Ethereum address), use that address. 2. Verify that the address from step 1 is an owner of the NFT specified in the URI. If it is not, the client MUST treat the URI as invalid and behave in the same manner as they would if no avatar URI was specified. Clients MAY support NFT URIs by rewriting them to `https` URIs for a service that provides NFT avatar image resolution support. #### Examples The following examples all resolve to the same avatar image: ``` eip155:1/erc721:0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d/0 # BAYC token 0 ipfs://QmRRPWG96cmgTn2qSzjwr2qvfNEuhunv6FNeMFGa9bx6mQ # IPFS hash for BAYC token 0 image https://ipfs.io/ipfs/QmRRPWG96cmgTn2qSzjwr2qvfNEuhunv6FNeMFGa9bx6mQ # HTTPS URL to IPFS gateway for BAYC token 0 image ``` ### Backwards Compatibility Not applicable. ### Security Considerations None. ### Copyright Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). import { EnsipHeader } from "../../components/EnsipHeader"; ## ENSIP-13: SAFE Authentication For ENS <EnsipHeader authors={["wwhchung","jwahdatehagh","crydoteth","sillytuna","cyberpnkwin"]} created="August 3, 2021" status="draft" /> Using ENS Text Records to facilitate safer and more convenient signing operations. | ### Abstract This EIP links one or more signing wallets via Ethereum Name Service Specification ([EIP-137](https://eips.ethereum.org/EIPS/eip-137)) to prove control and asset ownership of a main wallet. ### Motivation Proving ownership of an asset to a third party application in the Ethereum ecosystem is common. Users frequently sign payloads of data to authenticate themselves before gaining access to perform some operation. However, this method--akin to giving the third party root access to one's main wallet--is both insecure and inconvenient. ***Examples:*** 1. In order for you to edit your profile on OpenSea, you must sign a message with your wallet. 2. In order to access NFT gated content, you must sign a message with the wallet containing the NFT in order to prove ownership. 3. In order to gain access to an event, you must sign a message with the wallet containing a required NFT in order to prove ownership. 4. In order to claim an airdrop, you must interact with the smart contract with the qualifying wallet. 5. In order to prove ownership of an NFT, you must sign a payload with the wallet that owns that NFT. In all the above examples, one interacts with the dApp or smart contract using the wallet itself, which may be * inconvenient (if it is controlled via a hardware wallet or a multi-sig) * insecure (since the above operations are read-only, but you are signing/interacting via a wallet that has write access) Instead, one should be able to approve multiple wallets to authenticate on behalf of a given wallet. #### Problems with existing methods and solutions Unfortunately, we've seen many cases where users have accidentally signed a malicious payload. The result is almost always a significant loss of assets associated with the signing address. In addition to this, many users keep significant portions of their assets in 'cold storage'. With the increased security from 'cold storage' solutions, we usually see decreased accessibility because users naturally increase the barriers required to access these wallets. Some solutions propose dedicated registry smart contracts to create this link, or new protocols to be supported. This is problematic from an adoption standpoint, and there have not been any standards created for them. #### Proposal: Use the Ethereum Name Service (EIP-137) Rather than 're-invent the wheel', this proposal aims to use the widely adopted Ethereum Name Service in conjunction with the ENS Text Records feature ([EIP-634](https://eips.ethereum.org/EIPS/eip-634)) in order to achieve a safer and more convenient way to sign and authenticate, and provide 'read only' access to a main wallet via one or more secondary wallets. From there, the benefits are twofold. This EIP gives users increased security via outsourcing potentially malicious signing operations to wallets that are more accessible (hot wallets), while being able to maintain the intended security assumptions of wallets that are not frequently used for signing operations. ##### Improving dApp Interaction Security Many dApps requires one to prove control of a wallet to gain access. At the moment, this means that you must interact with the dApp using the wallet itself. This is a security issue, as malicious dApps or phishing sites can lead to the assets of the wallet being compromised by having them sign malicious payloads. However, this risk would be mitigated if one were to use a secondary wallet for these interactions. Malicious interactions would be isolated to the assets held in the secondary wallet, which can be set up to contain little to nothing of value. ##### Improving Multiple Device Access Security In order for a non-hardware wallet to be used on multiple devices, you must import the seed phrase to each device. Each time a seed phrase is entered on a new device, the risk of the wallet being compromised increases as you are increasing the surface area of devices that have knowledge of the seed phrase. Instead, each device can have its own unique wallet that is an authorized secondary wallet of the main wallet. If a device specific wallet was ever compromised or lost, you could simply remove the authorization to authenticate. Further, wallet authentication can be matokenUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119. Let: * `mainAddress` represent the wallet address we are trying to authenticate or prove asset ownership for. * `mainENS` represent the reverse lookup ENS string for `mainAddress`. * `authAddress` represent the address we want to use for signing in lieu of `mainAddress`. * `authENS` represent the reverse lookup ENS string for `authAddress`. * `authKey` represents a string in the format `[0-9A-Za-z]+`. Control of `mainAddress` and ownership of `mainAddress` assets by `authAddress` is proven if all the following conditions are met: * `mainAddress` has an ENS resolver record and a reverse record set to `mainENS`. * `authAddress` has an ENS resolver record and a reverse record set to `authENS`. * `authENS` has an ENS TEXT record `eip5131:vault` in the format `<authKey>:<mainAddress>`. * `mainENS` has an ENS TEXT record `eip5131:<authKey>`. #### Setting up one or many `authAddress` records on a single ENS domain The `mainAddress` MUST have an ENS resolver record and reverse record configured. In order to automatically discover the linked account, the `authAddress` SHOULD have an ENS resolver record and reverse record configured. 1. Choose an unused `<authKey>`. This can be any string in the format `[0-0A-Za-z]+`. 2. Set a TEXT record `eip5131:<authKey>` on `mainENS`, with the value set to the desired `authAddress`. 3. Set a TEXT record `eip5131:vault` on `authENS`, with the value set to the `<authKey>:mainAddress`. Currently this EIP does not enforce an upper-bound on the number of `authAddress` entries you can include. Users can repeat this process with as many address as they like. #### Authenticating `mainAddress` via `authAddress` Control of `mainAddress` and ownership of `mainAddress` assets is proven if any associated `authAddress` is the `msg.sender` or has signed the message. Practically, this would work by performing the following operations: 1. Get the resolver for `authENS` 2. Get the `eip5131:vault` TEXT record of `authENS` 3. Parse `<authKey>:<mainAddress>` to determine the `authKey` and `mainAddress`. 4. MUST get the reverse ENS record for `mainAddress` and verify that it matches `<mainENS>`. * Otherwise one could set up other ENS nodes (with auths) that point to `mainAddress` and authenticate via those. 5. Get the `eip5131:<authKey>` TEXT record of `mainENS` and ensure it matches `authAddress`. Note that this specification allows for both contract level and client/server side validation of signatures. It is not limited to smart contracts, which is why there is no proposed external interface definition. #### Revocation of `authAddress` To revoke permission of `authAddress`, delete the `eip5131:<authKey>` TEXT record of `mainENS` or update it to point to a new `authAddress`. ### Rationale #### Usage of EIP-137 The proposed specification makes use of EIP-137 rather than introduce another registry paradigm. The reason for this is due to the existing wide adoption of EIP-137 and ENS. However, the drawback to EIP-137 is that any linked `authAddress` must contain some ETH in order to set the `authENS` reverse record as well as the `eip5131:vault` TEXT record. This can be solved by a separate reverse lookup registry that enables `mainAddress` to set the reverse record and TEXT record with a message signed by `authAddress`. With the advent of L2s and ENS Layer 2 functionalities, off chain verification of linked addresses is possible even with domains managed across different chains. #### One-to-Many Authentication Relationship This proposed specification allows for a one (`mainAddress`) to many (`authAddress`) authentication relationship. i.e. one `mainAddress` can authorize many `authAddress` to authenticate, but an `authAddress` can only authenticate itself or a single `mainAddress`. The reason for this design choice is to allow for simplicity of authentication via client and smart contract code. You can determine which `mainAddress` the `authAddress` is signing for without any additional user input. Further, you can design UX without any user interaction necessary to 'pick' the interacting address by display assets owned by `authAddress` and `mainAddress` and use the appropriate address dependent on the asset the user is attempting to authenticate with. #### Reference Implementation ##### Client/Server Side In typescript, the validation function, using ethers.js would be as follows: ```solidity export interface LinkedAddress { ens: string, address: string, } export async function getLinkedAddress( provider: ethers.providers.EnsProvider, address: string ): Promise<LinkedAddress | null> { const addressENS = await provider.lookupAddress(address); if (!addressENS) return null; const vaultInfo = await (await provider.getResolver(addressENS))?.getText('eip5131:vault'); if (!vaultInfo) return null; const vaultInfoArray = vaultInfo.split(':'); if (vaultInfoArray.length !== 2) { throw new Error('EIP5131: Authkey and vault address not configured correctly.'); } const [ authKey, vaultAddress ] = vaultInfoArray; const vaultENS = await provider.lookupAddress(vaultAddress); if (!vaultENS) { throw new Error(`EIP5131: No ENS domain with reverse record set for vault.`); }; const expectedSigningAddress = await ( await provider.getResolver(vaultENS) )?.getText(`eip5131:${authKey}`); if (expectedSigningAddress?.toLowerCase() !== address.toLowerCase()) { throw new Error(`EIP5131: Authentication mismatch.`); }; return { ens: vaultENS, address: vaultAddress }; } ``` ##### Contract side ##### With a backend If your application operates a secure backend server, you could run the client/server code above, then use the result in conjunction with specs like [EIP-1271](https://eips.ethereum.org/EIPS/eip-1271) : `Standard Signature Validation Method for Contracts` for a cheap and secure way to validate that the the message signer is indeed authenticated for the main address. ##### Without a backend (JavaScript only) Provided is a reference implementation for an internal function to verify that the message sender has an authentication link to the main address. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz /** * ENS Registry Interface */ interface ENS { function resolver(bytes32 node) external view returns (address); } /** * ENS Resolver Interface */ interface Resolver { function addr(bytes32 node) external view returns (address); function name(bytes32 node) external view returns (string memory); function text(bytes32 node, string calldata key) external view returns (string memory); } /** * Validate a signing address is associtaed with a linked address */ library LinkedAddress { /** * Validate that the message sender is an authentication address for mainAddress * * @param ensRegistry Address of ENS registry * @param mainAddress The main address we want to authenticate for. * @param mainENSNodeHash The main ENS Node Hash * @param authKey The TEXT record of the authKey we are using for validation * @param authENSNodeHash The auth ENS Node Hash */ function validateSender( address ensRegistry, address mainAddress, bytes32 mainENSNodeHash, string calldata authKey, bytes32 authENSNodeHash ) internal view returns (bool) { return validate(ensRegistry, mainAddress, mainENSNodeHash, authKey, msg.sender, authENSNodeHash); } /** * Validate that the authAddress is an authentication address for mainAddress * * @param ensRegistry Address of ENS registry * @param mainAddress The main addr
프로젝트로 돌아가기