コード例 #1
0
        /// <summary>
        /// Verifies a BBS+ signature for a set of messages with a BBS public key
        /// </summary>
        /// <param name="verifyRequest">Request for the signature verification operation</param>
        /// <returns>
        /// A result indicating if the signature was verified
        /// </returns>
        public static bool Verify(VerifyRequest verifyRequest)
        {
            using var context = new UnmanagedMemoryContext();

            var handle = Native.bbs_verify_context_init(out var error);

            context.ThrowIfNeeded(error);

            Native.bbs_verify_context_set_public_key(handle, context.ToBuffer(verifyRequest.KeyPair.PublicKey), out error);
            context.ThrowIfNeeded(error);

            Native.bbs_verify_context_set_signature(handle, context.ToBuffer(verifyRequest.Signature), out error);
            context.ThrowIfNeeded(error);

            foreach (var message in verifyRequest.Messages)
            {
                Native.bbs_verify_context_add_message_string(handle, message, out error);
                context.ThrowIfNeeded(error);
            }

            var result = Native.bbs_verify_context_finish(handle, out error);

            context.ThrowIfNeeded(error);

            return(result == 1);
        }
コード例 #2
0
        /// <summary>
        /// Verifies a BBS+ signature for a set of messages with a BBS public key
        /// </summary>
        /// <param name="verifyRequest">Request for the signature verification operation</param>
        /// <returns>
        /// A result indicating if the signature was verified
        /// </returns>
        public bool Verify(VerifyRequest verifyRequest)
        {
            var bbsKeyPair = verifyRequest.KeyPair.GetBbsKey((uint)verifyRequest.Messages.Length);

            using var context = new UnmanagedMemory();

            var handle = NativeMethods.bbs_verify_context_init(out var error);

            context.ThrowOnError(error);

            NativeMethods.bbs_verify_context_set_public_key(handle, context.ToBuffer(bbsKeyPair.PublicKey), out error);
            context.ThrowOnError(error);

            NativeMethods.bbs_verify_context_set_signature(handle, context.ToBuffer(verifyRequest.Signature), out error);
            context.ThrowOnError(error);

            foreach (var message in verifyRequest.Messages)
            {
                NativeMethods.bbs_verify_context_add_message_string(handle, message, out error);
                context.ThrowOnError(error);
            }

            var result = NativeMethods.bbs_verify_context_finish(handle, out error);

            context.ThrowOnError(error);

            return(result == 0);
        }