{"id":18733187,"url":"https://github.com/bioforestchain/bfmeta-sign-util","last_synced_at":"2025-11-14T01:30:14.286Z","repository":{"id":65184870,"uuid":"585840652","full_name":"BioforestChain/BFMeta-Sign-Util","owner":"BioforestChain","description":"bfchain 生成签名及地址的工具包","archived":false,"fork":false,"pushed_at":"2023-07-14T02:10:14.000Z","size":56,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-28T23:17:03.950Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BioforestChain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-06T08:11:48.000Z","updated_at":"2023-04-25T12:51:17.000Z","dependencies_parsed_at":"2023-02-12T08:30:37.350Z","dependency_job_id":null,"html_url":"https://github.com/BioforestChain/BFMeta-Sign-Util","commit_stats":null,"previous_names":["bioforestchain/bfchain-sign-util"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FBFMeta-Sign-Util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FBFMeta-Sign-Util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FBFMeta-Sign-Util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioforestChain%2FBFMeta-Sign-Util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BioforestChain","download_url":"https://codeload.github.com/BioforestChain/BFMeta-Sign-Util/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239605124,"owners_count":19666998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T15:08:58.970Z","updated_at":"2025-11-14T01:30:13.972Z","avatar_url":"https://github.com/BioforestChain.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @bfmeta/sign-util\n\n    BFMeta 生成签名的工具包\n\n## 使用\n\n```node\nexport class CryptoHelper\n  implements BFMetaSignUtil.CryptoHelperInterface\n{\n  async sha256(msg: string | Uint8Array) {\n    if (msg instanceof Uint8Array) {\n      return crypto.createHash(\"sha256\").update(msg).digest();\n    }\n    return crypto\n      .createHash(\"sha256\")\n      .update(new Uint8Array(Buffer.from(msg)))\n      .digest();\n  }\n\n  async md5(data?: any): any {\n    const hash = crypto.createHash(\"md5\");\n    if (data) {\n      return hash.update(data).digest();\n    }\n    return hash;\n  }\n\n  async ripemd160(data?: any): any {\n    const hash = crypto.createHash(\"ripemd160\");\n    if (data) {\n      return hash.update(data).digest();\n    }\n    return hash;\n  }\n}\n\nimport { BFMetaSignUtil } from \"@bfmeta/sign-util\";\n(async () =\u003e {\n  const cryptoHelper = new CryptoHelper();\n  const bfmetaSignUtil = new BFMetaSignUtil(\"c\", Buffer as any, cryptoHelper);\n\n  const keypair = await bfmetaSignUtil.createKeypair(\"123\");\n  const keypair2 = bfmetaSignUtil.createKeypairBySecretKey(keypair.secretKey);\n  console.log(keypair2.publicKey.toString(\"hex\"));\n  // 获取公钥\n  const publicKey = keypair.publicKey.toString(\"hex\");\n  console.log(publicKey);\n  // 获取地址\n  const address = bfmetaSignUtil.getAddressFromPublicKey(keypair.publicKey);\n  console.log(address);\n  console.log(bfmetaSignUtil.getAddressFromPublicKeyString(publicKey));\n  // 校验地址\n  console.log(bfmetaSignUtil.isAddress(address));\n  console.log(bfmetaSignUtil.isAddress(\"abc\"));\n  // 生成签名\n  const msg = new Uint8Array(Buffer.from(\"abc\"));\n  const signature = await bfmetaSignUtil.detachedSign(msg, keypair.secretKey);\n  console.log(signature.toString(\"hex\"));\n  console.log(bfmetaSignUtil.signToString(msg, keypair.secretKey));\n  // 验证签名\n  const result = bfmetaSignUtil.detachedVeriy(msg, signature, keypair.publicKey);\n  console.log(result);\n})();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbioforestchain%2Fbfmeta-sign-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbioforestchain%2Fbfmeta-sign-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbioforestchain%2Fbfmeta-sign-util/lists"}