private void SetUpAllHonest(int n, int f) { _deliveryService = new DeliveryService(); _broadcasts = new IConsensusProtocol[n]; _broadcasters = new IConsensusBroadcaster[n]; _resultInterceptors = new ProtocolInvoker <BinaryAgreementId, bool> [n]; _privateKeys = new IPrivateConsensusKeySet[n]; var keygen = new TrustedKeyGen(n, f); var shares = keygen.GetPrivateShares().ToArray(); var pubKeys = new PublicKeySet(shares.Select(share => share.GetPublicKeyShare()), f); _publicKeys = new PublicConsensusKeySet(n, f, null !, pubKeys, Enumerable.Empty <ECDSAPublicKey>()); for (var i = 0; i < n; ++i) { _resultInterceptors[i] = new ProtocolInvoker <BinaryAgreementId, bool>(); _privateKeys[i] = new PrivateConsensusKeySet(null !, null !, shares[i]); _broadcasters[i] = new BroadcastSimulator(i, _publicKeys, _privateKeys[i], _deliveryService, true); } for (uint i = 0; i < n; ++i) { _broadcasts[i] = new BinaryAgreement(new BinaryAgreementId(0, 0), _publicKeys, _broadcasters[i]); _broadcasters[i].RegisterProtocols(new[] { _broadcasts[i], _resultInterceptors[i] }); } }
private void SetUp(int n, int f) { _deliveryService = new DeliveryService(); _broadcasts = new IConsensusProtocol[n]; _broadcasters = new IConsensusBroadcaster[n]; _resultInterceptors = new ProtocolInvoker <ReliableBroadcastId, EncryptedShare> [n]; _wallets = new IPrivateConsensusKeySet[n]; _publicKeys = new PublicConsensusKeySet( n, f, null !, null !, Enumerable.Range(0, n) .Select(i => new ECDSAPublicKey { Buffer = ByteString.CopyFrom(i.ToBytes().ToArray()) }) ); for (var i = 0; i < n; ++i) { _wallets[i] = TestUtils.EmptyWallet(n, f); _broadcasters[i] = new BroadcastSimulator(i, _publicKeys, _wallets[i], _deliveryService, false); _resultInterceptors[i] = new ProtocolInvoker <ReliableBroadcastId, EncryptedShare>(); } var bytes = Enumerable.Range(0, 32) .Select(x => (byte)(x * x * 0)) .ToArray(); _testShare = new EncryptedShare(G1.Generator, bytes, G2.Generator, Sender); }
private void SetUpAllHonest(int n, int f) { _deliveryService = new DeliveryService(); _acs = new IConsensusProtocol[n]; _broadcasters = new BroadcastSimulator[n]; _resultInterceptors = new ProtocolInvoker <CommonSubsetId, ISet <EncryptedShare> > [n]; _privateKeys = new IPrivateConsensusKeySet[n]; var keygen = new TrustedKeyGen(n, f); var shares = keygen.GetPrivateShares().ToArray(); var pubKeys = new PublicKeySet(shares.Select(share => share.GetPublicKeyShare()), f); _publicKeys = new PublicConsensusKeySet( n, f, null !, pubKeys, Enumerable.Range(0, n) .Select(i => new ECDSAPublicKey { Buffer = ByteString.CopyFrom(i.ToBytes().ToArray()) }) ); for (var i = 0; i < n; ++i) { _resultInterceptors[i] = new ProtocolInvoker <CommonSubsetId, ISet <EncryptedShare> >(); _privateKeys[i] = new PrivateConsensusKeySet(null !, null !, shares[i]); _broadcasters[i] = new BroadcastSimulator(i, _publicKeys, _privateKeys[i], _deliveryService, false); } for (uint i = 0; i < n; ++i) { _acs[i] = new CommonSubset(new CommonSubsetId(0), _publicKeys, _broadcasters[i]); _broadcasters[i].RegisterProtocols(new[] { _acs[i], _resultInterceptors[i] }); } }
public void SetUp(int n, int f) { _deliveryService = new DeliveryService(); _broadcasts = new IConsensusProtocol[n]; _broadcasters = new IConsensusBroadcaster[n]; _resultInterceptors = new ProtocolInvoker <HoneyBadgerId, ISet <IRawShare> > [n]; var keygen = new TrustedKeyGen(n, f); var shares = keygen.GetPrivateShares().ToArray(); var pubKeys = new PublicKeySet(shares.Select(share => share.GetPublicKeyShare()), f); var tpkeKeygen = new Crypto.TPKE.TrustedKeyGen(n, f); var ecdsaKeys = Enumerable.Range(0, n) .Select(i => Crypto.GenerateRandomBytes(32)) .Select(x => x.ToPrivateKey()) .Select(k => new EcdsaKeyPair(k)) .ToArray(); _publicKeys = new PublicConsensusKeySet(n, f, tpkeKeygen.GetPubKey(), pubKeys, ecdsaKeys.Select(k => k.PublicKey)); _privateKeys = new IPrivateConsensusKeySet[n]; for (var i = 0; i < n; ++i) { _resultInterceptors[i] = new ProtocolInvoker <HoneyBadgerId, ISet <IRawShare> >(); _privateKeys[i] = new PrivateConsensusKeySet(ecdsaKeys[i], tpkeKeygen.GetPrivKey(i), shares[i]); _broadcasters[i] = new BroadcastSimulator(i, _publicKeys, _privateKeys[i], _deliveryService, true); } }
public BroadcastSimulator( int sender, IPublicConsensusKeySet wallet, IPrivateConsensusKeySet privateKeys, DeliveryService deliveryService, bool mixMessages ) { _sender = sender; _deliveryService = deliveryService; _deliveryService.AddPlayer(GetMyId(), this); _wallet = wallet; _privateKeys = privateKeys; _silenced = new HashSet <int>(); }
private void SetUp(int n, int f) { _deliveryService = new DeliveryService(); _broadcasts = new IConsensusProtocol[n]; _broadcasters = new IConsensusBroadcaster[n]; _resultInterceptors = new ProtocolInvoker <BinaryBroadcastId, BoolSet> [n]; _privateKeys = new IPrivateConsensusKeySet[n]; _publicKeys = new PublicConsensusKeySet(n, f, null !, null !, Enumerable.Empty <ECDSAPublicKey>()); for (var i = 0; i < n; ++i) { _resultInterceptors[i] = new ProtocolInvoker <BinaryBroadcastId, BoolSet>(); _privateKeys[i] = TestUtils.EmptyWallet(n, f); _broadcasters[i] = new BroadcastSimulator(i, _publicKeys, _privateKeys[i], _deliveryService, false); } }
public void SetUp(int n, int f) { var keygen = new TrustedKeyGen(n, f); var shares = keygen.GetPrivateShares().ToArray(); var pubKeys = new PublicKeySet(shares.Select(share => share.GetPublicKeyShare()), f); _deliveryService = new DeliveryService(); _coins = new IConsensusProtocol[n]; _broadcasters = new IConsensusBroadcaster[n]; _resultInterceptors = new ProtocolInvoker <CoinId, CoinResult> [n]; _wallets = new IPrivateConsensusKeySet[n]; _publicKeys = new PublicConsensusKeySet(n, f, null !, pubKeys, Enumerable.Empty <ECDSAPublicKey>()); for (var i = 0; i < n; ++i) { _resultInterceptors[i] = new ProtocolInvoker <CoinId, CoinResult>(); _wallets[i] = new PrivateConsensusKeySet(null !, null !, shares[i]); _broadcasters[i] = new BroadcastSimulator(i, _publicKeys, _wallets[i], _deliveryService, false); _coins[i] = new CommonCoin( new CoinId(0, 0, 0), _publicKeys, shares[i], _broadcasters[i] ); _broadcasters[i].RegisterProtocols(new[] { _coins[i], _resultInterceptors[i] }); } }