From bd5750fdacadcbf8c219a6e3dd21c631250f14a1 Mon Sep 17 00:00:00 2001 From: Yolan Romailler Date: Thu, 18 Jan 2024 01:12:50 +0100 Subject: [PATCH] v1.1.0 update Adding automated chainhash switching. Also added a Goreleaser GHA. Some extra cleanups and extra tests too. --- .github/workflows/release.yml | 30 ++++ .goreleaser.yml | 41 ++++++ README.md | 15 +- cmd/tle/commands/commands.go | 23 ++- cmd/tle/commands/commands_test.go | 11 +- go.mod | 33 ++--- go.sum | 131 +++++------------- networks/http/http.go | 21 ++- {test_artifacts => testdata}/data.txt | 0 .../decryptedFile.bin | 0 .../encryptedFile.bin | Bin ...rem-timevault-mainnet-2024-01-17-16-12.tle | 33 +++++ ...rem-timevault-testnet-2024-01-17-16-12.tle | 32 +++++ .../lorem-tle-testnet-g-2024-01-17-15-31.tle | 32 +++++ ...le-testnet-quicknet-t-2024-01-17-15-28.tle | 32 +++++ ...-testnet-unchained-3s-2024-01-17-15-33.tle | 31 +++++ testdata/lorem.txt | 1 + tlock.go | 25 +++- tlock_age.go | 30 +++- tlock_test.go | 98 ++++++++++--- 20 files changed, 455 insertions(+), 164 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml rename {test_artifacts => testdata}/data.txt (100%) rename {test_artifacts => testdata}/decryptedFile.bin (100%) rename {test_artifacts => testdata}/encryptedFile.bin (100%) create mode 100644 testdata/lorem-timevault-mainnet-2024-01-17-16-12.tle create mode 100644 testdata/lorem-timevault-testnet-2024-01-17-16-12.tle create mode 100644 testdata/lorem-tle-testnet-g-2024-01-17-15-31.tle create mode 100644 testdata/lorem-tle-testnet-quicknet-t-2024-01-17-15-28.tle create mode 100644 testdata/lorem-tle-testnet-unchained-3s-2024-01-17-15-33.tle create mode 100644 testdata/lorem.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2869f05 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +name: goreleaser + +on: + push: + tags: + - 'v*' + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.21' + - run: go version + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..312b242 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,41 @@ +project_name: tlock + +before: + hooks: + - go mod download + +builds: + - id: tlock + binary: tle + main: ./cmd/tle/tle.go + flags: + - -trimpath + env: + - CGO_ENABLED=0 + asmflags: + - all=-trimpath={{.Env.HOME}} + gcflags: + - all=-trimpath={{.Env.HOME}} + goos: + - darwin + - linux + - windows + goarch: + - amd64 + - arm + - arm64 + goarm: + - 6 + - 7 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +release: + prerelease: auto diff --git a/README.md b/README.md index b6440e0..1b9c1f0 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Working endpoints to access it are, on mainnet: On mainnet, the only chainhash supporting timelock encryption, with a 3s frequency and signatures on the G1 group is: `dbd506d6ef76e5f386f41c651dcb808c5bcbd75471cc4eafa3f4df7ad4e4c493` -This is a production-ready network with high-availability guarantees. It is considered fully secure by the drand team +This is a production-ready network with high-availability guarantees. It is considered fully secure by the drand team and ran by the same League of Entropy that has been running drand in production since 2019. On testnet: @@ -249,19 +249,19 @@ $ cat encrypted_data | tle -d | age -d -o data.txt Note that you could do the same with PGP or any other encryption tool. ---- +--- ### Security considerations The security of our timelock encryption mechanism relies on four main things: - The security of the underlying [Identity Encryption Scheme](https://crypto.stanford.edu/~dabo/pubs/papers/bfibe.pdf) (proposed in 2001) and [its implementation](https://github.com/drand/kyber/blob/a780ab21355ebe7f60b441a586d5e73a40c564eb/encrypt/ibe/ibe.go#L39-L47) that we're using. - The security of the [threshold BLS scheme](https://link.springer.com/content/pdf/10.1007/s00145-004-0314-9.pdf) (proposed in 2003), and [its impementation](https://github.com/drand/kyber/blob/master/sign/tbls/tbls.go) by the network you're relying on. -- The security of [age](https://age-encryption.org/)'s underlying primitives, and that of the [age implementation](https://age-encryption.org/) we're using to encrypt the data, since we rely on the [hybrid encryption](https://en.wikipedia.org/wiki/Hybrid_cryptosystem) principle, where we only timelock encrypt ("wrap") a random symmetric key that is used by age to actually symmetrically encrypt the data using [Chacha20Poly1305](https://datatracker.ietf.org/doc/html/rfc8439)). -- The security of the threshold network providing you with its BLS signatures **at a given frequency**, for instance the default for `tle` is to rely on drand and its existing League of Entropy network. - -In practice this means that if you trust there are never more than the threshold `t` malicious nodes on the network you're relying on, you are guaranteed that you timelocked data cannot be decrypted earlier than what you intended. +- The security of [age](https://age-encryption.org/)'s underlying primitives, and that of the [age implementation](https://age-encryption.org/) we're using to encrypt the data, since we rely on the [hybrid encryption](https://en.wikipedia.org/wiki/Hybrid_cryptosystem) principle, where we only timelock encrypt ("wrap") a random symmetric key that is used by age to actually symmetrically encrypt the data using [Chacha20Poly1305](https://datatracker.ietf.org/doc/html/rfc8439)). +- The security of the threshold network providing you with its BLS signatures **at a given frequency**, for instance the default for `tle` is to rely on drand and its existing League of Entropy network. + +In practice this means that if you trust there are never more than the threshold `t` malicious nodes on the network you're relying on, you are guaranteed that you timelocked data cannot be decrypted earlier than what you intended. -Please note that neither BLS nor the IBE scheme we are relying on are "quantum resistant", therefore shall a Quantum Computer be built that's able to threaten their security, our current design wouldn't resist. There are also no quantum resistant scheme that we're aware of that could be used to replace our current design since post-quantum signatures schemes do not "thresholdize" too well in a post-quantum IBE-compatible way. +Please note that neither BLS nor the IBE scheme we are relying on are "quantum resistant", therefore shall a Quantum Computer be built that's able to threaten their security, our current design wouldn't resist. There are also no quantum resistant scheme that we're aware of that could be used to replace our current design since post-quantum signatures schemes do not "thresholdize" too well in a post-quantum IBE-compatible way. However, such a quantum computer seems unlikely to be built within the next 5-10 years and therefore we currently consider that you can expect a "**long term security**" horizon of at least 5 years by relying on our design. @@ -288,4 +288,3 @@ Therefore, the project is dual-licensed under Apache 2.0 and MIT terms: - Apache License, Version 2.0, ([LICENSE-APACHE](https://github.com/drand/drand/blob/master/LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) - MIT license ([LICENSE-MIT](https://github.com/drand/drand/blob/master/LICENSE-MIT) or https://opensource.org/licenses/MIT) -89 diff --git a/cmd/tle/commands/commands.go b/cmd/tle/commands/commands.go index b8f8490..9c94f5f 100644 --- a/cmd/tle/commands/commands.go +++ b/cmd/tle/commands/commands.go @@ -13,8 +13,10 @@ import ( // Default settings. const ( - defaultNetwork = "https://api.drand.sh/" - defaultChain = "52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971" + // DefaultNetwork is set to the HTTPs relay from drand, you can also use Cloudflare relay or any other relay. + DefaultNetwork = "https://api.drand.sh/" + // DefaultChain is set to the League of Entropy quicknet chainhash. + DefaultChain = "52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971" ) // ============================================================================= @@ -88,8 +90,8 @@ func Parse() (Flags, error) { flag.Usage = func() { fmt.Fprintf(os.Stderr, "%s\n", usage) } f := Flags{ - Network: defaultNetwork, - Chain: defaultChain, + Network: DefaultNetwork, + Chain: DefaultChain, } err := envconfig.Process("tle", &f) @@ -176,8 +178,8 @@ func validateFlags(f *Flags) error { if f.Armor { return fmt.Errorf("-a/--armor can't be used with -d/--decrypt") } - if f.Network != defaultNetwork { - if f.Chain == defaultChain { + if f.Network != DefaultNetwork { + if f.Chain == DefaultChain { fmt.Fprintf(os.Stderr, "You've specified a non-default network endpoint but still use the default chain hash.\n"+ "You might want to also specify a custom chainhash with the -c/--chain flag.\n\n") @@ -185,7 +187,7 @@ func validateFlags(f *Flags) error { } default: if f.Chain == "" { - return fmt.Errorf("-c/--chain can't be empty") + fmt.Fprintf(os.Stderr, "-c/--chain is empty, will default to quicknet chainhash (%s).\n", DefaultChain) } if f.Duration != "" && f.Round != 0 { return fmt.Errorf("-D/--duration can't be used with -r/--round") @@ -193,6 +195,13 @@ func validateFlags(f *Flags) error { if f.Duration == "" && f.Round == 0 { return fmt.Errorf("-D/--duration or -r/--round must be specified") } + if f.Network != DefaultNetwork { + if f.Chain == DefaultChain { + fmt.Fprintf(os.Stderr, + "You've specified a non-default network endpoint but still use the default chain hash.\n"+ + "You might want to also specify a custom chainhash with the -c/--chain flag.\n\n") + } + } } return nil diff --git a/cmd/tle/commands/commands_test.go b/cmd/tle/commands/commands_test.go index 25acc28..273d612 100644 --- a/cmd/tle/commands/commands_test.go +++ b/cmd/tle/commands/commands_test.go @@ -2,10 +2,11 @@ package commands import ( "bytes" - "github.com/stretchr/testify/require" "os" "testing" "time" + + "github.com/stretchr/testify/require" ) func TestParseDuration(t *testing.T) { @@ -125,8 +126,8 @@ func TestEncryptionWithDurationOverflow(t *testing.T) { flags := Flags{ Encrypt: true, Decrypt: false, - Network: defaultNetwork, - Chain: defaultChain, + Network: DefaultNetwork, + Chain: DefaultChain, Round: 0, Duration: "292277042628y", Armor: false, @@ -139,8 +140,8 @@ func TestEncryptionWithDurationOverflowUsingOtherUnits(t *testing.T) { flags := Flags{ Encrypt: true, Decrypt: false, - Network: defaultNetwork, - Chain: defaultChain, + Network: DefaultNetwork, + Chain: DefaultChain, Duration: "292277042627y12m1d", Armor: false, } diff --git a/go.mod b/go.mod index 9046458..2791556 100644 --- a/go.mod +++ b/go.mod @@ -4,18 +4,18 @@ go 1.19 require ( filippo.io/age v1.1.1 - github.com/drand/drand v1.5.7 + github.com/drand/drand v1.5.9 github.com/drand/kyber v1.2.0 github.com/drand/kyber-bls12381 v0.3.1 github.com/stretchr/testify v1.8.4 + gopkg.in/yaml.v3 v3.0.1 ) 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 + google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect ) require ( @@ -28,20 +28,17 @@ require ( 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.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 + github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.46.0 // indirect + github.com/prometheus/procfs v0.12.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 + go.uber.org/zap v1.26.0 // indirect + golang.org/x/crypto v0.18.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/text v0.14.0 // indirect + google.golang.org/grpc v1.60.1 // indirect + google.golang.org/protobuf v1.32.0 // indirect ) diff --git a/go.sum b/go.sum index d1ce2cb..2c7ba78 100644 --- a/go.sum +++ b/go.sum @@ -1,46 +1,35 @@ 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= -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/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/drand v1.5.9 h1:eZKRDPseEeV0baJXrdCBJbv2YaRsqJLS1UQCaQ7PGnA= +github.com/drand/drand v1.5.9/go.mod h1:TvJjCJ/s4Usn4pKRpDC0N1QaCwSt3YC8fRqhZdpOUU0= 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/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/go-chi/chi v1.5.4 h1:QHdzF2szwjqVV4wmByUnTcsbIg7UGaQ0tPF2t5GcAIs= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/status v1.1.1 h1:DuHXlSFHNKqTQ+/ACf5Vs6r4X/dH2EgIzR9Vr+H65kg= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -48,8 +37,6 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= 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= @@ -59,107 +46,65 @@ github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa github.com/kilic/bls12-381 v0.1.0 h1:encrdjqKMEvabVQ7qYOKu1OvhqpK4s47wDYtNiPtlp4= github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/nikkolasg/hexjson v0.1.0 h1:Cgi1MSZVQFoJKYeRpBNEcdF3LB+Zo4fYKsDz7h8uJYQ= github.com/nikkolasg/hexjson v0.1.0/go.mod h1:fbGbWFZ0FmJMFbpCMtJpwb0tudVxSSZ+Es2TsCg57cA= github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e h1:4cPxUYdgaGzZIT5/j0IfqOrrXmq6bG8AwvwisMXpdrg= github.com/opentracing-contrib/go-stdlib v1.0.0 h1:TBS7YuVotp8myLon4Pv7BtCBzOTo1DeZCld0Z63mW2w= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 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= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -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.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.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y= +github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/sercand/kuberesolver/v4 v4.0.0 h1:frL7laPDG/lFm5n98ODmWnn+cvPpzlkf3LhzuPhcHP4= +github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= 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= +github.com/weaveworks/common v0.0.0-20230531151736-e2613bee6b73 h1:CMM9+/AgM77vaMXMQedzqPRMuNwjbI0EcdofPqxc9F8= github.com/weaveworks/promrus v1.2.0 h1:jOLf6pe6/vss4qGHjXmGz4oDJQA+AOCqEL3FvvZGz7M= go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs= 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/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= 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= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= 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/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 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/genproto v0.0.0-20240102182953-50ed04b92917 h1:nz5NESFLZbJGPFxDT/HCn+V1mZ8JGNoY4nUpmW/Y2eg= +google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0 h1:s1w3X6gQxwrLEpxnLd/qXTVLgQE2yXwaOaoa6IlY/+o= +google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0/go.mod h1:CAny0tYF+0/9rmDB9fahA9YLzX3+AEVl1qXbv5hhj6c= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac h1:nUQEQmH/csSvFECKYRv6HWEyypysidKl2I6Qpsglq/0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= +google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= +google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= 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= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 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= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/networks/http/http.go b/networks/http/http.go index 3455b08..333fa06 100644 --- a/networks/http/http.go +++ b/networks/http/http.go @@ -6,8 +6,6 @@ import ( "encoding/hex" "errors" "fmt" - "github.com/drand/drand/chain" - "github.com/drand/drand/crypto" "log" "net" "net/http" @@ -15,7 +13,10 @@ import ( "strings" "time" - "github.com/drand/drand/client" + "github.com/drand/drand/chain" + "github.com/drand/drand/crypto" + + dclient "github.com/drand/drand/client" dhttp "github.com/drand/drand/client/http" "github.com/drand/kyber" ) @@ -32,7 +33,8 @@ var ErrNotUnchained = errors.New("not an unchained network") // Network represents the network support using the drand http client. type Network struct { chainHash string - client client.Client + host string + client dclient.Client publicKey kyber.Point scheme crypto.Scheme period time.Duration @@ -78,6 +80,7 @@ func NewNetwork(host string, chainHash string) (*Network, error) { network := Network{ chainHash: chainHash, + host: host, client: client, publicKey: info.PublicKey, scheme: *sch, @@ -129,6 +132,16 @@ func (n *Network) RoundNumber(t time.Time) uint64 { return n.client.RoundAt(t) } +// SwitchChainHash allows to start using another chainhash on the same host network +func (n *Network) SwitchChainHash(new string) error { + test, err := NewNetwork(n.host, new) + if err != nil { + return err + } + *n = *test + return nil +} + // ============================================================================= // transport sets reasonable defaults for the connection. diff --git a/test_artifacts/data.txt b/testdata/data.txt similarity index 100% rename from test_artifacts/data.txt rename to testdata/data.txt diff --git a/test_artifacts/decryptedFile.bin b/testdata/decryptedFile.bin similarity index 100% rename from test_artifacts/decryptedFile.bin rename to testdata/decryptedFile.bin diff --git a/test_artifacts/encryptedFile.bin b/testdata/encryptedFile.bin similarity index 100% rename from test_artifacts/encryptedFile.bin rename to testdata/encryptedFile.bin diff --git a/testdata/lorem-timevault-mainnet-2024-01-17-16-12.tle b/testdata/lorem-timevault-mainnet-2024-01-17-16-12.tle new file mode 100644 index 0000000..d88de3d --- /dev/null +++ b/testdata/lorem-timevault-mainnet-2024-01-17-16-12.tle @@ -0,0 +1,33 @@ +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHRsb2NrIDkyNzMwNDEgZGJkNTA2ZDZl +Zjc2ZTVmMzg2ZjQxYzY1MWRjYjgwOGM1YmNiZDc1NDcxY2M0ZWFmYTNmNGRmN2Fk +NGU0YzQ5Mwp0aXEvOWpEUGpwaGF6TlFUbGtmTSt1aXJWV1FqUHV0SXcvNFNBTUlG +c3FBUlpXMStMZ2YrVjh2V0VnYTdhSWFUCkJGamwzSjVBUWozZHJNWU9za0c5ekY5 +RjFrTnVRdFF2eGZYSkJzdUE0NjREcENCV2c0LzU1TW9KdzVCbnNtcjgKNlpKL2JV +RmxWdG9wK3doYndrcVNvTW0zNFBmSkpONGplbnZ1NEsvZngwUQotLS0gT0ptL0tu +M082WkdXb3RGd2tZdmtCSDdnVmdHMGpiNjFoQkJnMXNCeCtlTQrCR2RhNwkZpxyj +02GwG/LduXL4ecqWB8YjwHXQT0TqZRMzhkikH9DxApLr4W5jBfX0fkYHwvI/5X76 +5ekZFRMmF83ZVCcW4n4xwFFCm6lIRk+6V/fagQ5FjVF9VnovsTsGkm+AWRWMfjo/ +SCNPwZK6Zu4y144TuFc8dFndyS+d8yj3I+S6kBiORL56stKecUi2K4lXUxGf0fjt +EZT2qDcwq3ke8RMRDG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Q3FKj1x9mr6pEx4xBVP +V/exZ1SIUfK1HCiRWeuG3C4SdJvKX+qiTL9ISG0edXWnQEVYHtquJ3zqvVRyBM1f +Mm+JKqT4e9vWpBA1/KlQRIC/20+LeJt7yFpyPuyrgkJk4XtU3fSazpGY7ppWPOOv +vhD9r9NgWKYSXlyTkVQxjpy3UctqI7VvZawUw88= +-----END AGE ENCRYPTED FILE----- + diff --git a/testdata/lorem-timevault-testnet-2024-01-17-16-12.tle b/testdata/lorem-timevault-testnet-2024-01-17-16-12.tle new file mode 100644 index 0000000..6f1ccf2 --- /dev/null +++ b/testdata/lorem-timevault-testnet-2024-01-17-16-12.tle @@ -0,0 +1,32 @@ +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHRsb2NrIDE3OTQyNDA4IDc2NzI3OTdm +NTQ4ZjNmNDc0OGFjNGJmMzM1MmZjNmM2YjY0NjhjOWFkNDBhZDQ1NmEzOTc1NDVj +NmUyZGY1YmYKZ1RJNFNHZDZ3RDVQK1Y4Y1hwbzRzSmxDVk1rL2pmeUgxWVUwRFNP +VzhDeFViVG5FaWVHR3lhVC96RG9nQmRkegpaWnhsTGZ2Y0dlbmUrNGNqR3pjTnNM +WXpKTnVFdjg2Z3NSdmNhcXFBeTNzCi0tLSBtRnBPUTVpRGREc2lKY3d1VTQwcXdE +bmU4OTFKVmYycXYwS05wSkxjYmZjCvVDgZtZtOZTzeSH7y2uRTR+VqN4LMV8YuRK +LQcvTQVxshL3EZGbPUINT9PTRlwm8X+J+z9xvv0JjHHx6RLH4/qIzAkl3ClDmtK4 +dbcoLM9Tx3tU8bbOXer6Y6NoBxH9ARSO49XxhRYNzrI7hTFRMvOwWb80gXhrP6tz +HbCMnz2zGaF6yf6IqTzb5GpeFFYcYhrFdGIAoT1wogHc2eKF9XAzFMKS76Te6AZ4 +2OE3my9j0O394GvSAwHLMyjusigMtijGLc7ZossgmLuRq/fxqCr8FOL1Hp6GOV8l +0P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OzrtXJL5Cgu68M3biyOqcuOCpECMjVu +gjzRCC+EnL0J5UeD+7pxooyyDK+HO4NqQzO6+i9FHAV4LyhfVOUoPD5NdZC8UxkQ +2gi1tTioSjYNfglwTQ== +-----END AGE ENCRYPTED FILE----- + diff --git a/testdata/lorem-tle-testnet-g-2024-01-17-15-31.tle b/testdata/lorem-tle-testnet-g-2024-01-17-15-31.tle new file mode 100644 index 0000000..8b2edc7 --- /dev/null +++ b/testdata/lorem-tle-testnet-g-2024-01-17-15-31.tle @@ -0,0 +1,32 @@ +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHRsb2NrIDEwMDc5NzgwIGYzODI3ZDc3 +MmMxNTVmOTVhOWZkYTg5MDFkZGQ1OTU5MWEwODJkZjVhYzZlZmUzYTQ3OWRkYjFm +NWVlYjIwMmMKZ3pkSWhZa0NpU3ZaN2Nad2RPaENzU1YvQ2cxLzFBT0JWd1ZyKzY2 +elhZN0diUXNBTXRJdnBURjFpcndaUktzTApGdEJFWW5lWUZXWVVacC9OSXlTWUln +OWZtK0VYVElaemw1UHFyRnM5YXBmdnJtTGlDVC9KcUlhdFhzbWkwZ2xiCkEwKzhE +U1Z4WHQ0b2VmUFl5bEVLL3kwNDdtS2xDUHlnb29uVmcwQmZ3ZW8KLS0tIHRZcFha +RjVWSE9TRkVEWVJyNGttMjRUNXZYSGxzVTVUUS9lRWZ1c3g0blkKAO1jBNz+xYdh +8V5beOE8Az09L2UPlLHFucFGxyZTSs8kIh9K77F1AjG8mvL47BfpN8Bg8LDDNSIu +yMyUZqmLf/k/zlzFgJPpHBbZZaSvGtjEcCVhkXXZcqctP36mij9w12fdD3S0IcSu +Wc8aY6C8/600399JcPhApGvXYqp3t6B8JFInFoPWYNhaYmR9/lMBU3gnDhhTJwG2 +OME8aRDC36LARoicEGEAZSz2sxipZHXw3gMvmwmm1AT4mNHWNm90U4wwaiCICCiL +0iR9Eof6eKo197KWm7PT6TH4xEs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k +xAAW/EucFPwpoDgtqpyyUe2PuTe6n+L/O2BAxbHmO8i2zojcXw7LHxdxCZTVMedS +MKuVrZAswGQcw4+7QgFl3jrS3VDqap0is/xDPj69 +-----END AGE ENCRYPTED FILE----- diff --git a/testdata/lorem-tle-testnet-quicknet-t-2024-01-17-15-28.tle b/testdata/lorem-tle-testnet-quicknet-t-2024-01-17-15-28.tle new file mode 100644 index 0000000..ae1a408 --- /dev/null +++ b/testdata/lorem-tle-testnet-quicknet-t-2024-01-17-15-28.tle @@ -0,0 +1,32 @@ +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHRsb2NrIDU0MjMxNDIgY2M5YzM5ODQ0 +MjczN2NiZDE0MTUyNjYwMDkxOWVkZDY5ZjFkNmY5YjRhZGI2N2U0ZDkxMmZiYzY0 +MzQxYTlhNQpoek0rRzZyMFgvcjdxc0tlUnlyZ2wwbUc2ZFlDajdTeFhNUncvY2ZV +RWhNWE0vYklaOGU4VnUxU3RxNkZHV3RMCkRSVnVaYm9BT0xQR1VoQVhzNjdReEY4 +eEFSMjBveWJNZGZUMHFOZU43U1J4V0ZQU1hYck80dTZZcUtBZGl3MGcKaG9tU3BK +dTdqZnAzVnZpb0JKTVA1WXlaYzVqM0wrakhMYU9xdHBoUExKdwotLS0gdEJwcFZR +VUdabkVMVTF6TWFMb040VHp4Wmp2RFMxM29zTjVvQ0ppN1d0bwr0aKdwOuhX9epf +ewK2KOYCOM6p+cEzMFxYGUGjjui/NiDG4h8ih0fdr+N3Ig81+GH3h9KcfdkbZHV6 +L+hEGVZvAwWcOXi45iSCfUQO6ID4YA9/4AuxjnlSnwXFKcdwc4lMyhQdKE2Fe9j2 +SHG++eFe7fQi9M64ic3FOcNcrBXDNCmv7qUhSBxW8fFZjoJER5+oZd61yArLldMh +KWByL5iyg83cSfB79e9mHnAk/Y4fznlJzkgVc8eh9CWvY2rtVufwmUYZoBKnFd80 +M0FwnrvLDZmujUpiikZop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1ICS36Qq +rw4ve/c4w5gUoOZJ+YTmoWJHdmKo6GbD+OV3yBOUbhMu/mUyKWwDyFZE/TYNBV1y +yFtROCURe6axDDcOUgR+QEsl8oKXA6rppMwIeMg= +-----END AGE ENCRYPTED FILE----- diff --git a/testdata/lorem-tle-testnet-unchained-3s-2024-01-17-15-33.tle b/testdata/lorem-tle-testnet-unchained-3s-2024-01-17-15-33.tle new file mode 100644 index 0000000..924d77b --- /dev/null +++ b/testdata/lorem-tle-testnet-unchained-3s-2024-01-17-15-33.tle @@ -0,0 +1,31 @@ +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHRsb2NrIDE3OTQxNjI4IDc2NzI3OTdm +NTQ4ZjNmNDc0OGFjNGJmMzM1MmZjNmM2YjY0NjhjOWFkNDBhZDQ1NmEzOTc1NDVj +NmUyZGY1YmYKaTcyOGY1ZEUxaGhDVDVzOEhqTjBTamM0Kzl5Z1ZycmN3OGlIMDlW +YlNtV1pMNEQrckJud0Uyd3BGTFhrei80RgpsMzZIZjY4U3QzQmJTMUc2TFdOdnZN +ZjBlYXBWd2dXQ0pjRWJubC81bTlFCi0tLSBTKzZQMnYxVS9BUUU4ejJzbzZ6aTM5 +TUhFRzdLdmlzUEgzZUVzckxuNTQwCmu/aCcm+cL3w0LdFCwA0MyanPAg9TArmKoP +NvsISX5e4wH5Exf7N69TjjB39tsJ4wkku+Q1iAbFgy8eayq1kvNTNkRjUB0tfPq9 +Nz+zRvZFNVoy50HzdOds5mxWI/BeKK6B9abAImYWQJvjtjRxa0OSRaKoCaoNkuON +9f7BRTDDz3V8V9IcFsiMUCwOFzxOCniqhsQeyfTDi4lzqG9j/qaToIXil4ZVMmuk +QZJ82eX779JufYLIH64LI4igtTNO4d37S7MEy2IKEKCB58HZTs8j6T9HvTQgvq4O +JIr+1NrkKpxN4j1h+9XMJrVZCRwJq2yW3+azWFRqzpxBYv2fa3yMRQKmY8r29IdD +WeNteSgxDvW6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QbgeGYGi4a +tzxCagw5BdPQxvPJBA== +-----END AGE ENCRYPTED FILE----- diff --git a/testdata/lorem.txt b/testdata/lorem.txt new file mode 100644 index 0000000..4486046 --- /dev/null +++ b/testdata/lorem.txt @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse arcu nisi, ornare sed risus quis, scelerisque molestie massa. Integer ullamcorper in ex non accumsan. Sed bibendum feugiat velit eu tempus. Vivamus ultrices, nisi ut dictum tempus, eros turpis pretium mi, a feugiat justo lorem sit amet odio. Integer dignissim vestibulum consectetur. Nunc bibendum lacinia nisi viverra vehicula. Nam eget euismod tortor, eget efficitur neque. Praesent lacus nulla, iaculis sed augue vitae, congue dignissim neque. Aliquam ultricies lorem ligula, quis pretium nunc convallis sed. Sed eget varius mauris. Vivamus nulla lectus, varius nec fermentum eget, laoreet quis mauris. Mauris non lectus sit amet ligula interdum auctor vel sit amet nisl. Sed vel tincidunt leo, vitae pellentesque lectus. Suspendisse cursus, neque a molestie rhoncus, lectus odio fermentum erat, a feugiat nibh eros in lectus. Phasellus finibus mauris sodales, ullamcorper neque eget, sodales erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. diff --git a/tlock.go b/tlock.go index ae411a5..5fff4f0 100644 --- a/tlock.go +++ b/tlock.go @@ -6,17 +6,18 @@ package tlock import ( "bufio" "errors" + "fmt" + "io" + "time" + "filippo.io/age" "filippo.io/age/armor" - "fmt" "github.com/drand/drand/chain" "github.com/drand/drand/crypto" "github.com/drand/kyber" bls "github.com/drand/kyber-bls12381" "github.com/drand/kyber/encrypt/ibe" "gopkg.in/yaml.v3" - "io" - "time" ) // ErrTooEarly represents an error when a decryption operation happens early. @@ -33,23 +34,33 @@ type Network interface { PublicKey() kyber.Point Scheme() crypto.Scheme Signature(roundNumber uint64) ([]byte, error) + SwitchChainHash(string) error } // ============================================================================= // Tlock provides an API for time lock encryption and decryption. type Tlock struct { - network Network + network Network + trustChainhash bool } // New constructs a tlock for the specified network which can encrypt data that -// can be decrypted until the future. +// can be decrypted until the future. By default a new network will trust the +// chainhash it sees in ciphertexts and try and use these unless Strict was +// called to prevent it. func New(network Network) Tlock { return Tlock{ - network: network, + network: network, + trustChainhash: true, } } +func (t Tlock) Strict() Tlock { + t.trustChainhash = false + return t +} + // Encrypt will encrypt the source and write that to the destination. The encrypted // data will not be decryptable until the specified round is reached by the network. func (t Tlock) Encrypt(dst io.Writer, src io.Reader, roundNumber uint64) (err error) { @@ -83,7 +94,7 @@ func (t Tlock) Decrypt(dst io.Writer, src io.Reader) error { src = rr } - r, err := age.Decrypt(src, &tleIdentity{network: t.network}) + r, err := age.Decrypt(src, &tleIdentity{network: t.network, trustChainhash: t.trustChainhash}) if err != nil { return fmt.Errorf("hybrid decrypt: %w", err) } diff --git a/tlock_age.go b/tlock_age.go index bf2a23f..1872f5f 100644 --- a/tlock_age.go +++ b/tlock_age.go @@ -2,11 +2,13 @@ package tlock import ( "errors" - "filippo.io/age" "fmt" - "github.com/drand/drand/chain" + "os" "strconv" "time" + + "filippo.io/age" + "github.com/drand/drand/chain" ) var ErrWrongChainhash = errors.New("invalid chainhash") @@ -46,17 +48,20 @@ func (t *tleRecipient) Wrap(fileKey []byte) ([]*age.Stanza, error) { // tleIdentity implements the age Identity interface. This is used to decrypt // data with the age Decrypt API. type tleIdentity struct { - network Network + network Network + trustChainhash bool } // Unwrap is called by the age Decrypt API and is provided the DEK that was time // lock encrypted by the Wrap function via the Stanza. Inside of Unwrap we decrypt -// the DEK and provide back to age. +// the DEK and provide back to age. If the ciphertext uses a chainhash different +// from the one we are current using, we will try switching to it. func (t *tleIdentity) Unwrap(stanzas []*age.Stanza) ([]byte, error) { if len(stanzas) < 1 { return nil, errors.New("check stanzas length: should be at least one") } + invalid := "" for _, stanza := range stanzas { if stanza.Type != "tlock" { continue @@ -72,8 +77,16 @@ func (t *tleIdentity) Unwrap(stanzas []*age.Stanza) ([]byte, error) { } if t.network.ChainHash() != stanza.Args[1] { - return nil, fmt.Errorf("%w: current network uses %s != %s the ciphertext requires.\n"+ - "Note that is might have been encrypted using our testnet instead", ErrWrongChainhash, t.network.ChainHash(), stanza.Args[1]) + invalid = stanza.Args[1] + if t.trustChainhash { + fmt.Fprintf(os.Stderr, "WARN: stanza using different chainhash '%s', trying to use it instead.\n", invalid) + err = t.network.SwitchChainHash(invalid) + if err != nil { + continue + } + } else { + continue + } } ciphertext, err := BytesToCiphertext(t.network.Scheme(), stanza.Body) @@ -103,5 +116,10 @@ func (t *tleIdentity) Unwrap(stanzas []*age.Stanza) ([]byte, error) { return fileKey, nil } + if len(invalid) > 0 { + return nil, fmt.Errorf("%w: current network uses %s != %s the ciphertext requires.\n"+ + "Note that is might have been encrypted using our testnet instead", ErrWrongChainhash, t.network.ChainHash(), invalid) + } + return nil, fmt.Errorf("check stanza type: wrong type: %w", age.ErrIncorrectIdentity) } diff --git a/tlock_test.go b/tlock_test.go index 357ec64..1f9a2b0 100644 --- a/tlock_test.go +++ b/tlock_test.go @@ -3,27 +3,32 @@ package tlock_test import ( "bytes" _ "embed" // Calls init function. - "github.com/drand/drand/crypto" - bls "github.com/drand/kyber-bls12381" - "github.com/stretchr/testify/require" + "errors" "os" + "path/filepath" "strings" "testing" "time" + "github.com/drand/drand/crypto" + bls "github.com/drand/kyber-bls12381" + "github.com/stretchr/testify/require" + "github.com/drand/drand/chain" "github.com/drand/tlock" "github.com/drand/tlock/networks/http" ) var ( - //go:embed test_artifacts/data.txt + //go:embed testdata/data.txt dataFile []byte + //go:embed testdata/lorem.txt + loremBytes []byte ) const ( testnetHost = "https://pl-us.testnet.drand.sh/" - testnetChainHashOnG2 = "7672797f548f3f4748ac4bf3352fc6c6b6468c9ad40ad456a397545c6e2df5bf" + testnetUnchainedOnG2 = "7672797f548f3f4748ac4bf3352fc6c6b6468c9ad40ad456a397545c6e2df5bf" testnetQuicknetT = "cc9c398442737cbd141526600919edd69f1d6f9b4adb67e4d912fbc64341a9a5" mainnetHost = "https://api.drand.sh/" mainnetFastnet = "dbd506d6ef76e5f386f41c651dcb808c5bcbd75471cc4eafa3f4df7ad4e4c493" @@ -31,7 +36,7 @@ const ( ) func TestEarlyDecryptionWithDuration(t *testing.T) { - for host, hashes := range map[string][]string{testnetHost: {testnetChainHashOnG2, testnetQuicknetT}, + for host, hashes := range map[string][]string{testnetHost: {testnetUnchainedOnG2, testnetQuicknetT}, mainnetHost: {mainnetFastnet, mainnetQuicknet}} { for _, hash := range hashes { network, err := http.NewNetwork(host, hash) @@ -41,7 +46,7 @@ func TestEarlyDecryptionWithDuration(t *testing.T) { // Encrypt // Read the plaintext data to be encrypted. - in, err := os.Open("test_artifacts/data.txt") + in, err := os.Open("testdata/data.txt") require.NoError(t, err) defer in.Close() @@ -69,14 +74,14 @@ func TestEarlyDecryptionWithDuration(t *testing.T) { } func TestEarlyDecryptionWithRound(t *testing.T) { - network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) + network, err := http.NewNetwork(testnetHost, testnetUnchainedOnG2) require.NoError(t, err) // ========================================================================= // Encrypt // Read the plaintext data to be encrypted. - in, err := os.Open("test_artifacts/data.txt") + in, err := os.Open("testdata/data.txt") require.NoError(t, err) defer in.Close() @@ -102,14 +107,14 @@ func TestEncryptionWithDuration(t *testing.T) { t.Skip("skipping live testing in short mode") } - network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) + network, err := http.NewNetwork(testnetHost, testnetUnchainedOnG2) require.NoError(t, err) // ========================================================================= // Encrypt // Read the plaintext data to be encrypted. - in, err := os.Open("test_artifacts/data.txt") + in, err := os.Open("testdata/data.txt") require.NoError(t, err) defer in.Close() @@ -139,19 +144,80 @@ func TestEncryptionWithDuration(t *testing.T) { } } +func TestDecryptVariousChainhashes(t *testing.T) { + dir := "./testdata" + prefix := "lorem-" + + files, err := os.ReadDir(dir) + require.NoError(t, err) + network, err := http.NewNetwork(testnetHost, testnetUnchainedOnG2) + require.NoError(t, err) + + for _, file := range files { + if strings.HasPrefix(file.Name(), prefix) { + t.Run("Decrypt-"+file.Name(), func(ts *testing.T) { + filePath := filepath.Join(dir, file.Name()) + cipherData, err := os.Open(filePath) + require.NoError(ts, err) + var plainData bytes.Buffer + err = tlock.New(network).Decrypt(&plainData, cipherData) + if errors.Is(err, tlock.ErrWrongChainhash) { + require.Contains(ts, file.Name(), "timevault-mainnet-2024") + return + } + + require.NoError(ts, err) + + if !bytes.Equal(plainData.Bytes(), loremBytes) { + ts.Fatalf("decrypted file is invalid; expected %d; got %d:\n %v \n %v", len(loremBytes), len(plainData.Bytes()), loremBytes, plainData.Bytes()) + } + }) + } + } +} + +func TestDecryptStrict(t *testing.T) { + dir := "./testdata" + prefix := "lorem-" + + files, err := os.ReadDir(dir) + require.NoError(t, err) + network, err := http.NewNetwork(testnetHost, testnetUnchainedOnG2) + require.NoError(t, err) + + for _, file := range files { + if strings.Contains(file.Name(), "testnet-unchained-3s-2024") { + continue + } + if strings.Contains(file.Name(), "timevault-testnet-2024") { + continue + } + if strings.HasPrefix(file.Name(), prefix) { + t.Run("DontDecryptStrict-"+file.Name(), func(ts *testing.T) { + filePath := filepath.Join(dir, file.Name()) + cipherData, err := os.Open(filePath) + require.NoError(ts, err) + var plainData bytes.Buffer + err = tlock.New(network).Strict().Decrypt(&plainData, cipherData) + require.ErrorIs(ts, err, tlock.ErrWrongChainhash) + }) + } + } +} + func TestEncryptionWithRound(t *testing.T) { if testing.Short() { t.Skip("skipping live testing in short mode") } - network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) + network, err := http.NewNetwork(testnetHost, testnetUnchainedOnG2) require.NoError(t, err) // ========================================================================= // Encrypt // Read the plaintext data to be encrypted. - in, err := os.Open("test_artifacts/data.txt") + in, err := os.Open("testdata/data.txt") require.NoError(t, err) defer in.Close() @@ -179,7 +245,7 @@ func TestEncryptionWithRound(t *testing.T) { } func TestTimeLockUnlock(t *testing.T) { - network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) + network, err := http.NewNetwork(testnetHost, testnetUnchainedOnG2) require.NoError(t, err) futureRound := network.RoundNumber(time.Now()) @@ -250,7 +316,7 @@ z6hgtLUPYvAimgekc+CeyJ8fb/0MVrpq/Ewnx1MpKig8nQ== }) t.Run("With invalid network", func(tt *testing.T) { - network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) + network, err := http.NewNetwork(testnetHost, testnetUnchainedOnG2) require.NoError(tt, err) testReader := strings.NewReader(cipher) @@ -308,7 +374,7 @@ ZEFUb0ZyZS9aSHpyWVkKKwNyX6cuEEENAjic1ew7k8G6vyxDrY5NWFbAhkKy0IrN jLK74v9Latit5qAD7Gu/zTIsQXMuCuUf7ma7 -----END AGE ENCRYPTED FILE-----` expected := "hello world and other things" - network, err := http.NewNetwork(testnetHost, testnetChainHashOnG2) + network, err := http.NewNetwork(testnetHost, testnetUnchainedOnG2) require.NoError(t, err) testReader := strings.NewReader(cipher)