Ejemplo n.º 1
0
 public static UpdateMemberRequest ToUpdateMemberRequest(
     ProtoMember member,
     IList <MemberOperation> operations,
     ISigner signer)
 {
     return(ToUpdateMemberRequest(member, operations, signer, new List <MemberOperationMetadata>()));
 }
Ejemplo n.º 2
0
        public static UpdateMemberRequest ToUpdateMemberRequest(
            ProtoMember member,
            IList <MemberOperation> operations,
            ISigner signer,
            IList <MemberOperationMetadata> metadata)
        {
            var update = new MemberUpdate
            {
                MemberId   = member.Id,
                PrevHash   = member.LastHash,
                Operations = { operations }
            };

            return(new UpdateMemberRequest
            {
                Update = update,
                UpdateSignature = new Signature
                {
                    MemberId = member.Id,
                    KeyId = signer.GetKeyId(),
                    Signature_ = signer.Sign(update)
                },
                Metadata = { metadata }
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates member by applying the specified operations.
        /// </summary>
        /// <param name="member">the member to update, which should be the member that the
        /// client is bond to</param>
        /// <param name="operations">the operations to apply</param>
        /// <param name="metadata">the updated member</param>
        /// <returns></returns>
        public Task <ProtoMember> UpdateMember(
            ProtoMember member,
            IList <MemberOperation> operations,
            IList <MemberOperationMetadata> metadata)
        {
            var signer  = cryptoEngine.CreateSigner(Level.Privileged);
            var request = Util.ToUpdateMemberRequest(member, operations, signer, metadata);

            return(gateway(authenticationContext()).UpdateMemberAsync(request)
                   .ToTask(response => response.Member));
        }
Ejemplo n.º 4
0
        public static void VerifySignature(
            ProtoMember member,
            IMessage payload,
            Signature signature)
        {
            Key key;

            try
            {
                key = member.Keys.Single(k => k.Id.Equals(signature.KeyId));
            }
            catch (InvalidOperationException)
            {
                throw new CryptoKeyNotFoundException(signature.KeyId);
            }

            var verifier = new Ed25519Veifier(key.PublicKey);

            verifier.Verify(payload, signature.Signature_);
        }