update to standard .gitignore
This commit is contained in:
parent
ab105032ad
commit
cdeb44f43f
105
.gitignore
vendored
105
.gitignore
vendored
@ -1,63 +1,88 @@
|
|||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
node_modules/
|
### 目录 #################################################################
|
||||||
/test/unit/coverage/
|
|
||||||
/test/e2e/reports/
|
# 通用
|
||||||
.svn/
|
.svn/
|
||||||
|
.deploy_git/
|
||||||
.idea/
|
.idea/
|
||||||
.sass-cache/
|
.sass-cache/
|
||||||
.deploy_git/
|
/test/unit/coverage/
|
||||||
|
/test/e2e/reports/
|
||||||
|
node_modules/
|
||||||
|
*.apk
|
||||||
|
*.min.js
|
||||||
|
*.min.css
|
||||||
|
*.min.html
|
||||||
|
*.iml
|
||||||
|
*.njsproj
|
||||||
|
*.ntvs*
|
||||||
|
*.sw*
|
||||||
|
*.sln
|
||||||
|
*.suo
|
||||||
.gitattributes
|
.gitattributes
|
||||||
_desktop.ini
|
|
||||||
.DS_Store
|
|
||||||
.thumbnails
|
|
||||||
Thumbs.db
|
|
||||||
thumbs.db
|
|
||||||
.umi
|
.umi
|
||||||
.umi-production
|
.umi-production
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
yarn.lock
|
||||||
selenium-debug.log
|
selenium-debug.log
|
||||||
package-lock.json
|
Thumbs.db
|
||||||
*.iml
|
thumbs.db
|
||||||
*.njsproj
|
_desktop.ini
|
||||||
*.ntvs*
|
|
||||||
*.sln
|
|
||||||
*.suo
|
|
||||||
._*
|
|
||||||
.$*
|
|
||||||
~$*
|
|
||||||
|
|
||||||
.bashrc_custom
|
# vue-cli 项目
|
||||||
|
/dist/
|
||||||
|
|
||||||
|
# 来自 vue-cli 创建项目的 .gitignore
|
||||||
|
.project
|
||||||
|
|
||||||
# hexo
|
# hexo
|
||||||
db.json
|
/public/
|
||||||
|
|
||||||
# 客户端 uniapp 项目
|
# Hardhat
|
||||||
/unpackage/*
|
/artifacts/
|
||||||
!/unpackage/res/
|
/cache/
|
||||||
|
|
||||||
|
# seafile 临时文件
|
||||||
|
._*
|
||||||
|
|
||||||
|
.$*
|
||||||
|
|
||||||
|
# office 暂存文件
|
||||||
|
~$*
|
||||||
|
|
||||||
|
# 用户shell配置脚本
|
||||||
|
.bashrc_custom
|
||||||
|
|
||||||
|
# 苹果系统临时文件
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# 安卓缓存文件夹
|
||||||
|
.thumbnails
|
||||||
|
|
||||||
|
# local env files
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
|
||||||
|
# hexo
|
||||||
|
/db.json
|
||||||
|
|
||||||
|
# wo
|
||||||
|
envar-*.gitignore.js
|
||||||
|
# 服务端
|
||||||
/_archive/*
|
/_archive/*
|
||||||
/_datastore/*
|
/_datastore/*
|
||||||
/_logstore/*
|
|
||||||
/_filestore/*
|
/_filestore/*
|
||||||
|
/_logstore/*
|
||||||
/_webroot/*
|
/_webroot/*
|
||||||
/dist/
|
/_ssl/*
|
||||||
*.apk
|
# uniapp 客户端
|
||||||
*.min.js
|
/unpackage/*
|
||||||
*.min.css
|
!/unpackage/res/
|
||||||
*.min.html
|
package-lock.json
|
||||||
/pages4loader.json5
|
pages4loader.json5
|
||||||
envar-web-custom.js
|
|
||||||
envar-deploy-secret.js
|
|
||||||
|
|
||||||
# hexo 项目
|
|
||||||
public/
|
|
||||||
|
|
||||||
# 服务端(server or uniapp-uniCloud)项目
|
|
||||||
envar-base-custom.js
|
|
||||||
envar-base-dynamic.js
|
|
||||||
envar-base-secret.js
|
|
||||||
|
|
||||||
|
# 保留
|
||||||
!.gitkeep
|
!.gitkeep
|
||||||
|
63
ticc.js
63
ticc.js
@ -114,7 +114,7 @@ class TicCrypto {
|
|||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
* @memberof TicCrypto
|
* @memberof TicCrypto
|
||||||
*/
|
*/
|
||||||
static is_secword ({ secword, mode = 'strict', lang } = {}) {
|
static is_secword ({ secword = '', mode = 'strict', lang } = {}) {
|
||||||
// 注意 not all 12 words combinations are valid for both bitcore and bip39, because there are checksum in mnemonic. 另外,实际上bitcore和bip39对 12, 15, 18, 21, 24 长度的合法助记词都返回 true。
|
// 注意 not all 12 words combinations are valid for both bitcore and bip39, because there are checksum in mnemonic. 另外,实际上bitcore和bip39对 12, 15, 18, 21, 24 长度的合法助记词都返回 true。
|
||||||
|
|
||||||
//// for bitcore-mnemonic. 注意,bitcore-mnemonic 对少于12词的会抛出异常,很蠢。
|
//// for bitcore-mnemonic. 注意,bitcore-mnemonic 对少于12词的会抛出异常,很蠢。
|
||||||
@ -201,10 +201,7 @@ class TicCrypto {
|
|||||||
if (salt && typeof salt === 'string') data = data + this.hash_easy(salt)
|
if (salt && typeof salt === 'string') data = data + this.hash_easy(salt)
|
||||||
let inputEncoding = input // my.INPUT_LIST.includes(input)?input:my.INPUT // 'utf8', 'ascii' or 'latin1' for string data, default to utf8 if not specified; ignored for Buffer, TypedArray, or DataView.
|
let inputEncoding = input // my.INPUT_LIST.includes(input)?input:my.INPUT // 'utf8', 'ascii' or 'latin1' for string data, default to utf8 if not specified; ignored for Buffer, TypedArray, or DataView.
|
||||||
let outputEncoding = output === 'buf' ? undefined : output // (my.OUTPUT_LIST.includes(output)?output:my.OUTPUT) // output: 留空=》默认输出hex格式;或者手动指定 'buf', hex', 'latin1' or 'base64'
|
let outputEncoding = output === 'buf' ? undefined : output // (my.OUTPUT_LIST.includes(output)?output:my.OUTPUT) // output: 留空=》默认输出hex格式;或者手动指定 'buf', hex', 'latin1' or 'base64'
|
||||||
return crypto
|
return crypto.createHash(hasher).update(data, inputEncoding).digest(outputEncoding)
|
||||||
.createHash(hasher)
|
|
||||||
.update(data, inputEncoding)
|
|
||||||
.digest(outputEncoding)
|
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -396,10 +393,7 @@ class TicCrypto {
|
|||||||
static pass_to_keypair ({ pass, hasher = my.HASHER } = {}) {
|
static pass_to_keypair ({ pass, hasher = my.HASHER } = {}) {
|
||||||
// 如果使用其他机制,例如密码、随机数,不使用secword,也可生成keypair
|
// 如果使用其他机制,例如密码、随机数,不使用secword,也可生成keypair
|
||||||
if (this.is_hashable({ data: pass })) {
|
if (this.is_hashable({ data: pass })) {
|
||||||
var hashBuf = crypto
|
var hashBuf = crypto.createHash(hasher).update(pass).digest()
|
||||||
.createHash(hasher)
|
|
||||||
.update(pass)
|
|
||||||
.digest()
|
|
||||||
var keypair = nacl.sign.keyPair.fromSeed(hashBuf) // nacl的seed要求是32字节
|
var keypair = nacl.sign.keyPair.fromSeed(hashBuf) // nacl的seed要求是32字节
|
||||||
return {
|
return {
|
||||||
hash: hashBuf.toString('hex'),
|
hash: hashBuf.toString('hex'),
|
||||||
@ -469,10 +463,7 @@ class TicCrypto {
|
|||||||
}
|
}
|
||||||
if (tool === 'nacl') {
|
if (tool === 'nacl') {
|
||||||
// 采用自己的算法:bip39算法从secword到种子,hash后用 nacl.sign.keyPair.fromSeed()方法。
|
// 采用自己的算法:bip39算法从secword到种子,hash后用 nacl.sign.keyPair.fromSeed()方法。
|
||||||
let hashBuf = crypto
|
let hashBuf = crypto.createHash(hasher).update(this.secword_to_seed({ secword, pass })).digest()
|
||||||
.createHash(hasher)
|
|
||||||
.update(this.secword_to_seed({ secword, pass }))
|
|
||||||
.digest()
|
|
||||||
let keypair = nacl.sign.keyPair.fromSeed(hashBuf) // nacl.sign.keyPair.fromSeed 要求32字节的种子,而 this.secword2seed生成的是64字节种子,所以要先做一次sha256
|
let keypair = nacl.sign.keyPair.fromSeed(hashBuf) // nacl.sign.keyPair.fromSeed 要求32字节的种子,而 this.secword2seed生成的是64字节种子,所以要先做一次sha256
|
||||||
return {
|
return {
|
||||||
pubkey: Buffer.from(keypair.publicKey).toString('hex'), // 测试过 不能直接keypair.publicKey.toString('hex'),不是buffer类型
|
pubkey: Buffer.from(keypair.publicKey).toString('hex'), // 测试过 不能直接keypair.publicKey.toString('hex'),不是buffer类型
|
||||||
@ -688,14 +679,8 @@ class TicCrypto {
|
|||||||
.digest('hex')
|
.digest('hex')
|
||||||
.slice(-40)
|
.slice(-40)
|
||||||
} else {
|
} else {
|
||||||
let h256buf = crypto
|
let h256buf = crypto.createHash('sha256').update(Buffer.from(pubkey, 'hex')).digest()
|
||||||
.createHash('sha256')
|
let h160 = crypto.createHash('ripemd160').update(h256buf).digest('hex')
|
||||||
.update(Buffer.from(pubkey, 'hex'))
|
|
||||||
.digest()
|
|
||||||
let h160 = crypto
|
|
||||||
.createHash('ripemd160')
|
|
||||||
.update(h256buf)
|
|
||||||
.digest('hex')
|
|
||||||
return h160
|
return h160
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -718,9 +703,7 @@ class TicCrypto {
|
|||||||
if (coin === 'ETH' || coinFamily === 'ETH') {
|
if (coin === 'ETH' || coinFamily === 'ETH') {
|
||||||
// 对以太坊,按照 EIP55,把纯位置转换为大小写敏感能自我验证的hex地址。仍然为20节=40符。
|
// 对以太坊,按照 EIP55,把纯位置转换为大小写敏感能自我验证的hex地址。仍然为20节=40符。
|
||||||
position = position.toLowerCase().replace('0x', '')
|
position = position.toLowerCase().replace('0x', '')
|
||||||
let hash = keccak('keccak256')
|
let hash = keccak('keccak256').update(position).digest('hex')
|
||||||
.update(position)
|
|
||||||
.digest('hex')
|
|
||||||
address = '0x'
|
address = '0x'
|
||||||
for (var i = 0; i < position.length; i++) {
|
for (var i = 0; i < position.length; i++) {
|
||||||
if (parseInt(hash[i], 16) >= 8) {
|
if (parseInt(hash[i], 16) >= 8) {
|
||||||
@ -1100,10 +1083,7 @@ class TicCrypto {
|
|||||||
// hash为64hex字符,sig为128hex字符。返回用hex表达的距离。
|
// hash为64hex字符,sig为128hex字符。返回用hex表达的距离。
|
||||||
if (this.is_signature({ sig: sig }) && this.is_hash({ hash })) {
|
if (this.is_signature({ sig: sig }) && this.is_hash({ hash })) {
|
||||||
var hashSig = this.hash_easy(sig) // 把签名也转成32字节的哈希,同样长度方便比较
|
var hashSig = this.hash_easy(sig) // 把签名也转成32字节的哈希,同样长度方便比较
|
||||||
return new BigInt(hash, 16)
|
return new BigInt(hash, 16).subtract(new BigInt(hashSig, 16)).abs().toString(16)
|
||||||
.subtract(new BigInt(hashSig, 16))
|
|
||||||
.abs()
|
|
||||||
.toString(16)
|
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -1322,10 +1302,7 @@ class TicCrypto {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
static b64_to_b64t (b64 = '') {
|
static b64_to_b64t (b64 = '') {
|
||||||
return b64
|
return b64.replace(/\+/g, '.').replace(/\//g, '_').replace(/=/g, '')
|
||||||
.replace(/\+/g, '.')
|
|
||||||
.replace(/\//g, '_')
|
|
||||||
.replace(/=/g, '')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static b64t_to_b64 (b64t = '') {
|
static b64t_to_b64 (b64t = '') {
|
||||||
@ -1399,9 +1376,7 @@ class TicCrypto {
|
|||||||
static hex_to_eip55 (hex) {
|
static hex_to_eip55 (hex) {
|
||||||
if (/^(0x)?[\da-fA-F]+$/.test(hex)) {
|
if (/^(0x)?[\da-fA-F]+$/.test(hex)) {
|
||||||
hex = hex.toLowerCase().replace('0x', '')
|
hex = hex.toLowerCase().replace('0x', '')
|
||||||
let hash = keccak('keccak256')
|
let hash = keccak('keccak256').update(hex).digest('hex')
|
||||||
.update(hex)
|
|
||||||
.digest('hex')
|
|
||||||
let result = ''
|
let result = ''
|
||||||
for (var i = 0; i < hex.length; i++) {
|
for (var i = 0; i < hex.length; i++) {
|
||||||
if (parseInt(hash[i], 16) >= 8) {
|
if (parseInt(hash[i], 16) >= 8) {
|
||||||
@ -1457,11 +1432,7 @@ class TicCrypto {
|
|||||||
const pIdent = new BigInt('3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c', 16) // prime.add(1).divide(4);
|
const pIdent = new BigInt('3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c', 16) // prime.add(1).divide(4);
|
||||||
var signY = new Number(compressed[1]) - 2
|
var signY = new Number(compressed[1]) - 2
|
||||||
var x = new BigInt(compressed.substr(2), 16)
|
var x = new BigInt(compressed.substr(2), 16)
|
||||||
var y = x
|
var y = x.modPow(3, prime).add(7).mod(prime).modPow(pIdent, prime) // y mod p = +-(x^3 + 7)^((p+1)/4) mod p
|
||||||
.modPow(3, prime)
|
|
||||||
.add(7)
|
|
||||||
.mod(prime)
|
|
||||||
.modPow(pIdent, prime) // y mod p = +-(x^3 + 7)^((p+1)/4) mod p
|
|
||||||
if (y.mod(2).toJSNumber() !== signY) {
|
if (y.mod(2).toJSNumber() !== signY) {
|
||||||
// If the parity doesn't match it's the *other* root
|
// If the parity doesn't match it's the *other* root
|
||||||
y = prime.subtract(y) // y = prime - y
|
y = prime.subtract(y) // y = prime - y
|
||||||
@ -1527,21 +1498,15 @@ class TicCrypto {
|
|||||||
const fullHex = `01${multicodec[cidCodec]}${multialgo[cidAlgo]}${Number(cosh.length / 2).toString(16)}${cosh}`
|
const fullHex = `01${multicodec[cidCodec]}${multialgo[cidAlgo]}${Number(cosh.length / 2).toString(16)}${cosh}`
|
||||||
let converted = ''
|
let converted = ''
|
||||||
if (cidBase === 'b32') {
|
if (cidBase === 'b32') {
|
||||||
converted = this.hex_to_b32(fullHex)
|
converted = this.hex_to_b32(fullHex).toLowerCase().replace(/=/g, '')
|
||||||
.toLowerCase()
|
|
||||||
.replace(/=/g, '')
|
|
||||||
} else if (cidBase === 'B32') {
|
} else if (cidBase === 'B32') {
|
||||||
converted = this.hex_to_b32(fullHex)
|
converted = this.hex_to_b32(fullHex).toUpperCase().replace(/=/g, '')
|
||||||
.toUpperCase()
|
|
||||||
.replace(/=/g, '')
|
|
||||||
} else if (cidBase === 'b58') {
|
} else if (cidBase === 'b58') {
|
||||||
converted = this.hex_to_b58(fullHex)
|
converted = this.hex_to_b58(fullHex)
|
||||||
} else if (cidBase === 'b64p') {
|
} else if (cidBase === 'b64p') {
|
||||||
converted = Buffer.from(fullHex, 'hex').toString('base64')
|
converted = Buffer.from(fullHex, 'hex').toString('base64')
|
||||||
} else if (cidBase === 'b64') {
|
} else if (cidBase === 'b64') {
|
||||||
converted = Buffer.from(fullHex, 'hex')
|
converted = Buffer.from(fullHex, 'hex').toString('base64').replace(/=/g, '')
|
||||||
.toString('base64')
|
|
||||||
.replace(/=/g, '')
|
|
||||||
}
|
}
|
||||||
return multibase[cidBase] + converted
|
return multibase[cidBase] + converted
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user