-
Notifications
You must be signed in to change notification settings - Fork 84
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
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. |
There was a problem hiding this 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/authenticator.rs#L765
https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/authenticator.rs#L744
Doesn't this mean the legacy ed25519 includes the 0x00
scheme?
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
@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 |
No description provided.