Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VerifyProofRequest"/> class.
 /// </summary>
 /// <param name="publicKey">The public key.</param>
 /// <param name="proof">The proof.</param>
 /// <param name="messages">The messages.</param>
 /// <param name="nonce">The nonce.</param>
 /// <exception cref="ArgumentNullException">
 /// proof
 /// or
 /// messages
 /// or
 /// nonce
 /// or
 /// publicKey
 /// </exception>
 public VerifyProofRequest(BbsKey publicKey, byte[] proof, string[] messages, byte[] nonce)
 {
     Proof    = proof ?? throw new ArgumentNullException(nameof(proof));
     Messages = messages ?? throw new ArgumentNullException(nameof(messages));
     Nonce    = nonce ?? throw new ArgumentNullException(nameof(nonce));
     Key      = publicKey ?? throw new ArgumentNullException(nameof(publicKey));
 }
 public BlindSignRequest(BlsKeyPair secretKey, BbsKey publicKey, byte[] commitment, IndexedMessage[] messages)
 {
     KeyPair    = secretKey ?? throw new ArgumentNullException(nameof(secretKey));
     Key        = publicKey ?? throw new ArgumentNullException(nameof(publicKey));
     Commitment = commitment ?? throw new ArgumentNullException(nameof(commitment));
     Messages   = messages ?? throw new ArgumentNullException(nameof(messages));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VerifyBlindedCommitmentRequest"/> class.
 /// </summary>
 /// <param name="publicKey">The public key.</param>
 /// <param name="proof">The proof.</param>
 /// <param name="blindedIndices">The blinded indices.</param>
 /// <param name="nonce">The nonce.</param>
 /// <exception cref="ArgumentNullException">
 /// publicKey
 /// or
 /// proof
 /// or
 /// blindedIndices
 /// or
 /// nonce
 /// </exception>
 public VerifyBlindedCommitmentRequest(BbsKey publicKey, byte[] proof, uint[] blindedIndices, byte[] nonce)
 {
     Key            = publicKey ?? throw new ArgumentNullException(nameof(publicKey));
     Proof          = proof ?? throw new ArgumentNullException(nameof(proof));
     BlindedIndices = blindedIndices ?? throw new ArgumentNullException(nameof(blindedIndices));
     Nonce          = nonce ?? throw new ArgumentNullException(nameof(nonce));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateProofRequest"/> class.
        /// </summary>
        /// <param name="publicKey">Public key of the original signer of the signature</param>
        /// <param name="messages">The messages that were originally signed</param>
        /// <param name="signature">BBS signature to generate the BBS proof from</param>
        /// <param name="blindingFactor">The blinding factor used in blinded signature, if any messages are hidden using <see cref="ProofMessageType.HiddenExternalBlinding"/></param>
        /// <param name="nonce">A nonce for the resulting proof</param>
        /// <exception cref="System.ArgumentNullException">
        /// publicKey
        /// or
        /// messages
        /// or
        /// signature
        /// or
        /// nonce
        /// or
        /// Blinding factor must be provided
        /// </exception>
        public CreateProofRequest(BbsKey publicKey, ProofMessage[] messages, byte[] signature, byte[]?blindingFactor, byte[] nonce)
        {
            Key            = publicKey ?? throw new ArgumentNullException(nameof(publicKey));
            Messages       = messages ?? throw new ArgumentNullException(nameof(messages));
            Signature      = signature ?? throw new ArgumentNullException(nameof(signature));
            BlindingFactor = blindingFactor;
            Nonce          = nonce ?? throw new ArgumentNullException(nameof(nonce));

            if (messages.Any(x => x.ProofType == ProofMessageType.HiddenExternalBlinding) && blindingFactor == null)
            {
                throw new ArgumentNullException("Blinding factor must be provided");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateBlindedCommitmentRequest"/> class.
 /// </summary>
 /// <param name="publicKey">The public key.</param>
 /// <param name="messages">The messages.</param>
 /// <param name="nonce">The nonce.</param>
 /// <exception cref="ArgumentNullException">
 /// publicKey
 /// or
 /// messages
 /// or
 /// nonce
 /// </exception>
 public CreateBlindedCommitmentRequest(BbsKey publicKey, IndexedMessage[] messages, byte[] nonce)
 {
     Key      = publicKey ?? throw new ArgumentNullException(nameof(publicKey));
     Messages = messages ?? throw new ArgumentNullException(nameof(messages));
     Nonce    = nonce ?? throw new ArgumentNullException(nameof(nonce));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Create a <see cref="ByteBuffer"/> from a <see cref="BbsKey"/>
 /// </summary>
 /// <param name="buffer"></param>
 /// <returns></returns>
 internal ByteBuffer ToBuffer(BbsKey keyPair) => ToBuffer(keyPair.PublicKey.ToArray());