diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f758a58 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +fuzz/hfuzz_target +fuzz/hfuzz_workspace +fuzz/target +target diff --git a/README.md b/README.md index c16aae1..fcaddbe 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,29 @@ The anti-replay oracle used under the [Revault architecture](https://github.com/ ## Usage `cosignerd` must be used along with `revaultd`. Check `revaultd's` [tutorial](https://github.com/revault/revaultd/tree/master/doc/USAGE.md) to get started! +You can build it like any other Rust project, using Cargo: +``` +git clone https://github.com/revault/cosignerd +cd cosignerd && cargo build +``` + +You'll need a configuration file to start it. You can find an example at +[`contrib/config.toml`](contrib/config.toml): +``` +cargo run -- --conf ./contrib/config.toml +``` + +For testing purpose and/or running `cosignerd` on a non-UNIX system you can use Docker: +``` +# From the root of the repository +docker build -t cosignerd -f contrib/cosignerd.Dockerfile . +docker run --rm --name cosignerd cosignerd +``` +The configuration is here passed through environment variables: +``` +docker run -it --rm --name cosignerd -e NOISE_SECRET="\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02" -e BITCOIN_SECRET="\x43\xff\x32\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\81\x01" -e MANAGERS_NOISE_KEYS="e798cf79e7245f06f62cc76609d51c76d42f3da4fab831f543f3254e5c6d7dc7 a19052df1337936e549a6b830ff4cc0e9028eaf6e79779de76d200e3b201953b cebbe8b9edadab14f23dbe1f4f0d55c7a3e9de13ab9adbe4aefacdc26f7c7dd1" -e LOG_LEVEL="debug" cosignerd +``` + ## Licence BSD 3-clauses, see [LICENSE](LICENSE). diff --git a/contrib/cosignerd.Dockerfile b/contrib/cosignerd.Dockerfile new file mode 100644 index 0000000..c0e249e --- /dev/null +++ b/contrib/cosignerd.Dockerfile @@ -0,0 +1,29 @@ +FROM rust:alpine + +# Space separated list of managers' noise keys. Must be set at startup, that's a dummy key. +ENV MANAGERS_NOISE_KEYS="b28cf2091bbbecf347d29420f884a936713e7b2e86fe4f6653d7e12356d26114" +# Bitcoin and Noise private keys +ENV BITCOIN_SECRET="\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x42" +ENV NOISE_SECRET="\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x42" +# Other config options +ENV LOG_LEVEL="trace" + + +COPY . /srv/cosignerd/src +RUN apk add g++ make && \ + cd /srv/cosignerd/src && \ + RUSTFLAGS="-C target-feature=-crt-static" cargo build + +EXPOSE 8383/tcp + +CMD echo "daemon = false" >> /srv/cosignerd/config.toml && \ + echo "data_dir = '/srv/cosignerd/datadir'" >> /srv/cosignerd/config.toml && \ + echo "log_level = '$LOG_LEVEL'" >> /srv/cosignerd/config.toml && \ + for key in $MANAGERS_NOISE_KEYS; do \ + echo "[[managers]]" >> /srv/cosignerd/config.toml && \ + echo "noise_key = \"$key\"" >> /srv/cosignerd/config.toml \ + ; done && \ + mkdir /srv/cosignerd/datadir && \ + printf $BITCOIN_SECRET > /srv/cosignerd/datadir/bitcoin_secret && \ + printf $NOISE_SECRET > /srv/cosignerd/datadir/noise_secret && \ + /srv/cosignerd/src/target/debug/cosignerd --conf /srv/cosignerd/config.toml