https://github.com/ethereum/EIPs/blob/master/EIPS/eip-191.md

eip title author status type category created
191
Signed Data Standard
Martin Holst Swende (@holiman), Nick Johnson <arachnid@notdot.net>
Draft
Standards Track
ERC
2016-01-20

摘要

这个ERC提议了一个关于如何在以太坊合约中处理签名数据的详细说明。

动机

一些接受presigned交易的多签名钱包应用已经出现了。一笔presigned交易就是一堆二进制的signed_data,同时包含签名(rsv)。因为对signed_data的解释并不具体,导致了一些问题:

  1. 标准的以太坊交易可以作为signed_data提交。一笔以太坊交易可以拆解成这几个组件:RLP<nonce, gasPrice, startGas, to, value, data>(这里被称为RLPdata),r,s,v。如果对signed_data没有句法约束,这就意味着RLPdata可以用作句法有效的presigned交易。
  2. 多签名钱包同样也有问题:presigned交易并不和一个特定的validator绑定在一起,举一个特定钱包的例子:

    i. 用户ABC2/3-钱包X

    ii. 用户ABD2/3-钱包Y

    iii. 用户AB提交了一个presigned交易给X

    iv. 攻击者可以复用他们的给X的presigned交易,然后提交给Y

说明

我们为signed_data提议了以下格式:

0x19 <1 byte version> <version specific data> <data to sign>.

版本0对于版本特定数据有<20字节地址>,这个地址就是预期的验证者。在多签名钱包的例子中,就是钱包自己的地址。

最初的0x19字节用来确保signed_data不是有效的RLP

对于单个值为[0x00, 0x7f]的字节,字节的RLP编码就是它本身

这意味着任何signed_data不能是一个RLP结构,而是1个字节的RLP,后面再加上一些别的内容。

因此,任何ERC-191 signed_data永远不会是一笔以太坊交易。

额外地,之所以用0x19是因为自从ethereum/go-ethereum#2940,下面的一行文字会在personal_sign方法中预添加在要签名的hash数据之前:

"\x19Ethereum Signed Message:\n" + len(message).

因此,使用0x19是为了可以扩展这个模式,通过定义一个版本 0x45E)来处理这种类型的签名。

版本字节登记

Version byte EIP Description
0x00 191 Data with intended validator
0x01 712 Structured data
0x45 191 personal_sign messages

就是如果版本为0x00,那么后面还会跟着intened validator(address),然后才是data

如果是0x01,那么后面后面跟着的就是结构化数据,什么是结构化数据,看EIP-721

如果是0x45,那么后面后面跟着的就是进行personal_sign后的信息

ethereum/EIPs-191 Signed Data Standard的更多相关文章

  1. ethereum/EIPs-1077 Executable Signed Messages

    https://github.com/alexvandesande/EIPs/blob/ee2347027e94b93708939f2e448447d030ca2d76/EIPS/eip-1077.m ...

  2. ethereum/EIPs-712 Ethereum typed structured data hashing and signing

    https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md eip title author discussions-to status ...

  3. ethereum/EIPs-1078 Universal login / signup using ENS subdomains

    https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1078.md eip title author discussions-to status ...

  4. ethereum/EIPs-1271 smart contract

    https://github.com/PhABC/EIPs/blob/is-valid-signature/EIPS/eip-1271.md Standard Signature Validation ...

  5. ethereum/EIPs-725

    https://github.com/ethereum/EIPs/blob/master/EIPS/eip-725.md eip title author discussions-to status ...

  6. Ethereum White Paper

    https://github.com/ethereum/wiki/wiki/White-Paper White Paper EditNew Page James Ray edited this pag ...

  7. go ethereum源码分析 PartIV Transaction相关

    核心数据结构: core.types.transaction.go type Transaction struct { data txdata // caches hash atomic.Value ...

  8. ethereum/EIPs-1

    https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1.md 介绍了什么是EIP等等的详细信息: eip title status type a ...

  9. solidity return data和revert/require的reason string的获得

    前言: 在使用solidity写智能合约的时候,会使用到revert和require来进行断言,比如: require(tokenOwner[tokenId] == 0x0,'this is not ...

随机推荐

  1. C#基础---浅谈XML读取以及简单的ORM实现

    背景: 在开发ASP.NETMVC4 项目中,虽然web.config配置满足了大部分需求,不过对于某些特定业务,我们有时候需要添加新的配置文件来记录配置信息,那么XML文件配置无疑是我们选择的一个方 ...

  2. angularjs学习第七天笔记(系统指令学习)

    您好,接着在昨天对简单指令学习了解以后,今天开始学习了解angularjs中的系统指令 系统指令大部分都是以ng开始,这也是为什么在自定义指令命名时不要以ng开始的原因所在 系统指令在学习了分成两个部 ...

  3. [PHP] 算法-构建排除当前元素的乘积数组的PHP实现

    构建乘积数组给定一个数组A[0,1,...,n-1],请构建一个数组B[0,1,...,n-1],其中B中的元素B[i]=A[0]*A[1]*...*A[i-1]*A[i+1]*...*A[n-1]. ...

  4. When should you use a class vs a struct in C++?

    Question: In what scenarios is it better to use a struct vs a class in C++? Answer: The only differe ...

  5. 在UAP中如何通过WebView控件进行C#与JS的交互

    最近由于项目需求,需要利用C#在UWP中与JS进行交互,由于还没有什么实战经验,所有就现在网上百度了一下,但是百度的结果显示大部分都是在Android和IOS上面的方法,UWP中的几乎没有.还好微软又 ...

  6. ConcurrentHashMap底层实现原理(JDK1.8)源码分析

    ref:https://blog.csdn.net/xu768840497/article/details/79194701 http://www.cnblogs.com/leesf456/p/545 ...

  7. js判断当前浏览器语言类型

    console.log(window.navigator.language.slice(0, 2)); 得到的是zh

  8. recovery 升级过程执行自定义shell命令

    有时候我们需要,在升级的过程中,执行一些shell命令,来完成我们的一些需求,利用升级过程,进行一些特殊化的操作,思路如下: 第一: 把我们需要执行的命令,写成一个test.sh脚本,然后在recov ...

  9. css,响应鼠标事件,文字变色

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. bs4爬虫入门

    # -*- coding: utf-8 -*- """ Created on Fri Nov 16 13:35:33 2018 @author: zhen "& ...