Fix derived_secret, use correct size of secretstuff.derived secret

[ Updated tests to match -- RR]
This commit is contained in:
Ken Sedgwick 2022-08-09 21:09:57 -07:00 committed by neil saitug
parent eb006dcadd
commit 0878002fe6
3 changed files with 8 additions and 4 deletions

View File

@ -271,7 +271,7 @@ static u8 *handle_derive_secret(struct hsmd_client *c, const u8 *msg_in)
return hsmd_status_malformed_request(c, msg_in);
hkdf_sha256(&secret, sizeof(struct secret), NULL, 0,
&secretstuff.derived_secret, sizeof(&secretstuff.derived_secret),
&secretstuff.derived_secret, sizeof(secretstuff.derived_secret),
info, tal_bytelen(info));
return towire_hsmd_derive_secret_reply(NULL, &secret);

View File

@ -2268,7 +2268,7 @@ def test_makesecret(node_factory):
l1 = node_factory.get_node(options={"dev-force-privkey": "1212121212121212121212121212121212121212121212121212121212121212"})
secret = l1.rpc.makesecret("73636220736563726574")["secret"]
assert (secret == "04fe01631fcedc8d91f39ab43244e63afebaed68ee21d2f1c325fd1242726a18")
assert (secret == "a9a2e742405c28f059349132923a99337ae7f71168b7485496e3365f5bc664ed")
# Same if we do it by parameter name
assert l1.rpc.makesecret(hex="73636220736563726574")["secret"] == secret

View File

@ -2640,9 +2640,13 @@ def test_commando(node_factory, executor):
def test_commando_rune(node_factory):
l1, l2 = node_factory.line_graph(2, fundchannel=False)
l1, l2 = node_factory.get_nodes(2)
# Force l1's commando secret
l1.rpc.datastore(key=['commando', 'secret'], hex='1241faef85297127c2ac9bde95421b2c51e5218498ae4901dc670c974af4284b')
l1.restart()
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
# l1's commando secret is 1241faef85297127c2ac9bde95421b2c51e5218498ae4901dc670c974af4284b.
# I put that into a test node's commando.py to generate these runes (modified readonly to match ours):
# $ l1-cli commando-rune
# "rune": "zKc2W88jopslgUBl0UE77aEe5PNCLn5WwqSusU_Ov3A9MA=="