Skip to content

Conversation

@nkohen
Copy link
Collaborator

@nkohen nkohen commented Apr 16, 2020

Introduces signing with entropy to the JNI.

Also introduces and tests low R signing as was introduced to bitcoin-core here.

Closes #1312

@nkohen nkohen added core work for the core project secp256k1 labels Apr 16, 2020
Copy link
Collaborator

@benthecarman benthecarman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to make a ECDummyLowRSignature as well

Copy link
Collaborator

@benthecarman benthecarman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, however, to implement this into the wallet will be tricky with how it is. Currently when we get signers, they will use only use the signFunction and not the signLowR function.

Maybe it would be worth creating a LowRSign type that extends Sign and defaults to low r signing.

@Christewart Christewart merged commit 5b2ad82 into bitcoin-s:master Jul 29, 2020
Christewart pushed a commit that referenced this pull request May 1, 2021
* Added signing with entropy to the JNI and implemented low R signing

* Added check for determinism of low R signing

* Cleaned up test

* Implemented signing with entropy in Bouncy Castle

* Added docs for signing with entropy

* Fixed things after rebase

* De-parallelized signLowR and added scaladoc warnings to signWithEntropy
schildbach pushed a commit to schildbach/bitcoinj that referenced this pull request Feb 26, 2025
The goal is to make transaction sizes more predictable, simplifying the
fee calculation. This change will make sure signatures will always have
DER encodings of 70 bytes or less, without counting the sighash flags byte.

Note that one of our tests for a BIP143 native P2WPKH test vector had
to be changed, because that vector had been produced pre-grinding and
hasn't been updated since. However, the change only affects a P2PK input
which isn't really the focus of the test vector.

Also see similar changes in other projects:
bitcoin/bitcoin#13666
rust-bitcoin/rust-secp256k1#259
bitcoin-s/bitcoin-s#1342 + bitcoin-s/bitcoin-s#2408
bisq-network/bisq#7238

TODO extract HMacDSAKCalculatorWithEntrophy to top level class?
TODO make encodeToCompact() its own commit?
TODO more test vectors from other projects
TODO should sigs with DER encodings *less* than 70 bytes also be retried?
schildbach pushed a commit to schildbach/bitcoinj that referenced this pull request Feb 26, 2025
The goal is to make transaction sizes more predictable, simplifying the
fee calculation. This change will make sure signatures will always have
DER encodings of 70 bytes or less, without counting the sighash flags byte.

Note that one of our tests for a BIP143 native P2WPKH test vector had
to be changed, because that vector had been produced pre-grinding and
hasn't been updated since. However, the change only affects a P2PK input
which isn't really the focus of the test vector.

Also see similar changes in other projects:
bitcoin/bitcoin#13666
rust-bitcoin/rust-secp256k1#259
bitcoin-s/bitcoin-s#1342 + bitcoin-s/bitcoin-s#2408
bisq-network/bisq#7238

TODO extract HMacDSAKCalculatorWithEntrophy to top level class?
TODO make encodeToCompact() its own commit?
TODO more test vectors from other projects
TODO should sigs with DER encodings *less* than 70 bytes also be retried?
schildbach pushed a commit to schildbach/bitcoinj that referenced this pull request Apr 24, 2025
The goal is to make transaction sizes more predictable, simplifying the
fee calculation. This change will make sure signatures will always have
DER encodings of 70 bytes or less, without counting the sighash flags byte.

Note that one of our tests for a BIP143 native P2WPKH test vector had
to be changed, because that vector had been produced pre-grinding and
hasn't been updated since. However, the change only affects a P2PK input
which isn't really the focus of the test vector.

Also see similar changes in other projects:
bitcoin/bitcoin#13666
rust-bitcoin/rust-secp256k1#259
bitcoin-s/bitcoin-s#1342 + bitcoin-s/bitcoin-s#2408
spesmilo/electrum#5820
bisq-network/bisq#7238

TODO extract HMacDSAKCalculatorWithEntrophy to top level class?
TODO make encodeToCompact() its own commit?
TODO more test vectors from other projects
TODO should sigs with DER encodings *less* than 70 bytes also be retried?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core work for the core project secp256k1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement low R signing

3 participants