From ae96a990f15f7ba9d554245961506a7c1d9d16d0 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sat, 31 Oct 2020 12:20:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 110 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index c969d64..a03544e 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,43 @@ # tic.crypto -时光链密码学工具库:时光链专用的密码学工具库,用来处理哈希、加解密、签名、助记词、等等。 +时光链区块链密码学算法工具库:为区块链相关应用开发提供一套底层的基础算法工具库,用来处理哈希、加解密、签名、助记词、等等。 -## Table of Contents +- 支持 md5、sha256 等算法的哈希 +- 基于 bip39 等算法的助记词生成、检验 +- 基于 secp256k1 等曲线算法的签名、交易的加解密 +- 其他辅助算法工具 - 1. [Installation Guide](#1-installation-guide) - 2. [Usage](#2-usage) - 3. [API Specification](#3-api-specification) - 4. [References](#4-references) +- [tic.crypto](#ticcrypto) + - [硬件环境](#硬件环境) + - [软件环境](#软件环境) + - [安装指南](#安装指南) + - [用法](#用法) + - [编程接口规范](#编程接口规范) -## 1. Installation Guide +## 硬件环境 + +- 机型:Mac 或 PC 机 +- 内存:8GB 以上 +- 硬盘:500G 以上 + +## 软件环境 + +- 操作系统:跨平台通用,支持 MacOS, Linux, Windows +- 开发环境:推荐 Visual Studio Code +- 运行环境:nodejs 12.16 版本 + +## 安装指南 在前后端软件的 package.json 的依赖清单中引入本库: + ``` npm install git+https://git.faronear.org/tic/tic.action#RELEASE_OR_BRANCH --save ``` -## 2. Usage +## 用法 基本用法示例: + ``` let ticCrypto=require('tic.crypto') // 引用 let sw=ticCrypto.randomSecword() // 生成一个随机的助记词(即密语)。或者使用现成的密语。 @@ -26,44 +45,41 @@ let kp=ticCrypto.secword2keypair(sw) // 把密语转换成公私钥 let address=ticCrypto.secword2address(sw) // 把密语转换成地址 ``` -## 3. API Specification +## 编程接口规范 + +| 函数名 | 参数 | 备注 | +| ------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------- | +| hash | (data, option={hasher:'sha256', salt, input:'utf8', output:'hex'}) | 哈希算法。给 input(=utf8 | latin1 | ascii)格式的输入 data 加 salt 后,根据 hasher(=sha256 | md5 | sha1 | sha512 | ripemd160),输出 output(=hex | latin1 | base64 | buf)格式的哈希值。 | +| isHashable | (data) | | +| isHash | | | +| encrypt | (data, pwd, option={ cipher:'aes-256-cfb', input:'utf8', output:'hex' }) | | +| decrypt | (data, pwd, option={ cipher:'aes-256-cfb', input:'hex', output:'utf8' }) | | +| sign | (data, seckey, option) | | +| isSignature | | | +| verify | (data, signature, pubkey, option) | | +| pass2keypair | | | +| secword2keypair | | 密语到公私钥 { pubkey, seckey } | +| seckey2pubkey | | | +| secword2account | | 密语到账户 { address, pubkey, seckey } | +| secword2address | | 密语到地址 address | +| isSecword | | | +| isSeckey | | | +| isPubkey | | | +| isAddress | | | +| pubkey2address | | | +| secword2seed | | | +| randomSecword | (lang) | lang=[ 'CHINESE', 'ENGLISH', 'FRENCH', 'ITALIAN', 'JAPANESE', 'SPANISH' ] | +| randomSeckey | | | +| randomKeypair | | | +| randomString | | | +| randomNumber | | | +| randomUuid: { [Function: v4] v1 | | | +| getMerkleRoot | | | +| distanceSig | | | +| compareSig | | | +| sortSigList | | | +| getString2Sign | | | +| rsaSign | | | +| rsaVerify | | | -|函数名|参数|说明 -|-|-|-| -|hash|(data, option={hasher:'sha256', salt, input:'utf8', output:'hex'})|哈希算法。给input(=utf8|latin1|ascii)格式的输入data加salt后,根据hasher(=sha256|md5|sha1|sha512|ripemd160),输出output(=hex|latin1|base64|buf)格式的哈希值。| -|isHashable|(data)|| -|isHash||| -|encrypt|(data, pwd, option={ cipher:'aes-256-cfb', input:'utf8', output:'hex' })|| -|decrypt|(data, pwd, option={ cipher:'aes-256-cfb', input:'hex', output:'utf8' })|| -|sign|(data, seckey, option)|| -|isSignature||| -|verify|(data, signature, pubkey, option)|| -|pass2keypair||| -|secword2keypair||密语到公私钥 { pubkey, seckey }| -|seckey2pubkey||| -|secword2account||密语到账户 { address, pubkey, seckey }| -|secword2address||密语到地址 address| -|isSecword||| -|isSeckey||| -|isPubkey||| -|isAddress||| -|pubkey2address||| -|secword2seed||| -|randomSecword|(lang)|lang=[ 'CHINESE', 'ENGLISH', 'FRENCH', 'ITALIAN', 'JAPANESE', 'SPANISH' ] -|randomSeckey||| -|randomKeypair||| -|randomString||| -|randomNumber||| -|randomUuid: { [Function: v4] v1||| -|getMerkleRoot||| -|distanceSig||| -|compareSig||| -|sortSigList||| -|getString2Sign||| -|rsaSign||| -|rsaVerify||| --- - -## 4. References - -+ 返回根文档: