diff --git a/README.md b/README.md index ff8d52e..b6440e0 100644 --- a/README.md +++ b/README.md @@ -97,12 +97,14 @@ If the OUTPUT exists, it will be overwritten. NETWORK defaults to the drand mainnet endpoint https://api.drand.sh/. -CHAIN defaults to the chainhash of the fastnet network: +CHAIN defaults to the chainhash of quicknet: +52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971 +it used to be that of the fastnet network, but that one is being deprecated: dbd506d6ef76e5f386f41c651dcb808c5bcbd75471cc4eafa3f4df7ad4e4c493 You can also use the drand test network: https://pl-us.testnet.drand.sh/ -and its unchained network with chain hash 7672797f548f3f4748ac4bf3352fc6c6b6468c9ad40ad456a397545c6e2df5bf +and its unchained network on G2 with chainhash 7672797f548f3f4748ac4bf3352fc6c6b6468c9ad40ad456a397545c6e2df5bf Note that if you encrypted something prior to March 2023, this was the only available network and used to be the default. DURATION, when specified, expects a number followed by one of these units: @@ -112,7 +114,7 @@ Example: $ tle -D 10d -o encrypted_file data_to_encrypt After the specified duration: - $ tle -d -o dencrypted_file.txt encrypted_file + $ tle -d -o decrypted_file.txt encrypted_file ``` #### Timelock Encryption diff --git a/cmd/tle/commands/commands.go b/cmd/tle/commands/commands.go index ac6787f..b8f8490 100644 --- a/cmd/tle/commands/commands.go +++ b/cmd/tle/commands/commands.go @@ -14,12 +14,12 @@ import ( // Default settings. const ( defaultNetwork = "https://api.drand.sh/" - defaultChain = "dbd506d6ef76e5f386f41c651dcb808c5bcbd75471cc4eafa3f4df7ad4e4c493" + defaultChain = "52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971" ) // ============================================================================= -const usage = `tlock v1.0.0 -- github.com/drand/tlock +const usage = `tlock v1.1.0 -- github.com/drand/tlock Usage: tle [--encrypt] (-r round)... [--armor] [-o OUTPUT] [INPUT] @@ -42,12 +42,14 @@ If the OUTPUT exists, it will be overwritten. NETWORK defaults to the drand mainnet endpoint https://api.drand.sh/. -CHAIN defaults to the chainhash of the fastnet network: +CHAIN defaults to the chainhash of quicknet: +52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971 +it used to be that of the fastnet network, but that one is being deprecated: dbd506d6ef76e5f386f41c651dcb808c5bcbd75471cc4eafa3f4df7ad4e4c493 You can also use the drand test network: https://pl-us.testnet.drand.sh/ -and its unchained network with chain hash 7672797f548f3f4748ac4bf3352fc6c6b6468c9ad40ad456a397545c6e2df5bf +and its unchained network on G2 with chainhash 7672797f548f3f4748ac4bf3352fc6c6b6468c9ad40ad456a397545c6e2df5bf Note that if you encrypted something prior to March 2023, this was the only available network and used to be the default. DURATION, when specified, expects a number followed by one of these units: @@ -57,7 +59,7 @@ Example: $ tle -D 10d -o encrypted_file data_to_encrypt After the specified duration: - $ tle -d -o dencrypted_file.txt encrypted_file` + $ tle -d -o decrypted_file.txt encrypted_file` // PrintUsage displays the usage information. func PrintUsage(log *log.Logger) { diff --git a/go.mod b/go.mod index 6c89c81..9046458 100644 --- a/go.mod +++ b/go.mod @@ -4,43 +4,44 @@ go 1.19 require ( filippo.io/age v1.1.1 - github.com/drand/drand v1.5.4 + github.com/drand/drand v1.5.7 github.com/drand/kyber v1.2.0 - github.com/drand/kyber-bls12381 v0.2.6 - github.com/stretchr/testify v1.8.2 + github.com/drand/kyber-bls12381 v0.3.1 + github.com/stretchr/testify v1.8.4 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) require ( - github.com/BurntSushi/toml v1.2.1 // indirect + github.com/BurntSushi/toml v1.3.2 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/kelseyhightower/envconfig v1.4.0 github.com/kilic/bls12-381 v0.1.0 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/nikkolasg/hexjson v0.1.0 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect - go.uber.org/atomic v1.10.0 // indirect - go.uber.org/multierr v1.10.0 // indirect - go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect - google.golang.org/genproto v0.0.0-20230320184635-7606e756e683 // indirect - google.golang.org/grpc v1.53.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + github.com/prometheus/client_golang v1.16.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.11.1 // indirect + go.uber.org/atomic v1.11.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.25.0 // indirect + golang.org/x/crypto v0.13.0 // indirect + golang.org/x/net v0.15.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect + google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect + google.golang.org/grpc v1.58.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect ) diff --git a/go.sum b/go.sum index d7aa107..d1ce2cb 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,13 @@ filippo.io/age v1.1.1 h1:pIpO7l151hCnQ4BdyBujnGP2YlUo0uj6sAVNHGBvXHg= filippo.io/age v1.1.1/go.mod h1:l03SrzDUrBkdBx8+IILdnn2KZysqQdbEBUQ4p3sqEQE= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/ardanlabs/darwin/v2 v2.0.0 h1:XCisQMgQ5EG+ZvSEcADEo+pyfIMKyWAGnn5o2TgriYE= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -14,10 +17,14 @@ 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/drand/drand v1.5.4 h1:9foZlskCCB/Ju7cNZSm/LS3kRz0THky5hQ+WTDpdgJk= github.com/drand/drand v1.5.4/go.mod h1:PhE5yina6hETiY2yCTqI2LxyEhuHeKc4VA0Ems7ci6o= +github.com/drand/drand v1.5.7 h1:5f2D5aH1nEfVI9S6tl2p9bgIDMZ92oltmiY12Kh+eYU= +github.com/drand/drand v1.5.7/go.mod h1:jrJ0244yOHNL5V04vazk3mFatjAWm3i6dg6URWwgbXk= github.com/drand/kyber v1.2.0 h1:22SbBxsKbgQnJUoyYKIfG909PhBsj0vtANeu4BX5xgE= github.com/drand/kyber v1.2.0/go.mod h1:6TqFlCc7NGOiNVTF9pF2KcDRfllPd9XOkExuG5Xtwfo= github.com/drand/kyber-bls12381 v0.2.6 h1:bM93oy2o0ORt+NwZ6uRyZsMPgUvSwJ1ZOALX6VjD4xc= github.com/drand/kyber-bls12381 v0.2.6/go.mod h1:H4y9bLPu7KZA/1efDg+jtJ7emKx+ro3PU7/jWUVt140= +github.com/drand/kyber-bls12381 v0.3.1 h1:KWb8l/zYTP5yrvKTgvhOrk2eNPscbMiUOIeWBnmUxGo= +github.com/drand/kyber-bls12381 v0.3.1/go.mod h1:H4y9bLPu7KZA/1efDg+jtJ7emKx+ro3PU7/jWUVt140= github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= github.com/go-chi/chi v1.5.4 h1:QHdzF2szwjqVV4wmByUnTcsbIg7UGaQ0tPF2t5GcAIs= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= @@ -43,6 +50,8 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg= github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= @@ -67,12 +76,20 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= +github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.9.1-0.20230118214834-e3815afac6ff h1:8sKK+bDq41BDdR3Twlwv4ufZm3+N/hmnb0QkyocX9G0= github.com/sercand/kuberesolver v2.4.0+incompatible h1:WE2OlRf6wjLxHwNkkFLQGaZcVLEXjMjBPjjEU5vksH8= @@ -84,6 +101,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/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/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o= github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= github.com/weaveworks/common v0.0.0-20230208133027-16871410fca4 h1:8eoXaryYVOWJZCnCzULYXtxiHHLrJpvoD7p283ogmo8= @@ -93,30 +112,52 @@ go.dedis.ch/protobuf v1.0.11 h1:FTYVIEzY/bfl37lu3pR4lIj+F9Vp1jE8oh91VmxKgLo= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= +go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto v0.0.0-20230320184635-7606e756e683 h1:khxVcsk/FhnzxMKOyD+TDGwjbEOpcPuIpmafPGFmhMA= google.golang.org/genproto v0.0.0-20230320184635-7606e756e683/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= +google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g= +google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/grpc v1.58.0 h1:32JY8YpPMSR45K+c3o6b8VL73V+rR8k+DeMIr4vRH8o= +google.golang.org/grpc v1.58.0/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/networks/http/http.go b/networks/http/http.go index 08a9667..3455b08 100644 --- a/networks/http/http.go +++ b/networks/http/http.go @@ -72,7 +72,7 @@ func NewNetwork(host string, chainHash string) (*Network, error) { return nil, ErrNotUnchained } - if !(sch.Name == crypto.UnchainedSchemeID || sch.Name == crypto.ShortSigSchemeID) { + if !(sch.Name == crypto.UnchainedSchemeID || sch.Name == crypto.ShortSigSchemeID || sch.Name == crypto.SigsOnG1ID) { return nil, ErrNotUnchained } diff --git a/tlock.go b/tlock.go index 3676133..ae411a5 100644 --- a/tlock.go +++ b/tlock.go @@ -135,13 +135,18 @@ func TimeLock(scheme crypto.Scheme, publicKey kyber.Point, roundNumber uint64, d var cipherText *ibe.Ciphertext var err error - if scheme.Name == crypto.ShortSigSchemeID { - cipherText, err = ibe.EncryptCCAonG2(bls.NewBLS12381Suite(), publicKey, id, data) - } else if scheme.Name == crypto.UnchainedSchemeID { + switch scheme.Name { + case crypto.ShortSigSchemeID: + // the ShortSigSchemeID uses the wrong DST for G1, so we keep it for retro-compatibility + cipherText, err = ibe.EncryptCCAonG2(bls.NewBLS12381SuiteWithDST(bls.DefaultDomainG2(), bls.DefaultDomainG2()), publicKey, id, data) + case crypto.UnchainedSchemeID: cipherText, err = ibe.EncryptCCAonG1(bls.NewBLS12381Suite(), publicKey, id, data) - } else { + case crypto.SigsOnG1ID: + cipherText, err = ibe.EncryptCCAonG2(bls.NewBLS12381Suite(), publicKey, id, data) + default: return nil, fmt.Errorf("unsupported drand scheme '%s'", scheme.Name) } + if err != nil { return nil, fmt.Errorf("encrypt data: %w", err) } @@ -158,19 +163,27 @@ func TimeUnlock(scheme crypto.Scheme, publicKey kyber.Point, beacon chain.Beacon var data []byte var err error - if scheme.Name == crypto.ShortSigSchemeID { + switch scheme.Name { + case crypto.ShortSigSchemeID: var signature bls.KyberG1 if err := signature.UnmarshalBinary(beacon.Signature); err != nil { return nil, fmt.Errorf("unmarshal kyber G1: %w", err) } - data, err = ibe.DecryptCCAonG2(bls.NewBLS12381Suite(), &signature, ciphertext) - } else if scheme.Name == crypto.UnchainedSchemeID { + // the ShortSigSchemeID uses the wrong DST for G1, so we keep it for retro-compatibility + data, err = ibe.DecryptCCAonG2(bls.NewBLS12381SuiteWithDST(bls.DefaultDomainG2(), bls.DefaultDomainG2()), &signature, ciphertext) + case crypto.UnchainedSchemeID: var signature bls.KyberG2 if err := signature.UnmarshalBinary(beacon.Signature); err != nil { return nil, fmt.Errorf("unmarshal kyber G2: %w", err) } data, err = ibe.DecryptCCAonG1(bls.NewBLS12381Suite(), &signature, ciphertext) - } else { + case crypto.SigsOnG1ID: + var signature bls.KyberG1 + if err := signature.UnmarshalBinary(beacon.Signature); err != nil { + return nil, fmt.Errorf("unmarshal kyber G1: %w", err) + } + data, err = ibe.DecryptCCAonG2(bls.NewBLS12381Suite(), &signature, ciphertext) + default: return nil, fmt.Errorf("unsupported drand scheme '%s'", scheme.Name) } diff --git a/tlock_test.go b/tlock_test.go index 6734bbc..357ec64 100644 --- a/tlock_test.go +++ b/tlock_test.go @@ -22,49 +22,54 @@ var ( ) const ( - testnetHost = "https://pl-us.testnet.drand.sh/" - testnetChainHash = "7672797f548f3f4748ac4bf3352fc6c6b6468c9ad40ad456a397545c6e2df5bf" - mainnetHost = "https://api.drand.sh/" - mainnetChainHash = "dbd506d6ef76e5f386f41c651dcb808c5bcbd75471cc4eafa3f4df7ad4e4c493" + testnetHost = "https://pl-us.testnet.drand.sh/" + testnetChainHashOnG2 = "7672797f548f3f4748ac4bf3352fc6c6b6468c9ad40ad456a397545c6e2df5bf" + testnetQuicknetT = "cc9c398442737cbd141526600919edd69f1d6f9b4adb67e4d912fbc64341a9a5" + mainnetHost = "https://api.drand.sh/" + mainnetFastnet = "dbd506d6ef76e5f386f41c651dcb808c5bcbd75471cc4eafa3f4df7ad4e4c493" + mainnetQuicknet = "52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971" ) func TestEarlyDecryptionWithDuration(t *testing.T) { - for host, hash := range map[string]string{testnetHost: testnetChainHash, mainnetHost: mainnetChainHash} { - network, err := http.NewNetwork(host, hash) - require.NoError(t, err) + for host, hashes := range map[string][]string{testnetHost: {testnetChainHashOnG2, testnetQuicknetT}, + mainnetHost: {mainnetFastnet, mainnetQuicknet}} { + for _, hash := range hashes { + network, err := http.NewNetwork(host, hash) + require.NoError(t, err) - // ========================================================================= - // Encrypt + // ========================================================================= + // Encrypt - // Read the plaintext data to be encrypted. - in, err := os.Open("test_artifacts/data.txt") - require.NoError(t, err) - defer in.Close() + // Read the plaintext data to be encrypted. + in, err := os.Open("test_artifacts/data.txt") + require.NoError(t, err) + defer in.Close() - // Write the encoded information to this buffer. - var cipherData bytes.Buffer + // Write the encoded information to this buffer. + var cipherData bytes.Buffer - // Enough duration to check for a non-existent beacon. - duration := 10 * time.Second + // Enough duration to check for a non-existent beacon. + duration := 10 * time.Second - roundNumber := network.RoundNumber(time.Now().Add(duration)) - err = tlock.New(network).Encrypt(&cipherData, in, roundNumber) - require.NoError(t, err) + roundNumber := network.RoundNumber(time.Now().Add(duration)) + err = tlock.New(network).Encrypt(&cipherData, in, roundNumber) + require.NoError(t, err) - // ========================================================================= - // Decrypt + // ========================================================================= + // Decrypt - // Write the decoded information to this buffer. - var plainData bytes.Buffer + // Write the decoded information to this buffer. + var plainData bytes.Buffer - // We DO NOT wait for the future beacon to exist. - err = tlock.New(network).Decrypt(&plainData, &cipherData) - require.ErrorIs(t, err, tlock.ErrTooEarly) + // We DO NOT wait for the future beacon to exist. + err = tlock.New(network).Decrypt(&plainData, &cipherData) + require.ErrorIs(t, err, tlock.ErrTooEarly) + } } } func TestEarlyDecryptionWithRound(t *testing.T) { - network, err := http.NewNetwork(testnetHost, testnetChainHash) + network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) require.NoError(t, err) // ========================================================================= @@ -97,7 +102,7 @@ func TestEncryptionWithDuration(t *testing.T) { t.Skip("skipping live testing in short mode") } - network, err := http.NewNetwork(testnetHost, testnetChainHash) + network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) require.NoError(t, err) // ========================================================================= @@ -139,7 +144,7 @@ func TestEncryptionWithRound(t *testing.T) { t.Skip("skipping live testing in short mode") } - network, err := http.NewNetwork(testnetHost, testnetChainHash) + network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) require.NoError(t, err) // ========================================================================= @@ -174,7 +179,7 @@ func TestEncryptionWithRound(t *testing.T) { } func TestTimeLockUnlock(t *testing.T) { - network, err := http.NewNetwork(testnetHost, testnetChainHash) + network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) require.NoError(t, err) futureRound := network.RoundNumber(time.Now()) @@ -206,7 +211,7 @@ func TestCannotEncryptWithPointAtInfinity(t *testing.T) { infinity := suite.G2().Scalar().Zero() pointAtInfinity := suite.G2().Point().Mul(infinity, nil) - _, err := tlock.TimeLock(*crypto.NewPedersenBLSUnchainedSwapped(), pointAtInfinity, 10, []byte("deadbeef")) + _, err := tlock.TimeLock(*crypto.NewPedersenBLSUnchainedG1(), pointAtInfinity, 10, []byte("deadbeef")) require.ErrorIs(t, err, tlock.ErrInvalidPublicKey) }) @@ -232,7 +237,7 @@ UG9qN2haU0FWdEpFK0pUZzUwWmVsVS9YRWdOaDRadwpeDBRfXZtLOC49GlI+Kozr z6hgtLUPYvAimgekc+CeyJ8fb/0MVrpq/Ewnx1MpKig8nQ== -----END AGE ENCRYPTED FILE-----` t.Run("With valid network", func(tt *testing.T) { - network, err := http.NewNetwork(mainnetHost, mainnetChainHash) + network, err := http.NewNetwork(mainnetHost, mainnetFastnet) require.NoError(tt, err) testReader := strings.NewReader(cipher) @@ -245,7 +250,18 @@ z6hgtLUPYvAimgekc+CeyJ8fb/0MVrpq/Ewnx1MpKig8nQ== }) t.Run("With invalid network", func(tt *testing.T) { - network, err := http.NewNetwork(testnetHost, testnetChainHash) + network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) + require.NoError(tt, err) + + testReader := strings.NewReader(cipher) + var plainData bytes.Buffer + + err = tlock.New(network).Decrypt(&plainData, testReader) + require.ErrorIs(tt, err, tlock.ErrWrongChainhash) + }) + + t.Run("With quicknet-t invalid network", func(tt *testing.T) { + network, err := http.NewNetwork(testnetHost, testnetQuicknetT) require.NoError(tt, err) testReader := strings.NewReader(cipher) @@ -269,7 +285,7 @@ RndkR1oyL0xFTkZILzl4Y3NBOU5EWXRGcDBObmZidwpiI9yHPl4yVTbeImtNOklv Ds7/d2pdgkRooMJ58zoZd+AFXtAn2+7yGehvtkrWoSxgA8cf1aLuHFTAHho= -----END AGE ENCRYPTED FILE-----` expected := "hello world and other things" - network, err := http.NewNetwork(mainnetHost, mainnetChainHash) + network, err := http.NewNetwork(mainnetHost, mainnetFastnet) require.NoError(t, err) testReader := strings.NewReader(cipher) @@ -292,7 +308,7 @@ ZEFUb0ZyZS9aSHpyWVkKKwNyX6cuEEENAjic1ew7k8G6vyxDrY5NWFbAhkKy0IrN jLK74v9Latit5qAD7Gu/zTIsQXMuCuUf7ma7 -----END AGE ENCRYPTED FILE-----` expected := "hello world and other things" - network, err := http.NewNetwork(testnetHost, testnetChainHash) + network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) require.NoError(t, err) testReader := strings.NewReader(cipher) @@ -303,4 +319,28 @@ jLK74v9Latit5qAD7Gu/zTIsQXMuCuUf7ma7 require.Equal(t, expected, plainData.String()) }) + t.Run("on testnet with quicknet-t", func(t *testing.T) { + cipher := `-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHRsb2NrIDE2MjQ5MTAgY2M5YzM5ODQ0 +MjczN2NiZDE0MTUyNjYwMDkxOWVkZDY5ZjFkNmY5YjRhZGI2N2U0ZDkxMmZiYzY0 +MzQxYTlhNQpqTTVLOEhWVUFrOFFkNStIL0ZQOHplRkZPSEs4T0pjVG1FNW9LSW1z +bytQRmRDM3lycEdtRGFtck9XMGVycDcxCkVuS1hqL216dmI3RThFMDZMWTNWZEh5 +SWh3UFhWWFJlREZ5SHZiTWNPMDdNcWFLamV5MWRNMkMwTHR1SjNpWUoKeENEaEJQ +RDF3K3JjbEtNenI3QU5VVldWa3FmMHd0aGtxTmw3VEEwK0RjQQotLS0gUWFpL0U5 +VDNsVkpZT3F2Mk14NWRIU3IzbnhuUUsyaTdsS0ptclNoNk9lOAqkjk0Ypkj6JxKk +5ZxeTXAsxRyy9yptL4yKgd2i/J7k/O3C0Te7yPwsdkUC +-----END AGE ENCRYPTED FILE-----` + expected := "test today\n" + network, err := http.NewNetwork(testnetHost, testnetQuicknetT) + require.NoError(t, err) + + testReader := strings.NewReader(cipher) + var plainData bytes.Buffer + + err = tlock.New(network).Decrypt(&plainData, testReader) + require.NoError(t, err) + + require.Equal(t, expected, plainData.String()) + }) + }