Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alex v committed Nov 24, 2024
1 parent 4c96680 commit c66949a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/blsct/arith/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ template <typename T>
void Elements<T>::ConfirmIndexInsideRange(const uint32_t& index) const
{
if (index >= m_vec.size()) {
assert(0);
auto s = strprintf("index %d is out of range [0..%d]", index, m_vec.size() - 1ul);
throw std::runtime_error(s);
}
Expand Down
8 changes: 8 additions & 0 deletions src/blsct/range_proof/bulletproofs_plus/range_proof.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ struct RangeProofWithSeed : public RangeProof<T> {
typename T::Scalar min_value;
};

template <typename T>
struct RangeProofUncompressed {
FORMATTER_METHODS(RangeProof<T>, obj)
{
READWRITE(Using<range_proof::ProofBaseUncompressed<T>>(obj), obj.A, obj.A_wip, obj.B, obj.r_prime, obj.s_prime, obj.delta_prime, obj.alpha_hat, obj.tau_x);
}
};

} // namespace bulletproofs_plus

#endif // NAVIO_BLSCT_RANGE_PROOF_BULLETPROOFS_PLUS_RANGE_PROOF_H
5 changes: 5 additions & 0 deletions src/blsct/range_proof/proof_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ struct ProofBase {
}
};

template <typename T>
struct ProofBaseUncompressed {
FORMATTER_METHODS(ProofBase<T>, obj) { READWRITE(obj.Vs, obj.Ls, obj.Rs); }
};

} // namespace range_proof

#endif // NAVIO_BLSCT_RANGE_PROOF_PROOF_BASE_H
2 changes: 1 addition & 1 deletion src/blsct/wallet/txfactory_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ UnsignedOutput CreateOutput(const blsct::DoublePublicKey& destKeys, const CAmoun
stakeRp.Vs.Clear();

DataStream ss{};
ss << stakeRp;
ss << Using<bulletproofs_plus::RangeProofUncompressed<T>>(stakeRp);

ret.out.scriptPubKey = CScript() << OP_STAKED_COMMITMENT << blsct::Common::DataStreamToVector(ss) << OP_DROP << OP_TRUE;
}
Expand Down
5 changes: 5 additions & 0 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,17 @@ class CTxOut
{
if (!HasBLSCTRangeProof())
return false;

if (scriptPubKey.size() <= 7) return false;

if (blsctData.rangeProof.Vs.Size() == 0)
return false;

if (!tokenId.IsNull())
return false;

if (!(*(scriptPubKey.begin()) == OP_STAKED_COMMITMENT && *(scriptPubKey.begin() + 1) == OP_PUSHDATA2 && *(scriptPubKey.end() - 1) == OP_TRUE)) return false;

try {
auto commitment = std::vector<unsigned char>(scriptPubKey.begin() + 4, scriptPubKey.end());

Expand Down

0 comments on commit c66949a

Please sign in to comment.