Each party keeps one exponent secret and publishes one modular power. The ladders make both public values checkable.

highlighted = computed this step

Why secrets become public values

Alice and Bob keep their exponents secret, but publish modular powers. The ladders show that each public value is recomputed from g, the secret, and p.

A=gamodp,B=gbmodpA=g^a\bmod p,\quad B=g^b\bmod p
Alice public valueThe modular exponentiation ladder is recomputed from exact DH inputs.Alice public value - 5^6 mod 23stepbitpriorsquaremultiplyresult0111551152101020108skip8

Alice computes A

Alice keeps a=6 secret and publishes A=8.

56mod23=85^{6}\bmod{}23=8
Alice public valueThe modular exponentiation ladder is recomputed from exact DH inputs.Alice public value - 5^6 mod 23stepbitpriorsquaremultiplyresult0111551152101020108skip8

Bob computes B

Bob keeps b=15 secret and publishes B=19.

515mod23=195^{15}\bmod{}23=19
Bob public valueThe modular exponentiation ladder is recomputed from exact DH inputs.Bob public value - 5^15 mod 23stepbitpriorsquaremultiplyresult011155115210102110817173117131919

Summary

The public values are A=8 and B=19. NOTE: toy-modulus; no-side-channel; no-production; never-roll-your-own. Exact arithmetic on a deliberately tiny toy modulus; real DH uses 2048+ bit groups inside authenticated reviewed protocols.

A,B public valuesA,B\ \text{public values}
Bob public valueThe modular exponentiation ladder is recomputed from exact DH inputs.Bob public value - 5^15 mod 23stepbitpriorsquaremultiplyresult011155115210102110817173117131919