pubkey: pubkey_eq helper.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2015-09-30 10:54:54 +09:30
parent e7856e6e69
commit 242fa1b2dd
14 changed files with 109 additions and 75 deletions

View File

@@ -79,8 +79,7 @@ int main(int argc, char *argv[])
/* Get pubkeys */
if (!proto_to_pubkey(o1->commit_key, &pubkey2))
errx(1, "Invalid o1 commit pubkey");
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
if (!pubkey_eq(&pubkey1, &pubkey2))
errx(1, "o1 pubkey != this privkey");
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
errx(1, "Invalid o2 commit pubkey");

View File

@@ -77,8 +77,7 @@ int main(int argc, char *argv[])
/* Get pubkeys */
if (!proto_to_pubkey(o1->final_key, &pubkey2))
errx(1, "Invalid o1 final pubkey");
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
if (!pubkey_eq(&pubkey1, &pubkey2))
errx(1, "o1 pubkey != this privkey");
if (!proto_to_pubkey(o2->final_key, &pubkey2))
errx(1, "Invalid o2 final pubkey");

View File

@@ -60,8 +60,7 @@ int main(int argc, char *argv[])
/* Get pubkeys */
if (!proto_to_pubkey(o1->commit_key, &pubkey2))
errx(1, "Invalid o1 commit pubkey");
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
if (!pubkey_eq(&pubkey1, &pubkey2))
errx(1, "o1 pubkey != this privkey");
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
errx(1, "Invalid o2 commit pubkey");

View File

@@ -99,11 +99,9 @@ int main(int argc, char *argv[])
if (!proto_to_pubkey(o2->final_key, &pubkey2))
errx(1, "Invalid o2 final pubkey");
if (pubkey_len(&key) == pubkey_len(&pubkey1)
&& memcmp(key.key, pubkey1.key, pubkey_len(&pubkey1)) == 0) {
if (pubkey_eq(&key, &pubkey1)) {
own_commit_tx = true;
} else if (pubkey_len(&key) == pubkey_len(&pubkey2)
&& memcmp(key.key, pubkey2.key, pubkey_len(&pubkey2)) == 0) {
} else if (pubkey_eq(&key, &pubkey2)) {
own_commit_tx = false;
} else
errx(1, "Privkey doesn't match either key");

View File

@@ -77,8 +77,7 @@ int main(int argc, char *argv[])
/* Get pubkeys */
if (!proto_to_pubkey(o1->final_key, &pubkey2))
errx(1, "Invalid o1 final pubkey");
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
if (!pubkey_eq(&pubkey1, &pubkey2))
errx(1, "o1 pubkey != this privkey");
if (!proto_to_pubkey(o2->final_key, &pubkey2))
errx(1, "Invalid o2 final pubkey");

View File

@@ -74,8 +74,7 @@ int main(int argc, char *argv[])
/* Get pubkeys */
if (!proto_to_pubkey(o1->commit_key, &pubkey2))
errx(1, "Invalid o1 commit pubkey");
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
if (!pubkey_eq(&pubkey1, &pubkey2))
errx(1, "o1 pubkey != this privkey");
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
errx(1, "Invalid o2 commit pubkey");

View File

@@ -77,8 +77,7 @@ int main(int argc, char *argv[])
/* Get pubkeys */
if (!proto_to_pubkey(o1->commit_key, &pubkey2))
errx(1, "Invalid o1 commit pubkey");
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
if (!pubkey_eq(&pubkey1, &pubkey2))
errx(1, "o1 pubkey != this privkey");
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
errx(1, "Invalid o2 commit pubkey");