https://github.com/chainsafe/go-signature-adaptor
A pure Go implementation of ECDSA signature adaptors
https://github.com/chainsafe/go-signature-adaptor
cryptography ecdsa scriptless secp256k1
Last synced: 8 months ago
JSON representation
A pure Go implementation of ECDSA signature adaptors
- Host: GitHub
- URL: https://github.com/chainsafe/go-signature-adaptor
- Owner: ChainSafe
- License: lgpl-3.0
- Created: 2022-02-17T23:10:46.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-13T20:49:51.000Z (over 3 years ago)
- Last Synced: 2025-10-02T02:53:28.003Z (8 months ago)
- Topics: cryptography, ecdsa, scriptless, secp256k1
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-signature-adaptor
Pure Go implementation of signature adaptors using ECDSA. Currently implemented for secp256k1 but generalized to be extended over any curve. It is based off the [DLC spec](https://github.com/discreetlogcontracts/dlcspecs/blob/master/ECDSA-adaptor.md).
Adaptor signatures are a kind of signature encryption. Just as you would expect this means you canโt get the signature from the encrypted signature unless you know the decryption key. As you might not necessarily expect, this encryption is one-time in that anyone who knows the encrypted signature can recover the decryption key from the decrypted signature.
This weird leaking of the decryption key is incredibly useful has numerous applications in blockchain space and cryptography more generally.
## Example
```go
package main
import (
"fmt"
"github.com/ChainSafe/go-signature-adaptor/secp256k1"
)
func main() {
msg := []byte{1, 2, 3}
alice := secp256k1.GenerateKeypair()
bob := secp256k1.GenerateKeypair()
adaptor, _ := alice.AdaptorSign(msg, bob.Public())
ok, _ := alice.Public().VerifyAdaptor(msg[:], bob.Public(), adaptor)
if !ok {
panic("Alice sent invalid adaptor")
}
sig, _ := adaptor.Decrypt(bob.Private().Inner())
sigBytes, _ := sig.EncodeRecoverable()
fmt.Println("Posting decrypted ECDSA signature on-chain", sigBytes, "๐")
}
```
## Requirements
go 1.17+