Ejemplo n.º 1
0
        public static ProofInfo range_proof_info(this Secp256K1 self, RangeProof proof)
        {
            var   exp      = 0;
            var   mantissa = 0;
            ulong min      = 0;
            ulong max      = 0;

            var extraCommit = new byte [33];

            var success = Proxy.secp256k1_rangeproof_info(
                self.Ctx,
                ref exp,
                ref mantissa,
                ref min,
                ref max,
                proof.Proof,
                proof.Plen,
                extraCommit,
                0,
                Constants.Constants.GeneratorH
                ) == 1;

            return(new
                   ProofInfo
            {
                Success = success,
                Value = 0,
                Message = ProofMessage.Empty(),
                Mlen = 0,
                Min = min,
                Max = max,
                Exp = exp,
                Mantissa = mantissa
            });
        }
Ejemplo n.º 2
0
        public static ProofInfo rewind_range_proof(this Secp256K1 self, Commitment commit, RangeProof proof,
                                                   SecretKey nonce)
        {
            ulong value = 0;
            var   blind = new byte[32];

            var message = new byte[Constants.Constants.ProofMsgSize];
            var mlen    = (ulong)Constants.Constants.ProofMsgSize;

            ulong min = 0;
            ulong max = 0;

            var extraCommit = new byte[33];


            var success = Proxy.secp256k1_rangeproof_rewind(
                self.Ctx,
                blind,
                ref value,
                message,
                ref mlen,
                nonce.Value,
                ref min,
                ref max,
                commit.Value,
                proof.Proof,
                proof.Plen,
                extraCommit,
                0,
                Constants.Constants.GeneratorH
                ) == 1;


            return(new ProofInfo
            {
                Success = success,
                Value = value,
                Message = ProofMessage.from_bytes(message),
                Mlen = (int)mlen,
                Min = min,
                Max = max,
                Exp = 0,
                Mantissa = 0
            });
        }
Ejemplo n.º 3
0
        public static ProofRange verify_range_proof(this Secp256K1 self, Commitment commit, RangeProof proof)
        {
            ulong min = 0;
            ulong max = 0;

            var extraCommit = ByteUtil.Get_bytes(0, 33);

            var success =
                Proxy.secp256k1_rangeproof_verify(
                    self.Ctx,
                    ref min,
                    ref max,
                    commit.Value,
                    proof.Proof,
                    proof.Plen,
                    extraCommit,
                    0,
                    Constants.Constants.GeneratorH
                    ) == 1;

            if (success)
            {
                return new ProofRange
                       {
                           Min = min,
                           Max = max
                       }
            }
            ;
            throw new Exception("InvalidRangeProof");
        }