Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

secp256k1: Test consistency cleanup and rework. #2887

Merged
merged 16 commits into from
Mar 10, 2022

Commits on Mar 10, 2022

  1. Configuration menu
    Copy the full SHA
    f575845 View commit details
    Browse the repository at this point in the history
  2. secp256k1: Benchmark consistency pass.

    This makes several of the benchmarks more consistent in terms of
    resetting the timer and reporting memory allocations as well as moves
    the ones that only apply when accessing the package via the standard
    library elliptic curve adaptor code to a new file named
    ellipticadaptor_bench_test.go.
    
    It also converts the ecdsa signature verification benchmark to use bytes
    directly instead of standard lib big ints and remove the no longer
    necessary hexToBigInt helper.
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    087aa1a View commit details
    Browse the repository at this point in the history
  3. secp256k1: Consolidate Jacobian group chk in tests.

    In order to simplify and consolidate the test logic that ensures test
    points in Jacobian coordinates are valid group elements, this modifies
    the test helper function that determines if a given Jacobian point is on
    the secp256k1 curve to also check for the point at infinity, renames it
    to isValidJacobianPoint, and updates all callers accordingly.
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    39c2b18 View commit details
    Browse the repository at this point in the history
  4. secp256k1: Consolidate affine group check in tests.

    In order to simplify and consolidate the test logic that ensures test
    points in affine coordinates are valid group elements, this introduces a
    new test helper function that determines if a given affine point is on
    the secp256k1 curve or is the point at infinity and updates all callers
    accordingly.
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    1360ae6 View commit details
    Browse the repository at this point in the history
  5. secp256k1: Cleanup and move affine addition tests.

    This cleans up the tests for performing affine addition to make them
    more consistent with modern practices in the code and also moves them to
    the ellipticadaptor_test.go file since they only apply when accessing
    the package via the standard library elliptic curve adaptor code.
    
    The following is a high level overview of the changes:
    
    - Renames TestAddAffine to TestAddAffineAdaptor to make it clear it is
      testing via the adaptor
    - Adds names to each individual test for easier identification
    - Makes the individual test definitions consistent with the rest of the
      code
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    f2b42cc View commit details
    Browse the repository at this point in the history
  6. secp256k1: Cleanup and move affine double tests.

    This cleans up the tests for performing affine point doubling to make
    them more consistent with modern practices in the code and also moves
    them to the ellipticadaptor_test.go file since they only apply when
    accessing the package via the standard library elliptic curve adaptor
    code.
    
    The following is a high level overview of the changes:
    
    - Renames TestDoubleAffine to TestDoubleAffineAdaptor to make it clear
      it is testing via the adaptor
    - Adds names to each individual test for easier identification
    - Makes the individual test definitions consistent with the rest of the
      code
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    22185c1 View commit details
    Browse the repository at this point in the history
  7. secp256k1: Cleanup and move key generation tests.

    This cleans up the test for key generation to make it more consistent
    with modern practices in the code and also moves it to the
    privkey_test.go file since the associated function is defined in
    privkey.go.
    
    The following is a high level overview of the changes:
    
    - Rename TestKeyGeneration to TestGeneratePrivateKey to match the func
      name
    - Remove the curve-based indirection since it only works with secp256k1
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    f057e9b View commit details
    Browse the repository at this point in the history
  8. secp256k1: Cleanup and move affine scalar mul tests.

    This cleans up the tests for performing affine scalar point
    multiplication to make them more consistent with modern practices in the
    code and also moves them to the ellipticadaptor_test.go file since they
    only apply when accessing the package via the standard library elliptic
    curve adaptor code.
    
    The following is a high level overview of the changes:
    
    - Renames TestScalarMult to TestScalarMultAdaptor to make it clear it is
      testing via the adaptor
    - Adds names to each individual test for easier identification
    - Makes the individual test definitions consistent with the rest of the
      code
    - Adds some additional edge cases
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    3b1afe6 View commit details
    Browse the repository at this point in the history
  9. secp256k1: Cleanup affine scalar base mult tests.

    This cleans up the tests for performing affine scalar base
    multiplication to make them more consistent with modern practices in the
    code.
    
    The following is a high level overview of the changes:
    
    - Adds names to each individual test for easier identification
    - Makes the individual test definitions consistent with the rest of the
      code
    - Adds some additional edge cases
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    636070e View commit details
    Browse the repository at this point in the history
  10. secp256k1: Cleanup and move base mult rand tests.

    This cleans up the test for performing affine scalar base multiplication
    with random scalars to make it more consistent with modern practices in
    the code and also moves it to the ellipticadaptor_test.go file since it
    only applies when accessing the package via the standard library
    elliptic curve adaptor code.
    
    The following is a high level overview of the changes:
    
    - Adds a randBytes convenience func to acquire a specified number of
      random bytes from a given rng
    - Renames TestBaseMultVerify to TestScalarBaseMultAdaptorRandom to make
      it clear it is testing via the adaptor and based on random values
    - Uses a new seed for each invocation to ensure new random values are
      tested each run as opposed to always testing the same random values
      generated by the same seed
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    fde9b81 View commit details
    Browse the repository at this point in the history
  11. secp256k1: Cleanup private key tests.

    This cleans up the test for key generation to make it more
    consistent with modern practices in the code and adds a couple more test
    cases.
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    82faa8b View commit details
    Browse the repository at this point in the history
  12. secp256k1: Cleanup Jacobian addition tests.

    This cleans up the tests for performing Jacobian addition to make them
    more consistent with modern practices in the code.
    
    The following is a high level overview of the changes:
    
    - Adds names to each individual test for easier identification
    - Makes the individual test definitions consistent with the rest of the
      code
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    939e514 View commit details
    Browse the repository at this point in the history
  13. secp256k1: Cleanup Jacobian double tests.

    This cleans up the tests for performing Jacobian point doubling to make
    them more consistent with modern practices in the code.
    
    The following is a high level overview of the changes:
    
    - Adds names to each individual test for easier identification
    - Makes the individual test definitions consistent with the rest of the
      code
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    b2f6fd7 View commit details
    Browse the repository at this point in the history
  14. secp256k1: Add test gen for random mod n scalars.

    This adds a new test helper for generating random mod n scalars without
    also generating a companion big integer and updates the tests to make
    use of it.  It also marks the combined version as a test helper while
    here.
    
    The new helper will be useful for future tests.
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    53a9ec0 View commit details
    Browse the repository at this point in the history
  15. secp256k1: Add Jacobian scalar base mult tests.

    This adds tests for scalar base multiplication for points projected in
    Jacobian coordinates.
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    331adb1 View commit details
    Browse the repository at this point in the history
  16. secp256k1: Rework Jacobian rand scalar mult tests.

    This reworks the tests that deal with scalar point multiplication with
    points projected into Jacobian coordinates for randomly-generated
    scalars and points to make them more consistent with modern practices in
    the code as well as to expand the testing methodology to include
    additional assurances.
    
    It also updates the tests to ensure new random values are tested each
    run as opposed to the existing tests which always test the same values
    since they use the same random seed.
    
    Specifically:
    
    - The points are no longer converted to affine with each iteration which
      ensures z values other than 1 are tested
    - Each iteration now ensures calculating the negative version of the
      point and adding it results in the point at infinity
    - The check to ensure the same final point was calculated is now done
      outside of the loop to speed up the test
    davecgh committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    4a6438a View commit details
    Browse the repository at this point in the history