Skip to content

Commit

Permalink
Merge pull request #69 from jonasnick/certeq-signing
Browse files Browse the repository at this point in the history
  • Loading branch information
real-or-random authored Dec 16, 2024
2 parents 7507a5e + ed4f7a9 commit 3c3f9e2
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions python/chilldkg_ref/chilldkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,16 @@
###


CERTEQ_MSG_TAG = BIP_TAG + "certeq message"


def certeq_message(x: bytes, idx: int) -> bytes:
return idx.to_bytes(4, "big") + x
# Domain separation as described in BIP 340
prefix = (BIP_TAG + "certeq message").encode()
prefix = prefix + b"\x00" * (33 - len(prefix))
return prefix + idx.to_bytes(4, "big") + x


def certeq_participant_step(hostseckey: bytes, idx: int, x: bytes) -> bytes:
msg = certeq_message(x, idx)
return schnorr_sign(
msg, hostseckey, aux_rand=random_bytes(32), tag_prefix=CERTEQ_MSG_TAG
)
return schnorr_sign(msg, hostseckey, aux_rand=random_bytes(32))


def certeq_cert_len(n: int) -> int:
Expand All @@ -99,7 +97,6 @@ def certeq_verify(hostpubkeys: List[bytes], x: bytes, cert: bytes) -> None:
msg,
hostpubkeys[i][1:33],
cert[i * 64 : (i + 1) * 64],
tag_prefix=CERTEQ_MSG_TAG,
)
if not valid:
raise InvalidSignatureInCertificateError(i)
Expand Down

0 comments on commit 3c3f9e2

Please sign in to comment.