Draw

Each round has a predetermined close height, a predetermined
draw height and a predetermined lock height. They are normally
six blocks apart from each other.
When the Bitcoin blockchain reaches
the close height, the lottery will close and no more tickets will be
sold. At draw height, the winning sequence
will be generated using a combination of a secret seed (random seed, see below) and the block hash
of the block at that height. Until lock height is reached, if there
would be any reorganization of the blockchain, the winning sequence will simply be regenerated.
At lock height, the winning sequence is locked-in and final,
is made public here together with random seed,
and winnings can be claimed.

Random seed

Each round has a predetermined random seed generated by me (random seed).
It is kept secret until draw time, but the sha256 hash
of it (seed hash) is publicly available and is included on
each ticket, as a guarantee it has not changed.

Tickets

In the interest of decentralization and Don't trust. Verify, the tickets sold
are self-contained and not stored here. The validity is guaranteed by a signature
that is created by LND and can be checked against my node's public key. (The
public key is made public together with the other parameters for
the current round on the front-page).
Tickets without a valid signature can not be used to claim winnings.
Each ticket is unique (has a unique ticket-ID) and can only be used once.

Details

The generation of the winning sequence works like this:
The random seed (a string of random bytes) is concatenated with the
block hash for the block at height draw height in binary format and
the result it hashed with sha256. The hash is converted to
hex format and the rightmost 4 characters of that string that
falls within the range '0' – '9' (ASCII 48 – 57) will be the
winning sequence. Any other characters are ignored. In the
unlikely case that there would not be enough such characters,
we increase draw height by one and start over.
The height of the block we actually used will be called
actual draw height and will in practice always be
the same as draw height. In case it is not, lock height
will also be adjusted so the separation stays the same.