I'm implementing Pedersen commitment scheme in order to enhance entropy of a pre-image of a hash. I'm using secp256k1 for my curve parameters.
I am following naming conventions from here: What is a Pedersen commitment?
I am performing a commit $C = (m, r)$ and then another commit $C' = (m, r')$
Then I do the blind equality check $C - C' = (r - r')G.$
I got the blind equality check working, but only for some values of $r$. It looks like it works better when $r$ is a prime or when $r$ and $r'$ don't have common divisors.
What's the proper way to select $r$ values? Right now I am just selecting random values in between 0
and 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
uint256 _r3 = submodP( _r1 , _r2 )
. I'm not sure what $q$ is, to be honest. MaybesubmodP
is not enough on its own and I do need to $mod q$ on top of it. Thank you, I'll research that further. $\endgroup$mod 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
and I had to just change it tomod 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
and it now works fine. That solved my issue. $\endgroup$