1- use alloy:: primitives:: { Address , Bytes , FixedBytes } ;
2- use alloy:: sol_types:: SolType ;
1+ use alloy:: {
2+ primitives:: { Address , Bytes , FixedBytes } ,
3+ sol_types:: SolType ,
4+ } ;
35
46pub fn stub_signature_passkey ( validator : Address ) -> eyre:: Result < Bytes > {
57 // Create a more realistic WebAuthn stub signature for gas estimation
68 // Format: validator_address (20 bytes) + abi_encoded(authenticatorData, clientDataJSON, rs, credentialId)
7-
9+
810 // Minimal valid authenticator data (37 bytes minimum)
911 let authenticator_data = vec ! [
10- 0x49 , 0x96 , 0x0d , 0xe5 , 0x88 , 0x0e , 0x8c , 0x68 , 0x74 , 0x34 ,
11- 0x17 , 0x0f , 0x64 , 0x76 , 0x60 , 0x5b , 0x8f , 0xe4 , 0xae , 0xb9 ,
12- 0xa2 , 0x86 , 0x32 , 0xc7 , 0x99 , 0x5c , 0xf3 , 0xba , 0x83 , 0x1d ,
13- 0x97 , 0x63 , // rpIdHash (32 bytes)
12+ 0x49 , 0x96 , 0x0d , 0xe5 , 0x88 , 0x0e , 0x8c , 0x68 , 0x74 , 0x34 , 0x17 , 0x0f ,
13+ 0x64 , 0x76 , 0x60 , 0x5b , 0x8f , 0xe4 , 0xae , 0xb9 , 0xa2 , 0x86 , 0x32 , 0xc7 ,
14+ 0x99 , 0x5c , 0xf3 , 0xba , 0x83 , 0x1d , 0x97 ,
15+ 0x63 , // rpIdHash (32 bytes)
1416 0x01 , // flags
1517 0x00 , 0x00 , 0x00 , 0x00 , // counter (4 bytes)
1618 ] ;
17-
19+
1820 // Minimal client data JSON for gas estimation
19- let client_data_json = r#"{"type":"webauthn.get","challenge":"AAAAAAAAAAAAAAAAAAAAAA"}"# . to_string ( ) ;
20-
21+ let client_data_json =
22+ r#"{"type":"webauthn.get","challenge":"AAAAAAAAAAAAAAAAAAAAAA"}"#
23+ . to_string ( ) ;
24+
2125 // Stub signature components (r and s)
2226 let r_fixed = FixedBytes :: < 32 > :: ZERO ;
2327 let s_fixed = FixedBytes :: < 32 > :: ZERO ;
24-
28+
2529 // Stub credential ID
2630 let credential_id = vec ! [ 0u8 ; 16 ] ;
27-
31+
2832 // ABI encode the WebAuthn signature: (bytes authenticatorData, string clientDataJSON, bytes32[2] rs, bytes credentialId)
2933 type SignatureParams = (
3034 alloy:: sol_types:: sol_data:: Bytes ,
@@ -44,11 +48,11 @@ pub fn stub_signature_passkey(validator: Address) -> eyre::Result<Bytes> {
4448 ) ;
4549
4650 let encoded_signature = SignatureParams :: abi_encode_params ( & params) ;
47-
51+
4852 // Prepend validator address (20 bytes) to the encoded signature
4953 let mut result = Vec :: with_capacity ( 20 + encoded_signature. len ( ) ) ;
5054 result. extend_from_slice ( validator. as_slice ( ) ) ;
5155 result. extend_from_slice ( & encoded_signature) ;
52-
56+
5357 Ok ( Bytes :: from ( result) )
5458}
0 commit comments