Looking at RFC9374, the hash input is defined as follows:
cSHAKE128(Input, L, "", Context ID)
Input := Prefix | Additional Information | OGA ID | HOST_ID
L := Length in bits of the hash portion of ORCHID
The combination of Prefix | Additional Information | OGA ID are implemented as the variable h_orchid_left in det_orchid().
HOST_ID is, per RFC9374, defined as:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| EdDSA Curve | NULL |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Public Key |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
In det_orchid() the call
|
shake.update((h_orchid_left + hi)) |
with hi = prkey.public_key().export_key(format="raw") does not match the Input for cSHAKE128 as the HOST_ID is missing both the 2-byte EdDSA Curve enumeration and 2-bytes of null padding before the public key (hi).
The correct call is: shake.update((h_orchid_left + bytes([0, 1, 0, 0]) + hi)) -- assuming the EdDSA Curve in use for this script is always Ed25519, enumerated as the value of 1.
@rgmhtt please confirm.
Looking at RFC9374, the hash input is defined as follows:
The combination of
Prefix | Additional Information | OGA IDare implemented as the variableh_orchid_leftindet_orchid().HOST_ID is, per RFC9374, defined as:
In
det_orchid()the calldrip-scripts/det-gen.py
Line 51 in 77f7ba5
with
hi = prkey.public_key().export_key(format="raw")does not match the Input for cSHAKE128 as the HOST_ID is missing both the 2-byteEdDSA Curveenumeration and 2-bytes of null padding before the public key (hi).The correct call is:
shake.update((h_orchid_left + bytes([0, 1, 0, 0]) + hi))-- assuming the EdDSA Curve in use for this script is always Ed25519, enumerated as the value of1.@rgmhtt please confirm.