Ejemplo n.º 1
0
        /// <summary>
        /// Verifies a blinded commitment of messages
        /// </summary>
        /// <param name="request">Request for the commitment verification</param>
        /// <returns></returns>
        public static SignatureProofStatus VerifyBlindedCommitment(VerifyBlindedCommitmentRequest request)
        {
            using var context = new UnmanagedMemoryContext();

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

            context.ThrowIfNeeded(error);

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

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

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

            foreach (var index in request.BlindedIndices)
            {
                Native.bbs_verify_blind_commitment_context_add_blinded(handle, index, out error);
                context.ThrowIfNeeded(error);
            }

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

            context.ThrowIfNeeded(error);

            return((SignatureProofStatus)result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Verifies a blinded commitment of messages
        /// </summary>
        /// <param name="request">Request for the commitment verification</param>
        /// <returns></returns>
        public bool VerifyBlindedCommitment(VerifyBlindedCommitmentRequest request)
        {
            using var context = new UnmanagedMemory();

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

            context.ThrowOnError(error);

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

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

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

            foreach (var index in request.BlindedIndices)
            {
                NativeMethods.bbs_verify_blind_commitment_context_add_blinded(handle, index, out error);
                context.ThrowOnError(error);
            }

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

            context.ThrowOnError(error);

            return(result == 0);
        }