bip340 0.0.2
bip340: ^0.0.2 copied to clipboard
BIP340 (Schnorr) signature and verification.
bip340
#
Implements basic signing and verification functions for the BIP-340 Schnorr Signature Scheme.
It passes the tests attached to the BIP (dart run example/example.dart to run that), but no guarantees are made of anything and this is not safe cryptography, do not use to store Bitcoins.
Provides these functions:
String sign(String privateKey, String message, String aux)
Generates a schnorr signature using the BIP-340 scheme.
privateKeymust be 32-bytes hex-encoded, i.e., 64 characters.messagemust also be 32-bytes hex-encoded (a hash of the actual message).auxmust be 32-bytes random bytes, generated at signature time.- Returns the signature as a string of 64 bytes hex-encoded, i.e., 128 characters.
bool verify(String publicKey, String message, String signature)
Verifies a schnorr signature using the BIP-340 scheme.
publicKeymust be 32-bytes hex-encoded, i.e., 64 characters (if you have a pubkey with 33 bytes just remove the first one).messagemust also be 32-bytes hex-encoded (a hash of the actual message).signaturemust be 64-bytes hex-encoded, i.e., 128 characters.- Returns true if the signature is valid, false otherwise.
String getPublicKey(String privateKey)
Produces the public key from a private key
privateKeymust be a 31-bytes hex-encoded string, i.e. 64 characters.- Returns a public key as also 32-bytes hex-encoded.
Made for integration with Nostr.