Inter exchange Client Address Protocol (ICAP)- 互换客户端地址协议

https://github.com/ethereum/wiki/wiki/Inter-exchange-Client-Address-Protocol-(ICAP)

Transferring funds between third-party accounts, especially those of exchanges, places considerable burden on the user and is error prone, due to the way in which deposits are identified to the client account. This problem was tackled by the existing banking industry through having a common code known as IBAN. This code amalgamated the institution and client account along with a error-detection mechanism practically eliminating trivial errors and providing considerable convenience for the user. Unfortunately, this is a heavily regulated and centralised service accessible only to large, well-established institutions. The present protocol, ICAP, may be viewed as a decentralised version of it suitable for any institutions containing funds on the Ethereum system.

在第三方账户(尤其是交易所账户)之间转移资金,给用户带来了相当大的负担,而且由于客户账户的存款识别方式的不同,容易出错。现有银行业通过一种名为IBAN的通用代码解决了这个问题。这段代码融合了机构和客户账户,以及一种错误检测机制,实际上消除了琐碎的错误,并为用户提供了极大的便利。不幸的是,这是一项严格监管和集中的服务,只有大型、老牌机构才可以使用。目前的协议,ICAP,可以被看作是一个分散的版本,适用于任何在Ethereum系统中有资金的机构。

其实就是银行业中,比如中国银行要与花旗银行进行资金地转移,但是因为他们之间的账户标识(即银行卡号)是完全不同的,那么这时候就定义了IBAN这一个通用的标识来解决这个问题。而对应的在Ethereum系统中起相同作用的就是ICAP协议,目的是为了方便各大公链之间转账

 

IBAN

For a good overview of the IBAN system, please see Wikipedia's IBAN article. An IBAN code consists of up to 34 case insensitive alpha-numeric characters. It contains three pieces of information:

IBAN代码由多达34个不区分大小写的字母数字字符组成。它包含三个信息:

  • The country code; a top-level identifier for the context of the following (ISO 3166-1 alpha-2);国家代码;以下内容的顶级标识符
  • The error-detection code; uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003);错误检测的代码;使用mod-97-10校验和协议
  • The basic bank account number (BBAN); an identifier of the institution, branch and client account, whose composition is dependent on the aforementioned country.基本银行账号(BBAN);机构、分行和客户账户的标识符,其组成取决于上述国家

For the UK, the BBAN is composed of: BBAN组成有

  • Institution identifier, 4-character alphabetical, e.g. MIDL (ironically) represents HSBC bank.机构标识符,4个字母的字母,例如MIDL代表汇丰银行
  • Sort-code (branch identifier within the institution), a 6-digit decimal number, e.g. 402702would be the Lancaster branch of HSBC.分类码(机构内的分行代号),一个6位的十进制数,例如402702,将是汇丰银行兰开斯特分行。
  • Account number (client identifier within the branch), an 8-digit decimal number.帐户编号(分支中的客户标识符),一个8位的十进制数字。

 

Proposed Design 以太坊ICAP设计

Introduce a new IBAN country code: XE, formulated as the Ethereum E prefixed with the "extended" X, as used in non-jurisdictional currencies (e.g. XRP, XCP).

以太坊引入新的IBAN国家代码:XE,即以“扩展”X作为前缀的Ethereum E,用于非法定货币(例如XRP, XCP)。

There will be three BBAN possibilities for this code; direct, basic and indirect.

有三种BBAN代码类型:直接的,基本的和间接的。

Direct

The BBAN for this code when direct will be 30 characters and will comprise one field:

当direct时,此代码的BBAN为30个字符,并将包含一个字段

  • Account identifier, 30 characters alphanumeric (< 155-bit). This will be interpreted as a big-endian encoded base-36 integer representing the least significant bits of a 160-bit Ethereum address. As such, these Ethereum addresses will generally begin with a zero byte.

帐户标识符,30个字母数字(< 155位)。这将被解释为一个160位Ethereum地址的最低有效位的大端编码的36进制整数。因此,这些Ethereum地址通常以0字节开始。

XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS 对应 
address 0x00c5496aee77c1ba1f0854206a26dda82a81d6d8.

 

Basic

The same as the direct encoding, except that the code is 31 characters (making it non-compliant for IBAN) and composes the same, single, field:

与直接编码相同,只是代码是31个字符(使其不符合IBAN),并组成相同的、单一的字段

  • Account identifier, 31 characters alphanumeric (< 161-bit). This will be interpreted as a big-endian encoded base-36 integer representing a 160-bit Ethereum address.
    • 帐户标识符,31个字符字母数字(<161位)。这将被解释为一个代表160位以太坊地址的大端编码的36进制整数。

 

Indirect

The BBAN for this code when indirect will be 16 characters and will comprise three fields:

这个代码的BBAN是由16个字符和3个字段组成的

  • Asset identifier, 3-character alphanumeric (< 16-bit);资产标识符,3个字母数字
  • Institution identifier, 4-character alphanumeric (< 21-bit);机构标识符,4个字母数字
  • Institution client identifier, 9-character alphanumeric (< 47-bit);机构客户标识符,9个字母数字

Including the four initial characters, this leads to a final client-account address length of 20 characters, of the form:

还包括四个初始字符,这将导致表单的最终客户账户地址长度为20个字符

XE81ETHXREGGAVOFYORK

Split into:

  • XE The country code for Ethereum;Ethereum的国家代码
  • 81 The checksum;校验和
  • ETH The asset identifier within the client account - in this case, "ETH" is the only valid asset identifier, since Ethereum's base registry contract supports only this asset;客户账户中的资产标识符——在本例中,“ETH”是唯一有效的资产标识符,因为以太坊的基础注册合同仅支持该资产
  • XREG The institution code for the account - in this case, Ethereum's base registry contract;帐户的机构代码——在这种情况下,是Ethereum的基本注册合同
  • GAVOFYORK The client identifier within the institution - in this case, a direct payment with no additional data to whatever primary address is associated with the name "GAVOFYORK" in Ethereum's base registry contract;机构内的客户标识符——在这种情况下,对任何与Ethereum的基本注册合同中的名称“GAVOFYORK”相关的主地址进行无任何额外数据的直接支付

 

Notes

Institution codes beginning with X are reserved for system use.

以X开头的机构代码保留给系统使用。

Other forms

URI

General URIs can be formed though the URI scheme name iban, followed by the colon character :, followed by the 20-character alphanumeric identifier, thus for the example above, we would use:

可以通过URI方案名称iban来形成通用URI,后面跟着冒号:,后面跟着20个字符的字母数字标识符,因此,对于上面的示例,我们将使用

iban:XE81ETHXREGGAVOFYORK

 

QR Code

A QR code may be generated directly from the URI using standard QR encodings.

可以使用标准QR编码直接从URI生成二维码

For example, the example above iban:XE81ETHXREGGAVOFYORK would have the corresponding QR code:

 

以太坊地址转ICAP 地址的过程:(转自http://ju.outofmemory.cn/entry/368258)

以太坊钱包生成收款码时,有些是直接拿裸地址例如 "0x0728F0...75445F" 生成收款二维码,例如 TrustWallet;还有些是使用 "iban:" 开头的 ICAP 串来生成收款二维码,例如 imToken 1.0。

IBAN 本身是国际上一部分银行间转账使用的账号代码格式,以太坊社区在 IBAN 地址格式上做了一些扩展,用来编码以太坊地址和校验码,用作地址交换使用,叫做 ICAP ( Inter exchange Client Address Protocol )。

IBAN 编码看起来很简单,但在实现上字母到数值的转换方法挺 trick 的,需要花一些时间进行理解。为简化理解,下面我拿一个例子来说明整个编码过程。

假设我们已经有了一个以太坊地址:0x730aEA2B39AA2Cf6B24829b3D39dC9a1F9297B88,下面是生成对应 ICAP 地址的过程:

第一步:将原始 16 进制以太坊地址转换成为 36 进制地址:

 16进制 ETH 地址:0x730aEA2B39AA2Cf6B24829b3D39dC9a1F9297B88
 36进制 ETH 地址:DFRZLRUTFTFY4EVINAHYF7TQ6MACYH4

第二步:为 36 进制 ETH 地址拼接上国家码 "XE" 和空校验字符串 "00" 形成 36 进制待校验字串:

 36进制 ETH 地址: DFRZLRUTFTFY4EVINAHYF7TQ6MACYH4
 36进制待校验字串: DFRZLRUTFTFY4EVINAHYF7TQ6MACYH4XE00

第三步:将 36 进制待校验字串逐字符转成 10 进制数字字串:

 36进制待校验字串: DFRZLRUTFTFY4EVINAHYF7TQ6MACYH4XE00
 10进制待校验字串: 1315273521273029152915344143118231017341572926622101234174331400

第四步:将 10 进制大整数对 97 取模,然后用 98 - 模数:

校验码:42 = 98 - 1315273521273029152915344143118231017341572926622101234174331400 % 97

第五步:将校验码替换空校验字符串,然后重新安排 XE** 到地址前,并加上前缀:

 36进制待校验字串: DFRZLRUTFTFY4EVINAHYF7TQ6MACYH4XE00
 36进制已校验字串: DFRZLRUTFTFY4EVINAHYF7TQ6MACYH4XE42
 36进制 IBAN 号: iban:XE42DFRZLRUTFTFY4EVINAHYF7TQ6MACYH4

可以用这个 IBAN 号生成二维码

 

 

Transaction Semantics交易语义

The mechanism for indirect asset transfer over three routing protocols are specified, all of which are specific to the Ethereum domain (country-code of XE). One is for currency transfers directly to an included address ("direct"), another is for clients with the system address found through a Registry-lookup system of the client-ID, denoted by asset class ETH, whereas the last is for transfers to an intermediary with associated data to specify client, denoted by asset class XET(the latter two are "indirect").

所有这些指定了通过三个路由协议进行间接资产转移的机制都是特定于Ethereum域(XE的国家代码)的。一个是货币直接转移到一个included地址(“直接”);另一个是通过client-ID的注册中心去查找用户的系统地址,通过资产类别ETH来表示;而最后一个是与一个与有着指定客户的相关数据的中介的转移,通过资产类别XET来表示(后两个是“间接”)。

Direct

If the IBAN code is 34 characters, it is a direct address; a direct transfer is made to the address which, when base-36 encoded gives exactly the data segment (the last 30 characters) of the IBAN code.

如果IBAN代码是34个字符,它就是一个直接地址,直接转移到该地址。当base-36编码时,地址准确地给出IBAN代码的数据段(最后30个字符)。

 

Indirect ETH Asset: Simple transfers

Within the ETH asset code of Ethereum's country-code (XE), i.e. as long as the code begins with XE**ETH (where ** is the valid checksum), then we can define the required transaction to be the deposit address given by a call to the registry contract denoted by the institution code. For institutions not beginning with X, this corresponds to the primary address associated with the Ethereum standard name:

在Ethereum的国家代码(XE)的ETH资产代码中,即只要代码以XE**ETH(其中**是有效的校验和)开头,那么我们就可以将所需的交易定义为机构代码所表示的对注册合同的调用所给出的存款地址。对于不是以X开头的机构,这对应于与Ethereum标准名称相关联的主地址:

[institution code] / [client identifier]

The Ethereum standard name is simply the normal hierarchical lookup mechanism, as specified in the Ethereum standard interfaces document.

Ethereum标准名称只是Ethereum标准接口文档中指定的普通分层查找机制。

We define a registry contract as a contract fulfilling the Registry interface as specified in the Ethereum standard interfaces document.

我们将注册中心合同定义为满足Ethereum标准接口文档中指定的注册中心接口的合同。

TODO: JS code for specifying the transfer.

 

Indirect XET Asset: Institution transfers

For the XET asset code within the Ethereum country code (i.e. while the code begins XE**XET), then we can derive the transaction that must be made through a lookup to the Ethereum ibanregistry contract. For a given institution, this contract specifies two values: the deposit call signature hash and the institution's Ethereum address.

对于Ethereum国家代码中的XET资产代码(即当代码开始XE**XET时),我们可以推导出必须通过对Ethereum ibanregistry合同的查找进行的交易。对于给定的机构,该合同指定了两个值:存款调用签名散列和机构的Ethereum地址。

At present, only a single such deposit call is defined, which is:

目前只有一个存款调用被定义

function deposit(uint64 clientAccount)

whose signature hash is 0x13765838. The transaction to transfer the assets should be formed as an ether-laden call to the institution's Ethereum address using the deposit method as specified above, with the client account determined through the value of the big-endian, base-36 interpretation of the alpha-numeric Institution client identifier, literally using the value of the characters 0 to 9, then evaluating 'A' (or 'a') as 10, 'B' (or 'b') as 11 and so forth.

其签名哈希是0x13765838。转移资产的交易应该使用上面指定的存款方法与通过价值高位优先的客户账户形成一个对机构的Ethereum地址的ether-laden调用,字母数字机构客户端标识符的base-36解释,实际上是使用字符的值0到9,然后估“A”(或“a”)的值为10,“B”(或“b”)的值为11等等。

TODO: JS code for specifying the transfer._**![](https://etherscan.io/address/0xc94770007dda54cf92009bff0de90c06f603a09f)**_

 

ethereumjs/ethereumjs-icap这里去查看icap的实现

 
posted @ 2018-11-20 15:06  慢行厚积  阅读(1370)  评论(0编辑  收藏  举报