Question about difficulty calculation in Scala code

Hi, I’ve been reviewing the Scala code related to solution verification and particularly how the diffculty is calculated.

I found that for a recent block:

The “nBits” are: 117968545 which is hex: 0x7080ea1
This value is passed to the method RequiredDifficulty.decodeCompactBits which look like it returns the “difficulty” which for this block is: 2267884466208768 which is hex: 0x80EA100000000.

Then in AutolykosPowScheme.scala this code divides “q” by the difficulty but “q” is not defined anywhere I can find:

204   /**
205     * Get target `b` from encoded difficulty `nBits`
206     */
207   private[mining] def getB(nBits: Long): BigInt = {
208     q / RequiredDifficulty.decodeCompactBits(nBits)
209   }

Can anyone tell me what “q” is?

I’m looking for an example of the 32 byte value “b” from AutolykosPowScheme.validate(). Thanks!

1 Like

You can see its definition here. It is part of elliptic-curve parameters (namely “n”). More details in dependent lib here.