Giter Site home page Giter Site logo

testsol's Introduction

1. bollot_navie的缺点

  • 如果没有投票权的地址调用了vote函数,那么这样的调用也能正常运行
  • 投票下标可能会造成数组越界

2. BlindAuction流程

bid时需要指定一个bytes32类型的参数blindedBid,并支付一定数目的以太币,被记为deposit:

  • 实际出价金额
  • 本次出价的真伪
  • 出价者生成的一个秘钥

三者取散列生成,这个参数有两个作用:

  • 隐含本次出价真伪的信息
  • 用以揭晓期验证用户所揭晓的实际出价信息是否可信

注意: 无论本次出价行为是还是,deposit并不代表实际出价的价格数值,理论上只要大于实际出价数值即可.

揭晓时,出价者调用时需要指定三个数组:

  • 每次出价的实际金额
  • 出价行为的真伪
  • 对应的秘钥

按照出价的先后顺序,依次揭晓每次出价,求 (value,fake,secret)的散列值是否与先前被记录在合约中的bind.blindedBid相等

if 预出价 与 实际出价 hash对上 {
    
    if (无伪造 && 声称出价 >= 实际出价) {
        if (实际出价战胜第一名) {
            1. 这个出价的钱(实际)不马上退
            2. 上一个第一名的钱(钱)放到退钱列表
        } else {
            退钱(deposit)
        }
    } else {
        退钱(deposit)
    }

} else {
    钱(deposit)没了
}


3. 权限控制

为什么权限管理不相同呢?

  • 对于view函数,使用者可以通过eth_call,同样能得到结果,调用者可以使用任意的msg.sender
  • 而修改合约状态的函数,必须通过eth_sendTransaction调用,对交易签名的验证保证了msg.sender不可伪造

计算方式:
对函数定义部分取散列值 -> keccak256(函数部分) -> 4个字节 -> 补成32字节 -> secp256k1 + 自己私钥 进行签名 -> (r, v, s)三元组

还原地址方式:
(r, v, s) + 签名对象(hash (msg.sig)) -> 地址

因为r,v,s是使用私钥生成的签名,所以我们可以认为reader的身份是真实的.

这里我还有问题:

  • msg.sig暴露
  • r,v,s(签名)暴露

岂不是?

再回到https的协议, 证书公开,证书签名公开,岂不是可以使得中间人可以复用啦? 怎么思考这个问题?

4. erc20


  • 转账: 需要消耗点燃料费
  • 空投: 实现balanceof函数,空投变量
uint totalSupply = 100000000 ether; // 总发行量
uint currentTotalSupply = 0;    // 已经空投数量
uint airdropNum = 1 ether;      // 单个账户空投数量

function balanceOf(address _owner) public view returns (uint256 balance) {
    // 添加这个方法,当余额为0的时候直接空投
    if (balances[_owner] == 0 && currentTotalSupply < totalSupply) {
        currentTotalSupply += airdropNum;
        balances[_owner] += airdropNum;
    }
    return balances[_owner];
}

5. 复杂erc20

6. 猜数字

7. 更复杂erc20

cd /mnt/disk1/linux/reference/refer
git clone https://github.com/eoshackathon/multi-stage-ico

8. stages

  • 修改_totalSupply为internal
  • 修改_balances为internal

testsol's People

Contributors

yqsy avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.