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

Refactor and fix auth key formula in account resortation processor #705

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

heliuchuan
Copy link

No description provided.

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 64 lines in your changes missing coverage. Please review.

Project coverage is 50.5%. Comparing base (e943d0f) to head (e299fc6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...nt_restoration_models/account_restoration_utils.rs 74.9% 64 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #705     +/-   ##
=======================================
+ Coverage   50.3%   50.5%   +0.1%     
=======================================
  Files        253     253             
  Lines      28643   29244    +601     
=======================================
+ Hits       14432   14791    +359     
- Misses     14211   14453    +242     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@0xjunha 0xjunha left a comment

Choose a reason for hiding this comment

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

Thanks for the refactor! @heliuchuan
Utilizing AccountSignature and adding FeePayer support looks good to me.
Regarding auth key derivation logic, left some comments.

@@ -28,8 +28,7 @@ impl AuthKeyScheme for Ed25519AuthKeyScheme {
const SCHEME: u8 = 0x00;

fn auth_key(&self) -> Option<String> {
let mut preimage = self.public_key.clone();
preimage.push(Self::SCHEME);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the preimage include SCHEME suffix here?

Copy link
Author

Choose a reason for hiding this comment

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

the legacy ed25519 does not use scheme. scheme was added to abstract to diff auth schemes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

hmm yeah you are totally right. i messed up my test somehow. fixed

let mut preimage = vec![key_type.to_u8()];
match key_type {
AnyPublicKeyType::Ed25519 => preimage.push(0x20),
AnyPublicKeyType::Secp256k1Ecdsa => preimage.push(0x41),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need 0x20 or 0x41 here?

Copy link
Author

Choose a reason for hiding this comment

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

this equates to 32 and 65 respectively. it encodes the length which happens to be used when hashing the public key.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, just to confirm - is the length prefix part of BCS encoding

Copy link
Author

Choose a reason for hiding this comment

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

It unfortunately is not standardize between schemes. But it is for Ed25519 (which I believe is just a byproduct of the library used to serialize the pubkey) and Secp256k1Ecdsa (which is actually part of the standard way to represent the pubkey).

Keyless does not.

@yuunlimm
Copy link
Contributor

yuunlimm commented Feb 7, 2025

@heliuchuan could you make this change in this repo https://github.com/aptos-labs/aptos-indexer-processors-v2. we are trying to deprecate this repo starting next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants