Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto_algebra.move #6550

Merged
merged 27 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
eff86a9
generic algebraic structures and operations in move, plus bls12381 im…
zjma Apr 1, 2023
3b6aeff
fix prover test failures
zjma Apr 1, 2023
8240018
update
zjma Apr 3, 2023
c719236
update doc
zjma Apr 3, 2023
5d30346
update msm gas cost
zjma Apr 3, 2023
0933093
Merge remote-tracking branch 'origin/main' into algebra.move
zjma Apr 3, 2023
a3f0878
hash_to gas formula update
zjma Apr 3, 2023
2e21783
type names and documentations
zjma Apr 4, 2023
aa783b2
update groth16 example
zjma Apr 4, 2023
454f57f
update gas formula for dst shortening
zjma Apr 4, 2023
17e4d74
format name update
zjma Apr 4, 2023
77946c9
update gas parameters
zjma Apr 4, 2023
7d067aa
update gas scripts to not depend on MUL
zjma Apr 4, 2023
cdbe85c
reuse move-stdlib sha2 gas parameters in aptos-stdlib (#7568)
zjma Apr 4, 2023
f494bed
update doc
zjma Apr 4, 2023
de48ca8
shorten symbol names
zjma Apr 5, 2023
229b02a
doc update
zjma Apr 5, 2023
db98190
update gas script readme
zjma Apr 5, 2023
9674c40
Merge remote-tracking branch 'origin/main' into algebra.move
zjma Apr 5, 2023
aae2c55
rename module to crypt_algebra (#7586)
zjma Apr 5, 2023
fd73274
Merge remote-tracking branch 'origin/algebra.move' into algebra.move
zjma Apr 5, 2023
00b367b
better module names
zjma Apr 5, 2023
27eac74
Merge remote-tracking branch 'origin/main' into algebra.move
zjma Apr 5, 2023
9ef2dc8
Merge remote-tracking branch 'origin/main' into algebra.move
zjma Apr 6, 2023
66ade5b
aptos framework now has access to the full move stdlib gas params
zjma Apr 6, 2023
4c2a516
Merge remote-tracking branch 'origin/main' into algebra.move
zjma Apr 6, 2023
1f66fdb
Merge remote-tracking branch 'origin/main' into algebra.move
zjma Apr 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ rstest = "0.15.0"
rusty-fork = "0.3.0"
sha-1 = "0.10.0"
sha2 = "0.9.3"
sha2_0_10_6 = { package = "sha2", version = "0.10.6" }
sha3 = "0.9.1"
siphasher = "0.3.10"
serde = { version = "1.0.137", features = ["derive", "rc"] }
Expand Down
65 changes: 65 additions & 0 deletions aptos-move/aptos-gas/src/aptos_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,71 @@ crate::natives::define_gas_parameters_for_natives!(GasParameters, "aptos_framewo
[.account.create_address.base, "account.create_address.base", 300 * MUL],
[.account.create_signer.base, "account.create_signer.base", 300 * MUL],

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vgao1996, be sure to take a look here.

// Algebra gas parameters begin.
// Generated at time 1680606720.0709136 by `scripts/algebra-gas/update_algebra_gas_params.py` with gas_per_ns=10.23.
[.algebra.ark_bls12_381_fq12_add, { 8.. => "algebra.ark_bls12_381_fq12_add" }, 1_819 * MUL],
[.algebra.ark_bls12_381_fq12_clone, { 8.. => "algebra.ark_bls12_381_fq12_clone" }, 211 * MUL],
[.algebra.ark_bls12_381_fq12_deser, { 8.. => "algebra.ark_bls12_381_fq12_deser" }, 11_180 * MUL],
[.algebra.ark_bls12_381_fq12_div, { 8.. => "algebra.ark_bls12_381_fq12_div" }, 250_813 * MUL],
[.algebra.ark_bls12_381_fq12_eq, { 8.. => "algebra.ark_bls12_381_fq12_eq" }, 726 * MUL],
[.algebra.ark_bls12_381_fq12_from_u64, { 8.. => "algebra.ark_bls12_381_fq12_from_u64" }, 901 * MUL],
[.algebra.ark_bls12_381_fq12_inv, { 8.. => "algebra.ark_bls12_381_fq12_inv" }, 200_523 * MUL],
[.algebra.ark_bls12_381_fq12_mul, { 8.. => "algebra.ark_bls12_381_fq12_mul" }, 49_886 * MUL],
[.algebra.ark_bls12_381_fq12_neg, { 8.. => "algebra.ark_bls12_381_fq12_neg" }, 1_181 * MUL],
[.algebra.ark_bls12_381_fq12_one, { 8.. => "algebra.ark_bls12_381_fq12_one" }, 11 * MUL],
[.algebra.ark_bls12_381_fq12_pow_u256, { 8.. => "algebra.ark_bls12_381_fq12_pow_u256" }, 14_664_207 * MUL],
[.algebra.ark_bls12_381_fq12_serialize, { 8.. => "algebra.ark_bls12_381_fq12_serialize" }, 8_078 * MUL],
[.algebra.ark_bls12_381_fq12_square, { 8.. => "algebra.ark_bls12_381_fq12_square" }, 35_145 * MUL],
[.algebra.ark_bls12_381_fq12_sub, { 8.. => "algebra.ark_bls12_381_fq12_sub" }, 1_758 * MUL],
[.algebra.ark_bls12_381_fq12_zero, { 8.. => "algebra.ark_bls12_381_fq12_zero" }, 211 * MUL],
[.algebra.ark_bls12_381_fr_add, { 8.. => "algebra.ark_bls12_381_fr_add" }, 211 * MUL],
[.algebra.ark_bls12_381_fr_deser, { 8.. => "algebra.ark_bls12_381_fr_deser" }, 752 * MUL],
[.algebra.ark_bls12_381_fr_div, { 8.. => "algebra.ark_bls12_381_fr_div" }, 59_440 * MUL],
[.algebra.ark_bls12_381_fr_eq, { 8.. => "algebra.ark_bls12_381_fr_eq" }, 212 * MUL],
[.algebra.ark_bls12_381_fr_from_u64, { 8.. => "algebra.ark_bls12_381_fr_from_u64" }, 494 * MUL],
[.algebra.ark_bls12_381_fr_inv, { 8.. => "algebra.ark_bls12_381_fr_inv" }, 58_610 * MUL],
[.algebra.ark_bls12_381_fr_mul, { 8.. => "algebra.ark_bls12_381_fr_mul" }, 502 * MUL],
[.algebra.ark_bls12_381_fr_neg, { 8.. => "algebra.ark_bls12_381_fr_neg" }, 213 * MUL],
[.algebra.ark_bls12_381_fr_one, { 8.. => "algebra.ark_bls12_381_fr_one" }, 211 * MUL],
[.algebra.ark_bls12_381_fr_serialize, { 8.. => "algebra.ark_bls12_381_fr_serialize" }, 1_103 * MUL],
[.algebra.ark_bls12_381_fr_square, { 8.. => "algebra.ark_bls12_381_fr_square" }, 475 * MUL],
[.algebra.ark_bls12_381_fr_sub, { 8.. => "algebra.ark_bls12_381_fr_sub" }, 290 * MUL],
[.algebra.ark_bls12_381_fr_zero, { 8.. => "algebra.ark_bls12_381_fr_zero" }, 211 * MUL],
[.algebra.ark_bls12_381_g1_affine_deser_comp, { 8.. => "algebra.ark_bls12_381_g1_affine_deser_comp" }, 1_029_599 * MUL],
[.algebra.ark_bls12_381_g1_affine_deser_uncomp, { 8.. => "algebra.ark_bls12_381_g1_affine_deser_uncomp" }, 720_638 * MUL],
[.algebra.ark_bls12_381_g1_affine_serialize_comp, { 8.. => "algebra.ark_bls12_381_g1_affine_serialize_comp" }, 2_014 * MUL],
[.algebra.ark_bls12_381_g1_affine_serialize_uncomp, { 8.. => "algebra.ark_bls12_381_g1_affine_serialize_uncomp" }, 2_433 * MUL],
[.algebra.ark_bls12_381_g1_proj_add, { 8.. => "algebra.ark_bls12_381_g1_proj_add" }, 10_806 * MUL],
[.algebra.ark_bls12_381_g1_proj_double, { 8.. => "algebra.ark_bls12_381_g1_proj_double" }, 5_264 * MUL],
[.algebra.ark_bls12_381_g1_proj_eq, { 8.. => "algebra.ark_bls12_381_g1_proj_eq" }, 5_035 * MUL],
[.algebra.ark_bls12_381_g1_proj_generator, { 8.. => "algebra.ark_bls12_381_g1_proj_generator" }, 11 * MUL],
[.algebra.ark_bls12_381_g1_proj_infinity, { 8.. => "algebra.ark_bls12_381_g1_proj_infinity" }, 11 * MUL],
[.algebra.ark_bls12_381_g1_proj_neg, { 8.. => "algebra.ark_bls12_381_g1_proj_neg" }, 11 * MUL],
[.algebra.ark_bls12_381_g1_proj_scalar_mul, { 8.. => "algebra.ark_bls12_381_g1_proj_scalar_mul" }, 2_523_521 * MUL],
[.algebra.ark_bls12_381_g1_proj_sub, { 8.. => "algebra.ark_bls12_381_g1_proj_sub" }, 11_147 * MUL],
[.algebra.ark_bls12_381_g1_proj_to_affine, { 8.. => "algebra.ark_bls12_381_g1_proj_to_affine" }, 121_035 * MUL],
[.algebra.ark_bls12_381_g2_affine_deser_comp, { 8.. => "algebra.ark_bls12_381_g2_affine_deser_comp" }, 2_060_068 * MUL],
[.algebra.ark_bls12_381_g2_affine_deser_uncomp, { 8.. => "algebra.ark_bls12_381_g2_affine_deser_uncomp" }, 1_017_979 * MUL],
[.algebra.ark_bls12_381_g2_affine_serialize_comp, { 8.. => "algebra.ark_bls12_381_g2_affine_serialize_comp" }, 3_378 * MUL],
[.algebra.ark_bls12_381_g2_affine_serialize_uncomp, { 8.. => "algebra.ark_bls12_381_g2_affine_serialize_uncomp" }, 4_217 * MUL],
[.algebra.ark_bls12_381_g2_proj_add, { 8.. => "algebra.ark_bls12_381_g2_proj_add" }, 32_401 * MUL],
[.algebra.ark_bls12_381_g2_proj_double, { 8.. => "algebra.ark_bls12_381_g2_proj_double" }, 14_839 * MUL],
[.algebra.ark_bls12_381_g2_proj_eq, { 8.. => "algebra.ark_bls12_381_g2_proj_eq" }, 15_155 * MUL],
[.algebra.ark_bls12_381_g2_proj_generator, { 8.. => "algebra.ark_bls12_381_g2_proj_generator" }, 11 * MUL],
[.algebra.ark_bls12_381_g2_proj_infinity, { 8.. => "algebra.ark_bls12_381_g2_proj_infinity" }, 11 * MUL],
[.algebra.ark_bls12_381_g2_proj_neg, { 8.. => "algebra.ark_bls12_381_g2_proj_neg" }, 11 * MUL],
[.algebra.ark_bls12_381_g2_proj_scalar_mul, { 8.. => "algebra.ark_bls12_381_g2_proj_scalar_mul" }, 7_526_508 * MUL],
[.algebra.ark_bls12_381_g2_proj_sub, { 8.. => "algebra.ark_bls12_381_g2_proj_sub" }, 32_869 * MUL],
[.algebra.ark_bls12_381_g2_proj_to_affine, { 8.. => "algebra.ark_bls12_381_g2_proj_to_affine" }, 128_857 * MUL],
[.algebra.ark_bls12_381_multi_pairing_base, { 8.. => "algebra.ark_bls12_381_multi_pairing_base" }, 8_998_649 * MUL],
[.algebra.ark_bls12_381_multi_pairing_per_pair, { 8.. => "algebra.ark_bls12_381_multi_pairing_per_pair" }, 4_602_642 * MUL],
[.algebra.ark_bls12_381_pairing, { 8.. => "algebra.ark_bls12_381_pairing" }, 14_832_220 * MUL],
[.algebra.ark_h2c_bls12381g1_xmd_sha256_sswu_base, { 8.. => "algebra.ark_h2c_bls12381g1_xmd_sha256_sswu_base" }, 3_251_943 * MUL],
[.algebra.ark_h2c_bls12381g1_xmd_sha256_sswu_per_msg_byte, { 8.. => "algebra.ark_h2c_bls12381g1_xmd_sha256_sswu_per_msg_byte" }, 48 * MUL],
[.algebra.ark_h2c_bls12381g2_xmd_sha256_sswu_base, { 8.. => "algebra.ark_h2c_bls12381g2_xmd_sha256_sswu_base" }, 6_773_002 * MUL],
[.algebra.ark_h2c_bls12381g2_xmd_sha256_sswu_per_msg_byte, { 8.. => "algebra.ark_h2c_bls12381g2_xmd_sha256_sswu_per_msg_byte" }, 48 * MUL],
// Algebra gas parameters end.

[.bls12381.base, "bls12381.base", 150 * MUL],

[.bls12381.per_pubkey_deserialize, "bls12381.per_pubkey_deserialize", 109_000 * MUL],
Expand Down
4 changes: 3 additions & 1 deletion aptos-move/aptos-gas/src/gas_meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ use move_vm_types::{
use std::collections::BTreeMap;

// Change log:
// - V8
// - Added BLS12-381 operations.
// - V7
// - Native support for exists<T>
// - New formulae for storage fees based on fixed APT costs
Expand All @@ -57,7 +59,7 @@ use std::collections::BTreeMap;
// global operations.
// - V1
// - TBA
pub const LATEST_GAS_FEATURE_VERSION: u64 = 7;
pub const LATEST_GAS_FEATURE_VERSION: u64 = 8;

pub(crate) const EXECUTION_GAS_MULTIPLIER: u64 = 20;

Expand Down
3 changes: 2 additions & 1 deletion aptos-move/aptos-vm/src/natives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ pub fn aptos_natives(
timed_features: TimedFeatures,
features: Arc<Features>,
) -> NativeFunctionTable {
aptos_move_stdlib::natives::all_natives(CORE_CODE_ADDRESS, gas_params.move_stdlib)
aptos_move_stdlib::natives::all_natives(CORE_CODE_ADDRESS, gas_params.move_stdlib.clone())
.into_iter()
.filter(|(_, name, _, _)| name.as_str() != "vector")
.chain(aptos_framework::natives::all_natives(
CORE_CODE_ADDRESS,
gas_params.move_stdlib,
gas_params.aptos_framework,
timed_features,
features,
Expand Down
2 changes: 2 additions & 0 deletions aptos-move/framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ anyhow = { workspace = true }
aptos-aggregator = { workspace = true }
aptos-crypto = { workspace = true, features = ["fuzzing"] }
aptos-gas-algebra-ext = { workspace = true }
aptos-move-stdlib = { workspace = true }
aptos-sdk-builder = { workspace = true }
aptos-state-view = { workspace = true }
aptos-types = { workspace = true }
Expand Down Expand Up @@ -65,6 +66,7 @@ serde_bytes = { workspace = true }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
sha2 = { workspace = true }
sha2_0_10_6 = { workspace = true }
sha3 = { workspace = true }
siphasher = { workspace = true }
smallvec = { workspace = true }
Expand Down
Loading