schnorr.mx raw

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