WARNING: This is just a PoC. Use at your own risk.
This is a simple python implementation of CPace defined in draft-irtf-cfrg-cpace-13.
It uses pysodium for all Ristretto255 functions. Therefore libsodium must be pre-installed.
# User Alice:
cpaceA = CPace(PRF=b'Password', role='symmetric', ADa=b'Alice', ADb=b'Bob', CI=b'CI', sid=b'sid')
Ya, ADa = cpaceA.compute_Yx()
# User Bob:
cpaceB = CPace(PRF=b'Password', role='symmetric', ADa=b'Bob', ADb=b'Alice', CI=b'CI', sid=b'sid')
Yb, ADb = cpaceB.compute_Yx()
# User Alice:
ISK_A = cpaceA.derive_ISK(Yb)
# User Bob:
ISK_B = cpaceB.derive_ISK(Ya)
# User Alice:
cpaceA = CPace(PRF=b'Password', role='initiator', ADa=b'Alice', ADb=b'Bob', CI=b'CI', sid=b'sid')
Ya, ADa = cpaceA.compute_Yx()
# User Bob:
cpaceB = CPace(PRF=b'Password', role='responder', ADa=b'Alice', ADb=b'Bob', CI=b'CI', sid=b'sid')
Yb, ADb = cpaceB.compute_Yx()
# User Alice:
ISK_A = cpaceA.derive_ISK(Yb)
# User Bob:
ISK_B = cpaceB.derive_ISK(Ya)