mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-13 06:29:25 +00:00
Updating existing TX size limit test for the new DKG parameters
This commit is contained in:
@@ -84,23 +84,25 @@ fn tx_size_limit() {
|
|||||||
use tributary::TRANSACTION_SIZE_LIMIT;
|
use tributary::TRANSACTION_SIZE_LIMIT;
|
||||||
|
|
||||||
let max_dkg_coefficients = (MAX_KEY_SHARES_PER_SET * 2).div_ceil(3) + 1;
|
let max_dkg_coefficients = (MAX_KEY_SHARES_PER_SET * 2).div_ceil(3) + 1;
|
||||||
let max_key_shares_per_individual = MAX_KEY_SHARES_PER_SET - max_dkg_coefficients;
|
// n coefficients
|
||||||
// Handwave the DKG Commitments size as the size of the commitments to the coefficients and
|
// 2 ECDH values per recipient, and the encrypted share
|
||||||
// 1024 bytes for all overhead
|
let elements_outside_of_proof = max_dkg_coefficients + ((2 + 1) * MAX_KEY_SHARES_PER_SET);
|
||||||
let handwaved_dkg_commitments_size = (max_dkg_coefficients * MAX_KEY_LEN) + 1024;
|
// Then Pedersen Vector Commitments for each DH done, and the associated overhead in the proof
|
||||||
assert!(
|
// It's handwaved as one commitment per DH, where we do 2 per coefficient and 1 for the explicit
|
||||||
u32::try_from(TRANSACTION_SIZE_LIMIT).unwrap() >=
|
// ECDHs
|
||||||
(handwaved_dkg_commitments_size * max_key_shares_per_individual)
|
let vector_commitments = (2 * max_dkg_coefficients) + (2 * MAX_KEY_SHARES_PER_SET);
|
||||||
);
|
// Then we have commitments to the `t` polynomial of length 2 + 2 nc, where nc is the amount of
|
||||||
|
// commitments
|
||||||
|
let t_commitments = 2 + (2 * vector_commitments);
|
||||||
|
// The remainder of the proof should be ~30 elements
|
||||||
|
let proof_elements = 30;
|
||||||
|
|
||||||
// Encryption key, PoP (2 elements), message
|
let handwaved_dkg_size =
|
||||||
let elements_per_share = 4;
|
((elements_outside_of_proof + vector_commitments + t_commitments + proof_elements) *
|
||||||
let handwaved_dkg_shares_size =
|
MAX_KEY_LEN) +
|
||||||
(elements_per_share * MAX_KEY_LEN * MAX_KEY_SHARES_PER_SET) + 1024;
|
1024;
|
||||||
assert!(
|
// Further scale by two in case of any errors in the above
|
||||||
u32::try_from(TRANSACTION_SIZE_LIMIT).unwrap() >=
|
assert!(u32::try_from(TRANSACTION_SIZE_LIMIT).unwrap() >= (2 * handwaved_dkg_size));
|
||||||
(handwaved_dkg_shares_size * max_key_shares_per_individual)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user