public static Gen <HDKeyPathKVMap> HDKeyPaths(IEnumerable <PubKey> pks, int itemNum) => from MasterKeyFingerPrints in Gen.ListOf(itemNum, PrimitiveGenerator.UInt32()) from paths in Gen.ListOf(itemNum, CryptoGenerator.KeyPath()) let fingerPrintAndPath = MasterKeyFingerPrints.ToArray().Zip(paths.ToArray(), (m, p) => Tuple.Create(m, p)).ToList() select Utils.DictionaryFromList <PubKey, Tuple <uint, KeyPath> >(pks.ToList(), fingerPrintAndPath);
public static Gen <Dictionary <KeyId, Tuple <PubKey, ECDSASignature> > > PartialSigs() => from itemNum in Gen.Choose(0, 15) from sigs in CryptoGenerator.ECDSAs(itemNum) from pks in CryptoGenerator.PublicKeys(itemNum) let items = pks.ToList().Zip(sigs.ToList(), (pk, sig) => Tuple.Create(pk, sig)).ToList() select Utils.DictionaryFromList <KeyId, Tuple <PubKey, ECDSASignature> >(pks.Select(pk => pk.Hash).ToList(), items);
public static Gen <HDKeyPathKVMap> HDKeyPaths() => from itemNum in Gen.Choose(0, 15) from pks in Gen.ListOf(itemNum, CryptoGenerator.PublicKey()) from map in HDKeyPaths(pks, itemNum) select map;
private static Gen <PubKeyProvider> ConstPubKeyProviderGen() => from pk in CryptoGenerator.PublicKey() select PubKeyProvider.NewConst(pk);
private static Gen <PubKeyProvider> OriginPubKeyProviderGen(Network?n = null) => from keyOrigin in CryptoGenerator.RootedKeyPath() from inner in Gen.OneOf(ConstPubKeyProviderGen(), HDPubKeyProviderGen(n)) select PubKeyProvider.NewOrigin(keyOrigin, inner);
private static Gen <PubKeyProvider> HDPubKeyProviderGen(Network?n = null) => from extPk in n is null?CryptoGenerator.BitcoinExtPubKey() : CryptoGenerator.ExtPubKey().Select(e => new BitcoinExtPubKey(e, n)) from kp in CryptoGenerator.KeyPath() from t in Arb.Generate <PubKeyProvider.DeriveType>() select PubKeyProvider.NewHD(extPk, kp, t);
public static Gen <OutPoint> OutPoint() => from txid in CryptoGenerator.Hash256() from vout in Gen.Choose(0, Int32.MaxValue) select new OutPoint(txid, vout);