Haven 3.0 support

This commit is contained in:
MoneroOcean
2022-12-27 05:41:02 +00:00
parent eb4d1a5225
commit b627d4d36e
4 changed files with 47 additions and 14 deletions

View File

@@ -257,6 +257,7 @@ namespace rct {
RCTTypeCLSAG = 5,
RCTTypeCLSAGN = 6,
RCTTypeHaven2 = 7, // Add public mask sum terms, remove extraneous fields (txnFee_usd,txnFee_xasset,txnOffshoreFee_usd,txnOffshoreFee_xasset)
RCTTypeHaven3 = 8, // Add public mask sum term for collateral
};
enum RangeProofType { RangeProofBorromean, RangeProofBulletproof, RangeProofMultiOutputBulletproof, RangeProofPaddedBulletproof };
struct RCTConfig {
@@ -279,7 +280,7 @@ namespace rct {
xmr_amount txnOffshoreFee = 0;
xmr_amount txnOffshoreFee_usd = 0;
xmr_amount txnOffshoreFee_xasset = 0;
keyV maskSums; // contains 2 elements. 1. is the sum of masks of inputs. 2. is the sum of masks of changes.
keyV maskSums; // contains 2 or 3 elements. 1. is the sum of masks of inputs. 2. is the sum of masks of change outputs. 3. mask of the col output.
template<bool W, template <bool> class Archive>
bool serialize_rctsig_base(Archive<W> &ar, size_t inputs, size_t outputs)
@@ -287,10 +288,10 @@ namespace rct {
FIELD(type)
if (type == RCTTypeNull)
return ar.stream().good();
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeCLSAGN && type != RCTTypeHaven2)
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeCLSAGN && type != RCTTypeHaven2 && type != RCTTypeHaven3)
return false;
VARINT_FIELD(txnFee)
if (type == RCTTypeHaven2) {
if (type == RCTTypeHaven2 || type == RCTTypeHaven3) {
// serialize offshore fee
VARINT_FIELD(txnOffshoreFee)
} else if (type == RCTTypeCLSAG || type == RCTTypeCLSAGN) {
@@ -338,7 +339,7 @@ namespace rct {
return false;
for (size_t i = 0; i < outputs; ++i)
{
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2)
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3)
{
ar.begin_object();
if (!typename Archive<W>::is_saving())
@@ -369,7 +370,22 @@ namespace rct {
}
ar.end_array();
if (type == RCTTypeHaven2) {
// if txnOffshoreFee is not 0, it is a conversion tx
if (type == RCTTypeHaven3 && txnOffshoreFee) {
ar.tag("maskSums");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(3, maskSums);
if (maskSums.size() != 3)
return false;
FIELDS(maskSums[0])
ar.delimit_array();
FIELDS(maskSums[1])
ar.delimit_array();
FIELDS(maskSums[2])
ar.end_array();
} else if (type == RCTTypeHaven2) {
ar.tag("maskSums");
ar.begin_array();
@@ -430,12 +446,12 @@ namespace rct {
{
if (type == RCTTypeNull)
return ar.stream().good();
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeCLSAGN && type != RCTTypeHaven2)
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeCLSAGN && type != RCTTypeHaven2 && type != RCTTypeHaven3)
return false;
if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2)
if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3)
{
uint32_t nbp = bulletproofs.size();
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2)
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3)
VARINT_FIELD(nbp)
else
FIELD(nbp)
@@ -470,7 +486,7 @@ namespace rct {
ar.end_array();
}
if ((type == RCTTypeCLSAG) || (type == RCTTypeCLSAGN) || (type == RCTTypeHaven2))
if ((type == RCTTypeCLSAG) || (type == RCTTypeCLSAGN) || (type == RCTTypeHaven2) || (type == RCTTypeHaven3))
{
ar.tag("CLSAGs");
ar.begin_array();
@@ -561,7 +577,7 @@ namespace rct {
}
ar.end_array();
}
if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2)
if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3)
{
ar.tag("pseudoOuts");
ar.begin_array();
@@ -585,12 +601,12 @@ namespace rct {
keyV& get_pseudo_outs()
{
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 ? p.pseudoOuts : pseudoOuts;
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3 ? p.pseudoOuts : pseudoOuts;
}
keyV const& get_pseudo_outs() const
{
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 ? p.pseudoOuts : pseudoOuts;
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3 ? p.pseudoOuts : pseudoOuts;
}
};