Example #1
0
        public static void Ize(out UInt256 root, BeaconState?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(5);

            merkleizer.Feed(container.GenesisTime);
            merkleizer.Feed(container.Slot);
            merkleizer.Feed(container.Fork);
            merkleizer.Feed(container.LatestBlockHeader);
            merkleizer.Feed(container.BlockRoots);
            merkleizer.Feed(container.StateRoots);
            merkleizer.Feed(container.HistoricalRoots, BeaconState.HistoricalRootsLimit);
            merkleizer.Feed(container.Eth1Data);
            merkleizer.Feed(container.Eth1DataVotes, (uint)Time.SlotsPerEth1VotingPeriod);
            merkleizer.Feed(container.Eth1DepositIndex);
            merkleizer.Feed(container.Validators, Validator.ValidatorRegistryLimit);
            merkleizer.Feed(container.Balances, Validator.ValidatorRegistryLimit);
            merkleizer.Feed(container.RandaoMixes);
            merkleizer.Feed(container.Slashings);
            merkleizer.Feed(container.PreviousEpochAttestations, BeaconBlock.MaxAttestations * Time.SlotsPerEpoch);
            merkleizer.Feed(container.CurrentEpochAttestations, BeaconBlock.MaxAttestations * Time.SlotsPerEpoch);
            merkleizer.Feed(container.JustificationBits);
            merkleizer.Feed(container.PreviousJustifiedCheckpoint);
            merkleizer.Feed(container.CurrentJustifiedCheckpoint);
            merkleizer.Feed(container.FinalizedCheckpoint);
            merkleizer.CalculateRoot(out root);
        }
Example #2
0
        public static void Ize(out UInt256 root, IList <DepositData> value)
        {
            Merkleizer merkleizer = new Merkleizer(0);

            merkleizer.Feed(value, Ssz.MaximumDepositContracts);
            merkleizer.CalculateRoot(out root);
        }
Example #3
0
        public static void IzeBitlist(out UInt256 root, BitArray value, ulong maximumBitlistLength)
        {
            Merkleizer merkleizer = new Merkleizer(0);

            merkleizer.FeedBitlist(value, maximumBitlistLength);
            merkleizer.CalculateRoot(out root);
        }
Example #4
0
        public static void IzeBitvector(out UInt256 root, BitArray value)
        {
            Merkleizer merkleizer = new Merkleizer(0);

            merkleizer.FeedBitvector(value);
            merkleizer.CalculateRoot(out root);
        }
Example #5
0
        public static void Ize(out UInt256 root, SignedBeaconBlockHeader container)
        {
            Merkleizer merkleizer = new Merkleizer(1);

            merkleizer.Feed(container.Message);
            merkleizer.Feed(container.Signature);
            merkleizer.CalculateRoot(out root);
        }
Example #6
0
        public static void Ize(out UInt256 root, VoluntaryExit container)
        {
            Merkleizer merkleizer = new Merkleizer(1);

            merkleizer.Feed(container.Epoch);
            merkleizer.Feed(container.ValidatorIndex);
            merkleizer.CalculateRoot(out root);
        }
Example #7
0
        public static void Ize(out UInt256 root, SignedVoluntaryExit container)
        {
            Merkleizer merkleizer = new Merkleizer(1);

            merkleizer.Feed(container.Message);
            merkleizer.Feed(container.Signature);
            merkleizer.CalculateRoot(out root);
        }
Example #8
0
        public static void Ize(out UInt256 root, HistoricalBatch container)
        {
            Merkleizer merkleizer = new Merkleizer(1);

            merkleizer.Feed(container.BlockRoots);
            merkleizer.Feed(container.StateRoots);
            merkleizer.CalculateRoot(out root);
        }
Example #9
0
        public static void Ize(out UInt256 root, Checkpoint container)
        {
            Merkleizer merkleizer = new Merkleizer(1);

            merkleizer.Feed(container.Epoch);
            merkleizer.Feed(container.Root);
            merkleizer.CalculateRoot(out root);
        }
Example #10
0
        public static void Ize(out UInt256 root, DepositMessage container)
        {
            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.Feed(container.PublicKey);
            merkleizer.Feed(container.WithdrawalCredentials);
            merkleizer.Feed(container.Amount);
            merkleizer.CalculateRoot(out root);
        }
Example #11
0
        public static void Ize(out UInt256 root, ProposerSlashing container)
        {
            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.Feed(container.ProposerIndex);
            merkleizer.Feed(container.SignedHeader1);
            merkleizer.Feed(container.SignedHeader2);
            merkleizer.CalculateRoot(out root);
        }
Example #12
0
        public static void Ize(out UInt256 root, Fork container)
        {
            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.Feed(container.PreviousVersion);
            merkleizer.Feed(container.CurrentVersion);
            merkleizer.Feed(container.Epoch);
            merkleizer.CalculateRoot(out root);
        }
Example #13
0
        public static void Ize(out UInt256 root, IndexedAttestation container)
        {
            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.Feed(container.AttestingIndices, Attestation.MaxValidatorsPerCommittee);
            merkleizer.Feed(container.Data);
            merkleizer.Feed(container.Signature);
            merkleizer.CalculateRoot(out root);
        }
Example #14
0
        public static void Ize(out UInt256 root, BeaconBlockHeader container)
        {
            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.Feed(container.Slot);
            merkleizer.Feed(container.ParentRoot);
            merkleizer.Feed(container.StateRoot);
            merkleizer.Feed(container.BodyRoot);
            merkleizer.CalculateRoot(out root);
        }
Example #15
0
        public static void Ize(out UInt256 root, BeaconBlock container)
        {
            Merkleizer merkleizer = new Merkleizer(3);

            merkleizer.Feed(container.Slot);
            merkleizer.Feed(container.ParentRoot);
            merkleizer.Feed(container.StateRoot);
            merkleizer.Feed(container.Body);
            merkleizer.Feed(container.Signature);
            merkleizer.CalculateRoot(out root);
        }
Example #16
0
        public static void Ize(out UInt256 root, AttestationData container)
        {
            Merkleizer merkleizer = new Merkleizer(3);

            merkleizer.Feed(container.Slot);
            merkleizer.Feed(container.CommitteeIndex);
            merkleizer.Feed(container.BeaconBlockRoot);
            merkleizer.Feed(container.Source);
            merkleizer.Feed(container.Target);
            merkleizer.CalculateRoot(out root);
        }
Example #17
0
        public static void Ize(out UInt256 root, BeaconBlockBody container)
        {
            Merkleizer merkleizer = new Merkleizer(3);

            merkleizer.Feed(container.RandaoReversal);
            merkleizer.Feed(container.Eth1Data);
            merkleizer.Feed(container.Graffiti);
            merkleizer.Feed(container.ProposerSlashings, BeaconBlock.MaxProposerSlashings);
            merkleizer.Feed(container.AttesterSlashings, BeaconBlock.MaxAttesterSlashings);
            merkleizer.Feed(container.Attestations, BeaconBlock.MaxAttestations);
            merkleizer.Feed(container.Deposits, BeaconBlock.MaxDeposits);
            merkleizer.Feed(container.VoluntaryExits, BeaconBlock.MaxVoluntaryExits);
            merkleizer.CalculateRoot(out root);
        }
Example #18
0
        public static void Ize(out UInt256 root, Checkpoint?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(1);

            merkleizer.Feed(container.Value.Epoch);
            merkleizer.Feed(container.Value.Root);
            merkleizer.CalculateRoot(out root);
        }
Example #19
0
        public static void Ize(out UInt256 root, HistoricalBatch?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(1);

            merkleizer.Feed(container.BlockRoots);
            merkleizer.Feed(container.StateRoots);
            merkleizer.CalculateRoot(out root);
        }
Example #20
0
        public static void Ize(out UInt256 root, Deposit?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(1);

            merkleizer.Feed(container.Proof);
            merkleizer.Feed(container.Data);
            merkleizer.CalculateRoot(out root);
        }
Example #21
0
        public static void Ize(out UInt256 root, AttesterSlashing?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(1);

            merkleizer.Feed(container.Attestation1);
            merkleizer.Feed(container.Attestation2);
            merkleizer.CalculateRoot(out root);
        }
Example #22
0
        public static void Ize(out UInt256 root, Eth1Data?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.Feed(container.DepositRoot);
            merkleizer.Feed(container.DepositCount);
            merkleizer.Feed(container.BlockHash);
            merkleizer.CalculateRoot(out root);
        }
Example #23
0
        public static void Ize(out UInt256 root, VoluntaryExit?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.Feed(container.Epoch);
            merkleizer.Feed(container.ValidatorIndex);
            merkleizer.Feed(container.Signature);
            merkleizer.CalculateRoot(out root);
        }
Example #24
0
        public static void Ize(out UInt256 root, Fork?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.Feed(container.Value.PreviousVersion);
            merkleizer.Feed(container.Value.CurrentVersion);
            merkleizer.Feed(container.Value.Epoch);
            merkleizer.CalculateRoot(out root);
        }
Example #25
0
        public static void Ize(out UInt256 root, ProposerSlashing?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.Feed(container.ProposerIndex);
            merkleizer.Feed(container.Header1);
            merkleizer.Feed(container.Header2);
            merkleizer.CalculateRoot(out root);
        }
Example #26
0
        public static void Ize(out UInt256 root, Attestation?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.FeedBits(container.AggregationBits, (Attestation.MaxValidatorsPerCommittee + 255) / 256);
            merkleizer.Feed(container.Data);
            merkleizer.Feed(container.Signature);
            merkleizer.CalculateRoot(out root);
        }
Example #27
0
        public static void Ize(out UInt256 root, IndexedAttestation?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.Feed(container.AttestingIndices.ToArray(), Ssz.MaxValidatorsPerCommittee);
            merkleizer.Feed(container.Data);
            merkleizer.Feed(container.Signature);
            merkleizer.CalculateRoot(out root);
        }
Example #28
0
        public static void Ize(out UInt256 root, DepositData?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.Feed(container.PublicKey);
            merkleizer.Feed(container.WithdrawalCredentials);
            merkleizer.Feed(container.Amount);
            merkleizer.Feed(container.Signature);
            merkleizer.CalculateRoot(out root);
        }
Example #29
0
        public static void Ize(out UInt256 root, PendingAttestation?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(2);

            merkleizer.FeedBits(container.AggregationBits, (Attestation.MaxValidatorsPerCommittee + 255) / 256);
            merkleizer.Feed(container.Data);
            merkleizer.Feed(container.InclusionDelay);
            merkleizer.Feed(container.ProposerIndex);
            merkleizer.CalculateRoot(out root);
        }
Example #30
0
        public static void Ize(out UInt256 root, AttestationData?container)
        {
            if (container is null)
            {
                root = RootOfNull;
                return;
            }

            Merkleizer merkleizer = new Merkleizer(3);

            merkleizer.Feed(container.Slot);
            merkleizer.Feed(container.CommitteeIndex);
            merkleizer.Feed(container.BeaconBlockRoot);
            merkleizer.Feed(container.Source);
            merkleizer.Feed(container.Target);
            merkleizer.CalculateRoot(out root);
        }