示例#1
0
        /// <summary>
        /// Verifies a proof
        /// </summary>
        /// <param name="publicKey">The public key.</param>
        /// <param name="proof">The proof.</param>
        /// <param name="revealedMessages">The indexed messages.</param>
        /// <param name="nonce">The nonce.</param>
        /// <returns></returns>
        public static SignatureProofStatus VerifyProof(VerifyProofRequest request)
        {
            using var context = new UnmanagedMemoryContext();

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

            context.ThrowIfNeeded(error);

            Native.bbs_verify_proof_context_set_public_key(handle, context.ToBuffer(request.PublicKey), out error);
            context.ThrowIfNeeded(error);

            Native.bbs_verify_proof_context_set_nonce_string(handle, request.Nonce, out error);
            context.ThrowIfNeeded(error);

            Native.bbs_verify_proof_context_set_proof(handle, context.ToBuffer(request.Proof), out error);
            context.ThrowIfNeeded(error);

            foreach (var item in request.Messages)
            {
                Native.bbs_verify_proof_context_add_message_string(handle, item.Message, out error);
                context.ThrowIfNeeded(error);

                Native.bbs_verify_proof_context_add_revealed_index(handle, item.Index, out error);
                context.ThrowIfNeeded(error);
            }

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

            context.ThrowIfNeeded(error);

            return((SignatureProofStatus)result);
        }
示例#2
0
        /// <summary>
        /// Verifies a proof
        /// </summary>
        /// <param name="request">Verify proof request parameters</param>
        /// <returns></returns>
        public bool VerifyProof(VerifyProofRequest request)
        {
            using var context = new UnmanagedMemory();

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

            context.ThrowOnError(error);

            NativeMethods.bbs_verify_proof_context_set_public_key(handle, context.ToBuffer(request.Key), out error);
            context.ThrowOnError(error);

            NativeMethods.bbs_verify_proof_context_set_nonce_bytes(handle, context.ToBuffer(request.Nonce), out error);
            context.ThrowOnError(error);

            NativeMethods.bbs_verify_proof_context_set_proof(handle, context.ToBuffer(request.Proof), out error);
            context.ThrowOnError(error);

            foreach (var item in request.Messages)
            {
                NativeMethods.bbs_verify_proof_context_add_message_string(handle, item, out error);
                context.ThrowOnError(error);
            }

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

            context.ThrowOnError(error);

            return(result == 0);
        }