npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zxl-sdk

v1.5.0

Published

至信链SDK Node版本

Downloads

5

Readme

zxl-sdk

至信链node版SDK

下载安装

npm i zxl-sdk

使用示例

let ZxlSDK = require('zxl-sdk')
let Zxl = new ZxlSDK('190801000xxxxxx', '5d7300c738ddxxxxxxxxxxxxxxxxxxxx', true)

// 生成公私钥
let keys = Zxl.generateKeyPair()
console.log(keys)

// 更新公钥和签名
let updateData = Zxl.updateUserCert(pk, sk)
console.log(updateData)

// 获取文件路径
let img = 'cover-10d22361-9e8c-411b-90ba-4562d5d0ac30.jpeg'
let cwdPath = process.cwd()
let imgPath = cwdPath+'/'+img
console.log(imgPath)

// 获取文件hash
let hashInfo = Zxl.calculateHash(imgPath)
console.log(hashInfo)

// 扩展信息
let extStr = 'xxx,xxxxxxxxxxxxxxxx'

// 存证
let saveData = Zxl.evidenceSave(hashInfo.hash, extStr, sk)
console.log(saveData)

// 存证查询
let txHash = saveData.data.txHash
let queryData = Zxl.evidenceQuery('txHash', txHash)
console.log(queryData)

接口说明

new ZxlSDK(appId string, appKey string, is_test boolean)

功能:初始化 参数: appId 至信链ID appKey 至信链Key is_test 是否为测试环境,默认为非测试环境

generateKeyPair()

功能: 生成公钥和私钥
参数:无
返回值: { privateKey:公钥字符串
publicKey:私钥字符串
}

bindUserCert(pk string, sk string)

功能: 绑定用户公钥
参数:
pk 用户的公钥
sk 用户的私钥
返回值: { status: boolean 结果状态 data: null || { appId: 应用id blockHeight: 所在区块号 txHash: 交易hash createTime: 出块时间 } message: string || null }

updateUserCert(pk string, sk string)

功能: 更新用户公钥
参数:
pk 用户的公钥
sk 用户的私钥
返回值: { status: boolean 结果状态 data: null || { appId: 应用id blockHeight: 所在区块号 txHash: 交易hash createTime: 出块时间 } message: string || null }

calculateHash(path string)

功能: 通过文件路径,计算文件的哈希值
参数:
path 需要计算哈希的文件路径
返回值:
{ status: boolean 结果状态 hash: string || null 文件的哈希值 message: string || null 结果提示 }

calculateStrHash(str string)

功能: 对字符串计算哈希值
参数:
str 需要hash的字符串 返回值:
{ status: boolean 结果状态 hash: string || null 字符串的哈希值 message: string || null 结果提示 }

Sign(sk string, rawData []byte)

功能: 对数据进行签名
参数:
sk 私钥字符串
rawData 待签名数据
返回值:
string 签名结果字符串

Verify(pk, signedStr string, rawData []byte)

功能: 验证数据的签名是否正确
参数:
pk 用户公钥字符串
signedStr 签名字符串
rawData 数据内容
返回值:
bool 验证是否通过

evidenceSave(evHash, extendInfo, sk, pk string)

功能: 保存证据
参数:
evHash 证据的哈希信息
extendInfo 扩展信息
sk 用户私钥
pk 用户公钥
返回值: { status: boolean 结果状态 data: null || [ {
appId: 应用ID evId: 存证ID evHash: 存证hash extendInfo: 扩展信息 txHash: 交易hash blockHeight: 区块高度 createTime: 存证时间 } ] message: string || null }