• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript bip32.fromBase58函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中bip32.fromBase58函数的典型用法代码示例。如果您正苦于以下问题:TypeScript fromBase58函数的具体用法?TypeScript fromBase58怎么用?TypeScript fromBase58使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了fromBase58函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: getAppPrivateKey

 /**
  * Get a ECDSA private key hex-string for an application-specific
  *  address.
  * @param {String} appsNodeKey - the base58-encoded private key for
  * applications node (the `appsNodeKey` return in getIdentityKeyPair())
  * @param {String} salt - a string, used to salt the
  * application-specific addresses
  * @param {String} appDomain - the appDomain to generate a key for
  * @return {String} the private key hex-string. this will be a 64
  * character string
  */
 static getAppPrivateKey(appsNodeKey: string, salt: string, appDomain: string): string {
   const hash = crypto
     .createHash('sha256')
     .update(`${appDomain}${salt}`)
     .digest('hex')
   const appIndexHexes: string[] = []
   // note: there's hardcoded numbers here, precisely because I want this
   //   code to be very specific to the derivation paths we expect.
   if (hash.length !== 64) {
     throw new Error(`Unexpected app-domain hash length of ${hash.length}`)
   }
   for (let i = 0; i < 11; i++) { // split the hash into 3-byte chunks
     // because child nodes can only be up to 2^31,
     // and we shouldn't deal in partial bytes.
     appIndexHexes.push(hash.slice(i * 6, i * 6 + 6))
   }
   let appNode = bip32.fromBase58(appsNodeKey)
   appIndexHexes.forEach((hex) => {
     if (hex.length > 6) {
       throw new Error('Invalid hex string length')
     }
     appNode = appNode.deriveHardened(parseInt(hex, 16))
   })
   return getNodePrivateKey(appNode).slice(0, 64)
 }
开发者ID:blockstack,项目名称:blockstack-cli,代码行数:36,代码来源:wallet.ts


示例2: getLegacyAppPrivateKey

 /**
  * Get a ECDSA private key hex-string for an application-specific
  *  address.
  * @param {String} appsNodeKey - the base58-encoded private key for
  * applications node (the `appsNodeKey` return in getIdentityKeyPair())
  * @param {String} salt - a string, used to salt the
  * application-specific addresses
  * @param {String} appDomain - the appDomain to generate a key for
  * @return {String} the private key hex-string. this will be a 64
  * character string
  */
 static getLegacyAppPrivateKey(appsNodeKey: string, 
                               salt: string, appDomain: string): string {
   const hash = crypto
     .createHash('sha256')
     .update(`${appDomain}${salt}`)
     .digest('hex')
   const appIndex = hashCode(hash)
   const appNode = bip32.fromBase58(appsNodeKey).deriveHardened(appIndex)
   return getNodePrivateKey(appNode).slice(0, 64)
 }
开发者ID:blockstack,项目名称:blockstack-cli,代码行数:21,代码来源:wallet.ts


示例3: getNodeFromBitcoinKeychain

  static getNodeFromBitcoinKeychain(
    keychainBase58: string,
    addressIndex: number,
    chainType: string = EXTERNAL_ADDRESS
  ): BIP32 {
    let chain
    if (chainType === EXTERNAL_ADDRESS) {
      chain = 0
    } else if (chainType === CHANGE_ADDRESS) {
      chain = 1
    } else {
      throw new Error('Invalid chain type')
    }
    const keychain = bip32.fromBase58(keychainBase58)

    return keychain.derive(chain).derive(addressIndex)
  }
开发者ID:blockstack,项目名称:blockstack-cli,代码行数:17,代码来源:wallet.ts


示例4: fromBase58

 /**
  * Initialize a Blockstack wallet from a base58 string
  * @param {string} keychain - the Base58 string used to initialize
  *  the root node of the hierarchical wallet
  * @return {BlockstackWallet} the constructed wallet
  */
 static fromBase58(keychain: string): BlockstackWallet {
   return new BlockstackWallet(bip32.fromBase58(keychain))
 }
开发者ID:blockstack,项目名称:blockstack-cli,代码行数:9,代码来源:wallet.ts


示例5: fromBase58

import { fromBase58 } from 'bip32';

const node = fromBase58("xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi");

const child = node.derivePath('m/0');

const grandchild = child.derive(2);

grandchild.toWIF() === 'Kxtby4wzfHeCaRXma16dBNLgUE7Ct3Xkb6sRs3aZ56Bmtf1rcNWs';
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:9,代码来源:bip32-tests.ts



注:本文中的bip32.fromBase58函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript bip32.BIP32类代码示例发布时间:2022-05-25
下一篇:
TypeScript bignumber.js.default类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap