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

rename module to crypt_algebra #7586

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1,722 changes: 0 additions & 1,722 deletions aptos-move/framework/aptos-stdlib/doc/algebra.md

This file was deleted.

1,722 changes: 1,722 additions & 0 deletions aptos-move/framework/aptos-stdlib/doc/crypt_algebra.md

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions aptos-move/framework/aptos-stdlib/doc/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ This is the reference documentation of the Aptos standard library.
## Index


- [`0x1::algebra`](algebra.md#0x1_algebra)
- [`0x1::algebra_bls12381`](algebra_bls12381.md#0x1_algebra_bls12381)
- [`0x1::any`](any.md#0x1_any)
- [`0x1::aptos_hash`](hash.md#0x1_aptos_hash)
- [`0x1::big_vector`](big_vector.md#0x1_big_vector)
- [`0x1::bls12381`](bls12381.md#0x1_bls12381)
- [`0x1::capability`](capability.md#0x1_capability)
- [`0x1::comparator`](comparator.md#0x1_comparator)
- [`0x1::copyable_any`](copyable_any.md#0x1_copyable_any)
- [`0x1::crypt_algebra`](crypt_algebra.md#0x1_crypt_algebra)
- [`0x1::crypt_algebra_bls12381`](crypt_algebra_bls12381.md#0x1_crypt_algebra_bls12381)
- [`0x1::debug`](debug.md#0x1_debug)
- [`0x1::ed25519`](ed25519.md#0x1_ed25519)
- [`0x1::fixed_point64`](fixed_point64.md#0x1_fixed_point64)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/// `upcast<Gt, Fq12>()` and `downcast<Fq12, Gt>()` will be supported.
///
/// See `algebra_*.move` for currently implemented algebraic structures.
module aptos_std::algebra {
module aptos_std::crypt_algebra {
use std::option::{Option, some, none};
use std::features;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
spec aptos_std::algebra {
spec aptos_std::crypt_algebra {
spec add_internal<S>(handle_1: u64, handle_2: u64): u64 {
pragma opaque;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
/// `G2Full`: a group constructed by the points on a curve $E'(F_{q^2}): y^2=x^3+4(u+1)$ and the point at infinity,
/// under the elliptic curve point addition.
/// It contains the prime-order subgroup $G_2$ used in pairing.
module aptos_std::algebra_bls12381 {
module aptos_std::crypt_algebra_bls12381 {
//
// Marker types + serialization formats begin.
//
Expand Down Expand Up @@ -627,7 +627,7 @@ module aptos_std::algebra_bls12381 {
}

#[test_only]
use aptos_std::algebra::{zero, one, from_u64, eq, deserialize, serialize, neg, add, sub, mul, div, inv, rand_insecure, sqr, order, scalar_mul, multi_scalar_mul, double, hash_to, upcast, enable_cryptography_algebra_natives, pairing, multi_pairing, downcast, Element};
use aptos_std::crypt_algebra::{zero, one, from_u64, eq, deserialize, serialize, neg, add, sub, mul, div, inv, rand_insecure, sqr, order, scalar_mul, multi_scalar_mul, double, hash_to, upcast, enable_cryptography_algebra_natives, pairing, multi_pairing, downcast, Element};

#[test_only]
const FR_VAL_0_SERIALIZED_LSB: vector<u8> = x"0000000000000000000000000000000000000000000000000000000000000000";
Expand Down Expand Up @@ -753,7 +753,7 @@ module aptos_std::algebra_bls12381 {
}

#[test(fx = @std)]
#[expected_failure(abort_code = 0x010002, location = aptos_std::algebra)]
#[expected_failure(abort_code = 0x010002, location = aptos_std::crypt_algebra)]
fun test_multi_pairing_should_abort_when_sizes_mismatch(fx: signer) {
enable_cryptography_algebra_natives(&fx);
let g1_elements = vector[rand_insecure<G1>()];
Expand All @@ -762,7 +762,7 @@ module aptos_std::algebra_bls12381 {
}

#[test(fx = @std)]
#[expected_failure(abort_code = 0x010002, location = aptos_std::algebra)]
#[expected_failure(abort_code = 0x010002, location = aptos_std::crypt_algebra)]
fun test_multi_scalar_mul_should_abort_when_sizes_mismatch(fx: signer) {
enable_cryptography_algebra_natives(&fx);
let elements = vector[rand_insecure<G1>()];
Expand Down
30 changes: 15 additions & 15 deletions aptos-move/framework/src/natives/cryptography/algebra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ impl TryFrom<TypeTag> for Structure {

fn try_from(value: TypeTag) -> Result<Self, Self::Error> {
match value.to_string().as_str() {
"0x1::algebra_bls12381::Fr" => Ok(Structure::BLS12381Fr),
"0x1::algebra_bls12381::Fq12" => Ok(Structure::BLS12381Fq12),
"0x1::algebra_bls12381::G1" => Ok(Structure::BLS12381G1),
"0x1::algebra_bls12381::G2" => Ok(Structure::BLS12381G2),
"0x1::algebra_bls12381::Gt" => Ok(Structure::BLS12381Gt),
"0x1::crypt_algebra_bls12381::Fr" => Ok(Structure::BLS12381Fr),
"0x1::crypt_algebra_bls12381::Fq12" => Ok(Structure::BLS12381Fq12),
"0x1::crypt_algebra_bls12381::G1" => Ok(Structure::BLS12381G1),
"0x1::crypt_algebra_bls12381::G2" => Ok(Structure::BLS12381G2),
"0x1::crypt_algebra_bls12381::Gt" => Ok(Structure::BLS12381Gt),
_ => Err(()),
}
}
Expand Down Expand Up @@ -107,20 +107,20 @@ impl TryFrom<TypeTag> for SerializationFormat {

fn try_from(value: TypeTag) -> Result<Self, Self::Error> {
match value.to_string().as_str() {
"0x1::algebra_bls12381::FormatFq12LscLsb" => {
"0x1::crypt_algebra_bls12381::FormatFq12LscLsb" => {
Ok(SerializationFormat::BLS12381Fq12LscLsb)
},
"0x1::algebra_bls12381::FormatG1Uncompr" => {
"0x1::crypt_algebra_bls12381::FormatG1Uncompr" => {
Ok(SerializationFormat::BLS12381G1Uncompressed)
},
"0x1::algebra_bls12381::FormatG1Compr" => Ok(SerializationFormat::BLS12381G1Compressed),
"0x1::algebra_bls12381::FormatG2Uncompr" => {
"0x1::crypt_algebra_bls12381::FormatG1Compr" => Ok(SerializationFormat::BLS12381G1Compressed),
"0x1::crypt_algebra_bls12381::FormatG2Uncompr" => {
Ok(SerializationFormat::BLS12381G2Uncompressed)
},
"0x1::algebra_bls12381::FormatG2Compr" => Ok(SerializationFormat::BLS12381G2Compressed),
"0x1::algebra_bls12381::FormatGt" => Ok(SerializationFormat::BLS12381Gt),
"0x1::algebra_bls12381::FormatFrLsb" => Ok(SerializationFormat::BLS12381FrLsb),
"0x1::algebra_bls12381::FormatFrMsb" => Ok(SerializationFormat::BLS12381FrMsb),
"0x1::crypt_algebra_bls12381::FormatG2Compr" => Ok(SerializationFormat::BLS12381G2Compressed),
"0x1::crypt_algebra_bls12381::FormatGt" => Ok(SerializationFormat::BLS12381Gt),
"0x1::crypt_algebra_bls12381::FormatFrLsb" => Ok(SerializationFormat::BLS12381FrLsb),
"0x1::crypt_algebra_bls12381::FormatFrMsb" => Ok(SerializationFormat::BLS12381FrMsb),
_ => Err(()),
}
}
Expand All @@ -138,10 +138,10 @@ impl TryFrom<TypeTag> for HashToStructureSuite {

fn try_from(value: TypeTag) -> Result<Self, Self::Error> {
match value.to_string().as_str() {
"0x1::algebra_bls12381::HashG1XmdSha256SswuRo" => {
"0x1::crypt_algebra_bls12381::HashG1XmdSha256SswuRo" => {
Ok(HashToStructureSuite::Bls12381g1XmdSha256SswuRo)
},
"0x1::algebra_bls12381::HashG2XmdSha256SswuRo" => {
"0x1::crypt_algebra_bls12381::HashG2XmdSha256SswuRo" => {
Ok(HashToStructureSuite::Bls12381g2XmdSha256SswuRo)
},
_ => Err(()),
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/framework/src/natives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ pub fn all_natives(
)
);
add_natives_from_module!(
"algebra",
"crypt_algebra",
cryptography::algebra::make_all(
gas_params.algebra.clone(),
sha256_gas_params,
Expand Down
6 changes: 3 additions & 3 deletions aptos-move/move-examples/groth16_example/sources/groth16.move
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// Actual proof verifiers can be constructed using the pairings supported in the generic algebra module.
/// See the test cases in this module for an example of constructing with BLS12-381 curves.
module groth16_example::groth16 {
use aptos_std::algebra::{Element, from_u64, multi_scalar_mul, eq, multi_pairing, upcast, pairing, add, zero};
use aptos_std::crypt_algebra::{Element, from_u64, multi_scalar_mul, eq, multi_pairing, upcast, pairing, add, zero};

/// Proof verification as specified in the original paper,
/// with the following input (in the original paper notations).
Expand Down Expand Up @@ -77,9 +77,9 @@ module groth16_example::groth16 {
}

#[test_only]
use aptos_std::algebra::{deserialize, enable_cryptography_algebra_natives};
use aptos_std::crypt_algebra::{deserialize, enable_cryptography_algebra_natives};
#[test_only]
use aptos_std::algebra_bls12381::{Fr, FormatFrLsb, FormatG1Compr, FormatG2Compr, FormatFq12LscLsb, G1, G2, Gt, Fq12, FormatGt};
use aptos_std::crypt_algebra_bls12381::{Fr, FormatFrLsb, FormatG1Compr, FormatG2Compr, FormatFq12LscLsb, G1, G2, Gt, Fq12, FormatGt};

#[test(fx = @std)]
fun test_verify_proof_with_bls12381(fx: signer) {
Expand Down