您正在查看: EOS-开源推荐 分类下的文章

eosjs Signature Provider for Ledger

SignatureProvider,用于与Ledger设备中的eosjs通信。

github:https://github.com/EOSIO/eosjs-ledger-signature-provider

eos_faucet EOS 账号水龙头

eos_faucet

server side:

cd your_working_dir

git clone https://github.com/cryptokylin/eos_faucet.git

cd eos_faucet

open wallet.py, paste account (to create account, transfer tokens) name, wallet name, wallet password accordingly, then save

python clfaucet.py

client side:

you can create at most 1000 accounts per day.

curl http://your_server_ip/create_account?<new_account_name>

you can get 100 tokens each call and max 1000 tokens per day.

curl http://your_server_ip/get_token?<your_account_name>

note:

this code is for test purpose only, you should not use it on eos mainnet with your real account

github:https://github.com/cryptokylin/eos_faucet

比特币,以太坊,EOS 公私钥生成以及签名 BlockchainWallet-Crypto

BlockchainWallet-Crypto

简介

这个库到底能干什么
  1. 生成比特币公私钥地址
  2. 生成以太坊公私钥地址
  3. 根据 UTXO 信息打包比特币交易
  4. 根据 nonce 信息打包以太坊交易
  5. 对比特币交易进行签名
  6. 对以太坊交易进行签名
  7. 支持 BIP39 助记词
  8. 支持 BIP32 子私钥
  9. 支持 BIP44 多币种管理
  10. 支持 BIP38 加密私钥导入导出
  11. 支持以太坊 keystore 导入导出
  12. 生成以太坊调用智能合约的参数
  13. 生成 EOS 公私钥

EOS 从助记词生成私钥

现在 EOS 从助记词生成私钥有两种方式

  1. 12 个助记词之间用空格隔开拼接成字符串,然后 Hash 得到私钥
  2. 采用 Bip44 标准的生成方案,EOS 的币种序号详见最下方⎡相关资料⎦中的⎡Bip44 注册币种列表⎦

经过国内大部分钱包商议统一使用第二种方案解决 EOS 从助记词生成私钥的问题

欢迎给位提设计上的 lssues 和 pr

引入项目

allprojects {
  repositories {
    ...
        maven { url 'https://jitpack.io' }
  }
}

dependencies {
  implementation 'com.github.QuincySx:BlockchainWallet-Crypto:last-version'
}

使用说明

简单使用说明

相关资料

Bip44 注册币种列表

LICENSE

开源协议

github:https://github.com/QuincySx/BlockchainWallet-Crypto

Scatter javascript warpper for webview

github:https://github.com/xuewuli/Tiny.Scatter

Tiny.Scatter

Scatter javascript warpper for webview

inject to iOS WKWebView

extension WKWebViewConfiguration {
    static func makeScatterEOSSupport(account: String, publicKey: String, in messageHandler: WKScriptMessageHandler, with config: WKWebViewConfiguration) -> Void {
        var js = ""

        if let filepath = Bundle.main.path(forResource: "tiny_scatter", ofType: "js") {
            do {
                js += try String(contentsOfFile: filepath)
            } catch { }
        }

        js +=
        """
        // value as string "SIG_K1_..."
        function onSignEOSMessageSuccessful(id, value) {
            BrigeAPI.sendResponse(id, value)
        }

        // value as string with this format '{"signatures":["SIG_K1_..."]}'
        function onSignEOSSuccessful(id, value) {
            BrigeAPI.sendResponse(id, JSON.parse(value))
        }

        // error as string
        function onSignEOSError(id, error) {
            BrigeAPI.sendError(id, {"type": "signature_rejected", "message": error, "code": 402, "isError": true})
        }

        TinyIdentitys.initEOS("\(account)", "\(publicKey)");

        const scatter = new TinyScatter();
        scatter.loadPlugin(new TinyEOS());

        window.scatter = scatter;

        document.dispatchEvent(new CustomEvent('scatterLoaded'));

        """
        let onLoadScript = WKUserScript(source: "document.dispatchEvent(new CustomEvent('scatterLoaded'))", injectionTime: .atDocumentEnd, forMainFrameOnly: false)
        config.userContentController.addUserScript(onLoadScript)
        let userScript = WKUserScript(source: js, injectionTime: .atDocumentStart, forMainFrameOnly: false)
        config.userContentController.add(messageHandler, name: XMethod.signEOS.rawValue)
        config.userContentController.addUserScript(userScript)
    }
}

Additional Android injection init.js, your need thirdpart lib suchlike https://github.com/TrustWallet/Web3View (or roll you own) to accomplish the injection.


/**
/* use webView.evaluateJavascript to call when your finish the sign
/* @param id as number , you got it when XWebView.signEOS called
/* @param value as string, with this format '{"signatures":["SIG_K1_..."]}'
**/
function onSignEOSSuccessful(id, value) {
    BrigeAPI.sendResponse(id, JSON.parse(value))
}

// value as string "SIG_K1_..."
function onSignEOSMessageSuccessful(id, value) {
    BrigeAPI.sendResponse(id, value)
}

function onSignEOSError(id, error) {
    BrigeAPI.sendError(id, {"type": "signature_rejected", "message": error, "code": 402, "isError": true})
}

const messageHandlers = {
    signEOS: {
        postMessage: function (param) {
            //XWebView is your @JavascriptInterface
            XWebView.signEOS(param.id, param.object.data);
        }
    },
    signEOSMsg: {
        postMessage: function (param) {
            XWebView.signEOSMsg(param.id, param.object.data);
        }
    }
}

window.webkit = { messageHandlers };

TinyIdentitys.initEOS("%1$s", "%2$s");

const scatter = new TinyScatter();
scatter.loadPlugin(new TinyEOS());

window.scatter = scatter;

setTimeout(function() {document.dispatchEvent(new CustomEvent('scatterLoaded'));}, 1000);

EOS Encrypt

EOS Encrypt

github: https://github.com/EOS-Nation/eos-encrypt

Allows to encrypt & decypt a message with an EOS key pair using AES shared key encryption mechanism.

Decryption is achieved by combining the receiver's private key and the sender's public key to create the private key necessary to decrypt the message.

This module uses eosjs-ecc to perform the required cryptographic operations.

Install

npm

$ npm install --save eos-encrypt

Usage

import { encrypt, decrypt } from 'eos-encrypt';

const public_key = "EOS6M...DW5CV";
const private_key = "5KQwr...zkvFD3";

const message = "Private Message, shhhh!";
const encrypted = encrypt(private_key, public_key, message);
// => TO DECRYPT: eos-encrypt
// .1167451677...23460624..862584768Q+h1AeLQbjfzZJD1Nsx6kk3U/jSNStwoWstz9uNCadw=

const decrypted = decrypt(private_key, public_key, encrypted);
// => Private Message, shhhh!

API

Table of Contents

encrypt

Encrypt Message

Parameters

  • private_key string EOSIO Private Key
  • public_key string EOSIO Public Key
  • message string Message to Encrypt
  • options object Optional parameters (optional, default {})
    • options.memo string Serialized Memo (optional, default "TO DECRYPT: eos-encrypt\n")
    • options.maxsize number Maximum character message size (optional, default 256)

Examples

const encrypted = encrypt(private_key, public_key, message);

Returns string Encrypted Message

decrypt

Decrypt Message

Parameters

  • private_key string EOSIO Private Key
  • public_key string EOSIO Public Key
  • message string Encrypted Message
  • options object Optional parameters (optional, default {})
    • options.memo string Serialized Memo (optional, default "TO DECRYPT: eos-encrypt\n")

Examples

const decrypted = decrypt(private_key, public_key, message);

Returns string Decrypted Message

setMemo

Set Default Memo

Parameters

Examples

setMemo("TO DECRYPT: my-dapp\n");

Returns void