6 * crypto/shachain - compactly-representable chain of 256-bit numbers.
8 * This code produces a practically infinite (2^64) chain of 256-bit numbers
9 * from a single number, such that you can't derive element N from any element
10 * less than N, but can efficiently derive element N from a limited number
14 * Author: Rusty Russell <rusty@rustcorp.com.au>
18 * #include <ccan/crypto/shachain/shachain.h>
19 * #include <ccan/err/err.h>
24 * int main(int argc, char *argv[])
26 * size_t i, j, limit = 10;
30 * errx(1, "Usage: %s <passphrase> [<num-to-generate>]", argv[0]);
31 * sha256(&seed, argv[1], strlen(argv[1]));
33 * limit = atol(argv[2]);
35 * for (i = 0; i < limit; i++) {
37 * shachain_from_seed(&seed, i, &v);
39 * for (j = 0; j < sizeof(v.u.u8); j++)
40 * printf("%02x", v.u.u8[j]);
46 int main(int argc, char *argv[])
48 /* Expect exactly one argument */
52 if (strcmp(argv[1], "depends") == 0) {
53 printf("ccan/ilog\n");
54 printf("ccan/crypto/sha256\n");