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

Slice bytes of G multiples to avoid cache timings. #1

Merged
merged 1 commit into from
Mar 12, 2014

Conversation

sipa
Copy link
Contributor

@sipa sipa commented Mar 6, 2014

No description provided.

@gmaxwell
Copy link
Contributor

gmaxwell commented Mar 7, 2014

So measuring the cycle counts for pubkey generation (on my laptop, pinned to a single cpu and running with realtime priority):

(tn is with the pull, to is without)

summary(scan('tn'))
Read 1000000 items
Min. 1st Qu. Median Mean 3rd Qu. Max.
76450 76920 77010 78230 77110 439600
summary(scan('to'))
Read 1000000 items
Min. 1st Qu. Median Mean 3rd Qu. Max.
63810 64380 64450 65440 64540 311000
sd(scan('tn'))
Read 1000000 items
[1] 4820.458
sd(scan('to'))
Read 1000000 items
[1] 4523.553

So it's a fair bit slower, and it's not obvious that it reduced the timing variance. (though it is sightly less if I exclude measurements past the 3rd quartile)

@sipa
Copy link
Contributor Author

sipa commented Mar 7, 2014

I only expect time variations if you have significant ranges of identical multiplicand bits between consecutive runs, which I don't expect to happen in random multiplications.

sipa added a commit that referenced this pull request Mar 12, 2014
Slice bytes of G multiples to avoid cache timings.
@sipa sipa merged commit 78cb860 into bitcoin-core:master Mar 12, 2014
@ghost ghost mentioned this pull request Dec 8, 2017
benma pushed a commit to benma/secp256k1 that referenced this pull request Jun 21, 2019
make ECMULT_GEN_PREC_BITS configurable
real-or-random added a commit that referenced this pull request Oct 29, 2024
87384f5 cmake, test: Add `secp256k1_` prefix to test names (Hennadii Stepanov)

Pull request description:

  This PR improves regex matching options when using `ctest` in downstream projects, such as Bitcoin Core.

  For instance, a downstream project users can filter their tests like that:
  ```
  ctest --tests-regex "secp256k1"
  ```
  or
  ```
  ctest --exclude-regex "secp256k1"
  ```

  A `ctest` log with this PR:
  ```
  $ ctest --test-dir build -j 16
  Internal ctest changing into directory: /home/hebasto/git/secp256k1/secp256k1/build
  Test project /home/hebasto/git/secp256k1/secp256k1/build
      Start 1: secp256k1_noverify_tests
      Start 2: secp256k1_tests
      Start 3: secp256k1_exhaustive_tests
      Start 4: secp256k1_ecdsa_example
      Start 5: secp256k1_ecdh_example
      Start 6: secp256k1_schnorr_example
      Start 7: secp256k1_ellswift_example
      Start 8: secp256k1_musig_example
  1/8 Test #4: secp256k1_ecdsa_example ..........   Passed    0.00 sec
  2/8 Test #5: secp256k1_ecdh_example ...........   Passed    0.00 sec
  3/8 Test #6: secp256k1_schnorr_example ........   Passed    0.00 sec
  4/8 Test #7: secp256k1_ellswift_example .......   Passed    0.00 sec
  5/8 Test #8: secp256k1_musig_example ..........   Passed    0.00 sec
  6/8 Test #3: secp256k1_exhaustive_tests .......   Passed    6.19 sec
  7/8 Test #1: secp256k1_noverify_tests .........   Passed   38.83 sec
  8/8 Test #2: secp256k1_tests ..................   Passed   91.66 sec

  100% tests passed, 0 tests failed out of 8

  Total Test time (real) =  91.67 sec
  ```

ACKs for top commit:
  theuni:
    utACK 87384f5
  real-or-random:
    utACK 87384f5

Tree-SHA512: d8e46558cf58c9c660544b7bdfed24c991eb3e120b6511aa3968f509190130e498749a3c4dbabc87a7f22f0aa0056c6bcd3fc6c44f5eb131588945d593546840
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants