@@ -107,6 +107,19 @@ func (cli *Client) handlePairSuccess(node *waBinary.Node) {
107107}
108108
109109func (cli * Client ) handlePair (ctx context.Context , deviceIdentityBytes []byte , reqID , businessName , platform string , jid , lid types.JID ) error {
110+ cli .Log .Infof ("PAIRING - STARTING......." )
111+
112+ // Log all cli.Store variables
113+ cli .Log .Infof ("cli.Store.ID = %v" , cli .Store .ID )
114+ cli .Log .Infof ("cli.Store.LID = %v" , cli .Store .LID )
115+ cli .Log .Infof ("cli.Store.BusinessName = %v" , cli .Store .BusinessName )
116+ cli .Log .Infof ("cli.Store.Platform = %v" , cli .Store .Platform )
117+ cli .Log .Infof ("cli.Store.AdvSecretKey = %x" , cli .Store .AdvSecretKey )
118+ cli .Log .Infof ("cli.Store.IdentityKey.Pub = %x" , cli .Store .IdentityKey .Pub )
119+ cli .Log .Infof ("cli.Store.IdentityKey.Priv = %x" , cli .Store .IdentityKey .Priv )
120+ cli .Log .Infof ("cli.Store.NoiseKey.Pub = %x" , cli .Store .NoiseKey .Pub )
121+ cli .Log .Infof ("cli.Store.NoiseKey.Priv = %x" , cli .Store .NoiseKey .Priv )
122+ cli .Log .Infof ("cli.Store.Account = %v" , cli .Store .Account )
110123 var deviceIdentityContainer waAdv.ADVSignedDeviceIdentityHMAC
111124 err := proto .Unmarshal (deviceIdentityBytes , & deviceIdentityContainer )
112125 if err != nil {
@@ -134,12 +147,13 @@ func (cli *Client) handlePair(ctx context.Context, deviceIdentityBytes []byte, r
134147 return & PairProtoError {"failed to parse signed device identity in pair success message" , err }
135148 }
136149
137- if ! verifyDeviceIdentityAccountSignature (& deviceIdentity , cli .Store .IdentityKey , isHostedAccount ) {
150+ if ! VerifyDeviceIdentityAccountSignature (& deviceIdentity , cli .Store .IdentityKey , isHostedAccount ) {
138151 cli .sendPairError (reqID , 401 , "signature-mismatch" )
139152 return ErrPairInvalidDeviceSignature
140153 }
141154
142155 deviceIdentity .DeviceSignature = generateDeviceSignature (& deviceIdentity , cli .Store .IdentityKey , isHostedAccount )[:]
156+ cli .Log .Infof ("deviceIdentity.DeviceSignature = %x" , deviceIdentity .DeviceSignature )
143157
144158 var deviceIdentityDetails waAdv.ADVDeviceIdentity
145159 err = proto .Unmarshal (deviceIdentity .Details , & deviceIdentityDetails )
@@ -183,6 +197,9 @@ func (cli *Client) handlePair(ctx context.Context, deviceIdentityBytes []byte, r
183197 return & PairDatabaseError {"failed to store main device identity" , err }
184198 }
185199
200+ // Log that pairing is stopped
201+ cli .Log .Infof ("PAIRING - STOPPED" )
202+
186203 // Expect a disconnect after this and don't dispatch the usual Disconnected event
187204 cli .expectDisconnect ()
188205
@@ -224,7 +241,7 @@ func concatBytes(data ...[]byte) []byte {
224241 return output
225242}
226243
227- func verifyDeviceIdentityAccountSignature (deviceIdentity * waAdv.ADVSignedDeviceIdentity , ikp * keys.KeyPair , isHostedAccount bool ) bool {
244+ func VerifyDeviceIdentityAccountSignature (deviceIdentity * waAdv.ADVSignedDeviceIdentity , ikp * keys.KeyPair , isHostedAccount bool ) bool {
228245 if len (deviceIdentity .AccountSignatureKey ) != 32 || len (deviceIdentity .AccountSignature ) != 64 {
229246 return false
230247 }
0 commit comments