Also inline them into the header and simplify them.
Someone added functions for is_rct_whatever but used them almost
nowhere. This uses them (which would have saved a bunch of changes and
bugs in adding CLSAG in the first place).
-Werror is really a developer option to try to make code warning-clean,
but it shouldn't be forced on in the top-level Makefile that users are
directed to.
bl.* weren't being registered for non-service nodes. This fixes it by
moving endpoint setup from quorumnet_new (SN-only) to a new
quorumnet_init that does endpoint setup (for both SNs and non-SNs).
(This is a backport of the changes applied on the pulse branch to get
these fixes into `dev` for testing).
Passing the libsodium-derived private key into Monero was fine *except*
when you try to generate a pubkey from it via secret_key_to_public_key:
Monero for some reason has an extra check during pubkey generation that
requires the privkey is less than the basepoint. (This check is
pointless because a value above the basepoint is perfectly acceptable:
all operations are always mod basepoint).
This is easy to work around by explicitly doing a mod L on the private
key value before setting it in the Monero privkey. (This results in
exactly the same pubkey, and an exactly equivalent privkey).
This allows inspecting, generating, and restoring both Ed25519 and
legacy (naming in line with PR #1240 now avoiding the non-Ed25519 keys
by default) secret key files as needed by lokid:
$ ./loki-sn-keys generate key_ed25519
Generated SN Ed25519 secret key in key_ed25519
Public key: 8f94f6bbc1d5876484309fc7fd41396c6bd66c4631a34f04895887547cb374dd
X25519 pubkey: f3e42d1aff8db8232433ec86e3f56cdda44d4c510144f9b6786520175b08c97f
Lokinet address: t6kxpq6b4sdsjbbou9d94oj3pti7c5ngggtw6brjmndie9fuquqo.snode
$ ./loki-sn-keys legacy key
Generated SN legacy private key in key
Public key: f3a513ddfbe946c79c62c27cca2260b80606a2da1b4f75ba16c793a5750a8510
$ ./loki-sn-keys show key
key (legacy SN keypair)
==========
Private key: c8c17cc296c3e8bb603098b5d2535ad86662cdb24cd4c785c0485d0a490a2356
Public key: f3a513ddfbe946c79c62c27cca2260b80606a2da1b4f75ba16c793a5750a8510
$ ./loki-sn-keys show key_ed25519
key_ed25519 (Ed25519 SN keypair)
==========
Secret key: 3f078900bac5f3e97d5fe451a6e332826d29aae2e13fec895c1b527af88093c3
Public key: 8f94f6bbc1d5876484309fc7fd41396c6bd66c4631a34f04895887547cb374dd
X25519 pubkey: f3e42d1aff8db8232433ec86e3f56cdda44d4c510144f9b6786520175b08c97f
Lokinet address: t6kxpq6b4sdsjbbou9d94oj3pti7c5ngggtw6brjmndie9fuquqo.snode
$ ./loki-sn-keys restore key_ed25519-2
Enter the Ed25519 secret key:
3f078900bac5f3e97d5fe451a6e332826d29aae2e13fec895c1b527af88093c3
Public key: 8f94f6bbc1d5876484309fc7fd41396c6bd66c4631a34f04895887547cb374dd
X25519 pubkey: f3e42d1aff8db8232433ec86e3f56cdda44d4c510144f9b6786520175b08c97f
Lokinet address: t6kxpq6b4sdsjbbou9d94oj3pti7c5ngggtw6brjmndie9fuquqo.snode
Is this correct? Press Enter to continue, Ctrl-C to cancel.
Saved secret key to key_ed25519-2
$ ./loki-sn-keys restore-legacy key-2
Enter the legacy SN private key:
c8c17cc296c3e8bb603098b5d2535ad86662cdb24cd4c785c0485d0a490a2356
Public key: f3a513ddfbe946c79c62c27cca2260b80606a2da1b4f75ba16c793a5750a8510
Is this correct? Press Enter to continue, Ctrl-C to cancel.
Saved secret key to key-2
We currently generate (for service nodes) both a /key and /key_ed25519
file: the former is a SN's primary monero privkey (i.e. the private key
point of an Ed25519 key, but with no seed so that it can't do full
Ed25519 signatures), the latter is a sodium standard seed+pubkey
concatenated file.
This commit makes lokid stop generate a new /key file: instead, if it
doesn't already exist, we calculate the private key point from the
ed25519 key and set that as the monero-style private key. (The pubkeys
will be the same).
When a /key file exists, we continue to use it for the primary SN
keypair so that existing SN keys won't be affected.