vrf-solidity – vrf坚固性区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,vrf-solidity – vrf坚固性区块链毕设代写 是一篇很好的国外资料

vrf-solidity vrf-solidity - vrf坚固性 vrf-solidity - vrf坚固性

vrf-solidity is an open source fast and effective implementation of Verifiable Random Functions (VRFs) written in Solidity. More precisely, this library implements verification functions for VRF proofs based on the Elliptic Curve (EC) Secp256k1.

DISCLAIMER: This is experimental software. Use it at your own risk!

The solidity library has been designed aiming at decreasing gas consumption and its complexity due to EC operations.

It provides two main pure functions for verifying VRF proofs:

  • verify:
    • Description: VRF full verification (requires heavy EC computation)
    • Inputs:
      • _publicKey: The public key as an array composed of [pubKey-x, pubKey-y]
      • _proof: The VRF proof as an array composed of [gamma-x, gamma-y, c, s]
      • _message: The message (in bytes) used for computing the VRF
    • Output:
      • true, if VRF proof is valid
  • fastVerify:
    • Description: VRF fast verification by providing additional EC points. It uses the ecrecover precompiled function to verify EC multiplications (lower gas consumption).
    • Inputs:
      • _publicKey: The public key as an array composed of [pubKey-x, pubKey-y]
      • _proof: The VRF proof as an array composed of [gamma-x, gamma-y, c, s]
      • _message: The message (in bytes) used for computing the VRF
      • _uPoint: The u EC point defined as U = s*B - c*Y
      • _vComponents: The components required to compute v as V = s*H - c*Gamma
    • Output:
      • true, if VRF proof is valid

Additionally, the library provides some auxiliary pure functions to facilitate computing the aforementioned input parameters:

  • decodeProof:
    • Description: Decode from bytes to VRF proof
    • Input:
      • _proof: The VRF proof as bytes
    • Output:
      • The VRF proof as an array composed of [gamma-x, gamma-y, c, s]
  • decodePoint:
    • Description: Decode from bytes to EC point
    • Input:
      • _point: The EC point as bytes
    • Output:
      • The point as [point-x, point-y]
  • computeFastVerifyParams:
    • Description: Compute the parameters (EC points) required for the VRF fast verification function
    • Inputs:
      • _publicKey: The public key as an array composed of [pubKey-x, pubKey-y]
      • _proof: The VRF proof as an array composed of [gamma-x, gamma-y, c, s]
      • _message: The message (in bytes) used for computing the VRF
    • Output:
      • The fast verify required parameters as the tuple ([uPointX, uPointY], [sHX, sHY, cGammaX, cGammaY])
  • gammaToHash:
    • Description: Computes the VRF hash output as result of the digest of a ciphersuite-dependent prefix concatenated with the gamma point. This hash can be used for deterministically generating verifiable pseudorandom numbers.
    • Inputs:
      • _gammaX: The x-coordinate of the gamma EC point
      • _gammaY: The y-coordinate of the gamma EC point
    • Output:
      • The VRF hash ouput as shas256 digest

Elliptic Curve VRF (using Secp256k1)

This library follows the algorithms described in VRF-draft-04 in order to provide the VRF verification capability.

The supported cipher suite is SECP256K1_SHA256_TAI, i.e. the aforementioned algorithms using SHA256 as digest function and the secp256k1 curve. For the VRF algorithms the cipher suite code used is 0xFE.

For elliptic curve arithmetic operations vrf-solidity uses the elliptic-curve-solidity library.

Usage

VRF.sol library can be used directly by importing it.

Similarly to the VRFTestHelper.sol from the test project folder, a contract may use the library by instantiation as follows:

pragma solidity 0.6.12;  import "vrf-solidity/contracts/VRF.sol";   contract VRFTestHelper {    function functionUsingVRF(     uint256[2] memory public _publicKey,     uint256[4] memory public _proof,     bytes memory _message)   public returns (bool)   {     return VRF.verify(_publicKey, _proof, _message);   } }

The tests under the test folder can be seen as additional examples for interacting with the contract using Solidity and Javascript.

Benchmark

Gas consumption analysis was conducted in order to understand the associated costs to the usage of the vrf-solidity library. Only public functions were object of study as they are the only functions meant to be called by other parties.

The three auxiliary public functions (decodeProof, decodePoint and computeFastVerifyParams) are recommended to be used (if possible) as off-chain operations, so that there is not gas costs.

Gas consumption and USD price estimation with a gas price of 100 Gwei, derived from ETH Gas Station:

·--------------------------------------------|---------------------------|-------------|----------------------------· |    Solc version: 0.6.12+commit.27d51765    ·  Optimizer enabled: true  ·  Runs: 200  ·  Block limit: 6718946 gas  │ ·············································|···························|·············|····························· |  Methods                                   ·              100 gwei/gas               ·       590.98 usd/eth       │ ·················|···························|·············|·············|·············|··············|·············· |  Contract      ·  Method                   ·  Min        ·  Max        ·  Avg        ·  # calls     ·  usd (avg)  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  computeFastVerifyParams  ·    1513058  ·    1831274  ·    1611989  ·          91  ·      95.27  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  decodePoint              ·      55844  ·      55877  ·      55867  ·          10  ·       3.30  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  decodeProof              ·      56839  ·      56860  ·      56851  ·          10  ·       3.36  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  fastVerify               ·     106360  ·     352838  ·     150715  ·          94  ·       8.91  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  gammaToHash              ·      24189  ·      24201  ·      24198  ·          91  ·       1.43  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  verify                   ·    1543493  ·    1862450  ·    1643712  ·          92  ·      97.14  │ ·--------------------------------------------|-------------|-------------|-------------|--------------|-------------· 

Test Vectors

The following resources have been used for test vectors:

  • Secp256k1: Chuck Batson
  • VRF with ciphersuite SECP256K1_SHA256_TAI: vrf-rs

Acknowledgements

Some EC arithmetic operations have been opmitized thanks to the impressive work of the following resources:

  • Post by Vitalik Buterin in Ethresearch
  • SolCrypto library

License

vrf-rs is published under the MIT license.

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


vrf-solidity vrf-solidity - vrf坚固性 vrf-solidity - vrf坚固性

vrf solidity是用solidity编写的可验证随机函数(VRFs)的开源快速有效实现。更准确地说,该库实现了基于椭圆曲线(EC)Secp256k1的VRF证明的验证功能。

免责声明:这是实验性软件。使用它的风险自负!

固体度库的设计旨在降低因EC操作而产生的气体消耗及其复杂性。

它提供两个主要的纯函数来验证VRF证明:

  • 验证:描述:VRF完全验证(需要大量的EC计算)输入:_publicKey:作为数组的公钥由[pubKey-x,pubKey-y]_proof:VRF证明作为由[gamma-x,gamma-y,c,s]组成的数组的消息:用于计算VRF输出的消息(以字节为单位):如果VRF proof有效,
  • 说明:通过提供额外的EC点,VRF快速验证。它使用ecrecover预编译函数来验证EC乘法(较低的气体消耗)。

此外,该库还提供了一些辅助的纯函数,以便于计算上述输入参数:

  • 输入:_proof:VRF证明为字节
  • 输入:_point:以字节表示的EC点
  • 输入:_publicKey:公钥作为由[pubKey-x,pubKey-y]组成的数组的形式证明:VRF证明是由[gamma-x,gamma-y,c,s] _消息:用于计算VRF的消息(以字节为单位)
  • _gammaX:gamma EC点的x坐标

Elliptic Curve VRF (using Secp256k1)

该库遵循VRF-draft-04中描述的算法,以提供VRF验证能力。

支持的密码套件是SECP256K1_SHA256_TAI,即上述使用SHA256作为摘要函数的算法和SECP256K1曲线。对于VRF算法,使用的密码套件代码是0xFE。

对于椭圆曲线算术运算,vrf solidity使用椭圆曲线实度库。

Usage

类似于VRFTESHELPER.sol公司从test project文件夹中,契约可以通过实例化使用库,如下所示:

test文件夹下的测试可以看作是使用Solidity和Javascript与契约交互的附加示例。

pragma solidity 0.6.12;  import "vrf-solidity/contracts/VRF.sol";   contract VRFTestHelper {    function functionUsingVRF(     uint256[2] memory public _publicKey,     uint256[4] memory public _proof,     bytes memory _message)   public returns (bool)   {     return VRF.verify(_publicKey, _proof, _message);   } }

为了了解使用vrf固体度库的相关成本,进行了耗气量分析。只有公共职能才是研究的对象,因为它们是其他各方唯一需要调用的职能。

Benchmark

建议将三个辅助公共功能(decodeProof、decodePoint和computeFastVerifyParams)用作链下操作(如果可能),这样就不会产生天然气成本。

天然气消耗量和美元价格估算,天然气价格为100 Gwei,来源于ETH加油站:

以下资源已用于测试向量:

·--------------------------------------------|---------------------------|-------------|----------------------------· |    Solc version: 0.6.12+commit.27d51765    ·  Optimizer enabled: true  ·  Runs: 200  ·  Block limit: 6718946 gas  │ ·············································|···························|·············|····························· |  Methods                                   ·              100 gwei/gas               ·       590.98 usd/eth       │ ·················|···························|·············|·············|·············|··············|·············· |  Contract      ·  Method                   ·  Min        ·  Max        ·  Avg        ·  # calls     ·  usd (avg)  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  computeFastVerifyParams  ·    1513058  ·    1831274  ·    1611989  ·          91  ·      95.27  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  decodePoint              ·      55844  ·      55877  ·      55867  ·          10  ·       3.30  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  decodeProof              ·      56839  ·      56860  ·      56851  ·          10  ·       3.36  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  fastVerify               ·     106360  ·     352838  ·     150715  ·          94  ·       8.91  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  gammaToHash              ·      24189  ·      24201  ·      24198  ·          91  ·       1.43  │ ·················|···························|·············|·············|·············|··············|·············· |  VRF           ·  verify                   ·    1543493  ·    1862450  ·    1643712  ·          92  ·      97.14  │ ·--------------------------------------------|-------------|-------------|-------------|--------------|-------------· 

Test Vectors

由于以下资源令人印象深刻的工作,一些EC算术运算已被应用:

  • Secp256k1: Chuck Batson
  • VRF with ciphersuite SECP256K1_SHA256_TAI: vrf-rs

Acknowledgements

vrf rs是根据麻省理工学院的许可证出版的。

  • Post by Vitalik Buterin in Ethresearch
  • SolCrypto library

License

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

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

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

www.interchains.cc

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

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

提供最优质的资源集合

立即查看 了解详情