分类存档: 区块链

如何拥有一个永远在线的网站

有关如何使用4EVERLAND Ar Hosting的完整教程
原文地址
在发布IPFS和IC Hosting之后,4EVERLAND最近发布了Ar Hosting服务。4EVERLAND Ar Hosting允许用户在Arweave上永久托管其网页。

在本教程中,包括使用4EVERLAND Ar Hosting的特定步骤。

通过4EVERLAND在Arweave部署产品

1:作为Web3开发人员平台,您需要首先使用钱包登录4EVERLAND仪表板。(当前4EVERLAND支持MetaMask,Phantom,Flow钱包登录,Github仅支持旧用户)

2:转到仪表板,单击托管,选择项目,然后单击新项目。

Go to Dashboard, click on Hosting, select Projects and click on New Project.

3:在这里,新用户将需要注册一个Github帐户并选择要在存储库中部署的项目

Here, new users will need to sign up for a Github account and select the project you want to deploy in the repository

4:选择要部署到的平台。在这里,我们选择在Arweave上部署2048年项目。保留默认环境配置,然后单击“部署”。Select the platform you want to deploy to. Here we choose to deploy a 2048 project on Arweave. Keep the default environment configuration and click Deploy.

5:现在,您只需要等待部署完成即可。您可以随时选择取消部署。

Now you just need to wait for the deployment to complete. You can choose to cancel the deployment at any time.

6:在产品详细信息中,您将看到该页面的预览,Arweave Hash和分配的4EVERLAND域名。

ps: 也可以在domain下面添加绑定自定义域名,只需要把dns域名解析的cname指向4EVERLAND给的一串字符即可

检验btc和eth地址是否合法

btc地址验证合法性规则

3开头的比特币地址,34位。
1开头的比特币地址,长度26位到34位

Base58是Base64编码格式的子集,同样使用大小写字母和10个数字,但舍弃了一些容易错读和在特定字

体中容易混淆的字符。具体地,Base58不含Base64中的0(数字0)、O(大写字母o)、l(小写字母L)

、I(大写字母i),以及“+”和“/”两个字符。简而言之,Base58就是由不包括(0,O,l,I)的大

小写字母和数字组成。

比特币的Base58字母表
123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz

1.eth正则匹配规则 ^0x[a-fA-F0-9]{40}$
2.btc基本判断:
3开头的比特币地址,长度为34位。
1开头的比特币地址,长度为26位到34位
正则匹配规则
/\A(1|3)[a-zA-Z1-9]{26,33}\z/
更严格的判断参考:https://stackoverflow.com/questions/22127317/check-if-bitcoin-

address-is-valid

3.eth地址验证合法性规则

Private Function gettimestamp(tNum,tUserid,tdotype,moneytype)
Dim tStr1
tStr1=tNum&tUserid&tdotype&moneytype
gettimestamp=mid(md5t(tStr1,32,36)&”james626″,3,20)
End Function

ETH区块链浏览器

https://www.etherchain.org/

ETH&Bitcoin生成靓号地址程序

https://github.com/MyEtherWallet/VanityEth
靓号程序$ vanityeth -n 10 -i header

Python generate bitcoin address:
https://github.com/wyager/Bitcoin-HD-wallet-generator

Run python keygen.py to create a random seed, and then from that seed generate

addresses m/0h/0/[0-1]/[0-4].
This will create a file bitcoin_config.txt, which contains the pubkey and chain code

corresponding to m/0h/0.
Then, you can run python addrgen.py, which will also generate m/0h/0/[0-1]/[0-4], but

without knowing any private keys.

生成比特币地址

generate bitcoin addr:
https://github.com/wyager/Bitcoin-HD-wallet-generator
pip install moudle

EOS离线签名

最新版本建议用https://github.com/EOSIO/eosjs-ecc里面的签名函数来处理:

ecc.sign('hello eos', privatekey)

c++实现版本(待验证)

void SignedTransaction::sign(const std::vector<unsigned char> &pri_key, const TypeChainId &cid)
{
    std::vector<unsigned char> packedBytes = getDigestForSignature(cid);

    uint8_t packedSha256[SHA256_DIGEST_LENGTH];
    sha256_Raw(packedBytes.data(), packedBytes.size(), packedSha256);

    uint8_t signature[uECC_BYTES * 2] = { 0 };
    int recId = uECC_sign_forbc(pri_key.data(), packedSha256, signature);
    if (recId == -1) {
        // could not find recid, data probably already signed by the key before?
        return;
    } else {
        unsigned char bin[65+4] = { 0 };
        unsigned char *rmdhash = NULL;
        int binlen = 65+4;
        int headerBytes = recId + 27 + 4;
        bin[0] = (unsigned char)headerBytes;
        memcpy(bin + 1, signature, uECC_BYTES * 2);

        unsigned char temp[67] = { 0 };
        memcpy(temp, bin, 65);
        memcpy(temp + 65, "K1", 2);

        rmdhash = RMD(temp, 67);
        memcpy(bin + 1 +  uECC_BYTES * 2, rmdhash, 4);

        char sigbin[100] = { 0 };
        size_t sigbinlen = 100;
        b58enc(sigbin, &sigbinlen, bin, binlen);
        std::string sig = "SIG_K1_";
        sig += sigbin;

        signatures.push_back(sig);
    }
}

参考:https://github.com/OracleChain/EOSDevHelper.git

eosjs实现版本

/** Sign a transaction */
    public async sign({ chainId, requiredKeys, serializedTransaction }: SignatureProviderArgs) {
        const signBuf = Buffer.concat([
            new Buffer(chainId, "hex"), new Buffer(serializedTransaction), new Buffer(new Uint8Array(32)),
        ]);

        const signatures = requiredKeys.map(
            (pub) => ecc.Signature.sign(signBuf, this.keys.get(convertLegacyPublicKey(pub))).toString(),
        );

       return { signatures, serializedTransaction };

    }

说明:
const test = ecc.Signature.sign(new Buffer("0xa123","hex"),privatekey);
这个得到的就是
"SIG_K1_K9eDsXiqEMkJs8wPwEjiN6hL1h2Bm3gGQtUheidFczWNdBmDF24AUuPmiosi9CwtEW3jPFPao7HYWLJ63ic3TggjnoKtJF"
即离线签名的signatures,有了这个再push_transaction就可以完成交易了

java版本(已验证可用)

https://blog.csdn.net/liu1765686161/article/details/83308819
https://github.com/eosio/eosjs#offline-or-cold-storage-transaction:
https://eosc.app/

https://github.com/EOSIO/eosjs/blob/v16.0.8/src/write-api.js#L498-L510

https://github.com/OracleChain/EOSDevHelper

https://eosfans.io/topics/1176

获取EOS测试账号

endpointlist:https://www.eosdocs.io/resources/apiendpoints/
首先得弄两个eos测试账户,在这个网站上可以弄到,自备梯子
http://jungle.cryptolions.io/#home
点击create account以后出现三个空,第一行是填eos账户名,12位数字字母组合即可,第二行owner public key和第三行active public key怎么填呢?不想写程序的话,就用工具好了:
https://eostea.github.io/eos-generate-key/(推荐)
https://github.com/OracleChain/EOSDevHelper(待验证)
下载对应版本,配置settings,
host: jungle.cryptolions.io port:18888
打开创建账户里面,就自动生成owner public key和active public key
把这两个值拷贝出来到上面的网站里面就生成好了

刚创建的账号是没有测试币的,所以要去http://jungle.cryptolions.io/#home 上面的faucet弄点测试币,依然要梯子过验证,默认一次给100个eos,够用啦

ps:有个问题,工具生成public key,对应的private key怎么从工具里获得,难道就是unlock wallet的key,待后面有时间再验证

~~~~~~~~~~~~~~~~~~~
如何通过私钥生成公钥
源码 : https://github.com/eostea/eos-generate-key
工具 : https://eostea.github.io/eos-generate-key/
原理 : 待续

Postman获取eos账户信息

post访问http://mainnet.eoscanada.com/v1/chain/get_account
或者香港节点
http://api.hkeos.com/v1/chain/get_account
api.hkeos.com
body – raw:

{
"account_name":"eos账户名"
}

response:

{
    "account_name": "amyflashdcom",
    "head_block_num": 23399894,
    "head_block_time": "2018-10-25T05:25:10.000",
    "privileged": false,
    "last_code_update": "1970-01-01T00:00:00.000",
    "created": "2018-07-01T02:41:35.000",
    "core_liquid_balance": "0.0894 EOS",
    "ram_quota": 16653,
    "net_weight": 5100,
    "cpu_weight": 11100,
    "net_limit": {
        "used": 224,
        "available": 343870,
        "max": 344094
    },
    "cpu_limit": {
        "used": 1653,
        "available": 110924,
        "max": 112577
    },
    "ram_usage": 5574,
    "permissions": [
        {
            "perm_name": "active",
            "parent": "owner",
            "required_auth": {
                "threshold": 1,
                "keys": [
                    {
                        "key": "EOS5jZQnAwNAPsPN9bvT9qGoMVWzbk655bUfVWB73sy2kqTKfWXqa",
                        "weight": 1
                    }
                ],
                "accounts": [],
                "waits": []
            }
        },
        {
            "perm_name": "owner",
            "parent": "",
            "required_auth": {
                "threshold": 1,
                "keys": [
                    {
                        "key": "EOS5jZQnAwNAPsPN9bvT9qGoMVWzbk655bUfVWB73sy2kqTKfWXqa",
                        "weight": 1
                    }
                ],
                "accounts": [],
                "waits": []
            }
        }
    ],
    "total_resources": {
        "owner": "amyflashdcom",
        "net_weight": "0.5100 EOS",
        "cpu_weight": "1.1100 EOS",
        "ram_bytes": 15253
    },
    "self_delegated_bandwidth": {
        "from": "amyflashdcom",
        "to": "amyflashdcom",
        "net_weight": "0.5100 EOS",
        "cpu_weight": "1.1100 EOS"
    },
    "refund_request": null,
    "voter_info": {
        "owner": "amyflashdcom",
        "proxy": "",
        "producers": [
            "bitfinexeos1",
            "eos42freedom",
            "eosauthority",
            "eosbeijingbp",
            "eosbixinboot",
            "eoscafeblock",
            "eoscanadacom",
            "eoscannonchn",
            "eoscybexiobp",
            "eosfishrocks",
            "eosflytomars",
            "eoshuobipool",
            "eosiomeetone",
            "eosiosg11111",
            "eosisgravity",
            "eoslaomaocom",
            "eosnationftw",
            "eosnewyorkio",
            "helloeoscnbp",
            "jedaaaaaaaaa",
            "oraclegogogo",
            "starteosiobp",
            "zbeosbp11111"
        ],
        "staked": 16200,
        "last_vote_weight": "7634359820.36285972595214844",
        "proxied_vote_weight": "0.00000000000000000",
        "is_proxy": 0
    }
}

获取eos可用余额

post请求
http://mainnet.eoscanada.com/v1/chain/get_currency_balance
参数body-raw

{"code":"eosio.token", "account":"amyflashdcom", "symbol":"eos"}

response:

[
    "0.0894 EOS"
]

转:比特币多签地址P2SH

原文参考:https://blog.csdn.net/jerry81333/article/details/56824166

详细步骤:

由上图可以看出,第一步是私钥,经过ECDSA,也就是椭圆曲线算法得到公钥,然后公钥要经过数个步骤到第9步,才能得到比特币交易中的地址。很明显,大部分人会有疑问,6,7步SHA256为什么要执行两次,原因是这张图做的不够直观,具体可以看下图:

可以说,地址就是公钥经过SHA256+RIPEMD160之后的产物,原先6,7步的SHA256只是为了在末尾添加校验码。因为SHA256+RIPEMD160都是作用在二进制层面的,最后使用BASE58还原为易于人所能识别的钱包地址。因此,地址有可以称为公钥哈希。

交易标准
为了让所有节点都能识别交易,因此将交易信息标准化是必不可少的,比特币的区块链社区主要支持以下五种交易标准:P2PKH、P2PK、MS(限15个密钥)、P2SH和OP_Return。OP_Return将不会介绍,因为其存储的是信息(或者说只是字节),并非比特币货币。

比特币脚本语言:
可以理解为类HTML的语言,所有的节点都能理解,并且按照步骤进行编译。而在交易过程中,发送方会将自己的UTXO(字符串,在比特币区块链中能代表一定数额的比特币,使得比特币可以追踪)使用锁定脚本进行锁定,锁定在接收方的地址上(也就是表示只有证明自己是接收方,才能够使用)。接收方如果要使用,必须使用解锁脚本,证明自己是这个地址的主人,各个节点才认可这笔交易。

在比特币社区使用的脚本语言,是一种基于逆波兰表示法的基于堆栈的执行语言。如下图:

P2PKH(Pay-to-Public-Key-Hash):
现在的比特币网络上,大部分交易都是以P2PKH的方式进行的,以下是P2PKH的锁定脚本与解锁脚本:

表示签名,表示Public Key,具体操作步骤如下:

可以看出,主要验证两个验证,第一是Public Key是否能够转换成正确的地址,第二是Signature是否正确,也就是证明你是否是这个Public Key的主人。

Signature签名:

签名内容主要是此交易摘要(也就是交易信息的Hash)与私钥进行运算。验证的话,将签名与公钥进行运算,如果能正确的得到交易摘要,则成功。

P2PK(Pay-to-Public-Key)
P2PK锁定版脚本形式如下:

[html] view plain copy
OP_CHECKSIG
用于解锁的脚本是一个简单签名:
[html] view plain copy

经由交易验证软件确认的组合脚本为:
[html] view plain copy
OP_CHECKSIG
根据上方的规则去运行就可以发现,此规则比P2PKH要简单的多,只有一步验证,少了上方的地址验证。其实,P2PKH被创建主要目的一方面为使比特币地址更简短,使之更方便使用,核心内容还是P2PK的。

MS(Multiple Signatures)多重签名
通用的M-N多重签名锁定脚本形式为:

[html] view plain copy
M N OP_CHECKMULTISIG
其中,N是存档公钥总数,M是要求激活交易的最少公钥数。
例如,2-3多重签名条件:

[html] view plain copy
2 3 OP_CHECKMULTISIG
上述锁定脚本可由含有签名和公钥的脚本予以解锁:

[html] view plain copy
OP_0
OP_0为占位符,没啥实际意义。
两个脚本组合将形成一个验证脚本:

[html] view plain copy
OP_0 2 3 OP_CHECKMULTISIG

P2SH(Pay-to-Script-Hash)
P2SH是MS多重签名的简化版本,如果使用P2SH进行和上方相同的2-3多重签名条件,步骤如下:

锁定脚本:

[html] view plain copy
2 3 OP_CHECKMULTISIG
对锁定脚本,首先采用SHA256哈希算法,随后对其运用RIPEMD160算法。20字节的脚本为:
[html] view plain copy
8ac1d7a2fa204a16dc984fa81cfdf86a2a4e1731
于是锁定脚本变为:
[html] view plain copy
OP_HASH160 8ac1d7a2fa204a16dc984fa81cfdf86a2a4e1731 OP_EQUAL
此锁定脚本要比原先使用MS的锁定脚本要简短的多,当接收方要使用此交易中的UTXO时,需要提交解锁脚本(这里又可称为赎回脚本):

[html] view plain copy
<2 PK1 PK2 PK3 PK4 PK5 5 OP_CHECKMULTISIG>
与锁定脚本相结合:
[html] view plain copy
<2 PK1 PK2 PK3 PK4 PK5 5 OP_CHECKMULTISIG> OP_HASH160 8ac1d7a2fa204a16dc984fa81cfdf86a2a4e1731 OP_EQUAL
使用逆波兰表达式运算,就能很明显的得知,验证过程分两步,首先验证的是接收方附上的赎回脚本是否符合发送方的锁定脚本,如果是,便执行该脚本,进行多重签名的验证。
P2SH的特点是,将制作脚本的责任给了接收方,好处是可以暂缓节点存储的压力。

ICO里面如何用消息签名来验证钱包地址

原文链接:https://www.cryptocompare.com/wallets/guides/how-to-sign-a-message-with-electrum/