github.com/piotrnar/gocoin@v0.0.0-20240512203912-faa0448c5e96/client/speedups/sipasec.go (about)

     1  package main
     2  
     3  /*
     4    This is a EC_Verify speedup that is advised for non Windows systems.
     5  
     6    1) Build and install sipa's secp256k1 lib for your system
     7  
     8    2) Copy this file one level up and remove "speedup.go" from there
     9  
    10    3) Rebuild clinet.exe and enjoy sipa's verify lib.
    11  */
    12  
    13  import (
    14  	"github.com/piotrnar/gocoin/client/common"
    15  	"github.com/piotrnar/gocoin/lib/btc"
    16  	"github.com/piotrnar/gocoin/lib/others/cgo/sipasec"
    17  )
    18  
    19  func sipa_ec_verify(k, s, h []byte) bool {
    20  	return sipasec.EC_Verify(k, s, h) == 1
    21  }
    22  
    23  func schnorr_ec_verify(pkey, sign, msg []byte) bool {
    24  	return sipasec.Schnorr_Verify(pkey, sign, msg) == 1
    25  }
    26  
    27  func check_pay_to_contract(m_keydata, base, hash []byte, parity bool) bool {
    28  	return sipasec.CheckPayToContract(m_keydata, base, hash, parity) == 1
    29  }
    30  
    31  func init() {
    32  	common.Log.Println("Using libsecp256k1.a for ECVerify, SchnorrVerify & CheckPayToContact")
    33  	btc.EC_Verify = sipa_ec_verify
    34  	btc.Schnorr_Verify = schnorr_ec_verify
    35  	btc.Check_PayToContract = check_pay_to_contract
    36  }