Commit graph

136 commits

Author SHA1 Message Date
zhiqiangxu
e5d15fddb9
btcec/ecdsa: remove error return value for SignCompact (#2211) 2024-07-10 08:43:15 -04:00
oftenoccur
126b0ecff1
chore: fix some typos in comments (#2164)
Signed-off-by: oftenoccur <ezc5@sina.com>
2024-04-26 08:08:05 -04:00
ffranr
665eeb52b1
btcec: add new type SerializedKey
This commit adds a new type called `SerializedKey`.

A serialized type is useful when using public keys as map keys. This is
because functionally identical public keys can have different internal
representations. These differences would cause the map to treat them as
different keys.
2024-04-02 21:19:03 +01:00
ffranr
31647e46ec
btcec: add missing doc comments 2024-04-02 21:19:03 +01:00
mattn
3cb9f602e8
fix typos (#2100) 2024-03-25 09:44:25 -04:00
SulaimanAminuBarkindo
9d2184eb2d Add check for maximum signature length in ecdsa.ParseDERSignature
* Updated the `ecdsa.ParseDERSignature` to include the MaxSigLen constant, which defines the maximum length of a DER encoded signature.
* The MaxSigLen constant is set to 72 bytes, as per the explanation in the comment.
* A new test case has been added to test the functionality with a long signature.
* The test case checks if signatures longer than the specified maximum length are properly handled.
* The test ensures that signatures exceeding the maximum length are correctly identified as invalid.
2024-03-07 09:03:20 +01:00
vuittont60
6ed54f3bf2
btcec: fix typo 2024-01-09 17:12:36 +08:00
John C. Vernaleo
7520523a9a Correct comments in singature.go 2023-11-29 13:20:44 -05:00
wydengyre
a4236c5010 schnorr: simplify some signing math
We reuse the Bytes() function rather than duplicating its logic.
2023-11-29 09:44:44 -05:00
Evan Tedesco
6ea604df63 Fix typos on signature.go 2023-11-28 16:44:19 -05:00
xiaolou86
4171854739 Fix typos 2023-11-20 12:04:31 -05:00
wydengyre
1c0bc470e8 schnorr: bip-340 compliant signing
fixes https://github.com/btcsuite/btcd/issues/2021
2023-08-15 14:58:15 +01:00
wydengyre
ab9338ddbf schnorr: bip-340 compliant verification
fixes https://github.com/btcsuite/btcd/issues/2017
2023-08-12 10:09:27 +01:00
wydengyre
880d9f9026 schnorr: correct rfc reference in docs
The RFC used for deterministic nonce generation is rfc6979, not rfc6679. This commit fixes documentation in two places accordingly.
2023-08-03 18:49:26 +01:00
sputn1ck
883a03da99
musig2: add early nonce gen KnownSigners test
This commit changes the early nonce gen test to use the KnownSigners
Option for one of the contexts.
2023-07-11 14:01:37 +02:00
sputn1ck
8f84bb0e9b
musig2: fix early nonce gen option
Previously the early nonce generation option was not being respected
when creating the context, with the WithKnownSigners option being
used. This commit fixes that.
2023-07-11 14:01:36 +02:00
cui fliter
e160bb6922 multi: remove repetitive the
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-06-26 15:40:51 +08:00
Calvin Kim
ba5407615d multi: Run gofmt on the entire repository
The doc formatting changes introduced in the recent go version is
increasing the diff for all of the new commits.  Formatting it all in
this commit will help the readability of future PRs by reducing the
diff.
2023-06-21 22:31:09 +09:00
Olaoluwa Osuntokun
55e40f4536
btcec/schnorr/musig2: fix BenchmarkPartialVerify
In this commit, we fix the `BenchmarkPartialVerify` test. When we moved
to musig 1.0, we stopped requiring the input as an x-only key. So we
need to remove the round trip serialization to force the key to be
x-only.
2022-11-09 12:50:18 -08:00
Olaoluwa Osuntokun
31ecaff6fd
Merge pull request #1913 from sputn1ck/musig2_update
Musig2: Update to 1.0.0.rc2
2022-11-09 12:33:20 -08:00
Olaoluwa Osuntokun
a8244f587c
btcec/schnorr: use private key copy for BIP-340 signatures
This is a fix similar to https://github.com/btcsuite/btcd/pull/1905.
We'll always make a copy of the key in the local scope before passing it
around elsewhere. Depending on the parity of the public key, the private
key itself might need to be negated.

A similar test is added here that fails without the patch to the
signature.go file.
2022-11-09 11:30:15 -08:00
sputn1ck
d99a169663
btcec/schnorr/musig2: add pubkey check to Sign
This commit adds a check that the public key of the private key
that is passed to the Sign function is included in the slice of public
keys.

Reference ea47d52e2d
2022-11-03 23:02:12 +01:00
sputn1ck
c5b3ed699f
btcec/schnorr/musig2: add public key to secnonce
This commit adds the public key to the sec nonce and ensures that we're
signing with the right key.

Reference: 0e3cfaa526
2022-11-03 23:02:06 +01:00
sputn1ck
f6279eabbe
btcec/schnorr/musig2: add pk option to NonceGen
This commit adds the pk option to NonceGen and makes it mandatory.

Reference: a89f8578e1
2022-11-03 23:01:41 +01:00
Olaoluwa Osuntokun
eef9fbc5c9
btcec/schnorr/musig2: always pass in priv key for early nonce gen
This helps mitigate an issue discovered in musig2 under certain
scenarios:
https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-October/021000.html.
2022-10-25 16:34:17 -07:00
Olaoluwa Osuntokun
323871ff16
btcec/musig2: remove old canned test vector code 2022-10-20 17:58:04 -07:00
Olaoluwa Osuntokun
5d895bbea5
btcec/schnorr/musig2: add sig combine test vectors 2022-10-20 17:58:00 -07:00
Olaoluwa Osuntokun
ca28a98425
btcec/schnorr/musig2: add sig verify+sign test vectors 2022-10-20 17:57:57 -07:00
Olaoluwa Osuntokun
cc12483f0a
btcec/schnorr/musig2: add key tweak sign test vectors 2022-10-20 17:57:55 -07:00
Olaoluwa Osuntokun
4e55273815
btcec/schnorr/musig2: update key agg test vectors to musig2 1.0.0 2022-10-20 17:57:52 -07:00
Olaoluwa Osuntokun
3d9f4484df
btcec/schnorr/musig: update nonce test vectors to musig2 1.0.0 2022-10-20 17:57:50 -07:00
Olaoluwa Osuntokun
1567f20055
btcec/schnorr/musig2: update to musig 1.0.0
The major change in musig 1.0.0 is that plain public keys are used as
input to key aggregation.
2022-10-20 17:57:46 -07:00
Olaoluwa Osuntokun
a34e777916
btcec/schnorr/musig2: update musig2 impl to version 0.7.0
The two _concrete_ changes between version 0.4.0 (where we are before
this commit), and version 0.7.0 are:

  1. Variable length messages are now allowed, this comes with a new 8
     byte prefix for the messages.

     * Our implementation was already using a `[]byte` for the
       message/hash, so no extra API changes are needed here.

  2. The serialization for a blank message and a normal message (for
     nonce gen) is now distinct. A single byte is added (either 0 or 1)
     to indicate if a message was passed into nonce generation.
2022-10-20 17:57:42 -07:00
Olaoluwa Osuntokun
0f49e10006
Merge pull request #1866 from darioush/bump-btcutils-versions
Bump btcd version in btcutil package
2022-08-10 17:21:39 -07:00
sputn1ck
06ce9608aa
btcec/schnorr/musig2: add infinity testvectors
This commit adds the testvectors from
20ba03106d
2022-08-09 06:44:42 +02:00
sputn1ck
44eb8c64f8
btcec/schnorr/musig2: Allow infinity nonces
This commit updates the musig2 module to allow
infinity nonces, as per Musig2 0.4.0.
2022-08-09 06:44:25 +02:00
sputn1ck
4b2fe9f83e
btcec/schnorr/musig2: Add CombineSig testvectors
This commit adds the testvectors from
cdc3520c07
2022-08-04 11:55:19 +02:00
sputn1ck
5e960074ea
btcec/schnorr/musig2: Add PartialSigVerify testvectors
Adds testvectors from
ebb6a7454b
and
6788ee5412
2022-08-04 11:51:02 +02:00
sputn1ck
85356e8174
btcec/schnorr/musig2: Throw error on invalid partial sig 2022-08-04 11:49:29 +02:00
sputn1ck
53f47d65f1
btcec/schnorr/musig2: Add Sign test vectors
This commit adds the testvectors from
4c06f31daf
to the testcases
2022-08-04 11:49:17 +02:00
sputn1ck
8b59e7aa6b
btcec/schnorr/musig2: Add AggregateNonce testvectors
This commit adds the testvectors from
0ec2aefdaa
to the testcases
2022-08-04 11:46:52 +02:00
sputn1ck
1b85a60b6d
btcec/schnorr/musig2: Add AggregateKeys testvectors
This commit adds the testvectors from
20f60b0f37
to the testcases
2022-08-04 11:44:25 +02:00
sputn1ck
478a2f78c4
btcec/schnorr/musig2: Add nonce generation testcases
This commit adds the testcases specified under version 0.3.1 from
https://github.com/jonasnick/bips/blob/musig2/bip-musig2.mediawiki#change-log

and the fixes from
79438fd604
2022-08-04 11:38:20 +02:00
sputn1ck
4ad819e7af
btcec/schnorr/musig2: Update to MuSig 0.3.0
This commit changes the i's in GenNonces to 0 and 1 as per
https://github.com/jonasnick/bips/blob/musig2/bip-musig2.mediawiki#change-log
0.3
2022-08-04 11:34:10 +02:00
sputn1ck
3376655b9c
btcec/schnorr/musig2: XOR rand with secret key
This commit XORs the secret key (if a secret key is specified)
with the random bytes as per MuSig2 Spec
(https://github.com/jonasnick/bips/blob/musig2/bip-musig2.mediawiki#nonce-generation-1)
2022-08-04 11:32:57 +02:00
Darioush Jalali
149b0f09aa
go mod tidy in btcetc/ 2022-07-11 16:36:12 -07:00
Emmanuel T Odeke
4550049281 fuzz: add ParsePubKey fuzzer
Courtesy of the Cosmos Network security team, this change
adds a fuzzer to ParsePubKey, given that Tendermint uses
this code.
2022-05-05 20:35:35 -07:00
Olaoluwa Osuntokun
1da361b04e
btcec/schnorr/musig2: add optional json dump command to gen test vectors 2022-04-28 16:20:11 -07:00
Olaoluwa Osuntokun
ba20c75aaf
btcec/schnorr/musig2: pass in aux info during nonce generation 2022-04-28 16:20:07 -07:00
Olaoluwa Osuntokun
953e2dd94a
btcec/schnorr/musig2: enable early nonce generation w/ a context
In this commit, we enable early nonce generation, allowing callers to
obtain generated nonces before the total set of signers is actually
known. This type of nonce generation is useful for contexts like LN
funding when we want to minimize the round trips and send nonces before
we know the pubkey of the other party.
2022-04-28 16:20:05 -07:00