neo icon indicating copy to clipboard operation
neo copied to clipboard

[`Add`] `RandomNumberFactory` Class

Open cschuchardt88 opened this issue 9 months ago • 7 comments

Description

Removed RandomExtensions.NextBigIneger method. Replaced RandomExtensions.NextBigIneger with RandomNumberFactory methods. Added RandomNumberFactory class to the Neo.Extensions library.

Type of change

  • [x] Optimization (the change is only an optimization)
  • [ ] Style (the change is only a code style for better maintenance or standard purpose)
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update

How Has This Been Tested?

  • [x] Unit Testing

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [x] New and existing unit tests pass locally with my changes
  • [x] Any dependent changes have been merged and published in downstream modules

cschuchardt88 avatar Jun 07 '25 03:06 cschuchardt88

Rand is an extension of Random so Random has Random.NextBigInteger().

cschuchardt88 avatar Jun 10 '25 06:06 cschuchardt88

checked, Randomnumbergenerator provides Cryptographically secure randdomness.

Jim8y avatar Jun 10 '25 10:06 Jim8y

Rand is an extension of Random so Random has Random.NextBigInteger().

this extension should be removed, we don't need the Random instance with this

shargon avatar Jun 10 '25 13:06 shargon

The RandomNumberGenerator is much slower than current implementation;

This extension method used in ECFieldElement.Sqrt, and I found another implementation: https://github.com/bcgit/bc-java/blob/main/core/src/main/java/org/bouncycastle/math/ec/ECFieldElement.java#L292. This java implementation also uses pseudo-random numbers.

Pseudo-random numbers seem to be good enough here.

Wi1l-B0t avatar Jun 11 '25 12:06 Wi1l-B0t

Ok changes have been made.

cschuchardt88 avatar Jun 15 '25 03:06 cschuchardt88

The RandomNumberGenerator is much slower than current implementation;

This extension method used in ECFieldElement.Sqrt, and I found another implementation: https://github.com/bcgit/bc-java/blob/main/core/src/main/java/org/bouncycastle/math/ec/ECFieldElement.java#L292. This java implementation also uses pseudo-random numbers.

Pseudo-random numbers seem to be good enough here.

Remind.

Wi1l-B0t avatar Jun 21 '25 05:06 Wi1l-B0t

The RandomNumberGenerator is much slower than current implementation; This extension method used in ECFieldElement.Sqrt, and I found another implementation: https://github.com/bcgit/bc-java/blob/main/core/src/main/java/org/bouncycastle/math/ec/ECFieldElement.java#L292. This java implementation also uses pseudo-random numbers. Pseudo-random numbers seem to be good enough here.

Remind.

This will also be used in neo-build. So, it needs to be crypto random generator.

cschuchardt88 avatar Jun 21 '25 19:06 cschuchardt88