Пример #1
0
        public static BlsSignature GetAttestationSignature(IServiceProvider testServiceProvider, BeaconState state, AttestationData attestationData, byte[] privateKey)
        {
            var signatureDomains    = testServiceProvider.GetService <IOptions <SignatureDomains> >().Value;
            var beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>();

            var messageHash = attestationData.HashTreeRoot();
            var domain      = beaconStateAccessor.GetDomain(state, signatureDomains.BeaconAttester, attestationData.Target.Epoch);
            var signature   = TestSecurity.BlsSign(messageHash, privateKey, domain);

            return(signature);
        }
        public static BlsSignature GetAttestationSignature(IServiceProvider testServiceProvider, BeaconState state, AttestationData attestationData, byte[] privateKey)
        {
            SignatureDomains    signatureDomains    = testServiceProvider.GetService <IOptions <SignatureDomains> >().Value;
            BeaconChainUtility  beaconChainUtility  = testServiceProvider.GetService <BeaconChainUtility>();
            BeaconStateAccessor beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>();

            Root         attestationDataRoot = attestationData.HashTreeRoot();
            Domain       domain      = beaconStateAccessor.GetDomain(state, signatureDomains.BeaconAttester, attestationData.Target.Epoch);
            Root         signingRoot = beaconChainUtility.ComputeSigningRoot(attestationDataRoot, domain);
            BlsSignature signature   = TestSecurity.BlsSign(signingRoot, privateKey);

            return(signature);
        }
 public Root HashTreeRoot(AttestationData attestationData)
 {
     return(attestationData.HashTreeRoot());
 }