schnorr.mx raw

   1  package schnorr
   2  
   3  // BIP-340 Schnorr signatures via native JS BigInt.
   4  // The pure-Go secp256k1 implementation uses [4]uint64 field elements which
   5  // lose precision when compiled to JS (float64 can only represent integers
   6  // up to 2^53 exactly). This jsbridge delegates to schnorr.mjs which uses
   7  // JS BigInt for exact 256-bit arithmetic.
   8  
   9  // PubKeyFromSecKey derives the x-only public key from a secret key.
  10  // Returns (pubkey, ok).
  11  func PubKeyFromSecKey(seckey []byte) ([]byte, bool) { panic("jsbridge") }
  12  
  13  // SignSchnorr creates a BIP-340 Schnorr signature.
  14  // All inputs are 32 bytes. Returns (sig [64]byte, ok).
  15  func SignSchnorr(seckey, msg, auxRand []byte) ([]byte, bool) { panic("jsbridge") }
  16  
  17  // VerifySchnorr verifies a BIP-340 Schnorr signature.
  18  // pubkey: 32 bytes, msg: 32 bytes, sig: 64 bytes.
  19  func VerifySchnorr(pubkey, msg, sig []byte) bool { panic("jsbridge") }
  20  
  21  // ECDH computes the shared secret x-coordinate.
  22  // seckey: 32 bytes, pubkey: 32 bytes (x-only).
  23  func ECDH(seckey, pubkey []byte) ([]byte, bool) { panic("jsbridge") }
  24  
  25  // SHA256Sum computes the SHA-256 hash of data.
  26  // Returns the 32-byte hash.
  27  func SHA256Sum(data []byte) []byte { panic("jsbridge") }
  28  
  29  // ScalarAddModN adds two 32-byte big-endian scalars modulo secp256k1 order N.
  30  // Returns (result, ok). ok is false if the result is zero.
  31  func ScalarAddModN(a, b []byte) ([]byte, bool) { panic("jsbridge") }
  32  
  33  // CompressedPubKey derives the 33-byte SEC1 compressed public key from a secret key.
  34  // Returns (compressed, ok).
  35  func CompressedPubKey(seckey []byte) ([]byte, bool) { panic("jsbridge") }
  36