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

adopt AIP-61 terminology for consistency #12123

Merged
merged 5 commits into from
Feb 21, 2024
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
8 changes: 4 additions & 4 deletions api/doc/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -13433,7 +13433,7 @@
"ed25519": "#/components/schemas/PublicKey_string(HexEncodedBytes)",
"secp256k1_ecdsa": "#/components/schemas/PublicKey_string(HexEncodedBytes)",
"secp256r1_ecdsa": "#/components/schemas/PublicKey_string(HexEncodedBytes)",
"zk_id": "#/components/schemas/PublicKey_string(HexEncodedBytes)"
"oidb": "#/components/schemas/PublicKey_string(HexEncodedBytes)"
}
}
},
Expand All @@ -13447,7 +13447,7 @@
"properties": {
"type": {
"type": "string",
"example": "zk_id"
"example": "oidb"
}
}
},
Expand Down Expand Up @@ -13538,7 +13538,7 @@
"ed25519": "#/components/schemas/Signature_string(HexEncodedBytes)",
"secp256k1_ecdsa": "#/components/schemas/Signature_string(HexEncodedBytes)",
"web_authn": "#/components/schemas/Signature_string(HexEncodedBytes)",
"zk_id": "#/components/schemas/Signature_string(HexEncodedBytes)"
"oidb": "#/components/schemas/Signature_string(HexEncodedBytes)"
}
}
},
Expand All @@ -13552,7 +13552,7 @@
"properties": {
"type": {
"type": "string",
"example": "zk_id"
"example": "oidb"
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions api/doc/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10115,7 +10115,7 @@ components:
ed25519: '#/components/schemas/PublicKey_string(HexEncodedBytes)'
secp256k1_ecdsa: '#/components/schemas/PublicKey_string(HexEncodedBytes)'
secp256r1_ecdsa: '#/components/schemas/PublicKey_string(HexEncodedBytes)'
zk_id: '#/components/schemas/PublicKey_string(HexEncodedBytes)'
oidb: '#/components/schemas/PublicKey_string(HexEncodedBytes)'
PublicKey_string(HexEncodedBytes):
allOf:
- type: object
Expand All @@ -10124,7 +10124,7 @@ components:
properties:
type:
type: string
example: zk_id
example: oidb
- $ref: '#/components/schemas/HexEncodedBytes'
RawTableItemRequest:
type: object
Expand Down Expand Up @@ -10181,7 +10181,7 @@ components:
ed25519: '#/components/schemas/Signature_string(HexEncodedBytes)'
secp256k1_ecdsa: '#/components/schemas/Signature_string(HexEncodedBytes)'
web_authn: '#/components/schemas/Signature_string(HexEncodedBytes)'
zk_id: '#/components/schemas/Signature_string(HexEncodedBytes)'
oidb: '#/components/schemas/Signature_string(HexEncodedBytes)'
Signature_string(HexEncodedBytes):
allOf:
- type: object
Expand All @@ -10190,7 +10190,7 @@ components:
properties:
type:
type: string
example: zk_id
example: oidb
- $ref: '#/components/schemas/HexEncodedBytes'
SingleKeySignature:
type: object
Expand Down
10 changes: 5 additions & 5 deletions api/src/tests/accounts_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ async fn test_get_account_resources_with_pagination() {
{
println!("0x1::{}::{}", r.module, r.name);
}
assert_eq!(resources.len(), 5);
assert_eq!(resources, all_resources[0..5].to_vec());
assert_eq!(resources.len(), 4);
assert_eq!(resources, all_resources[0..4].to_vec());

// Make a request using the cursor. Assert the 5 results we get back are the next 5.
let req = warp::test::request().method("GET").path(&format!(
Expand All @@ -255,7 +255,7 @@ async fn test_get_account_resources_with_pagination() {
let cursor_header = StateKeyWrapper::from_str(cursor_header.to_str().unwrap()).unwrap();
let resources: Vec<MoveResource> = serde_json::from_slice(resp.body()).unwrap();
assert_eq!(resources.len(), 5);
assert_eq!(resources, all_resources[5..10].to_vec());
assert_eq!(resources, all_resources[4..9].to_vec());

// Get the rest of the resources, assert there is no cursor now.
let req = warp::test::request().method("GET").path(&format!(
Expand All @@ -267,8 +267,8 @@ async fn test_get_account_resources_with_pagination() {
assert_eq!(resp.status(), 200);
assert!(!resp.headers().contains_key("X-Aptos-Cursor"));
let resources: Vec<MoveResource> = serde_json::from_slice(resp.body()).unwrap();
assert_eq!(resources.len(), all_resources.len() - 10);
assert_eq!(resources, all_resources[10..].to_vec());
assert_eq!(resources.len(), all_resources.len() - 9);
assert_eq!(resources, all_resources[9..].to_vec());
}

// Same as the above test but for modules.
Expand Down
56 changes: 28 additions & 28 deletions api/types/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use aptos_types::{
block_metadata::BlockMetadata,
block_metadata_ext::BlockMetadataExt,
contract_event::{ContractEvent, EventWithVersion},
oidb,
transaction::{
authenticator::{
AccountAuthenticator, AnyPublicKey, AnySignature, MultiKey, MultiKeyAuthenticator,
Expand All @@ -28,7 +29,6 @@ use aptos_types::{
webauthn::{PartialAuthenticatorAssertionResponse, MAX_WEBAUTHN_SIGNATURE_BYTES},
Script, SignedTransaction, TransactionOutput, TransactionWithProof,
},
zkid,
};
use once_cell::sync::Lazy;
use poem_openapi::{Object, Union};
Expand Down Expand Up @@ -1198,24 +1198,24 @@ impl VerifyInput for WebAuthnSignature {
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Object)]
pub struct ZkIdSignature {
pub struct OidbSignature {
pub public_key: HexEncodedBytes,
pub signature: HexEncodedBytes,
}

impl VerifyInput for ZkIdSignature {
impl VerifyInput for OidbSignature {
fn verify(&self) -> anyhow::Result<()> {
let public_key_len = self.public_key.inner().len();
let signature_len = self.signature.inner().len();
if public_key_len > zkid::ZkIdPublicKey::MAX_LEN {
if public_key_len > oidb::OidbPublicKey::MAX_LEN {
bail!(
"zkID public key length is greater than the maximum number of {} bytes: found {} bytes",
zkid::ZkIdPublicKey::MAX_LEN, public_key_len
"OIDB public key length is greater than the maximum number of {} bytes: found {} bytes",
oidb::OidbPublicKey::MAX_LEN, public_key_len
)
} else if signature_len > zkid::ZkIdSignature::MAX_LEN {
} else if signature_len > oidb::OidbSignature::MAX_LEN {
bail!(
"zkID signature length is greater than the maximum number of {} bytes: found {} bytes",
zkid::ZkIdSignature::MAX_LEN, signature_len
"OIDB signature length is greater than the maximum number of {} bytes: found {} bytes",
oidb::OidbSignature::MAX_LEN, signature_len
)
} else {
Ok(())
Expand All @@ -1230,7 +1230,7 @@ pub enum Signature {
Ed25519(HexEncodedBytes),
Secp256k1Ecdsa(HexEncodedBytes),
WebAuthn(HexEncodedBytes),
ZkId(HexEncodedBytes),
Oidb(HexEncodedBytes),
}

impl TryFrom<Signature> for AnySignature {
Expand All @@ -1241,7 +1241,7 @@ impl TryFrom<Signature> for AnySignature {
Signature::Ed25519(s) => AnySignature::ed25519(s.inner().try_into()?),
Signature::Secp256k1Ecdsa(s) => AnySignature::secp256k1_ecdsa(s.inner().try_into()?),
Signature::WebAuthn(s) => AnySignature::webauthn(s.inner().try_into()?),
Signature::ZkId(s) => AnySignature::zkid(s.inner().try_into()?),
Signature::Oidb(s) => AnySignature::oidb(s.inner().try_into()?),
})
}
}
Expand All @@ -1258,7 +1258,7 @@ impl From<AnySignature> for Signature {
AnySignature::WebAuthn { signature } => {
Signature::WebAuthn(signature.to_bytes().to_vec().into())
},
AnySignature::ZkId { signature } => Signature::ZkId(signature.to_bytes().into()),
AnySignature::OIDB { signature } => Signature::Oidb(signature.to_bytes().into()),
}
}
}
Expand All @@ -1270,7 +1270,7 @@ pub enum PublicKey {
Ed25519(HexEncodedBytes),
Secp256k1Ecdsa(HexEncodedBytes),
Secp256r1Ecdsa(HexEncodedBytes),
ZkId(HexEncodedBytes),
Oidb(HexEncodedBytes),
}

impl TryFrom<PublicKey> for AnyPublicKey {
Expand All @@ -1281,7 +1281,7 @@ impl TryFrom<PublicKey> for AnyPublicKey {
PublicKey::Ed25519(p) => AnyPublicKey::ed25519(p.inner().try_into()?),
PublicKey::Secp256k1Ecdsa(p) => AnyPublicKey::secp256k1_ecdsa(p.inner().try_into()?),
PublicKey::Secp256r1Ecdsa(p) => AnyPublicKey::secp256r1_ecdsa(p.inner().try_into()?),
PublicKey::ZkId(p) => AnyPublicKey::zkid(p.inner().try_into()?),
PublicKey::Oidb(p) => AnyPublicKey::oidb(p.inner().try_into()?),
})
}
}
Expand All @@ -1298,7 +1298,7 @@ impl From<AnyPublicKey> for PublicKey {
AnyPublicKey::Secp256r1Ecdsa { public_key } => {
PublicKey::Secp256r1Ecdsa(public_key.to_bytes().to_vec().into())
},
AnyPublicKey::ZkId { public_key } => PublicKey::ZkId(public_key.to_bytes().into()),
AnyPublicKey::OIDB { public_key } => PublicKey::Oidb(public_key.to_bytes().into()),
}
}
}
Expand Down Expand Up @@ -1330,7 +1330,7 @@ impl VerifyInput for SingleKeySignature {
signature: s.clone(),
}
.verify(),
(PublicKey::ZkId(p), Signature::ZkId(s)) => ZkIdSignature {
(PublicKey::Oidb(p), Signature::Oidb(s)) => OidbSignature {
public_key: p.clone(),
signature: s.clone(),
}
Expand Down Expand Up @@ -1374,12 +1374,12 @@ impl TryFrom<SingleKeySignature> for AccountAuthenticator {
)?;
AnyPublicKey::secp256r1_ecdsa(key)
},
PublicKey::ZkId(p) => {
PublicKey::Oidb(p) => {
let key = p
.inner()
.try_into()
.context("Failed to parse given public_key bytes as ZkIdPublicKey")?;
AnyPublicKey::zkid(key)
.context("Failed to parse given public_key bytes as OidbPublicKey")?;
AnyPublicKey::oidb(key)
},
};

Expand All @@ -1405,12 +1405,12 @@ impl TryFrom<SingleKeySignature> for AccountAuthenticator {
.context( "Failed to parse given signature bytes as PartialAuthenticatorAssertionResponse")?;
AnySignature::webauthn(signature)
},
Signature::ZkId(s) => {
Signature::Oidb(s) => {
let signature = s
.inner()
.try_into()
.context("Failed to parse given signature bytes as ZkIdSignature")?;
AnySignature::zkid(signature)
.context("Failed to parse given signature bytes as OidbSignature")?;
AnySignature::oidb(signature)
},
};

Expand Down Expand Up @@ -1475,12 +1475,12 @@ impl TryFrom<MultiKeySignature> for AccountAuthenticator {
)?;
AnyPublicKey::secp256r1_ecdsa(key)
},
PublicKey::ZkId(p) => {
PublicKey::Oidb(p) => {
let key = p
.inner()
.try_into()
.context("Failed to parse given public_key bytes as ZkIdPublicKey")?;
AnyPublicKey::zkid(key)
.context("Failed to parse given public_key bytes as OidbPublicKey")?;
AnyPublicKey::oidb(key)
},
};
public_keys.push(key);
Expand Down Expand Up @@ -1508,12 +1508,12 @@ impl TryFrom<MultiKeySignature> for AccountAuthenticator {
)?;
AnySignature::webauthn(paar)
},
Signature::ZkId(s) => {
Signature::Oidb(s) => {
let signature = s
.inner()
.try_into()
.context("Failed to parse given signature as ZkIdSignature")?;
AnySignature::zkid(signature)
.context("Failed to parse given signature as OidbSignature")?;
AnySignature::oidb(signature)
},
};
signatures.push((indexed_signature.index, signature));
Expand Down
6 changes: 3 additions & 3 deletions aptos-move/aptos-release-builder/data/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,16 @@ proposals:
- FeatureFlag:
enabled:
- jwk_consensus
- name: step_12_enable_zkid
- name: step_12_enable_oidb
metadata:
title: "AIP-61: OpenID blockchain (OIDB) accounts"
description: "Enable validation of zkID transactions, allowing users to transact using their Web2 accounts"
description: "Enable validation of OIDB transactions, allowing users to transact using their Web2 accounts"
discussion_url: "https://github.com/aptos-foundation/AIPs/issues/297"
execution_mode: MultiStep
update_sequence:
- FeatureFlag:
enabled:
- zk_id_signature
- oidb_signature
- name: step_13_start_watching_google_jwks
metadata:
title: "Start JWK consensus for Google"
Expand Down
12 changes: 6 additions & 6 deletions aptos-move/aptos-release-builder/src/components/feature_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ pub enum FeatureFlag {
Bn254Structures,
WebAuthnSignature,
ReconfigureWithDkg,
ZkIdSignature,
ZkIdZkLessSignature,
OidbSignature,
OidbZkLessSignature,
RemoveDetailedError,
JwkConsensus,
ConcurrentFungibleAssets,
Expand Down Expand Up @@ -257,8 +257,8 @@ impl From<FeatureFlag> for AptosFeatureFlag {
FeatureFlag::Bn254Structures => AptosFeatureFlag::BN254_STRUCTURES,
FeatureFlag::WebAuthnSignature => AptosFeatureFlag::WEBAUTHN_SIGNATURE,
FeatureFlag::ReconfigureWithDkg => AptosFeatureFlag::RECONFIGURE_WITH_DKG,
FeatureFlag::ZkIdSignature => AptosFeatureFlag::ZK_ID_SIGNATURES,
FeatureFlag::ZkIdZkLessSignature => AptosFeatureFlag::ZK_ID_ZKLESS_SIGNATURE,
FeatureFlag::OidbSignature => AptosFeatureFlag::OIDB_SIGNATURE,
FeatureFlag::OidbZkLessSignature => AptosFeatureFlag::OIDB_ZKLESS_SIGNATURE,
FeatureFlag::RemoveDetailedError => AptosFeatureFlag::REMOVE_DETAILED_ERROR_FROM_HASH,
FeatureFlag::JwkConsensus => AptosFeatureFlag::JWK_CONSENSUS,
FeatureFlag::ConcurrentFungibleAssets => AptosFeatureFlag::CONCURRENT_FUNGIBLE_ASSETS,
Expand Down Expand Up @@ -341,8 +341,8 @@ impl From<AptosFeatureFlag> for FeatureFlag {
AptosFeatureFlag::BN254_STRUCTURES => FeatureFlag::Bn254Structures,
AptosFeatureFlag::WEBAUTHN_SIGNATURE => FeatureFlag::WebAuthnSignature,
AptosFeatureFlag::RECONFIGURE_WITH_DKG => FeatureFlag::ReconfigureWithDkg,
AptosFeatureFlag::ZK_ID_SIGNATURES => FeatureFlag::ZkIdSignature,
AptosFeatureFlag::ZK_ID_ZKLESS_SIGNATURE => FeatureFlag::ZkIdZkLessSignature,
AptosFeatureFlag::OIDB_SIGNATURE => FeatureFlag::OidbSignature,
AptosFeatureFlag::OIDB_ZKLESS_SIGNATURE => FeatureFlag::OidbZkLessSignature,
AptosFeatureFlag::REMOVE_DETAILED_ERROR_FROM_HASH => FeatureFlag::RemoveDetailedError,
AptosFeatureFlag::JWK_CONSENSUS => FeatureFlag::JwkConsensus,
AptosFeatureFlag::CONCURRENT_FUNGIBLE_ASSETS => FeatureFlag::ConcurrentFungibleAssets,
Expand Down
7 changes: 4 additions & 3 deletions aptos-move/aptos-vm/src/aptos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ use crate::{
get_max_binary_format_version, get_max_identifier_size, AptosMoveResolver, MoveVmExt,
RespawnedSession, SessionExt, SessionId,
},
oidb_validation,
sharded_block_executor::{executor_client::ExecutorClient, ShardedBlockExecutor},
system_module_names::*,
transaction_metadata::TransactionMetadata,
transaction_validation, verifier, zkid_validation, VMExecutor, VMValidator,
transaction_validation, verifier, VMExecutor, VMValidator,
};
use anyhow::anyhow;
use aptos_block_executor::txn_commit_hook::NoOpTransactionCommitHook;
Expand Down Expand Up @@ -1293,9 +1294,9 @@ impl AptosVM {
));
}

let authenticators = aptos_types::zkid::get_zkid_authenticators(transaction)
let authenticators = aptos_types::oidb::get_oidb_authenticators(transaction)
.map_err(|_| VMStatus::error(StatusCode::INVALID_SIGNATURE, None))?;
zkid_validation::validate_zkid_authenticators(&authenticators, self.features(), resolver)?;
oidb_validation::validate_oidb_authenticators(&authenticators, self.features(), resolver)?;

// The prologue MUST be run AFTER any validation. Otherwise you may run prologue and hit
// SEQUENCE_NUMBER_TOO_NEW if there is more than one transaction from the same sender and
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ mod errors;
mod gas;
pub mod move_vm_ext;
pub mod natives;
mod oidb_validation;
pub mod sharded_block_executor;
pub mod system_module_names;
pub mod testing;
pub mod transaction_metadata;
mod transaction_validation;
pub mod validator_txns;
pub mod verifier;
mod zkid_validation;

pub use crate::aptos_vm::{AptosSimulationVM, AptosVM};
use crate::sharded_block_executor::{executor_client::ExecutorClient, ShardedBlockExecutor};
Expand Down
Loading
Loading