public static ForkVersion DecodeForkVersion(ReadOnlySpan <byte> span, ref int offset) { ForkVersion forkVersion = new ForkVersion(span.Slice(offset, ForkVersionLength)); offset += ForkVersionLength; return(forkVersion); }
/// <summary> /// Returns the domain for the 'domain_type' and 'fork_version' /// </summary> public Domain ComputeDomain(DomainType domainType, ForkVersion forkVersion = new ForkVersion()) { Span<byte> combined = stackalloc byte[Domain.Length]; domainType.AsSpan().CopyTo(combined); forkVersion.AsSpan().CopyTo(combined.Slice(DomainType.Length)); return new Domain(combined); }
public static ForkVersion DecodeForkVersion(Span <byte> span, ref int offset) { ForkVersion forkVersion = new ForkVersion(BinaryPrimitives.ReadUInt32LittleEndian(span.Slice(offset))); offset += ForkVersion.SszLength; return(forkVersion); }
/// <summary> /// Returns the domain for the 'domain_type' and 'fork_version' /// </summary> public Domain ComputeDomain(DomainType domainType, ForkVersion forkVersion = new ForkVersion()) { Span <byte> combined = new Span <byte>(new byte[Domain.Length]); BinaryPrimitives.WriteUInt32LittleEndian(combined, (uint)domainType); forkVersion.AsSpan().CopyTo(combined.Slice(sizeof(DomainType))); return(new Domain(combined)); }
/// <summary> /// Returns the domain for the 'domain_type' and 'fork_version' /// </summary> public Domain ComputeDomain(DomainType domainType, ForkVersion forkVersion = new ForkVersion()) { var combined = new Span <byte>(new byte[Domain.Length]); domainType.AsSpan().CopyTo(combined); forkVersion.AsSpan().CopyTo(combined.Slice(DomainType.Length)); return(new Domain(combined)); }
public PeeringStatus(ForkVersion headForkVersion, Root finalizedRoot, Epoch finalizedEpoch, Root headRoot, Slot headSlot) { HeadForkVersion = headForkVersion; FinalizedRoot = finalizedRoot; FinalizedEpoch = finalizedEpoch; HeadRoot = headRoot; HeadSlot = headSlot; }
private ApplicationManager() { ResourceManager rm = Resources.ResourceManager; CurrentForkVersion = new ForkVersion { Major = int.Parse(rm.GetString("VersionMajor")), Minor = int.Parse(rm.GetString("VersionMinor")), Patch = int.Parse(rm.GetString("VersionPatch")) }; }
public static Fork DecodeFork(Span <byte> span) { if (span.Length != Fork.SszLength) { ThrowSourceLength <Fork>(span.Length, Fork.SszLength); } int offset = 0; ForkVersion previous = DecodeForkVersion(span, ref offset); ForkVersion current = DecodeForkVersion(span, ref offset); Epoch epoch = DecodeEpoch(span, ref offset); return(new Fork(previous, current, epoch)); }
private ApplicationManager() { ResourceManager rm = Resources.ResourceManager; CurrentForkVersion = new ForkVersion { Major = int.Parse(rm.GetString("VersionMajor")), Minor = int.Parse(rm.GetString("VersionMinor")), Patch = int.Parse(rm.GetString("VersionPatch")), Beta = int.Parse(rm.GetString("VersionBeta")) }; DiscordRichPresenceUtils.SetupRichPresence(); }
public static PeeringStatus DecodePeeringStatus(ReadOnlySpan <byte> span) { if (span.Length != PeeringStatusLength) { ThrowSourceLength <PeeringStatus>(span.Length, PeeringStatusLength); } int offset = 0; ForkVersion headForkVersion = DecodeForkVersion(span, ref offset); Root finalizedRoot = DecodeRoot(span, ref offset); Epoch finalizedEpoch = DecodeEpoch(span, ref offset); Root headRoot = DecodeRoot(span, ref offset); Slot headSlot = DecodeSlot(span, ref offset); return(new PeeringStatus(headForkVersion, finalizedRoot, finalizedEpoch, headRoot, headSlot)); }
private BlsSignature GetEpochSignature(IServiceProvider testServiceProvider, byte[] privateKey, ForkVersion forkVersion, Slot slot) { SignatureDomains signatureDomains = testServiceProvider.GetService <IOptions <SignatureDomains> >().Value; BeaconChainUtility beaconChainUtility = testServiceProvider.GetService <BeaconChainUtility>(); var domain = beaconChainUtility.ComputeDomain(signatureDomains.Randao, forkVersion); var epoch = beaconChainUtility.ComputeEpochAtSlot(slot); var epochRoot = epoch.HashTreeRoot(); var epochSigningRoot = beaconChainUtility.ComputeSigningRoot(epochRoot, domain); BLSParameters parameters = new BLSParameters() { PrivateKey = privateKey }; BLS bls = BLS.Create(parameters); var destination = new Span <byte>(new byte[96]); bls.TrySignData(epochSigningRoot.AsSpan(), destination, out var bytesWritten); var signature = new BlsSignature(destination.ToArray()); return(signature); }
public Fork(ForkVersion previousVersion, ForkVersion currentVersion, Epoch epoch) { PreviousVersion = previousVersion; CurrentVersion = currentVersion; Epoch = epoch; }
public static SszElement ToSszBasicVector(this ForkVersion item) { return(new SszBasicVector(item.AsSpan())); }
private static void Encode(Span <byte> span, ForkVersion value, ref int offset) { // FIXME: ForkVersion can be created by marshalling a span onto it, with no guarantee the underlying architecture is little endian. value.AsSpan().CopyTo(span.Slice(offset, ForkVersionLength)); offset += ForkVersionLength; }
public static void Encode(Span <byte> span, ForkVersion value) { value.AsSpan().CopyTo(span); }
private static void Encode(Span <byte> span, ForkVersion value, ref int offset) { BinaryPrimitives.WriteUInt32LittleEndian(span.Slice(offset), value.Number); offset += ForkVersion.SszLength; }
public static void Encode(Span <byte> span, ForkVersion value) { Encode(span, value.Number); }