Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/unclebob/bip340-elliptic-curve-signatures
Explore signing documents using BIP340 Schnorr Signatures. A la https://bips.xyz/340
https://github.com/unclebob/bip340-elliptic-curve-signatures
Last synced: about 1 month ago
JSON representation
Explore signing documents using BIP340 Schnorr Signatures. A la https://bips.xyz/340
- Host: GitHub
- URL: https://github.com/unclebob/bip340-elliptic-curve-signatures
- Owner: unclebob
- Created: 2022-01-13T19:14:47.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-17T23:00:26.000Z (almost 3 years ago)
- Last Synced: 2023-04-12T14:17:26.306Z (over 1 year ago)
- Language: Clojure
- Size: 11.7 KB
- Stars: 12
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BIP340 Elliptic Curve Signatures
This library follows the BitCoin BIP340 proposal for implementing
Schnorr signatures for secp256k1. (See: https://bips.xyz/340)Much of the code is based upon (stolen from) Aaron Dixon's [gist](https://gist.github.com/atdixon/7d65042f494683a8f855e735ec4e6203), with my thanks.
The api is very simple:
* `sha-256`
`([message])`
Returns the sha256 hash of the message.
Both the message and the hash are byte-arrays.
* `num->bytes ([length n])`
Returns the byte-array representation of the BigInteger n.
The array will have the specified length.
* `bytes->num ([bytes])`
Returns a BigInteger from a byte-array.
* `bytes->hex-string`
`([byte-array])`
Returns a string containing the hexadecimal
representation of the byte-array. This is the
inverse of hex-string->bytes.
* `hex-string->bytes`
`([hex-string])`
returns a byte-array containing the bytes described
by the hex-string. This is the inverse of bytes->hex-string.
* `pub-key`
`([private-key])`
returns the public-key for a given private key.
Both are byte-arrays of length 32.
* `sign`
`([private-key message])`
Returns the 64 byte signature of the message
and the private key. The message and the
private key are byte-arrays.
* `verify`
`([public-key message signature])`
Returns true if the public-key proves that the message was
signed using the private key. Otherwise returns nil.
The public-key and the message are byte-arrays of length 32.
The signature is a byte-array of length 64.### Notes:
* The three tag-hash constants `[challenge-tag-hash aux-tag-hash nonce-tag-hash]`
should probably not be publicly known. We need a way to initialize
them in a secure way.
* The algorithms are pretty slow. For high volume relays
they would need a lot of optimization.