From what I've read about elliptic curve Diffie-hellman with and without cofactor (I am pretty new to the whole thing so I am not able to understand everything) is that when the cofactor of the curve $h$ is $1$, Both should give the same result. So for curves such as secp256r1 (which has $h=1$) both should give the same result. Unfortunately, when I am coding it using some third party libraries for Diffie-Hellman primitive without cofactor, I am not getting the expected result of Diffie Hellman with the cofactor. At this point, I am not sure if I have understood the theory incorrectly or if there's some issue with my code. Could someone verify or refute my understanding?
Just to close this question . Yes, both ( ECDH with cofactor) and (ECDH without cofactor) give the same result if the cofactor of the curve is 1. After using another third party source I am getting the correct result. There was an issue in the code