diff --git a/cmd/replicatrd/main.go b/cmd/replicatrd/main.go index a7f1fe23..e5366a89 100644 --- a/cmd/replicatrd/main.go +++ b/cmd/replicatrd/main.go @@ -6,7 +6,7 @@ import ( "github.com/Hubmakerlabs/replicatr/cmd/replicatrd/replicatr" "github.com/Hubmakerlabs/replicatr/pkg/eventstore/badger" - log2 "mleku.online/git/log" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" ) const appName = "replicatr" diff --git a/go.mod b/go.mod index a990d8ac..06e7e0b2 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,6 @@ module github.com/Hubmakerlabs/replicatr go 1.21.5 require ( - github.com/btcsuite/btcd/btcec/v2 v2.3.2 - github.com/btcsuite/btcd/btcutil v1.1.3 github.com/davecgh/go-spew v1.1.1 github.com/dchest/blake256 v1.1.0 github.com/dgraph-io/badger/v4 v4.2.0 @@ -25,19 +23,13 @@ require ( golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 golang.org/x/net v0.18.0 lukechampine.com/frand v1.4.2 - mleku.online/git/bech32 v1.0.3 - mleku.online/git/ec v1.0.4 - mleku.online/git/log v1.0.7 ) require ( github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect github.com/andybalholm/brotli v1.0.5 // indirect - github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect - github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/gobwas/pool v0.2.1 // indirect diff --git a/go.sum b/go.sum index f809aed2..fc0e8f2f 100644 --- a/go.sum +++ b/go.sum @@ -2,33 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= -github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= -github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= -github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= -github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= -github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= -github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= -github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= -github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= -github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 h1:KdUfX2zKommPRa+PD0sWZUyXe9w277ABlgELO7H04IM= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= -github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= -github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= @@ -38,19 +13,11 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/blake256 v1.1.0 h1:4AuEhGPT/3TTKFhTfBpZ8hgZE7wJpawcYaEawwsbtqM= github.com/dchest/blake256 v1.1.0/go.mod h1:xXNWCE1jsAP8DAjP+rKw2MbeqLczjI3TRx2VK+9OEYY= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= -github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= @@ -70,8 +37,6 @@ github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/fiatjaf/generic-ristretto v0.0.1 h1:LUJSU87X/QWFsBXTwnH3moFe4N8AjUxT+Rfa0+bo6YM= github.com/fiatjaf/generic-ristretto v0.0.1/go.mod h1:cvV6ANHDA/GrfzVrig7N7i6l8CWnkVZvtQ2/wk9DPVE= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= @@ -95,7 +60,6 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= @@ -114,15 +78,10 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.17.3 h1:qkRjuerhUU1EmXLYGkSH6EZL+vPSxIrYjLNAK4slzwA= github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/klauspost/cpuid/v2 v2.2.3 h1:sxCkb+qR91z4vsqw4vGGZlDgPz3G7gjaLyK3V8y70BU= @@ -142,15 +101,6 @@ github.com/mdp/qrterminal/v3 v3.2.0 h1:qteQMXO3oyTK4IHwj2mWsKYYRBOp1Pj2WRYFYYNTC github.com/mdp/qrterminal/v3 v3.2.0/go.mod h1:XGGuua4Lefrl7TLEsSONiD+UEjQXJZ4mPzF+gWYIJkk= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -170,13 +120,11 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -196,7 +144,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -208,17 +155,13 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= @@ -230,16 +173,9 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -250,7 +186,6 @@ golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8= golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -290,12 +225,7 @@ google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -303,11 +233,5 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= lukechampine.com/frand v1.4.2 h1:RzFIpOvkMXuPMBb9maa4ND4wjBn71E1Jpf8BzJHMaVw= lukechampine.com/frand v1.4.2/go.mod h1:4S/TM2ZgrKejMcKMbeLjISpJMO+/eZ1zu3vYX9dtj3s= -mleku.online/git/bech32 v1.0.3 h1:RwtkFB19yRxsYqXyqVqPAIsYWXYPMJQGXcwVz37DHAs= -mleku.online/git/bech32 v1.0.3/go.mod h1:GU8Ll1fKaPJ4QrpAZzvCJk5hbXj9zJm4Y9IBSPkT6Bw= -mleku.online/git/ec v1.0.4 h1:wsXfszxoDUVqF3IcDmr+vFh7dONBgelL+6iESiHLVho= -mleku.online/git/ec v1.0.4/go.mod h1:D1BIglBfDaUsit3R+LVVXJ9SlxwjPnCJpp+gz6yARzY= -mleku.online/git/log v1.0.7 h1:jNDph/CW/GerRluqcWV6F+NMng1gmm5Qi/TFAJRAfpo= -mleku.online/git/log v1.0.7/go.mod h1:OdomTvlDYHzX1daD1LaqU+TtX484EbECPKOiMrlGkOY= rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY= rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs= diff --git a/pkg/ec/bench_test.go b/pkg/ec/bench_test.go index 21db51a2..932fa2f1 100644 --- a/pkg/ec/bench_test.go +++ b/pkg/ec/bench_test.go @@ -9,7 +9,7 @@ import ( "math/big" "testing" - secp "mleku.online/git/ec/secp" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // setHex decodes the passed big-endian hex string into the internal field value @@ -190,5 +190,5 @@ func BenchmarkParseCompressedPubKey(b *testing.B) { pk, e = ParsePubKey(rawPk) } _ = pk - _ = err + _ = e } diff --git a/pkg/ec/btcec.go b/pkg/ec/btcec.go index 6ed935f0..3e609f90 100644 --- a/pkg/ec/btcec.go +++ b/pkg/ec/btcec.go @@ -20,7 +20,7 @@ package btcec // reverse the transform than to operate in affine coordinates. import ( - secp "mleku.online/git/ec/secp" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // KoblitzCurve provides an implementation for secp256k1 that fits the ECC diff --git a/pkg/ec/chaincfg/deployment_time_frame.go b/pkg/ec/chaincfg/deployment_time_frame.go index 6ee0babe..78654b07 100644 --- a/pkg/ec/chaincfg/deployment_time_frame.go +++ b/pkg/ec/chaincfg/deployment_time_frame.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "mleku.online/git/ec/wire" + "github.com/Hubmakerlabs/replicatr/pkg/ec/wire" ) var ( @@ -91,7 +91,7 @@ func (m *MedianTimeDeploymentStarter) HasStarted(blkHeader *wire.BlockHeader) (b medianTime, e := m.blockClock.PastMedianTime(blkHeader) if e != nil { - return false, err + return false, e } // We check both after and equal here as after will fail for equivalent @@ -134,7 +134,7 @@ func (m *MedianTimeDeploymentEnder) HasEnded(blkHeader *wire.BlockHeader) (bool, medianTime, e := m.blockClock.PastMedianTime(blkHeader) if e != nil { - return false, err + return false, e } // We check both after and equal here as after will fail for equivalent diff --git a/pkg/ec/chaincfg/genesis.go b/pkg/ec/chaincfg/genesis.go index a7305a6c..8ab589e7 100644 --- a/pkg/ec/chaincfg/genesis.go +++ b/pkg/ec/chaincfg/genesis.go @@ -3,8 +3,8 @@ package chaincfg import ( "time" - "mleku.online/git/ec/chainhash" - "mleku.online/git/ec/wire" + "github.com/Hubmakerlabs/replicatr/pkg/ec/chainhash" + "github.com/Hubmakerlabs/replicatr/pkg/ec/wire" ) // genesisCoinbaseTx is the coinbase transaction for the genesis blocks for diff --git a/pkg/ec/chaincfg/params.go b/pkg/ec/chaincfg/params.go index d4bab387..ce0aec9f 100644 --- a/pkg/ec/chaincfg/params.go +++ b/pkg/ec/chaincfg/params.go @@ -4,8 +4,8 @@ import ( "math/big" "time" - "mleku.online/git/ec/chainhash" - "mleku.online/git/ec/wire" + "github.com/Hubmakerlabs/replicatr/pkg/ec/chainhash" + "github.com/Hubmakerlabs/replicatr/pkg/ec/wire" ) var ( diff --git a/pkg/ec/chainhash/hash.go b/pkg/ec/chainhash/hash.go index f33ca8c7..af975a21 100644 --- a/pkg/ec/chainhash/hash.go +++ b/pkg/ec/chainhash/hash.go @@ -127,7 +127,7 @@ func (hash *Hash) UnmarshalJSON(input []byte) (e error) { } var sh string - e := json.Unmarshal(input, &sh) + e = json.Unmarshal(input, &sh) if e != nil { return e } @@ -145,9 +145,9 @@ func NewHash(newHash []byte) (*Hash, error) { var sh Hash e := sh.SetBytes(newHash) if e != nil { - return nil, err + return nil, e } - return &sh, err + return &sh, e } // TaggedHash implements the tagged hash scheme described in BIP-340. We use @@ -186,7 +186,7 @@ func NewHashFromStr(hash string) (*Hash, error) { ret := new(Hash) e := Decode(ret, hash) if e != nil { - return nil, err + return nil, e } return ret, nil } @@ -212,7 +212,7 @@ func Decode(dst *Hash, src string) (e error) { // Hex decode the source bytes to a temporary destination. var reversedHash Hash - _, e := hex.Decode(reversedHash[HashSize-hex.DecodedLen(len(srcBytes)):], + _, e = hex.Decode(reversedHash[HashSize-hex.DecodedLen(len(srcBytes)):], srcBytes) if e != nil { return e @@ -231,7 +231,7 @@ func Decode(dst *Hash, src string) (e error) { // (i.e. represented as a bytes array) to a destination. func decodeLegacy(dst *Hash, src []byte) (e error) { var hashBytes []byte - e := json.Unmarshal(src, &hashBytes) + e = json.Unmarshal(src, &hashBytes) if e != nil { return e } diff --git a/pkg/ec/chainhash/hash_test.go b/pkg/ec/chainhash/hash_test.go index a6392e83..41c74f7f 100644 --- a/pkg/ec/chainhash/hash_test.go +++ b/pkg/ec/chainhash/hash_test.go @@ -8,6 +8,7 @@ import ( "bytes" "encoding/hex" "encoding/json" + "errors" "testing" ) @@ -182,8 +183,8 @@ func TestNewHashFromStr(t *testing.T) { t.Logf("Running %d tests", len(tests)) for i, test := range tests { result, e := NewHashFromStr(test.in) - if e != test.e { - t.Errorf(unexpectedErrStr, i, err, test.e) + if !errors.Is(e, test.err) { + t.Errorf(unexpectedErrStr, i, e, test.err) continue } else if e != nil { // Got expected error. Move on to the next test. @@ -203,18 +204,18 @@ func TestHashJsonMarshal(t *testing.T) { hash, e := NewHashFromStr(hashStr) if e != nil { - t.Errorf("NewHashFromStr error:%v, hashStr:%s", err, hashStr) + t.Errorf("NewHashFromStr error:%v, hashStr:%s", e, hashStr) } hashBytes, e := json.Marshal(hash) if e != nil { - t.Errorf("Marshal json error:%v, hash:%v", err, hashBytes) + t.Errorf("Marshal json error:%v, hash:%v", e, hashBytes) } var newHash Hash e = json.Unmarshal(hashBytes, &newHash) if e != nil { - t.Errorf("Unmarshal json error:%v, hash:%v", err, hashBytes) + t.Errorf("Unmarshal json error:%v, hash:%v", e, hashBytes) } if !hash.IsEqual(&newHash) { @@ -223,7 +224,7 @@ func TestHashJsonMarshal(t *testing.T) { e = newHash.UnmarshalJSON(legacyHashStr) if e != nil { - t.Errorf("Unmarshal legacy json error:%v, hash:%v", err, legacyHashStr) + t.Errorf("Unmarshal legacy json error:%v, hash:%v", e, legacyHashStr) } if !hash.IsEqual(&newHash) { diff --git a/pkg/ec/ciphering.go b/pkg/ec/ciphering.go index fcd60440..a4aae3ec 100644 --- a/pkg/ec/ciphering.go +++ b/pkg/ec/ciphering.go @@ -5,7 +5,7 @@ package btcec import ( - secp "mleku.online/git/ec/secp" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // GenerateSharedSecret generates a shared secret based on a secret key and a diff --git a/pkg/ec/curve.go b/pkg/ec/curve.go index 5b477d0f..99906208 100644 --- a/pkg/ec/curve.go +++ b/pkg/ec/curve.go @@ -6,7 +6,7 @@ package btcec import ( "fmt" - secp "mleku.online/git/ec/secp" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // JacobianPoint is an element of the group formed by the secp256k1 curve in @@ -85,7 +85,7 @@ func ParseJacobian(point []byte) (JacobianPoint, error) { noncePk, e := secp.ParsePubKey(point) if e != nil { - return JacobianPoint{}, err + return JacobianPoint{}, e } noncePk.AsJacobian(&result) diff --git a/pkg/ec/ecdsa/bench_test.go b/pkg/ec/ecdsa/bench_test.go index 36cecffd..d448261e 100644 --- a/pkg/ec/ecdsa/bench_test.go +++ b/pkg/ec/ecdsa/bench_test.go @@ -9,7 +9,7 @@ import ( "encoding/hex" "testing" - "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // hexToModNScalar converts the passed hex string into a ModNScalar and will diff --git a/pkg/ec/ecdsa/example_test.go b/pkg/ec/ecdsa/example_test.go index b8409d91..b9d1dd0c 100644 --- a/pkg/ec/ecdsa/example_test.go +++ b/pkg/ec/ecdsa/example_test.go @@ -12,8 +12,8 @@ import ( "fmt" "github.com/dchest/blake256" - "mleku.online/git/ec/ecdsa" - "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec/ecdsa" + "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // This example demonstrates signing a message with a secp256k1 secret key that diff --git a/pkg/ec/ecdsa/signature.go b/pkg/ec/ecdsa/signature.go index 5b14492d..c4410d0d 100644 --- a/pkg/ec/ecdsa/signature.go +++ b/pkg/ec/ecdsa/signature.go @@ -8,7 +8,7 @@ package ecdsa import ( "fmt" - "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // References: diff --git a/pkg/ec/ecdsa/signature_test.go b/pkg/ec/ecdsa/signature_test.go index adffacea..e665699b 100644 --- a/pkg/ec/ecdsa/signature_test.go +++ b/pkg/ec/ecdsa/signature_test.go @@ -18,7 +18,7 @@ import ( "github.com/dchest/blake256" - "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // hexToBytes converts the passed hex string into bytes and will panic if there @@ -206,9 +206,9 @@ func TestSignatureParsing(t *testing.T) { for _, test := range tests { _, e := ParseDERSignature(test.sig) - if !errors.Is(err, test.e) { - t.Errorf("%s mismatched err -- got %v, want %v", test.name, err, - test.e) + if !errors.Is(e, test.err) { + t.Errorf("%s mismatched err -- got %v, want %v", test.name, e, + test.err) continue } } @@ -979,9 +979,9 @@ func TestRecoverCompactErrors(t *testing.T) { // Ensure the expected error is hit. _, _, e := RecoverCompact(sig, hash) - if !errors.Is(err, test.e) { - t.Errorf("%s: mismatched err -- got %v, want %v", test.name, err, - test.e) + if !errors.Is(e, test.err) { + t.Errorf("%s: mismatched err -- got %v, want %v", test.name, e, + test.err) continue } } @@ -1031,7 +1031,7 @@ func TestSignAndRecoverCompactRandom(t *testing.T) { gotPubKey, gotCompressed, e := RecoverCompact(gotSig, hash[:]) if e != nil { t.Fatalf("unexpected err: %v\nsig: %x\nhash: %x\nsecret key: %x", - err, gotSig, hash, secKey.Serialize()) + e, gotSig, hash, secKey.Serialize()) } if gotCompressed != compressed { t.Fatalf("unexpected compressed flag: %v\nsig: %x\nhash: %x\n"+ diff --git a/pkg/ec/error.go b/pkg/ec/error.go index 8e09801b..0d5585d1 100644 --- a/pkg/ec/error.go +++ b/pkg/ec/error.go @@ -4,7 +4,7 @@ package btcec import ( - secp "mleku.online/git/ec/secp" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // Error identifies an error related to public key cryptography using a diff --git a/pkg/ec/field.go b/pkg/ec/field.go index 6dad5cbd..3b13e4f4 100644 --- a/pkg/ec/field.go +++ b/pkg/ec/field.go @@ -1,6 +1,6 @@ package btcec -import secp "mleku.online/git/ec/secp" +import secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" // FieldVal implements optimized fixed-precision arithmetic over the secp256k1 // finite field. This means all arithmetic is performed modulo diff --git a/pkg/ec/modnscalar.go b/pkg/ec/modnscalar.go index 7aaeff9f..9dd60b51 100644 --- a/pkg/ec/modnscalar.go +++ b/pkg/ec/modnscalar.go @@ -4,7 +4,7 @@ package btcec import ( - secp "mleku.online/git/ec/secp" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // ModNScalar implements optimized 256-bit constant-time fixed-precision diff --git a/pkg/ec/pubkey.go b/pkg/ec/pubkey.go index 3a482751..c7ce1a8e 100644 --- a/pkg/ec/pubkey.go +++ b/pkg/ec/pubkey.go @@ -5,7 +5,7 @@ package btcec import ( - secp "mleku.online/git/ec/secp" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // These constants define the lengths of serialized public keys. diff --git a/pkg/ec/schnorr/bench_test.go b/pkg/ec/schnorr/bench_test.go index aba66dd0..9e347e95 100644 --- a/pkg/ec/schnorr/bench_test.go +++ b/pkg/ec/schnorr/bench_test.go @@ -11,8 +11,8 @@ import ( "math/big" "testing" - "mleku.online/git/ec" - "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // hexToBytes converts the passed hex string into bytes and will panic if there @@ -141,7 +141,7 @@ func BenchmarkSign(b *testing.B) { } testSig = sig - testErr = err + testErr = e } // BenchmarkSignRfc6979 benchmarks how long it takes to sign a message. @@ -165,5 +165,5 @@ func BenchmarkSignRfc6979(b *testing.B) { } testSig = sig - testErr = err + testErr = e } diff --git a/pkg/ec/schnorr/error.go b/pkg/ec/schnorr/error.go index 43b01861..3b3b7a7f 100644 --- a/pkg/ec/schnorr/error.go +++ b/pkg/ec/schnorr/error.go @@ -6,7 +6,7 @@ package schnorr import ( - ecdsa_schnorr "mleku.online/git/ec/secp/schnorr" + ecdsa_schnorr "github.com/Hubmakerlabs/replicatr/pkg/ec/secp/schnorr" ) // ErrorKind identifies a kind of error. It has full support for errors.Is diff --git a/pkg/ec/schnorr/musig2/bench_test.go b/pkg/ec/schnorr/musig2/bench_test.go index 6cdea1b3..040e83b8 100644 --- a/pkg/ec/schnorr/musig2/bench_test.go +++ b/pkg/ec/schnorr/musig2/bench_test.go @@ -9,8 +9,8 @@ import ( "fmt" "testing" - "mleku.online/git/ec" - "mleku.online/git/ec/schnorr" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec/schnorr" ) var ( @@ -114,7 +114,7 @@ func BenchmarkPartialSign(b *testing.B) { } testSig = sig - testErr = err + testErr = e }) } } diff --git a/pkg/ec/schnorr/musig2/context.go b/pkg/ec/schnorr/musig2/context.go index 709a387f..aee9d6ad 100644 --- a/pkg/ec/schnorr/musig2/context.go +++ b/pkg/ec/schnorr/musig2/context.go @@ -5,8 +5,8 @@ package musig2 import ( "fmt" - "mleku.online/git/ec" - "mleku.online/git/ec/schnorr" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec/schnorr" ) var ( @@ -222,7 +222,7 @@ func NewContext(signingKey *btcec.SecretKey, shouldSort bool, // verification. case opts.keySet != nil: if e := ctx.combineSignerKeys(); e != nil { - return nil, err + return nil, e } // The total signers are known, so we add ourselves, and skip key @@ -247,7 +247,7 @@ func NewContext(signingKey *btcec.SecretKey, shouldSort bool, WithNonceSecretKeyAux(signingKey), ) if e != nil { - return nil, err + return nil, e } } @@ -297,7 +297,6 @@ func (c *Context) combineSignerKeys() (e error) { // Next, we'll use this information to compute the aggregated // public key that'll be used for signing in practice. - var e error c.combinedKey, _, _, e = AggregateKeys( c.opts.keySet, c.shouldSort, keyAggOpts..., ) @@ -339,7 +338,7 @@ func (c *Context) RegisterSigner(pub *btcec.PublicKey) (bool, error) { haveAllSigners = len(c.opts.keySet) == c.opts.numSigners if haveAllSigners { if e := c.combineSignerKeys(); e != nil { - return false, err + return false, e } } @@ -488,7 +487,7 @@ func (c *Context) NewSession(options ...SessionOption) (*Session, error) { WithNonceCombinedKeyAux(c.combinedKey.FinalKey), ) if e != nil { - return nil, err + return nil, e } } @@ -539,7 +538,7 @@ func (s *Session) RegisterPubNonce(nonce [PubNonceSize]byte) (bool, error) { if haveAllNonces { combinedNonce, e := AggregateNonces(s.pubNonces) if e != nil { - return false, err + return false, e } s.combinedNonce = &combinedNonce @@ -589,7 +588,7 @@ func (s *Session) Sign(msg [32]byte, s.localNonces = nil if e != nil { - return nil, err + return nil, e } s.msg = msg diff --git a/pkg/ec/schnorr/musig2/keys.go b/pkg/ec/schnorr/musig2/keys.go index 671c8331..5e0da46d 100644 --- a/pkg/ec/schnorr/musig2/keys.go +++ b/pkg/ec/schnorr/musig2/keys.go @@ -7,11 +7,11 @@ import ( "fmt" "sort" - secp "mleku.online/git/ec/secp" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" - "mleku.online/git/ec" - "mleku.online/git/ec/chainhash" - "mleku.online/git/ec/schnorr" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec/chainhash" + "github.com/Hubmakerlabs/replicatr/pkg/ec/schnorr" ) var ( @@ -440,11 +440,11 @@ func AggregateKeys(keys []*btcec.PublicKey, sort bool, // each one, until we have our final tweaked key, and the related // accumulators. for i := 1; i <= len(opts.tweaks); i++ { - finalKeyJ, parityAcc, tweakAcc, e = tweakKey( + finalKeyJ, parityAcc, tweakAcc, err = tweakKey( finalKeyJ, parityAcc, opts.tweaks[i-1].Tweak, tweakAcc, opts.tweaks[i-1].IsXOnly, ) - if e != nil { + if err != nil { return nil, nil, nil, err } } diff --git a/pkg/ec/schnorr/musig2/keys_test.go b/pkg/ec/schnorr/musig2/keys_test.go index 6fb509c0..9160f37f 100644 --- a/pkg/ec/schnorr/musig2/keys_test.go +++ b/pkg/ec/schnorr/musig2/keys_test.go @@ -11,10 +11,10 @@ import ( "strings" "testing" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec/schnorr" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" "github.com/stretchr/testify/require" - "mleku.online/git/ec" - "mleku.online/git/ec/schnorr" - secp "mleku.online/git/ec/secp" ) const ( @@ -109,7 +109,7 @@ func keysFromIndices(t *testing.T, indices []int, mustParseHex(pubKeys[keyIdx]), ) if e != nil { - return nil, err + return nil, e } } @@ -200,18 +200,18 @@ func TestMuSig2KeyAggTestVectors(t *testing.T) { switch testCase.Comment { case "Invalid public key": require.ErrorIs( - t, err, + t, e, secp.ErrPubKeyNotOnCurve, ) case "Public key exceeds field size": require.ErrorIs( - t, err, secp.ErrPubKeyXTooBig, + t, e, secp.ErrPubKeyXTooBig, ) case "First byte of public key is not 2 or 3": require.ErrorIs( - t, err, + t, e, secp.ErrPubKeyInvalidFormat, ) @@ -246,11 +246,11 @@ func TestMuSig2KeyAggTestVectors(t *testing.T) { switch testCase.Comment { case "Tweak is out of range": - require.ErrorIs(t, err, ErrTweakedKeyOverflows) + require.ErrorIs(t, e, ErrTweakedKeyOverflows) case "Intermediate tweaking result is point at infinity": - require.ErrorIs(t, err, ErrTweakedKeyIsInfinity) + require.ErrorIs(t, e, ErrTweakedKeyIsInfinity) default: t.Fatalf("uncaught err: %v", e) diff --git a/pkg/ec/schnorr/musig2/musig2_test.go b/pkg/ec/schnorr/musig2/musig2_test.go index 91f2b361..b4534723 100644 --- a/pkg/ec/schnorr/musig2/musig2_test.go +++ b/pkg/ec/schnorr/musig2/musig2_test.go @@ -10,7 +10,7 @@ import ( "sync" "testing" - "mleku.online/git/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec" ) const ( @@ -20,7 +20,7 @@ const ( func mustParseHex(str string) []byte { b, e := hex.DecodeString(str) if e != nil { - panic(fmt.Errorf("unable to parse hex: %v", err)) + panic(fmt.Errorf("unable to parse hex: %v", e)) } return b @@ -274,7 +274,7 @@ func TestMuSigEarlyNonce(t *testing.T) { // If we try to make a context, with just the secret key and sorting // value, we should get an error. _, e = NewContext(privKey1, true) - if !errors.Is(err, ErrSignersNotSpecified) { + if !errors.Is(e, ErrSignersNotSpecified) { t.Fatalf("unexpected ctx error: %v", e) } @@ -299,7 +299,7 @@ func TestMuSigEarlyNonce(t *testing.T) { // At this point, the combined key shouldn't be available for signer 1, // but should be for signer 2, as they know about all signers. - if _, e := ctx1.CombinedKey(); !errors.Is(err, ErrNotEnoughSigners) { + if _, e := ctx1.CombinedKey(); !errors.Is(e, ErrNotEnoughSigners) { t.Fatalf("unepxected error: %v", e) } _, e = ctx2.CombinedKey() @@ -329,12 +329,12 @@ func TestMuSigEarlyNonce(t *testing.T) { // If we try to make a session, we should get an error since we dn't // have all the signers yet. - if _, e := ctx1.NewSession(); !errors.Is(err, ErrNotEnoughSigners) { + if _, e := ctx1.NewSession(); !errors.Is(e, ErrNotEnoughSigners) { t.Fatalf("unexpected session key error: %v", e) } // The combined key should also be unavailable as well. - if _, e := ctx1.CombinedKey(); !errors.Is(err, ErrNotEnoughSigners) { + if _, e := ctx1.CombinedKey(); !errors.Is(e, ErrNotEnoughSigners) { t.Fatalf("unexpected combined key error: %v", e) } @@ -349,7 +349,7 @@ func TestMuSigEarlyNonce(t *testing.T) { // If we try to register the signer again, we should get an error. _, e = ctx2.RegisterSigner(&pubKey1) - if !errors.Is(err, ErrAlreadyHaveAllSigners) { + if !errors.Is(e, ErrAlreadyHaveAllSigners) { t.Fatalf("should not be able to register too many signers") } @@ -368,7 +368,7 @@ func TestMuSigEarlyNonce(t *testing.T) { // If we try to sign before we have the combined nonce, we shoudl get // an error. _, e = session1.Sign(msg) - if !errors.Is(err, ErrCombinedNonceUnavailable) { + if !errors.Is(e, ErrCombinedNonceUnavailable) { t.Fatalf("unable to gen sig: %v", e) } @@ -391,7 +391,7 @@ func TestMuSigEarlyNonce(t *testing.T) { // Registering the nonce again should error out. _, e = session2.RegisterPubNonce(nonce1.PubNonce) - if !errors.Is(err, ErrAlredyHaveAllNonces) { + if !errors.Is(e, ErrAlredyHaveAllNonces) { t.Fatalf("shouldn't be able to register nonces twice") } @@ -414,7 +414,7 @@ func TestMuSigEarlyNonce(t *testing.T) { // If we try to combine another sig, then we should get an error. _, e = session1.CombineSig(sig2) - if !errors.Is(err, ErrAlredyHaveAllSigs) { + if !errors.Is(e, ErrAlredyHaveAllSigs) { t.Fatalf("shouldn't be able to combine again") } diff --git a/pkg/ec/schnorr/musig2/nonces.go b/pkg/ec/schnorr/musig2/nonces.go index 76ade001..d6db1633 100644 --- a/pkg/ec/schnorr/musig2/nonces.go +++ b/pkg/ec/schnorr/musig2/nonces.go @@ -9,9 +9,9 @@ import ( "errors" "io" - "mleku.online/git/ec" - "mleku.online/git/ec/chainhash" - "mleku.online/git/ec/schnorr" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec/chainhash" + "github.com/Hubmakerlabs/replicatr/pkg/ec/schnorr" ) const ( @@ -266,19 +266,19 @@ func genNonceAuxBytes(rand []byte, pubkey []byte, i int, // First, write out the randomness generated in the prior step. if _, e := w.Write(rand); e != nil { - return nil, err + return nil, e } // Next, we'll write out: len(pk) || pk e := writeBytesPrefix(&w, pubkey, uint8Writer) if e != nil { - return nil, err + return nil, e } // Next, we'll write out: len(aggpk) || aggpk. e = writeBytesPrefix(&w, opts.combinedKey, uint8Writer) if e != nil { - return nil, err + return nil, e } switch { @@ -286,7 +286,7 @@ func genNonceAuxBytes(rand []byte, pubkey []byte, i int, // uint8 of a zero byte: m_prefixed = bytes(1, 0). case opts.msg == nil: if _, e := w.Write([]byte{0x00}); e != nil { - return nil, err + return nil, e } // Otherwise, we'll write a single byte of 0x01 with a 1 byte length @@ -296,26 +296,26 @@ func genNonceAuxBytes(rand []byte, pubkey []byte, i int, fallthrough default: if _, e := w.Write([]byte{0x01}); e != nil { - return nil, err + return nil, e } e = writeBytesPrefix(&w, opts.msg, uint64Writer) if e != nil { - return nil, err + return nil, e } } // Finally we'll write out the auxiliary input. e = writeBytesPrefix(&w, opts.auxInput, uint32Writer) if e != nil { - return nil, err + return nil, e } // Next we'll write out the interaction/index number which will // uniquely generate two nonces given the rest of the possibly static // parameters. if e := binary.Write(&w, byteOrder, uint8(i)); e != nil { - return nil, err + return nil, e } // With the message buffer complete, we'll now derive the tagged hash @@ -340,7 +340,7 @@ func GenNonces(options ...NonceGenOption) (*Nonces, error) { // CSPRNG. var randBytes [32]byte if _, e := opts.randReader.Read(randBytes[:]); e != nil { - return nil, err + return nil, e } // If the options contain a secret key, we XOR it with with the tagged @@ -357,11 +357,11 @@ func GenNonces(options ...NonceGenOption) (*Nonces, error) { // two secret nonces: k1 and k2. k1, e := genNonceAuxBytes(randBytes[:], opts.publicKey, 0, opts) if e != nil { - return nil, err + return nil, e } k2, e := genNonceAuxBytes(randBytes[:], opts.publicKey, 1, opts) if e != nil { - return nil, err + return nil, e } var k1Mod, k2Mod btcec.ModNScalar @@ -403,7 +403,7 @@ func AggregateNonces(pubNonces [][PubNonceSize]byte) ([PubNonceSize]byte, nonceJ, e := btcec.ParseJacobian(slicer(pubNonceBytes)) if e != nil { - return btcec.JacobianPoint{}, err + return btcec.JacobianPoint{}, e } pubNonceJs[i] = &nonceJ @@ -430,14 +430,14 @@ func AggregateNonces(pubNonces [][PubNonceSize]byte) ([PubNonceSize]byte, return n[:btcec.PubKeyBytesLenCompressed] }) if e != nil { - return finalNonce, err + return finalNonce, e } combinedNonce2, e := combineNonces(func(n [PubNonceSize]byte) []byte { return n[btcec.PubKeyBytesLenCompressed:] }) if e != nil { - return finalNonce, err + return finalNonce, e } copy(finalNonce[:], btcec.JacobianToByteSlice(combinedNonce1)) diff --git a/pkg/ec/schnorr/musig2/nonces_test.go b/pkg/ec/schnorr/musig2/nonces_test.go index 7e6de1e5..f32458bd 100644 --- a/pkg/ec/schnorr/musig2/nonces_test.go +++ b/pkg/ec/schnorr/musig2/nonces_test.go @@ -160,7 +160,7 @@ func TestMusig2AggregateNoncesTestVectors(t *testing.T) { t.Run(fmt.Sprintf("invalid_case=%v", i), func(t *testing.T) { _, e := AggregateNonces(testNonces) require.True(t, e != nil) - require.Equal(t, testCase.ExpectedErr, err.Error()) + require.Equal(t, testCase.ExpectedErr, e.Error()) }) } } diff --git a/pkg/ec/schnorr/musig2/sign.go b/pkg/ec/schnorr/musig2/sign.go index 59236eb4..b8c953d0 100644 --- a/pkg/ec/schnorr/musig2/sign.go +++ b/pkg/ec/schnorr/musig2/sign.go @@ -7,11 +7,11 @@ import ( "fmt" "io" - secp "mleku.online/git/ec/secp" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" - "mleku.online/git/ec" - "mleku.online/git/ec/chainhash" - "mleku.online/git/ec/schnorr" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec/chainhash" + "github.com/Hubmakerlabs/replicatr/pkg/ec/schnorr" ) var ( @@ -221,13 +221,13 @@ func computeSigningNonce(combinedNonce [PubNonceSize]byte, combinedNonce[:btcec.PubKeyBytesLenCompressed], ) if e != nil { - return nil, nil, err + return nil, nil, e } r2J, e := btcec.ParseJacobian( combinedNonce[btcec.PubKeyBytesLenCompressed:], ) if e != nil { - return nil, nil, err + return nil, nil, e } // With our nonce blinding value, we'll now combine both the public @@ -307,7 +307,7 @@ func Sign(secNonce [SecNonceSize]byte, privKey *btcec.SecretKey, pubKeys, opts.sortKeys, keyAggOpts..., ) if e != nil { - return nil, err + return nil, e } // We'll now combine both the public nonces, using the blinding factor @@ -317,7 +317,7 @@ func Sign(secNonce [SecNonceSize]byte, privKey *btcec.SecretKey, combinedNonce, combinedKey.FinalKey, msg, ) if e != nil { - return nil, err + return nil, e } // Next we'll parse out our two secret nonces, which we'll be using in @@ -374,8 +374,8 @@ func Sign(secNonce [SecNonceSize]byte, privKey *btcec.SecretKey, challengeBytes := chainhash.TaggedHash( ChallengeHashTag, challengeMsg.Bytes(), ) - var e btcec.ModNScalar - e.SetByteSlice(challengeBytes[:]) + var ee btcec.ModNScalar + ee.SetByteSlice(challengeBytes[:]) // Next, we'll compute a, our aggregation coefficient for the key that // we're signing with. @@ -384,7 +384,7 @@ func Sign(secNonce [SecNonceSize]byte, privKey *btcec.SecretKey, // With mu constructed, we can finally generate our partial signature // as: s = (k1_1 + b*k_2 + e*a*d) mod n. s := new(btcec.ModNScalar) - s.Add(&k1).Add(k2.Mul(nonceBlinder)).Add(e.Mul(a).Mul(&privKeyScalar)) + s.Add(&k1).Add(k2.Mul(nonceBlinder)).Add(ee.Mul(a).Mul(&privKeyScalar)) sig := NewPartialSignature(s, nonceKey) @@ -397,7 +397,7 @@ func Sign(secNonce [SecNonceSize]byte, privKey *btcec.SecretKey, signOpts..., ) if !sigValid { - return nil, fmt.Errorf("sig is invalid!") + return nil, fmt.Errorf("sig is invalid") } } @@ -550,8 +550,8 @@ func verifyPartialSig(partialSig *PartialSignature, pubNonce [PubNonceSize]byte, challengeBytes := chainhash.TaggedHash( ChallengeHashTag, challengeMsg.Bytes(), ) - var e btcec.ModNScalar - e.SetByteSlice(challengeBytes[:]) + var ee btcec.ModNScalar + ee.SetByteSlice(challengeBytes[:]) signingKey, e := btcec.ParsePubKey(pubKey) if e != nil { @@ -581,7 +581,7 @@ func verifyPartialSig(partialSig *PartialSignature, pubNonce [PubNonceSize]byte, // In the final set, we'll check that: s*G == R' + e*a*g*P. var sG, rP btcec.JacobianPoint btcec.ScalarBaseMultNonConst(s, &sG) - btcec.ScalarMultNonConst(e.Mul(a).Mul(finalParityFactor), &signKeyJ, &rP) + btcec.ScalarMultNonConst(ee.Mul(a).Mul(finalParityFactor), &signKeyJ, &rP) btcec.AddNonConst(&rP, &pubNonceJ, &rP) sG.ToAffine() diff --git a/pkg/ec/schnorr/musig2/sign_test.go b/pkg/ec/schnorr/musig2/sign_test.go index 4a58e77f..d05cee23 100644 --- a/pkg/ec/schnorr/musig2/sign_test.go +++ b/pkg/ec/schnorr/musig2/sign_test.go @@ -12,9 +12,9 @@ import ( "strings" "testing" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" "github.com/stretchr/testify/require" - "mleku.online/git/ec" - secp "mleku.online/git/ec/secp" ) const ( @@ -163,7 +163,7 @@ func TestMusig2SignVerify(t *testing.T) { t, testCase.Indices, testCases.PubKeys, ) if e != nil { - require.ErrorIs(t, err, secp.ErrPubKeyNotOnCurve) + require.ErrorIs(t, e, secp.ErrPubKeyNotOnCurve) return } @@ -228,7 +228,7 @@ func TestMusig2SignVerify(t *testing.T) { bytes.NewReader(mustParseHex(testCase.Sig)), ) if e != nil && strings.Contains(testCase.Comment, "group size") { - require.ErrorIs(t, err, ErrPartialSigInvalid) + require.ErrorIs(t, e, ErrPartialSigInvalid) } e = verifyPartialSig( @@ -252,13 +252,13 @@ func TestMusig2SignVerify(t *testing.T) { t, testCase.NonceIndices, testCases.PubNonces, ) _, e := AggregateNonces(pubNonces) - require.ErrorIs(t, err, secp.ErrPubKeyNotOnCurve) + require.ErrorIs(t, e, secp.ErrPubKeyNotOnCurve) case "Invalid pubkey": _, e := keysFromIndices( t, testCase.Indices, testCases.PubKeys, ) - require.ErrorIs(t, err, secp.ErrPubKeyNotOnCurve) + require.ErrorIs(t, e, secp.ErrPubKeyNotOnCurve) default: t.Fatalf("unhandled case: %v", testCase.Comment) diff --git a/pkg/ec/schnorr/pubkey.go b/pkg/ec/schnorr/pubkey.go index 50a32d9b..5554a0a9 100644 --- a/pkg/ec/schnorr/pubkey.go +++ b/pkg/ec/schnorr/pubkey.go @@ -8,11 +8,12 @@ package schnorr import ( "fmt" - "mleku.online/git/ec" - secp "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // These constants define the lengths of serialized public keys. + const ( PubKeyBytesLen = 32 ) @@ -20,15 +21,15 @@ const ( // ParsePubKey parses a public key for a koblitz curve from a bytestring into a // btcec.Publickey, verifying that it is valid. It only supports public keys in // the BIP-340 32-byte format. -func ParsePubKey(pubKeyStr []byte) (*btcec.PublicKey, error) { +func ParsePubKey(pubKeyStr []byte) (p *btcec.PublicKey, e error) { if pubKeyStr == nil { - e := fmt.Errorf("nil pubkey byte string") - return nil, err + e = fmt.Errorf("nil pubkey byte string") + return nil, e } if len(pubKeyStr) != PubKeyBytesLen { - e := fmt.Errorf("bad pubkey byte string size (want %v, have %v)", + e = fmt.Errorf("bad pubkey byte string size (want %v, have %v)", PubKeyBytesLen, len(pubKeyStr)) - return nil, err + return nil, e } // We'll manually prepend the compressed byte so we can re-use the diff --git a/pkg/ec/schnorr/signature.go b/pkg/ec/schnorr/signature.go index 2b71cb0d..27e3c2d5 100644 --- a/pkg/ec/schnorr/signature.go +++ b/pkg/ec/schnorr/signature.go @@ -5,10 +5,10 @@ package schnorr import ( "fmt" - "mleku.online/git/ec" - "mleku.online/git/ec/chainhash" - secp "mleku.online/git/ec/secp" - ecdsa_schnorr "mleku.online/git/ec/secp/schnorr" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec/chainhash" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" + ecdsa_schnorr "github.com/Hubmakerlabs/replicatr/pkg/ec/secp/schnorr" ) const ( @@ -332,7 +332,7 @@ func schnorrSign(privKey, nonce *btcec.ModNScalar, pubKey *btcec.PublicKey, // If Verify(bytes(P), m, sig) fails, abort. if !opts.fastSign { if e := schnorrVerify(sig, hash, pBytes); e != nil { - return nil, err + return nil, e } } @@ -511,7 +511,7 @@ func Sign(privKey *btcec.SecretKey, hash []byte, sig, e := schnorrSign(&privKeyScalar, &kPrime, pub, hash, opts) kPrime.Zero() if e != nil { - return nil, err + return nil, e } return sig, nil diff --git a/pkg/ec/schnorr/signature_test.go b/pkg/ec/schnorr/signature_test.go index 4022ba81..8970de47 100644 --- a/pkg/ec/schnorr/signature_test.go +++ b/pkg/ec/schnorr/signature_test.go @@ -12,11 +12,11 @@ import ( "testing" "testing/quick" - "mleku.online/git/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec" "github.com/davecgh/go-spew/spew" - secp_ecdsa "mleku.online/git/ec/secp" - ecdsa_schnorr "mleku.online/git/ec/secp/schnorr" + secp_ecdsa "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" + ecdsa_schnorr "github.com/Hubmakerlabs/replicatr/pkg/ec/secp/schnorr" ) type bip340Test struct { @@ -193,7 +193,7 @@ var bip340TestVectors = []bip340Test{ func decodeHex(hexStr string) []byte { b, e := hex.DecodeString(hexStr) if e != nil { - panic("invalid hex string in test source: err " + err.Error() + + panic("invalid hex string in test source: err " + e.Error() + ", hex: " + hexStr) } @@ -256,7 +256,7 @@ func TestSchnorrVerify(t *testing.T) { _, e := ParsePubKey(pubKeyBytes) switch { case !test.validPubKey && e != nil: - if !errors.Is(err, test.expectErr) { + if !errors.Is(e, test.expectErr) { t.Fatalf("test #%v: pubkey validation should "+ "have failed, expected %v, got %v", i, test.expectErr, e) @@ -288,7 +288,7 @@ func TestSchnorrVerify(t *testing.T) { } if !test.verifyResult && test.expectErr != nil { - if !errors.Is(err, test.expectErr) { + if !errors.Is(e, test.expectErr) { t.Fatalf("test #%v: expect error %v : got %v", i, test.expectErr, e) } diff --git a/pkg/ec/seckey.go b/pkg/ec/seckey.go index 868c1080..31b3efa7 100644 --- a/pkg/ec/seckey.go +++ b/pkg/ec/seckey.go @@ -5,7 +5,7 @@ package btcec import ( - secp "mleku.online/git/ec/secp" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // SecretKey wraps an ecdsa.SecretKey as a convenience mainly for signing diff --git a/pkg/ec/secp/curve_test.go b/pkg/ec/secp/curve_test.go index 3ca76ea0..b711dc22 100644 --- a/pkg/ec/secp/curve_test.go +++ b/pkg/ec/secp/curve_test.go @@ -465,7 +465,7 @@ func TestNAFRandom(t *testing.T) { result := naf(valBytes[:]) pos, neg := result.Pos(), result.Neg() if e := checkNAFEncoding(pos, neg, bigIntVal); e != nil { - t.Fatalf("encoding err: %v\nin: %x\npos: %x\nneg: %x", err, + t.Fatalf("encoding err: %v\nin: %x\npos: %x\nneg: %x", e, bigIntVal, pos, neg) } } @@ -742,7 +742,7 @@ func TestSplitKRandom(t *testing.T) { origK := randModNScalar(t, rng) k1, k2 := splitK(origK) if e := checkLambdaDecomposition(origK, &k1, &k2); e != nil { - t.Fatalf("decomposition err: %v\nin: %v\nk1: %v\nk2: %v", err, + t.Fatalf("decomposition err: %v\nin: %v\nk1: %v\nk2: %v", e, origK, k1, k2) } } diff --git a/pkg/ec/secp/example_test.go b/pkg/ec/secp/example_test.go index e3ca9f9a..1b6da616 100644 --- a/pkg/ec/secp/example_test.go +++ b/pkg/ec/secp/example_test.go @@ -13,7 +13,7 @@ import ( "encoding/hex" "fmt" - secp "mleku.online/git/ec/secp" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // This example demonstrates use of GenerateSharedSecret to encrypt a message @@ -23,7 +23,7 @@ func Example_encryptDecryptMessage() { newAEAD := func(key []byte) (cipher.AEAD, error) { block, e := aes.NewCipher(key) if e != nil { - return nil, err + return nil, e } return cipher.NewGCM(block) } diff --git a/pkg/ec/secp/precomps/genprecomps.go b/pkg/ec/secp/precomps/genprecomps.go index 8faa69f2..de59e42b 100644 --- a/pkg/ec/secp/precomps/genprecomps.go +++ b/pkg/ec/secp/precomps/genprecomps.go @@ -17,7 +17,7 @@ import ( "math/big" "os" - "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // curveParams houses the secp256k1 curve parameters for convenient access. diff --git a/pkg/ec/secp/pubkey_test.go b/pkg/ec/secp/pubkey_test.go index ef1f1052..ed438277 100644 --- a/pkg/ec/secp/pubkey_test.go +++ b/pkg/ec/secp/pubkey_test.go @@ -17,7 +17,7 @@ func TestParsePubKey(t *testing.T) { tests := []struct { name string // test description key string // hex encoded public key - err error // expected error + e error // expected error wantX string // expected x coordinate wantY string // expected y coordinate }{{ @@ -25,7 +25,7 @@ func TestParsePubKey(t *testing.T) { key: "04" + "11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c" + "b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", - err: nil, + e: nil, wantX: "11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c", wantY: "b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", }, { @@ -33,25 +33,25 @@ func TestParsePubKey(t *testing.T) { key: "04" + "15db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c" + "b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", - err: ErrPubKeyNotOnCurve, + e: ErrPubKeyNotOnCurve, }, { name: "uncompressed y changed (not on curve)", key: "04" + "11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c" + "b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a4", - err: ErrPubKeyNotOnCurve, + e: ErrPubKeyNotOnCurve, }, { name: "uncompressed claims compressed", key: "03" + "11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c" + "b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", - err: ErrPubKeyInvalidFormat, + e: ErrPubKeyInvalidFormat, }, { name: "uncompressed as hybrid ok (ybit = 0)", key: "06" + "11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c" + "4d1f1522047b33068bbb9b07d1e9f40564749b062b3fc0666479bc08a94be98c", - err: nil, + e: nil, wantX: "11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c", wantY: "4d1f1522047b33068bbb9b07d1e9f40564749b062b3fc0666479bc08a94be98c", }, { @@ -59,7 +59,7 @@ func TestParsePubKey(t *testing.T) { key: "07" + "11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c" + "b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", - err: nil, + e: nil, wantX: "11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c", wantY: "b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", }, { @@ -67,65 +67,65 @@ func TestParsePubKey(t *testing.T) { key: "06" + "11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c" + "b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", - err: ErrPubKeyMismatchedOddness, + e: ErrPubKeyMismatchedOddness, }, { name: "compressed ok (ybit = 0)", key: "02" + "ce0b14fb842b1ba549fdd675c98075f12e9c510f8ef52bd021a9a1f4809d3b4d", - err: nil, + e: nil, wantX: "ce0b14fb842b1ba549fdd675c98075f12e9c510f8ef52bd021a9a1f4809d3b4d", wantY: "0890ff84d7999d878a57bee170e19ef4b4803b4bdede64503a6ac352b03c8032", }, { name: "compressed ok (ybit = 1)", key: "03" + "2689c7c2dab13309fb143e0e8fe396342521887e976690b6b47f5b2a4b7d448e", - err: nil, + e: nil, wantX: "2689c7c2dab13309fb143e0e8fe396342521887e976690b6b47f5b2a4b7d448e", wantY: "499dd7852849a38aa23ed9f306f07794063fe7904e0f347bc209fdddaf37691f", }, { name: "compressed claims uncompressed (ybit = 0)", key: "04" + "ce0b14fb842b1ba549fdd675c98075f12e9c510f8ef52bd021a9a1f4809d3b4d", - err: ErrPubKeyInvalidFormat, + e: ErrPubKeyInvalidFormat, }, { name: "compressed claims uncompressed (ybit = 1)", key: "04" + "2689c7c2dab13309fb143e0e8fe396342521887e976690b6b47f5b2a4b7d448e", - err: ErrPubKeyInvalidFormat, + e: ErrPubKeyInvalidFormat, }, { name: "compressed claims hybrid (ybit = 0)", key: "06" + "ce0b14fb842b1ba549fdd675c98075f12e9c510f8ef52bd021a9a1f4809d3b4d", - err: ErrPubKeyInvalidFormat, + e: ErrPubKeyInvalidFormat, }, { name: "compressed claims hybrid (ybit = 1)", key: "07" + "2689c7c2dab13309fb143e0e8fe396342521887e976690b6b47f5b2a4b7d448e", - err: ErrPubKeyInvalidFormat, + e: ErrPubKeyInvalidFormat, }, { name: "compressed with invalid x coord (ybit = 0)", key: "03" + "ce0b14fb842b1ba549fdd675c98075f12e9c510f8ef52bd021a9a1f4809d3b4c", - err: ErrPubKeyNotOnCurve, + e: ErrPubKeyNotOnCurve, }, { name: "compressed with invalid x coord (ybit = 1)", key: "03" + "2689c7c2dab13309fb143e0e8fe396342521887e976690b6b47f5b2a4b7d448d", - err: ErrPubKeyNotOnCurve, + e: ErrPubKeyNotOnCurve, }, { name: "empty", key: "", - err: ErrPubKeyInvalidLen, + e: ErrPubKeyInvalidLen, }, { name: "wrong length", key: "05", - err: ErrPubKeyInvalidLen, + e: ErrPubKeyInvalidLen, }, { name: "uncompressed x == p", key: "04" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f" + "b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", - err: ErrPubKeyXTooBig, + e: ErrPubKeyXTooBig, }, { // The y coordinate produces a valid point for x == 1 (mod p), but it // should fail to parse instead of wrapping around. @@ -133,13 +133,13 @@ func TestParsePubKey(t *testing.T) { key: "04" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc30" + "bde70df51939b94c9c24979fa7dd04ebd9b3572da7802290438af2a681895441", - err: ErrPubKeyXTooBig, + e: ErrPubKeyXTooBig, }, { name: "uncompressed y == p", key: "04" + "11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", - err: ErrPubKeyYTooBig, + e: ErrPubKeyYTooBig, }, { // The x coordinate produces a valid point for y == 1 (mod p), but it // should fail to parse instead of wrapping around. @@ -147,37 +147,37 @@ func TestParsePubKey(t *testing.T) { key: "04" + "1fe1e5ef3fceb5c135ab7741333ce5a6e80d68167653f6b2b24bcbcfaaaff507" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc30", - err: ErrPubKeyYTooBig, + e: ErrPubKeyYTooBig, }, { name: "compressed x == p (ybit = 0)", key: "02" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", - err: ErrPubKeyXTooBig, + e: ErrPubKeyXTooBig, }, { name: "compressed x == p (ybit = 1)", key: "03" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", - err: ErrPubKeyXTooBig, + e: ErrPubKeyXTooBig, }, { // This would be valid for x == 2 (mod p), but it should fail to parse // instead of wrapping around. name: "compressed x > p (p + 2 -- aka 2) (ybit = 0)", key: "02" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc31", - err: ErrPubKeyXTooBig, + e: ErrPubKeyXTooBig, }, { // This would be valid for x == 1 (mod p), but it should fail to parse // instead of wrapping around. name: "compressed x > p (p + 1 -- aka 1) (ybit = 1)", key: "03" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc30", - err: ErrPubKeyXTooBig, + e: ErrPubKeyXTooBig, }, { name: "hybrid x == p (ybit = 1)", key: "07" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f" + "b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", - err: ErrPubKeyXTooBig, + e: ErrPubKeyXTooBig, }, { // The y coordinate produces a valid point for x == 1 (mod p), but it // should fail to parse instead of wrapping around. @@ -185,13 +185,13 @@ func TestParsePubKey(t *testing.T) { key: "06" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc30" + "bde70df51939b94c9c24979fa7dd04ebd9b3572da7802290438af2a681895441", - err: ErrPubKeyXTooBig, + e: ErrPubKeyXTooBig, }, { name: "hybrid y == p (ybit = 0 when mod p)", key: "06" + "11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", - err: ErrPubKeyYTooBig, + e: ErrPubKeyYTooBig, }, { // The x coordinate produces a valid point for y == 1 (mod p), but it // should fail to parse instead of wrapping around. @@ -199,14 +199,14 @@ func TestParsePubKey(t *testing.T) { key: "07" + "1fe1e5ef3fceb5c135ab7741333ce5a6e80d68167653f6b2b24bcbcfaaaff507" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc30", - err: ErrPubKeyYTooBig, + e: ErrPubKeyYTooBig, }} for _, test := range tests { pubKeyBytes := hexToBytes(test.key) pubKey, e := ParsePubKey(pubKeyBytes) - if !errors.Is(err, test.e) { - t.Errorf("%s mismatched err -- got %v, want %v", test.name, err, + if !errors.Is(e, test.e) { + t.Errorf("%s mismatched e -- got %v, want %v", test.name, e, test.e) continue } diff --git a/pkg/ec/secp/schnorr/pubkey.go b/pkg/ec/secp/schnorr/pubkey.go index 836e0acd..3f43745a 100644 --- a/pkg/ec/secp/schnorr/pubkey.go +++ b/pkg/ec/secp/schnorr/pubkey.go @@ -8,7 +8,7 @@ package schnorr import ( "fmt" - "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // These constants define the lengths of serialized public keys. diff --git a/pkg/ec/secp/schnorr/signature.go b/pkg/ec/secp/schnorr/signature.go index e7285032..2b08235c 100644 --- a/pkg/ec/secp/schnorr/signature.go +++ b/pkg/ec/secp/schnorr/signature.go @@ -10,7 +10,7 @@ import ( "github.com/dchest/blake256" "github.com/minio/sha256-simd" - "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) const ( diff --git a/pkg/ec/secp/schnorr/signature_bench_test.go b/pkg/ec/secp/schnorr/signature_bench_test.go index 4d13fe87..5201fae4 100644 --- a/pkg/ec/secp/schnorr/signature_bench_test.go +++ b/pkg/ec/secp/schnorr/signature_bench_test.go @@ -8,7 +8,7 @@ import ( "encoding/hex" "testing" - "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // hexToModNScalar converts the passed hex string into a ModNScalar and will diff --git a/pkg/ec/secp/schnorr/signature_test.go b/pkg/ec/secp/schnorr/signature_test.go index 84443df4..975f7033 100644 --- a/pkg/ec/secp/schnorr/signature_test.go +++ b/pkg/ec/secp/schnorr/signature_test.go @@ -12,7 +12,7 @@ import ( "time" "github.com/minio/sha256-simd" - "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) // TestSignatureParsing ensures that signatures are properly parsed including @@ -70,9 +70,9 @@ func TestSignatureParsing(t *testing.T) { for _, test := range tests { _, e := ParseSignature(hexToBytes(test.sig)) - if !errors.Is(err, test.e) { - t.Errorf("%s mismatched err -- got %v, want %v", test.name, err, - test.e) + if !errors.Is(e, test.err) { + t.Errorf("%s mismatched err -- got %v, want %v", test.name, e, + test.err) continue } } @@ -533,10 +533,9 @@ func TestVerifyErrors(t *testing.T) { // allowed range is caught. sig, e := ParseSignature(hexToBytes(test.sigR + test.sigS)) if e != nil { - if !errors.Is(err, test.e) { + if !errors.Is(e, test.err) { t.Errorf("%s: mismatched err -- got %v, want %v", test.name, - err, - test.e) + e, test.err) } continue @@ -544,9 +543,9 @@ func TestVerifyErrors(t *testing.T) { // Ensure the expected error is hit. e = schnorrVerifyBlake256(sig, hash, pubKey) - if !errors.Is(err, test.e) { - t.Errorf("%s: mismatched err -- got %v, want %v", test.name, err, - test.e) + if !errors.Is(e, test.err) { + t.Errorf("%s: mismatched err -- got %v, want %v", test.name, e, + test.err) continue } } diff --git a/pkg/ec/secp/seckey.go b/pkg/ec/secp/seckey.go index b89c8128..bf6e0576 100644 --- a/pkg/ec/secp/seckey.go +++ b/pkg/ec/secp/seckey.go @@ -63,7 +63,7 @@ func generateSecretKey(rand io.Reader) (*SecretKey, error) { var b32 [32]byte for valid := false; !valid; { if _, e := io.ReadFull(rand, b32[:]); e != nil { - return nil, err + return nil, e } // The secret key is only valid when it is in the range [1, N-1], where diff --git a/pkg/ec/secp/seckey_test.go b/pkg/ec/secp/seckey_test.go index 5ba214d2..27b2c582 100644 --- a/pkg/ec/secp/seckey_test.go +++ b/pkg/ec/secp/seckey_test.go @@ -102,8 +102,8 @@ func TestGenerateSecretKeyError(t *testing.T) { // Generate a secret key using the mock reader and ensure the expected // error is returned. _, e := GenerateSecretKeyFromRand(mockReader) - if !errors.Is(err, errDisabled) { - t.Fatalf("mismatched err -- got %v, want %v", err, errDisabled) + if !errors.Is(e, errDisabled) { + t.Fatalf("mismatched err -- got %v, want %v", e, errDisabled) return } } diff --git a/pkg/ec/taproot/taproot.go b/pkg/ec/taproot/taproot.go index 40001cd7..1d2b2cf4 100644 --- a/pkg/ec/taproot/taproot.go +++ b/pkg/ec/taproot/taproot.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - "mleku.online/git/bech32" - "mleku.online/git/ec/chaincfg" + "github.com/Hubmakerlabs/replicatr/pkg/bech32" + "github.com/Hubmakerlabs/replicatr/pkg/ec/chaincfg" ) // AddressSegWit is the base address type for all SegWit addresses. @@ -60,7 +60,7 @@ func decodeSegWitAddress(address string) (byte, []byte, error) { // Decode the bech32 encoded address. _, data, bech32version, e := bech32.DecodeGeneric(address) if e != nil { - return 0, nil, err + return 0, nil, e } // The first byte of the decoded address is the witness version, it must @@ -80,7 +80,7 @@ func decodeSegWitAddress(address string) (byte, []byte, error) { // bytes, we'll need to regroup into 8 bit words. regrouped, e := bech32.ConvertBits(data[1:], 5, 8, false) if e != nil { - return 0, nil, err + return 0, nil, e } // The regrouped data must be between 2 and 40 bytes. @@ -117,7 +117,7 @@ func encodeSegWitAddress(hrp string, witnessVersion byte, // encode each character in the address string. converted, e := bech32.ConvertBits(witnessProgram, 8, 5, true) if e != nil { - return "", err + return "", e } // Concatenate the witness version and program, and encode the resulting @@ -139,7 +139,7 @@ func encodeSegWitAddress(hrp string, witnessVersion byte, witnessVersion) } if e != nil { - return "", err + return "", e } // Check validity by decoding the created address. diff --git a/pkg/ec/wire/blockheader.go b/pkg/ec/wire/blockheader.go index 10c7b1c5..1502a025 100644 --- a/pkg/ec/wire/blockheader.go +++ b/pkg/ec/wire/blockheader.go @@ -3,7 +3,7 @@ package wire import ( "time" - "mleku.online/git/ec/chainhash" + "github.com/Hubmakerlabs/replicatr/pkg/ec/chainhash" ) // BlockHeader defines information about a block and is used in the bitcoin diff --git a/pkg/ec/wire/msgtx.go b/pkg/ec/wire/msgtx.go index b96c7a08..e229ce30 100644 --- a/pkg/ec/wire/msgtx.go +++ b/pkg/ec/wire/msgtx.go @@ -1,7 +1,7 @@ package wire import ( - "mleku.online/git/ec/chainhash" + "github.com/Hubmakerlabs/replicatr/pkg/ec/chainhash" ) // OutPoint defines a bitcoin data type that is used to track previous diff --git a/pkg/go-nostr/connect/connect.go b/pkg/go-nostr/connect/connect.go index 03e755ed..873fca24 100644 --- a/pkg/go-nostr/connect/connect.go +++ b/pkg/go-nostr/connect/connect.go @@ -10,17 +10,14 @@ import ( "net" "net/http" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/gobwas/httphead" "github.com/gobwas/ws" "github.com/gobwas/ws/wsflate" "github.com/gobwas/ws/wsutil" - log2 "mleku.online/git/log" ) -var ( - log = log2.GetLogger() - fails = log.D.Chk -) +var log, fails = log2.GetStd() type Connection struct { Conn net.Conn diff --git a/pkg/go-nostr/event/event.go b/pkg/go-nostr/event/event.go index 419eae20..afaaa078 100644 --- a/pkg/go-nostr/event/event.go +++ b/pkg/go-nostr/event/event.go @@ -9,8 +9,8 @@ import ( "github.com/Hubmakerlabs/replicatr/pkg/go-nostr/escape" "github.com/Hubmakerlabs/replicatr/pkg/go-nostr/tags" "github.com/Hubmakerlabs/replicatr/pkg/go-nostr/timestamp" - "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcec/v2/schnorr" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec/schnorr" "github.com/mailru/easyjson" "github.com/mailru/easyjson/jwriter" "github.com/tidwall/gjson" diff --git a/pkg/go-nostr/keys/keys.go b/pkg/go-nostr/keys/keys.go index 50eff283..8c665f8c 100644 --- a/pkg/go-nostr/keys/keys.go +++ b/pkg/go-nostr/keys/keys.go @@ -8,8 +8,8 @@ import ( "math/big" "strings" - "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcec/v2/schnorr" + "github.com/Hubmakerlabs/replicatr/pkg/ec" + "github.com/Hubmakerlabs/replicatr/pkg/ec/schnorr" ) func GeneratePrivateKey() string { diff --git a/pkg/go-nostr/nip04/nip04.go b/pkg/go-nostr/nip04/nip04.go index 1a2416a4..e9ebae7b 100644 --- a/pkg/go-nostr/nip04/nip04.go +++ b/pkg/go-nostr/nip04/nip04.go @@ -10,7 +10,7 @@ import ( "fmt" "strings" - "github.com/btcsuite/btcd/btcec/v2" + "github.com/Hubmakerlabs/replicatr/pkg/ec" ) // ComputeSharedSecret returns a shared secret key used to encrypt messages. diff --git a/pkg/go-nostr/nip04/nip04_test.go b/pkg/go-nostr/nip04/nip04_test.go index f4b25760..718c56a5 100644 --- a/pkg/go-nostr/nip04/nip04_test.go +++ b/pkg/go-nostr/nip04/nip04_test.go @@ -13,12 +13,12 @@ func TestEncryptionAndDecryption(t *testing.T) { ciphertext, e := Encrypt(message, sharedSecret) if e != nil { - t.Errorf("failed to encrypt: %s", err.Error()) + t.Errorf("failed to encrypt: %s", e.Error()) } plaintext, e := Decrypt(ciphertext, sharedSecret) if e != nil { - t.Errorf("failed to decrypt: %s", err.Error()) + t.Errorf("failed to decrypt: %s", e.Error()) } if message != plaintext { @@ -34,12 +34,12 @@ func TestEncryptionAndDecryptionWithMultipleLengths(t *testing.T) { ciphertext, e := Encrypt(message, sharedSecret) if e != nil { - t.Errorf("failed to encrypt: %s", err.Error()) + t.Errorf("failed to encrypt: %s", e.Error()) } plaintext, e := Decrypt(ciphertext, sharedSecret) if e != nil { - t.Errorf("failed to decrypt: %s", err.Error()) + t.Errorf("failed to decrypt: %s", e.Error()) } if message != plaintext { diff --git a/pkg/go-nostr/nip13/nip13_test.go b/pkg/go-nostr/nip13/nip13_test.go index 4a2890a5..daba43c1 100644 --- a/pkg/go-nostr/nip13/nip13_test.go +++ b/pkg/go-nostr/nip13/nip13_test.go @@ -26,7 +26,8 @@ func TestCheck(t *testing.T) { } for i, tc := range tests { if e := Check(eventID, tc.minDifficulty); e != tc.wantErr { - t.Errorf("%d: Check(%q, %d) returned %v; want err: %v", i, eventID, tc.minDifficulty, err, tc.wantErr) + t.Errorf("%d: Check(%q, %d) returned %v; want err: %v", i, eventID, + tc.minDifficulty, e, tc.wantErr) } } } @@ -96,13 +97,13 @@ func TestGenerateTimeout(t *testing.T) { done := make(chan error) go func() { _, e := Generate(event, 256, time.Millisecond) - done <- err + done <- e }() select { case <-time.After(time.Second): t.Error("Generate took too long to timeout") case e := <-done: - if !errors.Is(err, ErrGenerateTimeout) { + if !errors.Is(e, ErrGenerateTimeout) { t.Errorf("Generate returned %v; want ErrGenerateTimeout", e) } } diff --git a/pkg/go-nostr/nip19/nip19.go b/pkg/go-nostr/nip19/nip19.go index 51975fc6..c7c86289 100644 --- a/pkg/go-nostr/nip19/nip19.go +++ b/pkg/go-nostr/nip19/nip19.go @@ -6,8 +6,8 @@ import ( "encoding/hex" "fmt" + "github.com/Hubmakerlabs/replicatr/pkg/bech32" "github.com/Hubmakerlabs/replicatr/pkg/go-nostr/pointers" - "github.com/btcsuite/btcd/btcutil/bech32" ) func Decode(bech32string string) (prefix string, value any, e error) { diff --git a/pkg/go-nostr/nip46/signer.go b/pkg/go-nostr/nip46/signer.go index 08db853e..e6b127a7 100644 --- a/pkg/go-nostr/nip46/signer.go +++ b/pkg/go-nostr/nip46/signer.go @@ -38,7 +38,7 @@ func (s Session) ParseRequest(evt *event.T) (Request, error) { } e = json.Unmarshal([]byte(plain), &req) - return req, err + return req, e } func (s Session) MakeResponse( @@ -50,7 +50,7 @@ func (s Session) MakeResponse( if e != nil { resp = Response{ ID: id, - Error: err.Error(), + Error: e.Error(), } } else if result != "" { resp = Response{ @@ -129,7 +129,7 @@ func (p *Signer) HandleRequest(evt *event.T) (req Request, resp Response, eventR session, e := p.GetSession(evt.PubKey) if e != nil { - return req, resp, eventResponse, false, err + return req, resp, eventResponse, false, e } req, e = session.ParseRequest(evt) @@ -226,13 +226,13 @@ func (p *Signer) HandleRequest(evt *event.T) (req Request, resp Response, eventR resp, eventResponse, e = session.MakeResponse(req.ID, evt.PubKey, result, resultErr) if e != nil { - return req, resp, eventResponse, harmless, err + return req, resp, eventResponse, harmless, e } e = eventResponse.Sign(p.secretKey) if e != nil { - return req, resp, eventResponse, harmless, err + return req, resp, eventResponse, harmless, e } - return req, resp, eventResponse, harmless, err + return req, resp, eventResponse, harmless, e } diff --git a/pkg/go-nostr/nson/nson.go b/pkg/go-nostr/nson/nson.go index eed2ba17..ea87fe4a 100644 --- a/pkg/go-nostr/nson/nson.go +++ b/pkg/go-nostr/nson/nson.go @@ -114,7 +114,7 @@ func Unmarshal(data string, evt *event.T) (e error) { func MarshalBytes(evt *event.T) ([]byte, error) { v, e := Marshal(evt) - return unsafe.Slice(unsafe.StringData(v), len(v)), err + return unsafe.Slice(unsafe.StringData(v), len(v)), e } func Marshal(evt *event.T) (string, error) { diff --git a/pkg/go-nostr/relays/relay_test.go b/pkg/go-nostr/relays/relay_test.go index 5d99f95c..f85fe357 100644 --- a/pkg/go-nostr/relays/relay_test.go +++ b/pkg/go-nostr/relays/relay_test.go @@ -155,7 +155,7 @@ func TestConnectContextCanceled(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) cancel() // make ctx expired _, e := RelayConnect(ctx, ws.URL) - if !errors.Is(err, context.Canceled) { + if !errors.Is(e, context.Canceled) { t.Errorf("RelayConnectContext returned %v error; want context.Canceled", e) } } diff --git a/pkg/go-nostr/relays/relays_test.go b/pkg/go-nostr/relays/relays_test.go index ff5d45b5..5e37b01e 100644 --- a/pkg/go-nostr/relays/relays_test.go +++ b/pkg/go-nostr/relays/relays_test.go @@ -25,18 +25,18 @@ func TestEOSEMadness(t *testing.T) { timeout := time.After(3 * time.Second) n := 0 - e := 0 + ee := 0 for { select { - case event := <-sub.Events: - if event == nil { - t.Fatalf("event is nil: %v", event) + case ev := <-sub.Events: + if ev == nil { + t.Fatalf("event is nil: %v", ev) } n++ case <-sub.EndOfStoredEvents: - e++ - if e > 1 { + ee++ + if ee > 1 { t.Fatalf("eose infinite loop") } continue @@ -48,7 +48,7 @@ func TestEOSEMadness(t *testing.T) { } end: - if e != 1 { + if ee != 1 { t.Fatalf("didn't get an eose") } if n < 2 { diff --git a/pkg/log/log_test.go b/pkg/log/log_test.go index c0a153a3..198bb480 100644 --- a/pkg/log/log_test.go +++ b/pkg/log/log_test.go @@ -4,13 +4,10 @@ import ( "errors" "testing" - l "mleku.online/git/log" + l "github.com/Hubmakerlabs/replicatr/pkg/log" ) -var ( - log = l.GetLogger() - fails = log.E.Chk -) +var log, fails = l.GetStd() func TestGetLogger(t *testing.T) { l.SetLogLevel(l.Trace) diff --git a/pkg/nostr/.idea/dictionaries b/pkg/nostr/.idea/dictionaries new file mode 100644 index 00000000..7cc7a60d --- /dev/null +++ b/pkg/nostr/.idea/dictionaries @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pkg/nostr/.idea/misc.xml b/pkg/nostr/.idea/misc.xml new file mode 100644 index 00000000..0d260169 --- /dev/null +++ b/pkg/nostr/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/pkg/nostr/.idea/modules.xml b/pkg/nostr/.idea/modules.xml new file mode 100644 index 00000000..812a1d60 --- /dev/null +++ b/pkg/nostr/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pkg/nostr/.idea/vcs.xml b/pkg/nostr/.idea/vcs.xml new file mode 100644 index 00000000..5c569407 --- /dev/null +++ b/pkg/nostr/.idea/vcs.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/pkg/nostr/.idea/workspace.xml b/pkg/nostr/.idea/workspace.xml new file mode 100644 index 00000000..cc2ad1bb --- /dev/null +++ b/pkg/nostr/.idea/workspace.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + true + + \ No newline at end of file diff --git a/pkg/nostr/binary/event.go b/pkg/nostr/binary/event.go index 2fe67b38..6512196d 100644 --- a/pkg/nostr/binary/event.go +++ b/pkg/nostr/binary/event.go @@ -3,17 +3,17 @@ package binary import ( "encoding/hex" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/eventid" "github.com/Hubmakerlabs/replicatr/pkg/nostr/kind" "github.com/Hubmakerlabs/replicatr/pkg/nostr/tags" "github.com/Hubmakerlabs/replicatr/pkg/nostr/timestamp" - log2 "mleku.online/git/log" ) +var log, fails = log2.GetStd() + var ( - log = log2.GetLogger() - fails = log.D.Chk hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString ) diff --git a/pkg/nostr/enveloper/enveloper_test.go b/pkg/nostr/enveloper/enveloper_test.go index bd2915bb..69136b40 100644 --- a/pkg/nostr/enveloper/enveloper_test.go +++ b/pkg/nostr/enveloper/enveloper_test.go @@ -4,21 +4,20 @@ import ( "encoding/json" "testing" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/OK" - close2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/closer" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/eose" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/OK" + close2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/closer" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/eose" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/event" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/notice" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/req" "github.com/Hubmakerlabs/replicatr/pkg/nostr/eventest" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filtertest" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/notice" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/req" - log2 "mleku.online/git/log" ) -var log = log2.GetLogger() -var fails = log.D.Chk +var log, fails = log2.GetStd() func TestEnveloper(t *testing.T) { // log2.SetLogLevel(log2.Debug) diff --git a/pkg/nostr/OK/okenvelope.go b/pkg/nostr/envelopes/OK/okenvelope.go similarity index 98% rename from pkg/nostr/OK/okenvelope.go rename to pkg/nostr/envelopes/OK/okenvelope.go index f53b1b98..462f2994 100644 --- a/pkg/nostr/OK/okenvelope.go +++ b/pkg/nostr/envelopes/OK/okenvelope.go @@ -5,16 +5,15 @@ import ( "sort" "strings" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" "github.com/Hubmakerlabs/replicatr/pkg/nostr/eventid" "github.com/Hubmakerlabs/replicatr/pkg/nostr/labels" "github.com/Hubmakerlabs/replicatr/pkg/wire/array" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" ) -var log = log2.GetLogger() -var fails = log.D.Chk +var log, fails = log2.GetStd() type Reason string diff --git a/pkg/nostr/auth/challenge.go b/pkg/nostr/envelopes/auth/challenge.go similarity index 100% rename from pkg/nostr/auth/challenge.go rename to pkg/nostr/envelopes/auth/challenge.go diff --git a/pkg/nostr/auth/response.go b/pkg/nostr/envelopes/auth/response.go similarity index 96% rename from pkg/nostr/auth/response.go rename to pkg/nostr/envelopes/auth/response.go index 7a580f85..75dde46b 100644 --- a/pkg/nostr/auth/response.go +++ b/pkg/nostr/envelopes/auth/response.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/kind" @@ -12,12 +13,11 @@ import ( "github.com/Hubmakerlabs/replicatr/pkg/nostr/tags" "github.com/Hubmakerlabs/replicatr/pkg/wire/array" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" ) +var log, fails = log2.GetStd() + var ( - log = log2.GetLogger() - fails = log.D.Chk hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString ) diff --git a/pkg/nostr/auth/validate.go b/pkg/nostr/envelopes/auth/validate.go similarity index 100% rename from pkg/nostr/auth/validate.go rename to pkg/nostr/envelopes/auth/validate.go diff --git a/pkg/nostr/closed/closedenvelope.go b/pkg/nostr/envelopes/closed/closedenvelope.go similarity index 96% rename from pkg/nostr/closed/closedenvelope.go rename to pkg/nostr/envelopes/closed/closedenvelope.go index 443bac5c..c8fb4c1a 100644 --- a/pkg/nostr/closed/closedenvelope.go +++ b/pkg/nostr/envelopes/closed/closedenvelope.go @@ -3,16 +3,15 @@ package closed import ( "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" "github.com/Hubmakerlabs/replicatr/pkg/nostr/labels" "github.com/Hubmakerlabs/replicatr/pkg/nostr/subscriptionid" "github.com/Hubmakerlabs/replicatr/pkg/wire/array" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" ) -var log = log2.GetLogger() -var fails = log.D.Chk +var log, fails = log2.GetStd() // Envelope is a wrapper for a signal to cancel a subscription. type Envelope struct { diff --git a/pkg/nostr/closer/closeenvelope.go b/pkg/nostr/envelopes/closer/closeenvelope.go similarity index 84% rename from pkg/nostr/closer/closeenvelope.go rename to pkg/nostr/envelopes/closer/closeenvelope.go index 1ff4153a..9a63834f 100644 --- a/pkg/nostr/closer/closeenvelope.go +++ b/pkg/nostr/envelopes/closer/closeenvelope.go @@ -3,16 +3,15 @@ package closer import ( "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" "github.com/Hubmakerlabs/replicatr/pkg/nostr/labels" "github.com/Hubmakerlabs/replicatr/pkg/nostr/subscriptionid" "github.com/Hubmakerlabs/replicatr/pkg/wire/array" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" ) -var log = log2.GetLogger() -var fails = log.D.Chk +var log, fails = log2.GetStd() // Envelope is a wrapper for a signal to cancel a subscription. type Envelope struct { @@ -25,9 +24,9 @@ func NewCloseEnvelope(s subscriptionid.T) (ce *Envelope) { return &Envelope{T: s} } -func (E *Envelope) Label() (l string) { return labels.CLOSE } -func (E *Envelope) String() (s string) { return E.ToArray().String() } -func (E *Envelope) Bytes() (s []byte) { return E.ToArray().Bytes() } +func (E *Envelope) Label() (l string) { return labels.CLOSE } +func (E *Envelope) String() (s string) { return E.ToArray().String() } +func (E *Envelope) Bytes() (s []byte) { return E.ToArray().Bytes() } func (E *Envelope) ToArray() (a array.T) { return array.T{labels.CLOSE, E.T} diff --git a/pkg/nostr/countrequest/countenvelope.go b/pkg/nostr/envelopes/countrequest/countenvelope.go similarity index 92% rename from pkg/nostr/countrequest/countenvelope.go rename to pkg/nostr/envelopes/countrequest/countenvelope.go index b714d0a1..1abef45b 100644 --- a/pkg/nostr/countrequest/countenvelope.go +++ b/pkg/nostr/envelopes/countrequest/countenvelope.go @@ -5,18 +5,18 @@ import ( "encoding/json" "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filter" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filters" "github.com/Hubmakerlabs/replicatr/pkg/nostr/labels" "github.com/Hubmakerlabs/replicatr/pkg/nostr/subscriptionid" "github.com/Hubmakerlabs/replicatr/pkg/wire/array" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" ) +var log, fails = log2.GetStd() + var ( - log = log2.GetLogger() - fails = log.D.Chk hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString ) @@ -25,7 +25,7 @@ type Envelope struct { filters.T } -func (C *Envelope) Label() labels.T { return labels.LCount } +func (C *Envelope) Label() string { return labels.COUNT } func (C *Envelope) String() (s string) { return C.ToArray().String() } func (C *Envelope) Bytes() (s []byte) { return C.ToArray().Bytes() } @@ -39,6 +39,11 @@ func (C *Envelope) MarshalJSON() (bytes []byte, e error) { return C.ToArray().Bytes(), nil } +func (C *Envelope) UnmarshalJSON(bytes []byte) error { + // TODO implement me + panic("implement me") +} + func (C *Envelope) Unmarshal(buf *text.Buffer) (e error) { log.D.Ln("ok envelope unmarshal", string(buf.Buf)) if C == nil { diff --git a/pkg/nostr/countresponse/countresponse.go b/pkg/nostr/envelopes/countresponse/countresponse.go similarity index 96% rename from pkg/nostr/countresponse/countresponse.go rename to pkg/nostr/envelopes/countresponse/countresponse.go index 166d573d..2998d23d 100644 --- a/pkg/nostr/countresponse/countresponse.go +++ b/pkg/nostr/envelopes/countresponse/countresponse.go @@ -5,18 +5,17 @@ import ( "encoding/json" "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" "github.com/Hubmakerlabs/replicatr/pkg/nostr/labels" "github.com/Hubmakerlabs/replicatr/pkg/nostr/subscriptionid" "github.com/Hubmakerlabs/replicatr/pkg/wire/array" "github.com/Hubmakerlabs/replicatr/pkg/wire/object" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" ) +var log, fails = log2.GetStd() var ( - log = log2.GetLogger() - fails = log.D.Chk hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString ) diff --git a/pkg/nostr/eose/eoseenvelope.go b/pkg/nostr/envelopes/eose/eoseenvelope.go similarity index 96% rename from pkg/nostr/eose/eoseenvelope.go rename to pkg/nostr/envelopes/eose/eoseenvelope.go index 34c8ff4c..1ff78c5f 100644 --- a/pkg/nostr/eose/eoseenvelope.go +++ b/pkg/nostr/envelopes/eose/eoseenvelope.go @@ -3,16 +3,15 @@ package eose import ( "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" "github.com/Hubmakerlabs/replicatr/pkg/nostr/labels" "github.com/Hubmakerlabs/replicatr/pkg/nostr/subscriptionid" "github.com/Hubmakerlabs/replicatr/pkg/wire/array" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" ) -var log = log2.GetLogger() -var fails = log.D.Chk +var log, fails = log2.GetStd() // Envelope is a message that indicates that all cached events have been // delivered and thereafter events will be new and delivered in pubsub subscribe diff --git a/pkg/nostr/event/eventenvelope.go b/pkg/nostr/envelopes/event/eventenvelope.go similarity index 94% rename from pkg/nostr/event/eventenvelope.go rename to pkg/nostr/envelopes/event/eventenvelope.go index 43759af9..9bb7b293 100644 --- a/pkg/nostr/event/eventenvelope.go +++ b/pkg/nostr/envelopes/event/eventenvelope.go @@ -4,12 +4,15 @@ import ( "encoding/json" "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/labels" "github.com/Hubmakerlabs/replicatr/pkg/nostr/subscriptionid" "github.com/Hubmakerlabs/replicatr/pkg/wire/array" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" ) +var log, fails = log2.GetStd() var _ enveloper.Enveloper = (*Envelope)(nil) @@ -21,7 +24,7 @@ type Envelope struct { SubscriptionID subscriptionid.T // The Event is here a pointer because it should not be copied unnecessarily. - Event *T + Event *event.T } func (env *Envelope) UnmarshalJSON(bytes []byte) error { @@ -32,7 +35,7 @@ func (env *Envelope) UnmarshalJSON(bytes []byte) error { // NewEventEnvelope builds an Envelope from a provided T // string and pointer to an T, and returns either the Envelope or an // error if the Subscription ID is invalid or the T is nil. -func NewEventEnvelope(si string, ev *T) (ee *Envelope, e error) { +func NewEventEnvelope(si string, ev *event.T) (ee *Envelope, e error) { var sid subscriptionid.T if sid, e = subscriptionid.New(si); fails(e) { return @@ -122,7 +125,7 @@ func (env *Envelope) Unmarshal(buf *text.Buffer) (e error) { return } // allocate an event to unmarshal into - env.Event = &T{} + env.Event = &event.T{} if e = json.Unmarshal(eventObj, env.Event); fails(e) { log.D.S(string(eventObj)) return diff --git a/pkg/nostr/notice/noticeenvelope.go b/pkg/nostr/envelopes/notice/noticeenvelope.go similarity index 95% rename from pkg/nostr/notice/noticeenvelope.go rename to pkg/nostr/envelopes/notice/noticeenvelope.go index 5edf21a8..983ce452 100644 --- a/pkg/nostr/notice/noticeenvelope.go +++ b/pkg/nostr/envelopes/notice/noticeenvelope.go @@ -3,15 +3,13 @@ package notice import ( "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/labels" "github.com/Hubmakerlabs/replicatr/pkg/wire/array" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" ) -var log = log2.GetLogger() -var fails = log.D.Chk - +var log, fails = log2.GetStd() // Envelope is a relay message intended to be shown to users in a nostr // client interface. @@ -19,9 +17,6 @@ type Envelope struct { Text string } - - - func (E *Envelope) UnmarshalJSON(bytes []byte) error { // TODO implement me panic("implement me") diff --git a/pkg/nostr/envelopes/process.go b/pkg/nostr/envelopes/process.go index e3b87ef0..f8e9197b 100644 --- a/pkg/nostr/envelopes/process.go +++ b/pkg/nostr/envelopes/process.go @@ -3,21 +3,20 @@ package envelopes import ( "fmt" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/OK" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/closed" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/closer" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/eose" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/OK" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/closed" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/closer" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/eose" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/event" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/notice" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/req" "github.com/Hubmakerlabs/replicatr/pkg/nostr/labels" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/notice" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/req" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" ) -var log = log2.GetLogger() -var fails = log.D.Chk +var log, fails = log2.GetStd() // ProcessEnvelope scans a message and if it finds a correctly formed Envelope // it unmarshals it and returns it. diff --git a/pkg/nostr/req/reqenvelope.go b/pkg/nostr/envelopes/req/reqenvelope.go similarity index 97% rename from pkg/nostr/req/reqenvelope.go rename to pkg/nostr/envelopes/req/reqenvelope.go index 6c40d871..5b6f5dc6 100644 --- a/pkg/nostr/req/reqenvelope.go +++ b/pkg/nostr/envelopes/req/reqenvelope.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filter" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filters" @@ -11,11 +12,9 @@ import ( "github.com/Hubmakerlabs/replicatr/pkg/nostr/subscriptionid" "github.com/Hubmakerlabs/replicatr/pkg/wire/array" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" ) -var log = log2.GetLogger() -var fails = log.D.Chk +var log, fails = log2.GetStd() // Envelope is the wrapper for a query to a relay. type Envelope struct { diff --git a/pkg/nostr/event/event.go b/pkg/nostr/event/event.go index 31633ba9..bf55492f 100644 --- a/pkg/nostr/event/event.go +++ b/pkg/nostr/event/event.go @@ -4,6 +4,7 @@ import ( "encoding/hex" "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/eventid" "github.com/Hubmakerlabs/replicatr/pkg/nostr/kind" "github.com/Hubmakerlabs/replicatr/pkg/nostr/tags" @@ -11,14 +12,13 @@ import ( "github.com/Hubmakerlabs/replicatr/pkg/wire/array" "github.com/Hubmakerlabs/replicatr/pkg/wire/object" "github.com/minio/sha256-simd" - "mleku.online/git/ec/schnorr" - secp256k1 "mleku.online/git/ec/secp" - log2 "mleku.online/git/log" + "github.com/Hubmakerlabs/replicatr/pkg/ec/schnorr" + secp256k1 "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) +var log, fails = log2.GetStd() + var ( - log = log2.GetLogger() - fails = log.D.Chk hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString ) diff --git a/pkg/nostr/event/event_test.go b/pkg/nostr/event/event_test.go index 863d0df3..c356c859 100644 --- a/pkg/nostr/event/event_test.go +++ b/pkg/nostr/event/event_test.go @@ -7,6 +7,7 @@ import ( "math/rand" "testing" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/eventest" "github.com/Hubmakerlabs/replicatr/pkg/nostr/kind" @@ -14,15 +15,12 @@ import ( "github.com/Hubmakerlabs/replicatr/pkg/nostr/tag" "github.com/Hubmakerlabs/replicatr/pkg/nostr/tags" "github.com/Hubmakerlabs/replicatr/pkg/nostr/timestamp" - secp256k1 "mleku.online/git/ec/secp" - log2 "mleku.online/git/log" + secp256k1 "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) -var ( - log = log2.GetLogger() - fails = log.D.Chk - hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString -) +var log, fails = log2.GetStd() + +var hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString const ( TestSecBech32 = "nsec1z7tlduw3qkf4fz6kdw3jaq2h02jtexgwkrck244l3p834a930sjsh8t89c" diff --git a/pkg/nostr/eventid/eventid.go b/pkg/nostr/eventid/eventid.go index 0ed79552..b2ef5f92 100644 --- a/pkg/nostr/eventid/eventid.go +++ b/pkg/nostr/eventid/eventid.go @@ -4,13 +4,13 @@ import ( "encoding/hex" "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" ) +var log, fails = log2.GetStd() + var ( - log = log2.GetLogger() - fails = log.D.Chk hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString ) diff --git a/pkg/nostr/filter/filters.go b/pkg/nostr/filter/filters.go index 98719b80..ae5d7d75 100644 --- a/pkg/nostr/filter/filters.go +++ b/pkg/nostr/filter/filters.go @@ -5,16 +5,15 @@ import ( "fmt" "sort" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/kinds" "github.com/Hubmakerlabs/replicatr/pkg/nostr/tag" "github.com/Hubmakerlabs/replicatr/pkg/nostr/timestamp" "github.com/Hubmakerlabs/replicatr/pkg/wire/object" - log2 "mleku.online/git/log" ) -var log = log2.GetLogger() -var fails = log.D.Chk +var log, fails = log2.GetStd() // T is a query where one or all elements can be filled in. // diff --git a/pkg/nostr/nip19/keys.go b/pkg/nostr/nip19/keys.go index a327832e..dc514606 100644 --- a/pkg/nostr/nip19/keys.go +++ b/pkg/nostr/nip19/keys.go @@ -4,19 +4,17 @@ import ( "encoding/hex" "fmt" - btcec "mleku.online/git/ec" - log2 "mleku.online/git/log" + btcec "github.com/Hubmakerlabs/replicatr/pkg/ec" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" - "mleku.online/git/bech32" - "mleku.online/git/ec/schnorr" - secp "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/bech32" + "github.com/Hubmakerlabs/replicatr/pkg/ec/schnorr" + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) -var ( - log = log2.GetLogger() - fails = log.D.Chk - hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString -) +var log, fails = log2.GetStd() + +var hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString const ( // MinKeyStringLen is 56 because Bech32 needs 52 characters plus 4 for the HRP, @@ -180,10 +178,11 @@ func DecodeSignature(encoded string) (sig *schnorr.Signature, e error) { return schnorr.ParseSignature(b8[:64]) } -func GetPublicKey(sk string) (string, error) { - b, e := hex.DecodeString(sk) +func GetPublicKey(sk string) (s string, e error) { + var b []byte + b, e = hex.DecodeString(sk) if e != nil { - return "", err + return "", e } _, pk := btcec.PrivKeyFromBytes(b) diff --git a/pkg/nostr/nip19/keys_test.go b/pkg/nostr/nip19/keys_test.go index 291c7778..f9e61281 100644 --- a/pkg/nostr/nip19/keys_test.go +++ b/pkg/nostr/nip19/keys_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/minio/sha256-simd" - "mleku.online/git/ec/schnorr" - secp256k1 "mleku.online/git/ec/secp" + "github.com/Hubmakerlabs/replicatr/pkg/ec/schnorr" + secp256k1 "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) func TestConvertBits(t *testing.T) { diff --git a/pkg/nostr/nip19/nip19.go b/pkg/nostr/nip19/nip19.go index 40e8ea6e..b5fbfb78 100644 --- a/pkg/nostr/nip19/nip19.go +++ b/pkg/nostr/nip19/nip19.go @@ -10,7 +10,7 @@ import ( "github.com/Hubmakerlabs/replicatr/pkg/nostr/eventid" "github.com/Hubmakerlabs/replicatr/pkg/nostr/kind" "github.com/Hubmakerlabs/replicatr/pkg/nostr/pointers" - "mleku.online/git/bech32" + "github.com/Hubmakerlabs/replicatr/pkg/bech32" ) const ( diff --git a/pkg/nostr/nip4/nip4.go b/pkg/nostr/nip4/nip4.go index 47d6e1ca..d2fdd78e 100644 --- a/pkg/nostr/nip4/nip4.go +++ b/pkg/nostr/nip4/nip4.go @@ -6,20 +6,14 @@ import ( "crypto/cipher" "crypto/rand" "encoding/base64" - "encoding/hex" "fmt" "strings" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/nip19" - secp "mleku.online/git/ec/secp" - log2 "mleku.online/git/log" -) - -var ( - log = log2.GetLogger() - fails = log.D.Chk - hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString + secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp" ) +var log, fails = log2.GetStd() // ComputeSharedSecret computes an Elliptic Curve Diffie Hellman shared secret // out of one public key and another secret key. diff --git a/pkg/nostr/nip5/nip05.go b/pkg/nostr/nip5/nip05.go index 7928a6b6..0ec464aa 100644 --- a/pkg/nostr/nip5/nip05.go +++ b/pkg/nostr/nip5/nip05.go @@ -8,15 +8,11 @@ import ( "net/http" "strings" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/pointers" - log2 "mleku.online/git/log" ) -var ( - log = log2.GetLogger() - fails = log.D.Chk - hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString -) +var log, fails = log2.GetStd() type ( name2KeyMap map[string]string diff --git a/pkg/nostr/quotes/quotes/gen.go b/pkg/nostr/quotes/quotes/gen.go index d823f9b5..b1ea1894 100644 --- a/pkg/nostr/quotes/quotes/gen.go +++ b/pkg/nostr/quotes/quotes/gen.go @@ -35,7 +35,7 @@ var D = []Source{ func main() { var jsons []string e := filepath.Walk(".", - func(path string, info fs.FileInfo, e error) (e error) { + func(path string, info fs.FileInfo, er error) (e error) { if strings.HasSuffix(path, "json") { jsons = append(jsons, path) } diff --git a/pkg/nostr/relay/helpers.go b/pkg/nostr/relay/helpers.go index b9278ca4..949a035d 100644 --- a/pkg/nostr/relay/helpers.go +++ b/pkg/nostr/relay/helpers.go @@ -1,13 +1,7 @@ package relay import ( - "encoding/hex" - - log2 "mleku.online/git/log" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" ) -var ( - log = log2.GetLogger() - fails = log.D.Chk - hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString -) +var log, fails = log2.GetStd() diff --git a/pkg/nostr/relay/relay.go b/pkg/nostr/relay/relay.go index a951c2bf..a18e439c 100644 --- a/pkg/nostr/relay/relay.go +++ b/pkg/nostr/relay/relay.go @@ -10,24 +10,25 @@ import ( "time" "github.com/Hubmakerlabs/replicatr/pkg/go-nostr/connect" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/OK" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/auth" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/countresponse" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/eose" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/OK" + auth2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/auth" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/countresponse" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/eose" + event2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/event" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/notice" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filter" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filters" "github.com/Hubmakerlabs/replicatr/pkg/nostr/kind" "github.com/Hubmakerlabs/replicatr/pkg/nostr/normalize" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/notice" "github.com/Hubmakerlabs/replicatr/pkg/nostr/tags" "github.com/Hubmakerlabs/replicatr/pkg/nostr/timestamp" + "github.com/puzpuzpuz/xsync/v2" "github.com/gobwas/ws" "github.com/gobwas/ws/wsutil" - "github.com/puzpuzpuz/xsync/v2" ) // Option is the type of the argument passed for that. Some examples of this are @@ -266,7 +267,7 @@ func (r *Relay) Connect(ctx context.Context) (e error) { } else { log.D.F("NOTICE from %s: '%s'\n", r.URL, env.Text) } - case *auth.Challenge: + case *auth2.Challenge: if env.Challenge == "" { continue } @@ -274,7 +275,7 @@ func (r *Relay) Connect(ctx context.Context) (e error) { if r.challenges != nil { r.challenges <- env.Challenge } - case *event.Envelope: + case *event2.Envelope: if env.SubscriptionID == "" { continue } @@ -368,7 +369,7 @@ func (r *Relay) Publish(ctx context.Context, evt *event.T) (s Status, e error) { r.okCallbacks.Store(string(evt.ID), okCallback) defer r.okCallbacks.Delete(string(evt.ID)) // publish event - envb, _ := (&event.Envelope{Event: evt}).MarshalJSON() + envb, _ := (&event2.Envelope{Event: evt}).MarshalJSON() log.D.F("{%s} sending %v\n", r.URL, string(envb)) s = PublishStatusSent if e = <-r.Write(envb); fails(e) { @@ -427,7 +428,7 @@ func (r *Relay) Auth(ctx context.Context, event *event.T) (s Status, e error) { r.okCallbacks.Store(string(event.ID), okCallback) defer r.okCallbacks.Delete(string(event.ID)) // send AUTH - authResponse, _ := (&auth.Response{T: event}).MarshalJSON() + authResponse, _ := (&auth2.Response{T: event}).MarshalJSON() log.D.F("{%s} sending %v\n", r.URL, string(authResponse)) if e = <-r.Write(authResponse); e != nil { // s will be "failed" diff --git a/pkg/nostr/relay/relay_test.go b/pkg/nostr/relay/relay_test.go index f920fcd7..674405cf 100644 --- a/pkg/nostr/relay/relay_test.go +++ b/pkg/nostr/relay/relay_test.go @@ -23,7 +23,7 @@ import ( "github.com/Hubmakerlabs/replicatr/pkg/nostr/normalize" "github.com/Hubmakerlabs/replicatr/pkg/nostr/tags" "github.com/Hubmakerlabs/replicatr/pkg/nostr/timestamp" - btcec "mleku.online/git/ec" + btcec "github.com/Hubmakerlabs/replicatr/pkg/ec" "golang.org/x/net/websocket" ) @@ -163,7 +163,7 @@ func TestConnectContextCanceled(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) cancel() // make ctx expired _, e := RelayConnect(ctx, ws.URL) - if !errors.Is(err, context.Canceled) { + if !errors.Is(e, context.Canceled) { t.Errorf("RelayConnectContext returned %v error; want context.Canceled", e) } } @@ -216,7 +216,7 @@ func makeKeyPair(t *testing.T) (priv, pub string) { func MustRelayConnect(url string) *Relay { rl, e := RelayConnect(context.Background(), url) if e != nil { - panic(err.Error()) + panic(e.Error()) } return rl } diff --git a/pkg/nostr/relay/subscription.go b/pkg/nostr/relay/subscription.go index 8b2b4671..6cebfbb7 100644 --- a/pkg/nostr/relay/subscription.go +++ b/pkg/nostr/relay/subscription.go @@ -7,11 +7,11 @@ import ( "sync" "sync/atomic" - close2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/closer" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/countrequest" + close2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/closer" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/countrequest" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/req" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filters" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/req" "github.com/Hubmakerlabs/replicatr/pkg/nostr/subscriptionid" ) diff --git a/pkg/nostr/sdk/cache/memory/cache.go b/pkg/nostr/sdk/cache/memory/cache.go index c3a24443..5108cdb3 100644 --- a/pkg/nostr/sdk/cache/memory/cache.go +++ b/pkg/nostr/sdk/cache/memory/cache.go @@ -5,15 +5,10 @@ import ( "encoding/hex" "time" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" ristretto "github.com/fiatjaf/generic-ristretto" - log2 "mleku.online/git/log" -) - -var ( - log = log2.GetLogger() - fails = log.D.Chk - hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString ) +var log, fails = log2.GetStd() type RistrettoCache[V any] struct { Cache *ristretto.Cache[string, V] diff --git a/pkg/nostr/sdk/helpers.go b/pkg/nostr/sdk/helpers.go index 51ceb8d5..770a6f29 100644 --- a/pkg/nostr/sdk/helpers.go +++ b/pkg/nostr/sdk/helpers.go @@ -3,11 +3,11 @@ package sdk import ( "encoding/hex" - log2 "mleku.online/git/log" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" ) +var log, fails = log2.GetStd() + var ( - log = log2.GetLogger() - fails = log.D.Chk hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString ) diff --git a/pkg/nostr/tags/tags.go b/pkg/nostr/tags/tags.go index 1bc1001c..980fbc74 100644 --- a/pkg/nostr/tags/tags.go +++ b/pkg/nostr/tags/tags.go @@ -7,13 +7,12 @@ import ( "errors" "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/tag" - log2 "mleku.online/git/log" ) +var log, fails = log2.GetStd() var ( - log = log2.GetLogger() - fails = log.D.Chk hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString ) diff --git a/pkg/pool/pool.go b/pkg/pool/pool.go index 331529e1..8f7a33bc 100644 --- a/pkg/pool/pool.go +++ b/pkg/pool/pool.go @@ -6,19 +6,18 @@ import ( "sync" "time" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filter" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filters" "github.com/Hubmakerlabs/replicatr/pkg/nostr/normalize" "github.com/Hubmakerlabs/replicatr/pkg/nostr/relay" "github.com/fiatjaf/generic-ristretto/z" - log2 "mleku.online/git/log" "github.com/puzpuzpuz/xsync/v2" ) -var log = log2.GetLogger() -var fails = log.D.Chk +var log, fails = log2.GetStd() const MAX_LOCKS = 50 diff --git a/pkg/relay/add-event.go b/pkg/relay/add-event.go index 25945a70..c2986bf2 100644 --- a/pkg/relay/add-event.go +++ b/pkg/relay/add-event.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/OK" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/OK" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filter" "github.com/Hubmakerlabs/replicatr/pkg/nostr/kinds" diff --git a/pkg/relay/eventstore/badger/helpers.go b/pkg/relay/eventstore/badger/helpers.go index a3e7b83f..c8d76970 100644 --- a/pkg/relay/eventstore/badger/helpers.go +++ b/pkg/relay/eventstore/badger/helpers.go @@ -4,18 +4,14 @@ import ( "encoding/binary" "encoding/hex" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" - log2 "mleku.online/git/log" "github.com/Hubmakerlabs/replicatr/pkg/relay/eventstore" "golang.org/x/exp/slices" ) -var ( - log = log2.GetLogger() - fails = log.D.Chk - hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString -) +var log, fails = log2.GetStd() func getTagIndexPrefix(tagValue string) ([]byte, int) { var k []byte // the key with full length for created_at and idx at the end, but not filled with these diff --git a/pkg/relay/eventstore/helpers.go b/pkg/relay/eventstore/helpers.go index 7e5c3559..f94bdd26 100644 --- a/pkg/relay/eventstore/helpers.go +++ b/pkg/relay/eventstore/helpers.go @@ -1,17 +1,10 @@ package eventstore import ( - "encoding/hex" - + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" - log2 "mleku.online/git/log" -) - -var ( - log = log2.GetLogger() - fails = log.D.Chk - hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString ) +var log, fails = log2.GetStd() func isOlder(previous, next *event.T) bool { return previous.CreatedAt < next.CreatedAt || diff --git a/pkg/relay/handlers.go b/pkg/relay/handlers.go index 9f1a0faf..fbe4dda3 100644 --- a/pkg/relay/handlers.go +++ b/pkg/relay/handlers.go @@ -11,18 +11,18 @@ import ( "sync" "time" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/OK" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/auth" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/closed" - close2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/closer" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/countrequest" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/countresponse" "github.com/Hubmakerlabs/replicatr/pkg/nostr/enveloper" "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/eose" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/OK" + auth2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/auth" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/closed" + close2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/closer" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/countrequest" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/countresponse" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/eose" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/event" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/req" "github.com/Hubmakerlabs/replicatr/pkg/nostr/eventid" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/req" "github.com/fasthttp/websocket" "github.com/minio/sha256-simd" "github.com/rs/cors" @@ -232,10 +232,10 @@ func (rl *Relay) HandleWebsocket(w http.ResponseWriter, r *http.Request) { cancelReqCtx) case *close2.Envelope: removeListenerId(ws, env.T) - case *auth.Response: + case *auth2.Response: wsBaseUrl := strings.Replace(rl.ServiceURL, "http", "ws", 1) - if pubkey, o := auth.Validate(env.T, + if pubkey, o := auth2.Validate(env.T, ws.Challenge, wsBaseUrl); o { ws.AuthedPublicKey = pubkey diff --git a/pkg/relay/helpers.go b/pkg/relay/helpers.go index be937a93..53dde096 100644 --- a/pkg/relay/helpers.go +++ b/pkg/relay/helpers.go @@ -1,7 +1,6 @@ package relay import ( - "encoding/hex" "hash/maphash" "net/http" "strconv" @@ -9,13 +8,6 @@ import ( "unsafe" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" - log2 "mleku.online/git/log" -) - -var ( - log = log2.GetLogger() - fails = log.D.Chk - hexDecode, encodeToHex = hex.DecodeString, hex.EncodeToString ) func pointerHasher[V any](_ maphash.Seed, k *V) uint64 { diff --git a/pkg/relay/listener.go b/pkg/relay/listener.go index c75e9e0c..6082b453 100644 --- a/pkg/relay/listener.go +++ b/pkg/relay/listener.go @@ -4,6 +4,8 @@ import ( "context" "fmt" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" + event2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filter" filters2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/filters" @@ -11,6 +13,8 @@ import ( "github.com/puzpuzpuz/xsync/v2" ) +var log, fails = log2.GetStd() + type Listener struct { filters filters2.T cancel context.CancelCauseFunc @@ -83,7 +87,7 @@ func notifyListeners(evt *event.T) { var sid subscriptionid.T sid, e = subscriptionid.New(id) log.D.Chk(e) - log.E.Chk(ws.WriteJSON(&event.Envelope{SubscriptionID: sid, Event: evt})) + log.E.Chk(ws.WriteJSON(&event2.Envelope{SubscriptionID: sid, Event: evt})) return true }) return true diff --git a/pkg/relay/serve-req.go b/pkg/relay/serve-req.go index 66e9a251..81cb9303 100644 --- a/pkg/relay/serve-req.go +++ b/pkg/relay/serve-req.go @@ -5,10 +5,11 @@ import ( "errors" "sync" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/OK" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/OK" + event2 "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/event" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/notice" "github.com/Hubmakerlabs/replicatr/pkg/nostr/event" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filter" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/notice" "github.com/Hubmakerlabs/replicatr/pkg/nostr/subscriptionid" ) @@ -49,7 +50,7 @@ func (rl *Relay) handleRequest(ctx context.Context, id subscriptionid.T, for _, ovw := range rl.OverwriteResponseEvent { ovw(ctx, evt) } - rl.D.Chk(ws.WriteJSON(event.Envelope{SubscriptionID: id, Event: evt})) + rl.D.Chk(ws.WriteJSON(event2.Envelope{SubscriptionID: id, Event: evt})) } eose.Done() }(ch) diff --git a/pkg/relay/utils.go b/pkg/relay/utils.go index 1f149c1e..c71f2384 100644 --- a/pkg/relay/utils.go +++ b/pkg/relay/utils.go @@ -3,7 +3,7 @@ package relay import ( "context" - "github.com/Hubmakerlabs/replicatr/pkg/nostr/auth" + "github.com/Hubmakerlabs/replicatr/pkg/nostr/envelopes/auth" "github.com/Hubmakerlabs/replicatr/pkg/nostr/filter" "github.com/sebest/xff" ) diff --git a/pkg/wire/array/array.go b/pkg/wire/array/array.go index bbae8bc1..9e467e95 100644 --- a/pkg/wire/array/array.go +++ b/pkg/wire/array/array.go @@ -12,15 +12,11 @@ import ( "reflect" "time" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" "github.com/Hubmakerlabs/replicatr/pkg/wire/object" "github.com/Hubmakerlabs/replicatr/pkg/wire/text" - log2 "mleku.online/git/log" -) - -var ( - log = log2.GetLogger() - fails = log.D.Chk ) +var log, fails = log2.GetStd() // Arrayer is an interface for a type that can return an array.T - or in other // words []interface{} made into concrete. diff --git a/pkg/wire/text/rfc8259_test.go b/pkg/wire/text/rfc8259_test.go index fd71ee7f..9292708f 100644 --- a/pkg/wire/text/rfc8259_test.go +++ b/pkg/wire/text/rfc8259_test.go @@ -5,7 +5,7 @@ import ( "github.com/minio/sha256-simd" "lukechampine.com/frand" - log2 "mleku.online/git/log" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" ) func GenRandString(l int, src *frand.RNG) (str string) { diff --git a/pkg/wire/text/unescape.go b/pkg/wire/text/unescape.go index ce422b05..1f26c5de 100644 --- a/pkg/wire/text/unescape.go +++ b/pkg/wire/text/unescape.go @@ -5,13 +5,10 @@ import ( "unicode/utf16" "unicode/utf8" - log2 "mleku.online/git/log" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" ) -var ( - log = log2.GetLogger() - fails = log.D.Chk -) +var log, fails = log2.GetStd() // FirstHexCharToValue returns the hex value of a provided character from the // first place in an 8 bit value of two characters. diff --git a/pkg/wire/text/unescape_test.go b/pkg/wire/text/unescape_test.go index 6a48eeeb..d72711f7 100644 --- a/pkg/wire/text/unescape_test.go +++ b/pkg/wire/text/unescape_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - log2 "mleku.online/git/log" + log2 "github.com/Hubmakerlabs/replicatr/pkg/log" ) func TestUnescapeByteString(t *testing.T) {