基于区块链的毕业设计HD Keyring – HD键环

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计HD Keyring – HD键环 是一篇很好的国外资料

HD Keyring HD Keyring - HD键环

A simple JS class wrapped around ethereumjs-wallet designed to expose an interface common to many different signing strategies, to be used in a KeyringController, like is being used in MetaMask

The Keyring Class Protocol

One of the goals of this class is to allow developers to easily add new signing strategies to MetaMask. We call these signing strategies Keyrings, because they can manage multiple keys.

Keyring.type

A class property that returns a unique string describing the Keyring. This is the only class property or method, the remaining methods are instance methods.

constructor( options )

As a Javascript class, your Keyring object will be used to instantiate new Keyring instances using the new keyword. For example:

const keyring = new YourKeyringClass(options); 

The constructor currently receives an options object that will be defined by your keyring-building UI, once the user has gone through the steps required for you to fully instantiate a new keyring. For example, choosing a pattern for a vanity account, or entering a seed phrase.

We haven’t defined the protocol for this account-generating UI yet, so for now please ensure your Keyring behaves nicely when not passed any options object.

Keyring Instance Methods

All below instance methods must return Promises to allow asynchronous resolution.

serialize()

In this method, you must return any JSON-serializable JavaScript object that you like. It will be encoded to a string, encrypted with the user’s password, and stored to disk. This is the same object you will receive in the deserialize() method, so it should capture all the information you need to restore the Keyring’s state.

deserialize( object )

As discussed above, the deserialize() method will be passed the JavaScript object that you returned when the serialize() method was called.

addAccounts( n = 1 )

The addAccounts(n) method is used to inform your keyring that the user wishes to create a new account. You should perform whatever internal steps are needed so that a call to serialize() will persist the new account, and then return an array of the new account addresses.

The method may be called with or without an argument, specifying the number of accounts to create. You should generally default to 1 per call.

getAccounts()

When this method is called, you must return an array of hex-string addresses for the accounts that your Keyring is able to sign for.

signTransaction(address, transaction)

This method will receive a hex-prefixed, all-lowercase address string for the account you should sign the incoming transaction with.

For your convenience, the transaction is an instance of ethereumjs-tx, (https://github.com/ethereumjs/ethereumjs-tx) so signing can be as simple as:

transaction.sign(privateKey) 

You must return a valid signed ethereumjs-tx (https://github.com/ethereumjs/ethereumjs-tx) object when complete, it can be the same transaction you received.

signMessage(address, data)

The eth_sign method will receive the incoming data, alread hashed, and must sign that hash, and then return the raw signed hash.

exportAccount(address)

Exports the specified account as a private key hex string.

We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products. Learn more.


HD Keyring<HD Keyring>

一个简单的JS类包装在ethereumjs wallet中,旨在公开许多不同签名策略的通用接口,并将其用于KeyringController中,例如MetaMask中使用的类,该类的目标之一是允许开发人员轻松地向MetaMask添加新的签名策略。我们称这些签名策略为Keyrings,因为它们可以管理多个密钥。

Keyring类协议

返回描述密钥环的唯一字符串的类属性。这是唯一的类属性或方法,其余的方法是实例方法。

钥匙圈类型

作为一个Javascript类,Keyring对象将用于使用new关键字实例化新的Keyring实例。例如:

构造函数(选项)

一旦用户完成了完全实例化新keyring所需的步骤,构造函数当前将收到一个options对象,该对象将由keyring构建UI定义。例如,为虚荣帐户选择模式,或输入种子短语。

const keyring = new YourKeyringClass(options); 

我们尚未定义此帐户生成UI的协议,因此现在请确保您的Keyring在未传递任何options对象时表现良好。

下面的所有实例方法都必须返回承诺以允许异步解析。

Keyring实例方法

在这个方法中,必须返回您喜欢的任何JSON可序列化JavaScript对象。它将被编码成一个字符串,用用户的密码加密,并存储到磁盘上。这是您将在deserialize()方法中接收到的同一个对象,因此它应该捕获恢复Keyring状态所需的所有信息。

serialize()

如上所述,将向deserialize()方法传递调用serialize()方法时返回的JavaScript对象。

反序列化(object)

addAccounts(n)方法用于通知keyring用户希望创建新帐户。您应该执行所需的任何内部步骤,以便serialize()的调用将持久化新帐户,然后返回新帐户地址的数组。

addAccounts(n=1)

调用该方法时可以使用参数,也可以不使用参数,指定要创建的帐户数。通常情况下,每次调用应默认为1。

调用此方法时,必须返回密钥环能够签名的帐户的十六进制字符串地址数组。

getAccounts()

此方法将收到一个十六进制前缀的、全小写的地址字符串,该字符串用于签署传入事务。

signTransaction(地址,事务)

为了方便起见,事务是以太坊ethjs tx的一个实例(https://github.com/ethereumjs/ethereumjs-tx)因此签名可以很简单:

您必须返回一个有效的签名的以太坊ethjs tx(https://github.com/ethereumjs/ethereumjs-tx)对象完成后,它可以是您接收到的同一事务。

transaction.sign(privateKey) 

eth_sign方法将接收传入的数据,alread hashed,并且必须对该哈希进行签名,然后返回原始签名哈希。

signMessage(地址,数据)

将指定帐户导出为私钥十六进制字符串。

导出帐户(地址)

我们使用可选的第三方分析cookies来了解您如何使用GitHub.com网站所以我们可以制造更好的产品。了解更多。

我们使用可选的第三方分析cookies来了解您如何使用GitHub.com网站所以我们可以制造更好的产品。
您可以随时通过单击页面底部的Cookie首选项来更新您的选择。有关更多信息,请参阅我们的隐私声明。

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/18359.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 !
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计HD Keyring – HD键环

提供最优质的资源集合

立即查看 了解详情